summaryrefslogtreecommitdiffhomepage
path: root/server/server.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2014-12-25 06:39:39 -0800
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2014-12-25 06:39:39 -0800
commit02f33490e74f7aa9c0680067934da3088cacf754 (patch)
tree05b8722c4d1251b297ff5eec1bdc1b3204268c61 /server/server.go
parent4da71624586971c253bfb2625bdd91e121254b22 (diff)
rest: kill RestResponse interface
We can use RestResponse struct for all request types. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/server.go')
-rw-r--r--server/server.go12
1 files changed, 4 insertions, 8 deletions
diff --git a/server/server.go b/server/server.go
index 6a633d3e..ac1e4f81 100644
--- a/server/server.go
+++ b/server/server.go
@@ -20,7 +20,6 @@ import (
log "github.com/Sirupsen/logrus"
"github.com/osrg/gobgp/api"
"github.com/osrg/gobgp/config"
- "github.com/osrg/gobgp/packet"
"net"
"os"
"strconv"
@@ -153,7 +152,7 @@ func (server *BgpServer) broadcast(msg *message) {
func (server *BgpServer) handleRest(restReq *api.RestRequest) {
switch restReq.RequestType {
case api.REQ_NEIGHBORS:
- result := &api.RestResponseDefault{}
+ result := &api.RestResponse{}
peerList := make([]*Peer, 0)
for _, peer := range server.peerMap {
peerList = append(peerList, peer)
@@ -165,13 +164,10 @@ func (server *BgpServer) handleRest(restReq *api.RestRequest) {
case api.REQ_NEIGHBOR: // get neighbor state
remoteAddr := restReq.RemoteAddr
- result := &api.RestResponseNeighbor{}
+ result := &api.RestResponse{}
peer, found := server.peerMap[remoteAddr]
if found {
- c := peer.peerConfig
- result.NeighborState = bgp.FSMState(c.BgpNeighborCommonState.State).String()
- result.RemoteAddr = c.NeighborAddress.String()
- result.RemoteAs = c.PeerAs
+ result.Data = peer
} else {
result.ResponseErr = fmt.Errorf("Neighbor that has %v does not exist.", remoteAddr)
}
@@ -179,7 +175,7 @@ func (server *BgpServer) handleRest(restReq *api.RestRequest) {
close(restReq.ResponseCh)
case api.REQ_LOCAL_RIB:
remoteAddr := restReq.RemoteAddr
- result := &api.RestResponseNeighbor{}
+ result := &api.RestResponse{}
peer, found := server.peerMap[remoteAddr]
if found {
msg := message{