MCPcopy
hub / github.com/osrg/gobgp / Test_IPRouteBody_IPv6

Function Test_IPRouteBody_IPv6

pkg/zebra/zapi_test.go:510–812  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

508}
509
510func Test_IPRouteBody_IPv6(t *testing.T) {
511 assert := assert.New(t)
512 size := map[uint8]uint8{2: 43, 3: 43, 4: 48, 5: 55, 6: 59}
513 command := map[uint8]APIType{
514 2: zapi3IPv6RouteAdd,
515 3: zapi3IPv6RouteAdd,
516 4: zapi4IPv6RouteAdd,
517 5: zapi6Frr7RouteAdd,
518 6: zapi6Frr7RouteAdd,
519 }
520 routeType := routeConnect
521 message := map[uint8]MessageFlag{
522 2: MessageNexthop | messageIFIndex | zapi4MessageDistance | zapi4MessageMetric | zapi3MessageMTU,
523 3: MessageNexthop | messageIFIndex | zapi4MessageDistance | zapi4MessageMetric | zapi3MessageMTU,
524 4: MessageNexthop | messageIFIndex | zapi4MessageDistance | zapi4MessageMetric | zapi4MessageMTU,
525 5: MessageNexthop | MessageDistance | MessageMetric | MessageMTU,
526 6: MessageNexthop | MessageDistance | MessageMetric | MessageMTU,
527 }
528 nexthopType := map[uint8]nexthopType{
529 2: backwardNexthopTypeIPv6,
530 3: backwardNexthopTypeIPv6,
531 4: nexthopTypeIPv6,
532 5: nexthopTypeIPv6IFIndex,
533 6: nexthopTypeIPv6IFIndex,
534 }
535 messageWithoutNexthop := map[uint8]MessageFlag{
536 2: zapi4MessageDistance | zapi4MessageMetric,
537 3: zapi4MessageDistance | zapi4MessageMetric,
538 4: zapi4MessageDistance | zapi4MessageMetric,
539 5: MessageDistance | MessageMetric,
540 6: MessageDistance | MessageMetric,
541 }
542 for v := MinZapiVer; v <= MaxZapiVer; v++ {
543 // decodeFromBytes IPV6_ROUTE
544 buf := make([]byte, size[v])
545 buf[0] = byte(routeType)
546 pos := 1
547 software := NewSoftware(v, "")
548 switch v {
549 case 2, 3:
550 buf[pos] = byte(FlagSelected.ToEach(v, software))
551 pos++
552 case 4, 5, 6:
553 binary.BigEndian.PutUint16(buf[pos:], 0) // Instance
554 pos += 2
555 binary.BigEndian.PutUint32(buf[pos:], uint32(FlagSelected.ToEach(v, software)))
556 pos += 4
557 }
558
559 if v == 6 {
560 binary.BigEndian.PutUint32(buf[pos:], uint32(message[v])) // frr7.5: 32bit
561 pos += 4
562 } else {
563 buf[pos] = uint8(message[v]) // before frr7.4: 8bit
564 pos++
565 }
566
567 if v > 4 {

Callers

nothing calls this directly

Calls 7

decodeFromBytesMethod · 0.95
serializeMethod · 0.95
NewSoftwareFunction · 0.85
ErrorMethod · 0.80
StringMethod · 0.65
ToEachMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…