Skip to content

Commit d380b50

Browse files
authored
rtnetlink: add address label encoding (#138)
Signed-off-by: James Tucker <[email protected]>
1 parent 3f746d9 commit d380b50

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

address.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ func (a *AddressAttributes) encode(ae *netlink.AttributeEncoder) error {
202202
if a.Multicast != nil {
203203
ae.Do(unix.IFA_MULTICAST, encodeIP(a.Multicast))
204204
}
205+
if a.Label != "" {
206+
ae.String(unix.IFA_LABEL, a.Label)
207+
}
205208
ae.Uint32(unix.IFA_FLAGS, a.Flags)
206209

207210
return nil

address_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ func TestAddressMessageMarshalBinary(t *testing.T) {
5353
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5454
0x08, 0x00, 0x01, 0x00, 0xc0, 0x00, 0x02, 0x01,
5555
0x08, 0x00, 0x04, 0x00, 0xff, 0xff, 0xff, 0xff,
56+
0x07, 0x00, 0x03, 0x00, 0x6c, 0x6f, 0x00, 0x00,
5657
0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
5758
},
5859
},
@@ -69,7 +70,8 @@ func TestAddressMessageMarshalBinary(t *testing.T) {
6970
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7071
0x14, 0x00, 0x01, 0x00, 0x20, 0x01, 0x0d, 0xb8,
7172
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
72-
0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00,
73+
0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x03, 0x00,
74+
0x6c, 0x6f, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00,
7375
0x00, 0x00, 0x00, 0x00,
7476
},
7577
},

0 commit comments

Comments
 (0)