OpenSDN source code
bfd_client.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Juniper Networks, Inc. All rights reserved.
3  */
4 #include <boost/asio.hpp>
5 #include <boost/bind/bind.hpp>
6 #include <boost/function.hpp>
7 #include <boost/scoped_ptr.hpp>
8 #include <boost/random.hpp>
9 #include <set>
10 
11 #include "base/logging.h"
12 #include "bfd/bfd_client.h"
13 #include "bfd/bfd_common.h"
14 #include "bfd/bfd_connection.h"
15 #include "bfd/bfd_server.h"
16 #include "bfd/bfd_session.h"
17 
18 using namespace BFD;
19 using boost::bind;
20 using std::make_pair;
21 using std::pair;
22 using namespace boost::placeholders;
23 
24 Client::Client(Connection *cm, ClientId id) : id_(id), cm_(cm) {
25 }
26 
28  // DeleteClientSessions();
29 }
30 
33 }
34 
36  return cm_->GetServer()->SessionByKey(key);
37 }
38 
39 bool Client::Up(const SessionKey &key) const {
40  Session *session = GetSession(key);
41  return session && session->Up();
42 }
43 
44 void Client::AddSession(const SessionKey &key, const SessionConfig &config) {
45  cm_->GetServer()->AddSession(key, config, bind(&Client::Notify, this, _1,
46  _2));
47 }
48 
50  cm_->GetServer()->DeleteSession(key);
51 }
52 
53 void Client::Notify(const SessionKey &key, const BFD::BFDState &new_state) {
54  cm_->NotifyStateChange(key, new_state == kUp);
55 }
void Notify(const SessionKey &key, const BFD::BFDState &new_state)
Definition: bfd_client.cc:53
void DeleteClientSessions()
Definition: bfd_client.cc:31
Session * GetSession(const SessionKey &key) const
Definition: bfd_client.cc:35
Connection * cm_
Definition: bfd_client.h:30
void AddSession(const SessionKey &key, const SessionConfig &config)
Definition: bfd_client.cc:44
bool Up(const SessionKey &key) const
Definition: bfd_client.cc:39
virtual ~Client()
Definition: bfd_client.cc:27
void DeleteSession(const SessionKey &key)
Definition: bfd_client.cc:49
Client(Connection *cm, ClientId client_id=0)
Definition: bfd_client.cc:24
virtual Server * GetServer() const =0
virtual void NotifyStateChange(const SessionKey &key, const bool &up)=0
void DeleteClientSessions()
Definition: bfd_server.cc:68
void AddSession(const SessionKey &key, const SessionConfig &config, ChangeCb cb)
Definition: bfd_server.cc:36
Session * SessionByKey(const boost::asio::ip::address &address, const SessionIndex &index=SessionIndex())
Definition: bfd_server.cc:167
void DeleteSession(const SessionKey &key)
Definition: bfd_server.cc:53
bool Up() const
Definition: bfd_session.cc:324
Definition: bfd_client.h:9
uint32_t ClientId
Definition: bfd_common.h:19
BFDState
Definition: bfd_common.h:21
@ kUp
Definition: bfd_common.h:22