Line data Source code
1 : /* 2 : * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 3 : * Copyright Contributors to the OpenSDN project 4 : */ 5 : 6 : #include "vrouter/ksync/agent_ksync_types.h" 7 : #include "ksync_agent_sandesh.h" 8 : #include "ksync_init.h" 9 : 10 : 11 0 : AgentKsyncSandesh::AgentKsyncSandesh(const std::string &context): 12 0 : context_(context), name_("") { 13 0 : agent_ = Agent::GetInstance(); 14 0 : } 15 : 16 0 : void AgentKsyncSandesh::SetResp() { 17 0 : Alloc(); 18 0 : resp_->set_context(context_); 19 0 : } 20 : 21 0 : void AgentKsyncSandesh::DoKsyncSandeshInternal(AgentKsyncSandeshPtr sandesh) { 22 : InterfaceKSyncObject *ksyncobj = 23 0 : static_cast<InterfaceKSyncObject *>(AgentGetKsyncObject()); 24 0 : KSyncEntry *entry = NULL; 25 : 26 0 : SetResp(); 27 0 : entry = ksyncobj->Next(NULL); 28 0 : while (entry != NULL) { 29 0 : UpdateResp(entry); 30 0 : entry = ksyncobj->Next(entry); 31 : } 32 0 : resp_->Response(); 33 0 : } 34 : 35 : 36 0 : void AgentKsyncSandesh::DoKsyncSandesh(AgentKsyncSandeshPtr sandesh) { 37 0 : sandesh->DoKsyncSandeshInternal(sandesh); 38 0 : return; 39 : } 40 : 41 : //////////////////////////// 42 : //// ksync interface ////// 43 : /////////////////////////// 44 : 45 0 : AgentKsyncIntfSandesh::AgentKsyncIntfSandesh(const std::string &context) : 46 0 : AgentKsyncSandesh(context){ 47 0 : } 48 : 49 0 : bool AgentKsyncIntfSandesh::UpdateResp(KSyncEntry *entry) { 50 0 : InterfaceKSyncEntry *intf = static_cast< InterfaceKSyncEntry *>(entry); 51 0 : return intf->KSyncEntrySandesh(resp_); 52 : } 53 : 54 0 : KSyncDBObject *AgentKsyncIntfSandesh::AgentGetKsyncObject() { 55 0 : return agent_->ksync()->interface_ksync_obj(); 56 : } 57 : 58 0 : void AgentKsyncIntfSandesh::Alloc() { 59 0 : resp_ = new KSyncItfResp(); 60 0 : } 61 : 62 : //////////////////////////// 63 : //// ksync NextHopList ////// 64 : /////////////////////////// 65 : 66 0 : AgentKsyncNhListSandesh::AgentKsyncNhListSandesh(const std::string &context) : 67 0 : AgentKsyncSandesh(context){ 68 0 : } 69 : 70 0 : bool AgentKsyncNhListSandesh::UpdateResp(KSyncEntry *entry) { 71 0 : NHKSyncEntry *nh_list = static_cast< NHKSyncEntry *>(entry); 72 0 : return nh_list->KSyncEntrySandesh(resp_); 73 : } 74 : 75 0 : KSyncDBObject *AgentKsyncNhListSandesh::AgentGetKsyncObject() { 76 0 : return agent_->ksync()->nh_ksync_obj(); 77 : } 78 : 79 0 : void AgentKsyncNhListSandesh::Alloc() { 80 0 : resp_ = new KSyncNhListResp(); 81 0 : } 82 :