forked from jwhited/corebgp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotification_error.go
More file actions
38 lines (33 loc) · 809 Bytes
/
notification_error.go
File metadata and controls
38 lines (33 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package corebgp
import "fmt"
type notificationError struct {
notification *Notification
out bool
}
func newNotificationError(n *Notification, out bool) *notificationError {
return ¬ificationError{
notification: n,
out: out,
}
}
func (n *notificationError) dampPeer() bool {
return n.notification.Code != NOTIF_CODE_CEASE
}
func (n *notificationError) Error() string {
direction := "received"
if n.out {
direction = "sent"
}
var codeDesc, subcodeDesc string
d, ok := notifCodesMap[n.notification.Code]
if ok {
codeDesc = d.desc
s, ok := d.subcodes[n.notification.Subcode]
if ok {
subcodeDesc = s
}
}
return fmt.Sprintf("notification %s code: %d (%s) subcode: %d (%s)",
direction, n.notification.Code, codeDesc, n.notification.Subcode,
subcodeDesc)
}