MCPcopy Create free account
hub / github.com/coreswitch/zebra / Serialize

Method Serialize

bgp/message.go:554–576  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

552}
553
554func (msg *BgpOpen) Serialize() ([]byte, error) {
555 buf := make([]byte, 10) // Version(1) + AS(2) + HoldTime(2) + RouterId(4) + OptParamLen(1)
556 buf[0] = msg.Version
557 var as uint16 = AS_TRANS
558 if msg.As <= 65535 {
559 as = uint16(msg.As)
560 }
561 binary.BigEndian.PutUint16(buf[1:3], as)
562 binary.BigEndian.PutUint16(buf[3:5], msg.HoldTime)
563 copy(buf[5:9], msg.RouterId)
564 obuf := make([]byte, 0)
565 for _, p := range msg.OptParams {
566 pbuf, err := p.Serialize()
567 if err != nil {
568 return nil, err
569 }
570 obuf = append(obuf, pbuf...)
571 }
572 msg.OptParamLen = uint8(len(obuf))
573 fmt.Println("msg.OptParamLen", msg.OptParamLen)
574 buf[9] = msg.OptParamLen
575 return append(buf, obuf...), nil
576}
577
578type BgpUpdate struct {
579 WithdrawLen uint16

Callers

nothing calls this directly

Calls 1

SerializeMethod · 0.65

Tested by

no test coverage detected