(t *testing.T)
| 990 | } |
| 991 | |
| 992 | func Test_NexthopUpdateBody(t *testing.T) { |
| 993 | assert := assert.New(t) |
| 994 | |
| 995 | size := map[uint8]uint8{2: 21, 3: 21, 4: 22, 5: 26, 6: 34} |
| 996 | command := map[uint8]APIType{ |
| 997 | 2: zapi3NexthopUpdate, |
| 998 | 3: zapi3NexthopUpdate, |
| 999 | 4: zapi4NexthopUpdate, |
| 1000 | 5: zapi5Frr5NexthopUpdate, |
| 1001 | 6: nexthopUpdate, |
| 1002 | } |
| 1003 | nexthopType := map[uint8]nexthopType{ |
| 1004 | 2: backwardNexthopTypeIPv4IFIndex, |
| 1005 | 3: backwardNexthopTypeIPv4IFIndex, |
| 1006 | 4: nexthopTypeIPv4IFIndex, |
| 1007 | 5: nexthopTypeIPv4IFIndex, |
| 1008 | 6: nexthopTypeIPv4IFIndex, |
| 1009 | } |
| 1010 | |
| 1011 | for v := MinZapiVer; v <= MaxZapiVer; v++ { |
| 1012 | // Input binary |
| 1013 | bufIn := make([]byte, size[v]) |
| 1014 | pos := 0 |
| 1015 | if v == 6 { // frr7.5 |
| 1016 | // message flag |
| 1017 | copy(bufIn[pos:pos+4], []byte{0x00, 0x00, 0x00, 0x00}) |
| 1018 | pos += 4 |
| 1019 | } |
| 1020 | // afi(2 bytes)=AF_INET, prefix_len(1 byte)=32, prefix(4 bytes)="192.168.1.1" |
| 1021 | copy(bufIn[pos:pos+7], []byte{0x00, 0x02, 0x20, 0xc0, 0xa8, 0x01, 0x01}) |
| 1022 | pos += 7 |
| 1023 | |
| 1024 | if v > 4 { // Type(1byte), Instance(2byte) |
| 1025 | copy(bufIn[pos:pos+3], []byte{byte(routeConnect), 0x00, 0x00}) |
| 1026 | pos += 3 |
| 1027 | } |
| 1028 | if v > 3 { // Distance |
| 1029 | bufIn[pos] = 0 |
| 1030 | pos++ |
| 1031 | } |
| 1032 | // metric(4 bytes)=1, number of nexthops(1 byte)=1 |
| 1033 | copy(bufIn[pos:pos+5], []byte{0x00, 0x00, 0x00, 0x01, 0x01}) |
| 1034 | pos += 5 |
| 1035 | if v == 6 { // version == 6 and not frr6 |
| 1036 | binary.BigEndian.PutUint32(bufIn[pos:], 0) // vrfid |
| 1037 | pos += 4 |
| 1038 | } |
| 1039 | bufIn[pos] = byte(nexthopType[v]) |
| 1040 | pos++ |
| 1041 | if v == 6 { // frr7.3 and later |
| 1042 | bufIn[pos] = byte(0) // nexthop flag |
| 1043 | pos++ |
| 1044 | } |
| 1045 | // nexthop_ip(4 bytes)="192.168.0.1", nexthop_Ifindex(4 byte)=2 |
| 1046 | copy(bufIn[pos:pos+8], []byte{0xc0, 0xa8, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02}) |
| 1047 | pos += 8 |
| 1048 | if v == 5 { // frr7.3&7.4 (latest software of zapi v6) depends on nexthop flag |
| 1049 | bufIn[pos] = byte(0) // label num |
nothing calls this directly
no test coverage detected
searching dependent graphs…