summaryrefslogtreecommitdiffhomepage
path: root/table
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2014-12-25 22:12:34 -0800
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2014-12-25 22:12:34 -0800
commit94e35ee50de5750d46ae32b1c9d736671a0e84a6 (patch)
treed6e1d461cff683308cd91db7e7cbf25b8d48b82d /table
parent0adb1d0dcd57b17444a3364e576b3bcf94266ce4 (diff)
packet: define BGPPathAttr type
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'table')
-rw-r--r--table/path.go4
-rw-r--r--table/table_manager.go57
2 files changed, 2 insertions, 59 deletions
diff --git a/table/path.go b/table/path.go
index 635cbf5d..4d4e0c44 100644
--- a/table/path.go
+++ b/table/path.go
@@ -27,7 +27,7 @@ import (
type Path interface {
String() string
GetPathAttrs() []bgp.PathAttributeInterface
- GetPathAttr(int) (int, bgp.PathAttributeInterface)
+ GetPathAttr(bgp.BGPAttrType) (int, bgp.PathAttributeInterface)
getRouteFamily() RouteFamily
setSource(source *PeerInfo)
getSource() *PeerInfo
@@ -193,7 +193,7 @@ func (pd *PathDefault) GetPathAttrs() []bgp.PathAttributeInterface {
return pd.pathAttrs
}
-func (pd *PathDefault) GetPathAttr(pattrType int) (int, bgp.PathAttributeInterface) {
+func (pd *PathDefault) GetPathAttr(pattrType bgp.BGPAttrType) (int, bgp.PathAttributeInterface) {
attrMap := [bgp.BGP_ATTR_TYPE_AS4_AGGREGATOR + 1]reflect.Type{}
attrMap[bgp.BGP_ATTR_TYPE_ORIGIN] = reflect.TypeOf(&bgp.PathAttributeOrigin{})
attrMap[bgp.BGP_ATTR_TYPE_AS_PATH] = reflect.TypeOf(&bgp.PathAttributeAsPath{})
diff --git a/table/table_manager.go b/table/table_manager.go
index c6b15543..18dbfb2d 100644
--- a/table/table_manager.go
+++ b/table/table_manager.go
@@ -54,63 +54,6 @@ func (rf RouteFamily) String() string {
}
}
-type AttributeType int
-
-const (
- BGP_ATTR_TYPE_ORIGIN AttributeType = bgp.BGP_ATTR_TYPE_ORIGIN
- BGP_ATTR_TYPE_AS_PATH AttributeType = bgp.BGP_ATTR_TYPE_AS_PATH
- BGP_ATTR_TYPE_NEXT_HOP AttributeType = bgp.BGP_ATTR_TYPE_NEXT_HOP
- BGP_ATTR_TYPE_MULTI_EXIT_DISC AttributeType = bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC
- BGP_ATTR_TYPE_LOCAL_PREF AttributeType = bgp.BGP_ATTR_TYPE_LOCAL_PREF
- BGP_ATTR_TYPE_ATOMIC_AGGREGATE AttributeType = bgp.BGP_ATTR_TYPE_ATOMIC_AGGREGATE
- BGP_ATTR_TYPE_AGGREGATOR AttributeType = bgp.BGP_ATTR_TYPE_AGGREGATOR
- BGP_ATTR_TYPE_COMMUNITIES AttributeType = bgp.BGP_ATTR_TYPE_COMMUNITIES
- BGP_ATTR_TYPE_ORIGINATOR_ID AttributeType = bgp.BGP_ATTR_TYPE_ORIGINATOR_ID
- BGP_ATTR_TYPE_CLUSTER_LIST AttributeType = bgp.BGP_ATTR_TYPE_CLUSTER_LIST
- BGP_ATTR_TYPE_MP_REACH_NLRI AttributeType = bgp.BGP_ATTR_TYPE_MP_REACH_NLRI
- BGP_ATTR_TYPE_MP_UNREACH_NLRI AttributeType = bgp.BGP_ATTR_TYPE_MP_UNREACH_NLRI
- BGP_ATTR_TYPE_EXTENDED_COMMUNITIES AttributeType = bgp.BGP_ATTR_TYPE_EXTENDED_COMMUNITIES
- BGP_ATTR_TYPE_AS4_PATH AttributeType = bgp.BGP_ATTR_TYPE_AS4_PATH
- BGP_ATTR_TYPE_AS4_AGGREGATOR AttributeType = bgp.BGP_ATTR_TYPE_AS4_AGGREGATOR
-)
-
-func (attr AttributeType) String() string {
- switch attr {
- case BGP_ATTR_TYPE_ORIGIN:
- return "BGP_ATTR_TYPE_ORIGIN"
- case BGP_ATTR_TYPE_AS_PATH:
- return "BGP_ATTR_TYPE_AS_PATH"
- case BGP_ATTR_TYPE_NEXT_HOP:
- return "BGP_ATTR_TYPE_NEXT_HOP"
- case BGP_ATTR_TYPE_MULTI_EXIT_DISC:
- return "BGP_ATTR_TYPE_MULTI_EXIT_DISC"
- case BGP_ATTR_TYPE_LOCAL_PREF:
- return "BGP_ATTR_TYPE_LOCAL_PREF"
- case BGP_ATTR_TYPE_ATOMIC_AGGREGATE:
- return "BGP_ATTR_TYPE_ATOMIC_AGGREGATE"
- case BGP_ATTR_TYPE_AGGREGATOR:
- return "BGP_ATTR_TYPE_AGGREGATOR"
- case BGP_ATTR_TYPE_COMMUNITIES:
- return "BGP_ATTR_TYPE_COMMUNITIES"
- case BGP_ATTR_TYPE_ORIGINATOR_ID:
- return "BGP_ATTR_TYPE_ORIGINATOR_ID"
- case BGP_ATTR_TYPE_CLUSTER_LIST:
- return "BGP_ATTR_TYPE_CLUSTER_LIST"
- case BGP_ATTR_TYPE_MP_REACH_NLRI:
- return "BGP_ATTR_TYPE_MP_REACH_NLRI"
- case BGP_ATTR_TYPE_MP_UNREACH_NLRI:
- return "BGP_ATTR_TYPE_MP_UNREACH_NLRI"
- case BGP_ATTR_TYPE_EXTENDED_COMMUNITIES:
- return "BGP_ATTR_TYPE_EXTENDED_COMMUNITIES"
- case BGP_ATTR_TYPE_AS4_PATH:
- return "BGP_ATTR_TYPE_AS4_PATH"
- case BGP_ATTR_TYPE_AS4_AGGREGATOR:
- return "BGP_ATTR_TYPE_AS4_AGGREGATOR"
- default:
- return "Unknown"
- }
-}
-
type ProcessMessage struct {
innerMessage *bgp.BGPMessage
fromPeer *PeerInfo