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