-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
106 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,33 @@ | ||
package mgmt_2022 | ||
|
||
// Persistency represents the persistency of a face. | ||
import "errors" | ||
|
||
type Persistency uint64 | ||
|
||
// Face persistencies (shared with management). | ||
const ( | ||
PersistencyPersistent Persistency = 0 | ||
PersistencyOnDemand Persistency = 1 | ||
PersistencyPermanent Persistency = 2 | ||
) | ||
|
||
var PersistencyList = map[Persistency]string{ | ||
PersistencyPersistent: "persistent", | ||
PersistencyOnDemand: "on-demand", | ||
PersistencyPermanent: "permanent", | ||
} | ||
|
||
func (p Persistency) String() string { | ||
switch p { | ||
case PersistencyPersistent: | ||
return "Persistent" | ||
case PersistencyOnDemand: | ||
return "OnDemand" | ||
case PersistencyPermanent: | ||
return "Permanent" | ||
default: | ||
return "Unknown" | ||
if s, ok := PersistencyList[p]; ok { | ||
return s | ||
} | ||
return "unknown" | ||
} | ||
|
||
func ParsePersistency(s string) (Persistency, error) { | ||
for k, v := range PersistencyList { | ||
if v == s { | ||
return k, nil | ||
} | ||
} | ||
return 0, errors.New("unknown persistency") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package mgmt_2022 | ||
|
||
type RouteFlag uint64 | ||
|
||
const ( | ||
RouteFlagNoFlag RouteFlag = 0 | ||
RouteFlagChildInherit RouteFlag = 1 | ||
RouteFlagCapture RouteFlag = 2 | ||
) | ||
|
||
var RouteFlagList = map[RouteFlag]string{ | ||
RouteFlagChildInherit: "child-inherit", | ||
RouteFlagCapture: "capture", | ||
} | ||
|
||
func (v RouteFlag) String() string { | ||
if s, ok := RouteFlagList[v]; ok { | ||
return s | ||
} | ||
return "unknown" | ||
} | ||
|
||
func (v RouteFlag) IsSet(flags uint64) bool { | ||
return uint64(v)&flags != 0 | ||
} | ||
|
||
type RouteOrigin uint64 | ||
|
||
const ( | ||
RouteOriginApp RouteOrigin = 0 | ||
RouteOriginStatic RouteOrigin = 255 | ||
RouteOriginNLSR RouteOrigin = 128 | ||
RouteOriginPrefixAnn RouteOrigin = 129 | ||
RouteOriginClient RouteOrigin = 65 | ||
RouteOriginAutoreg RouteOrigin = 64 | ||
RouteOriginAutoconf RouteOrigin = 66 | ||
) | ||
|
||
var RouteOriginList = map[RouteOrigin]string{ | ||
RouteOriginApp: "app", | ||
RouteOriginStatic: "static", | ||
RouteOriginNLSR: "nlsr", | ||
RouteOriginPrefixAnn: "prefixann", | ||
RouteOriginClient: "client", | ||
RouteOriginAutoreg: "autoreg", | ||
RouteOriginAutoconf: "autoconf", | ||
} | ||
|
||
func (v RouteOrigin) String() string { | ||
if s, ok := RouteOriginList[v]; ok { | ||
return s | ||
} | ||
return "unknown" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters