diff options
author | Pat Ruddy <pat@voltanet.io> | 2021-02-14 13:09:55 +0100 |
---|---|---|
committer | Pat Ruddy <pat@voltanet.io> | 2021-02-17 14:35:31 +0100 |
commit | 5a224c19f195c03275011b0b642b844182485334 (patch) | |
tree | 09dfbb7db61ece54fa7bdb596af91893c2fd3689 /lib | |
parent | bgpd: mplsvpn snmp: NULL check correct pointer (diff) | |
download | frr-5a224c19f195c03275011b0b642b844182485334.tar.xz frr-5a224c19f195c03275011b0b642b844182485334.zip |
bgpd, lib: add oid2in6_addr utility and use it
The existing code was using the oid2in_addr API to copy IPv6
addresses passing an IPv6 length. Create a utility to do this
properly and avoid annoying coverity with type checking.
Signed-off-by: Pat Ruddy <pat@voltanet.io>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/smux.h | 1 | ||||
-rw-r--r-- | lib/snmp.c | 11 |
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/smux.h b/lib/smux.h index e07df2369..11c1becd6 100644 --- a/lib/smux.h +++ b/lib/smux.h @@ -143,6 +143,7 @@ extern int smux_trap_multi_index(struct variable *vp, size_t vp_len, size_t trapobjlen, uint8_t sptrap); extern int oid_compare(const oid *, int, const oid *, int); extern void oid2in_addr(oid[], int, struct in_addr *); +extern void oid2in6_addr(oid oid[], struct in6_addr *addr); extern void oid2int(oid oid[], int *dest); extern void *oid_copy(void *, const void *, size_t); extern void oid_copy_addr(oid[], const struct in_addr *, int); diff --git a/lib/snmp.c b/lib/snmp.c index e92f622bb..17a4ed4a1 100644 --- a/lib/snmp.c +++ b/lib/snmp.c @@ -64,6 +64,17 @@ void oid2in_addr(oid oid[], int len, struct in_addr *addr) *pnt++ = oid[i]; } +void oid2in6_addr(oid oid[], struct in6_addr *addr) +{ + unsigned int i; + uint8_t *pnt; + + pnt = (uint8_t *)addr; + + for (i = 0; i < sizeof(struct in6_addr); i++) + *pnt++ = oid[i]; +} + void oid2int(oid oid[], int *dest) { uint8_t i; |