diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-12-25 02:52:18 -0800 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-12-25 02:52:18 -0800 |
commit | 93dcc43b1dd184a6e917862e4ee9a31d79411b26 (patch) | |
tree | 77d46962d5c9a5e8ac9ff944c3d3a1b49368aeb8 /server/peer.go | |
parent | 1f80266d6ef342a2ed89c76936afd1e16cf3001d (diff) |
rest: support local-rib URL
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/peer.go')
-rw-r--r-- | server/peer.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/server/peer.go b/server/peer.go index 5c26fc18..a0ec5064 100644 --- a/server/peer.go +++ b/server/peer.go @@ -18,6 +18,7 @@ package server import ( "encoding/json" log "github.com/Sirupsen/logrus" + "github.com/osrg/gobgp/api" "github.com/osrg/gobgp/config" "github.com/osrg/gobgp/packet" "github.com/osrg/gobgp/table" @@ -103,6 +104,14 @@ func (peer *Peer) path2update(pathList []table.Path) []*bgp.BGPMessage { return msgs } +func (peer *Peer) handleREST(restReq *api.RestRequest) { + result := &api.RestResponseDefault{} + j, _ := json.Marshal(peer.rib.Tables[bgp.RF_IPv4_UC]) + result.Data = j + restReq.ResponseCh <- result + close(restReq.ResponseCh) +} + func (peer *Peer) handlePeermessage(m *message) { sendpath := func(pList []table.Path, wList []table.Destination) { @@ -123,6 +132,8 @@ func (peer *Peer) handlePeermessage(m *message) { case PEER_MSG_DOWN: pList, wList, _ := peer.rib.DeletePathsforPeer(m.data.(*table.PeerInfo)) sendpath(pList, wList) + case PEER_MSG_REST: + peer.handleREST(m.data.(*api.RestRequest)) } } |