OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
bridge_route_audit_ksync.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #include <base/string_util.h>
6 #include <cmn/agent.h>
7 #include <ksync/ksync_entry.h>
8 #include <ksync/ksync_object.h>
9 #include <ksync/ksync_netlink.h>
12 
14  (BridgeRouteAuditKSyncObject *obj, uint32_t vrf_id, const MacAddress &mac)
15  : ksync_obj_(obj), vrf_id_(vrf_id), mac_(mac) {
16 }
17 
20  : ksync_obj_(obj), vrf_id_(entry->vrf_id_), mac_(entry->mac_) {
21 }
22 
24 }
25 
27  return false;
28 }
29 
31  return NULL;
32 }
33 
35  std::stringstream s;
36 
37  const VrfEntry* vrf =
39  string vrf_info = vrf? vrf->GetName() : integerToString(vrf_id_);
40  s << "Route Vrf : " << vrf_info << " Mac: " << mac_.ToString();
41  return s.str();
42 }
43 
45  const BridgeRouteAuditKSyncEntry &entry = static_cast
46  <const BridgeRouteAuditKSyncEntry &>(rhs);
47 
48  if (vrf_id_ != entry.vrf_id_) {
49  return vrf_id_ < entry.vrf_id_;
50  }
51 
52  return mac_ < entry.mac_;
53 }
54 
56  return ksync_obj_;
57 }
58 
60  KSyncRouteInfo &info) const {
61  info.set_operation("DELETE");
62  info.set_plen(0);
63  info.set_vrf(vrf_id_);
64  info.set_mac(mac_.ToString());
65  info.set_type("BRIDGE");
66 }
67 
68 int BridgeRouteAuditKSyncEntry::AddMsg(char *buf, int buf_len) {
69  /* No message has to be sent to vrouter. Add is taken care in
70  * RouteKSyncEntry */
71  return 0;
72 }
73 
74 int BridgeRouteAuditKSyncEntry::ChangeMsg(char *buf, int buf_len){
75  /* No message has to be sent to vrouter. Change is taken care in
76  * RouteKSyncEntry */
77  return 0;
78 }
79 
80 int BridgeRouteAuditKSyncEntry::EncodeDelete(char *buf, int buf_len) {
81  vr_route_req encoder;
82  int encode_len;
83 
84  encoder.set_h_op(sandesh_op::DEL);
85  encoder.set_rtr_rid(0);
86  encoder.set_rtr_vrf_id(vrf_id_);
87  encoder.set_rtr_family(AF_BRIDGE);
88 
89  std::vector<int8_t> mac((int8_t *)mac_,
90  (int8_t *)mac_ + mac_.size());
91  encoder.set_rtr_mac(mac);
92  encoder.set_rtr_replace_plen(0);
93 
94  int error = 0;
95  encode_len = encoder.WriteBinary((uint8_t *)buf, buf_len, &error);
96  assert(error == 0);
97  assert(encode_len <= buf_len);
98  return encode_len;
99 }
100 
101 int BridgeRouteAuditKSyncEntry::DeleteMsg(char *buf, int buf_len) {
102  KSyncRouteInfo info;
103  FillObjectLog(sandesh_op::DEL, info);
104  KSYNC_TRACE(Route, GetObject(), info);
105 
106  return EncodeDelete(buf, buf_len);
107 }
108 
110 // BridgeRouteAuditKSyncObject routines
112 
114  KSyncObject("KSync BridgeRouteTable"), ksync_(ksync) {
115 }
116 
118 }
119 
121  uint32_t idx) {
122  const BridgeRouteAuditKSyncEntry *route =
123  static_cast<const BridgeRouteAuditKSyncEntry *>(key);
125  route);
126  return static_cast<KSyncEntry *>(ksync);
127 }
#define KSYNC_TRACE(obj, parent,...)
Definition: ksync_object.h:304
KSyncEntry * Alloc(const KSyncEntry *key, uint32_t index)
Definition: vrf.h:86
Agent * agent() const
Definition: ksync_init.h:39
bool IsLess(const KSyncEntry &rhs) const
Definition: route.h:14
void FillObjectLog(sandesh_op::type type, KSyncRouteInfo &info) const
int AddMsg(char *buf, int buf_len)
static size_t size()
Definition: mac_address.h:57
const string & GetName() const
Definition: vrf.h:100
std::string ToString() const
Definition: mac_address.cc:53
VrfEntry * FindVrfFromId(size_t index)
Definition: vrf.cc:884
uint8_t type
Definition: load_balance.h:109
static const std::string integerToString(const NumberType &num)
Definition: string_util.h:19
int EncodeDelete(char *buf, int buf_len)
int ChangeMsg(char *buf, int buf_len)
BridgeRouteAuditKSyncObject * ksync_obj_
VrfTable * vrf_table() const
Definition: agent.h:485
int DeleteMsg(char *buf, int buf_len)
virtual KSyncEntry * UnresolvedReference()
BridgeRouteAuditKSyncEntry(BridgeRouteAuditKSyncObject *obj, uint32_t vrf_id, const MacAddress &mac)