summaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorHiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp>2015-01-19 16:41:41 +0900
committerHiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp>2015-01-19 21:39:58 +0900
commit3ff14a50f135a1d169e76999a7ea86826a0308a9 (patch)
tree9cd9e8bd3fdafa82c8b506828e0067407db9d18d /server
parentc34707d670c0944162b01198d93c78c957286830 (diff)
rest: support adj-rib-in/out
Diffstat (limited to 'server')
-rw-r--r--server/peer.go21
-rw-r--r--server/server.go2
2 files changed, 22 insertions, 1 deletions
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)
diff --git a/server/server.go b/server/server.go
index cbd67732..14a1ac5f 100644
--- a/server/server.go
+++ b/server/server.go
@@ -241,7 +241,7 @@ func (server *BgpServer) handleRest(restReq *api.RestRequest) {
}
restReq.ResponseCh <- result
close(restReq.ResponseCh)
- case api.REQ_LOCAL_RIB, api.REQ_NEIGHBOR_SHUTDOWN, api.REQ_NEIGHBOR_RESET, api.REQ_NEIGHBOR_SOFT_RESET_IN, api.REQ_NEIGHBOR_SOFT_RESET_OUT:
+ case api.REQ_LOCAL_RIB, api.REQ_NEIGHBOR_SHUTDOWN, api.REQ_NEIGHBOR_RESET, api.REQ_NEIGHBOR_SOFT_RESET_IN, api.REQ_NEIGHBOR_SOFT_RESET_OUT, api.REQ_ADJ_RIB_IN, api.REQ_ADJ_RIB_OUT:
remoteAddr := restReq.RemoteAddr
result := &api.RestResponse{}
info, found := server.peerMap[remoteAddr]