From 3ff14a50f135a1d169e76999a7ea86826a0308a9 Mon Sep 17 00:00:00 2001 From: Hiroshi Yokoi Date: Mon, 19 Jan 2015 16:41:41 +0900 Subject: rest: support adj-rib-in/out --- server/peer.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'server/peer.go') diff --git a/server/peer.go b/server/peer.go index 3b03046b..73aab7e6 100644 --- a/server/peer.go +++ b/server/peer.go @@ -189,6 +189,27 @@ func (peer *Peer) handleREST(restReq *api.RestRequest) { case api.REQ_NEIGHBOR_SOFT_RESET_OUT: pathList := peer.adjRib.GetOutPathList(peer.rf) peer.sendMessages(table.CreateUpdateMsgFromPaths(pathList)) + case api.REQ_ADJ_RIB_IN: + fallthrough + case api.REQ_ADJ_RIB_OUT: + rfs := []bgp.RouteFamily{bgp.RF_IPv4_UC, bgp.RF_IPv6_UC} + adjrib := make(map[string][]table.Path) + + if restReq.RequestType == api.REQ_ADJ_RIB_IN { + for _, rf := range rfs { + paths := peer.adjRib.GetInPathList(rf) + adjrib[rf.String()] = paths + log.Debugf("RouteFamily=%v adj-rib-in found : %d", rf.String(), len(paths)) + } + } else { + for _, rf := range rfs { + paths := peer.adjRib.GetOutPathList(rf) + adjrib[rf.String()] = paths + log.Debugf("RouteFamily=%v adj-rib-out found : %d", rf.String(), len(paths)) + } + } + j, _ := json.Marshal(adjrib) + result.Data = j } restReq.ResponseCh <- result close(restReq.ResponseCh) -- cgit v1.2.3