osrg / gobgp

BGP implemented in the Go Programming Language
https://osrg.github.io/gobgp/
Apache License 2.0
3.62k stars 688 forks source link

export showNeighbor to get neighbor state changes #987

Closed PeiwenChen closed 8 years ago

PeiwenChen commented 8 years ago

Hi @ishidawataru We can send the request of REQ_MONITOR_NEIGHBOR_PEER_STATE to monitor the peer state changes, and read the response, like the below:

req = gobgp.NewGrpcRequest(gobgp.REQ_MONITOR_NEIGHBOR_PEER_STATE, "", packet.RF_IPv4_UC, nil)
    s.GrpcReqCh <- req
    for res := range req.ResponseCh {
        p := cmd.ApiStruct2Peer(res.Data.(*api.Peer))
        // cmd.showNeighbor(p.Conf.Id) 
    }

But since the showNeighbor is not exported (lower case), we cannot print the state changes. Can we export it?

ishidawataru commented 8 years ago

showNeighbor() is not just formatting function. It also retrieves neighbor info via gRPC using some global variables (client, globalOpts) which are initialised in other place of cli code.

So I think you can't use showNeighbor() as you want. We could segregate formatting part (https://github.com/osrg/gobgp/blob/master/gobgp/cmd/neighbor.go#L161-L296) from showNeighbor() and create new function ( FormatNeighbor() ?).

PeiwenChen commented 8 years ago

Thanks for your response. Actually I am not blocking by this issue currently, so no rush to fix.

Yeah, a FormatNeighbor or PrintNeighbor sounds good!

fujita commented 8 years ago

The API to monitor the state of neighbors has been changed. This is not valid any more.