[lonetix/bgp] Take advantage of smallbytecopy.h for prefix copies

pull/2/head
Lorenzo Cogotti 3 years ago
parent 4eb6e55570
commit 914911ba87

@ -17,6 +17,7 @@
#include "sys/con.h" #include "sys/con.h"
#include "argv.h" #include "argv.h"
#include "numlib.h" #include "numlib.h"
#include "smallbytecopy.h"
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
@ -454,7 +455,7 @@ Prefix *Bgp_NextMpPrefix(Bgpmpiter *it)
cur->isAddPath = TRUE; cur->isAddPath = TRUE;
cur->pathId = pfx->pathId; cur->pathId = pfx->pathId;
cur->width = pfx->width; cur->width = pfx->width;
memcpy(cur->bytes, pfx->bytes, PFXLEN(pfx->width)); _smallbytecopy16(cur->bytes, pfx->bytes, PFXLEN(pfx->width));
} else { } else {
// Regular prefix // Regular prefix
const RawPrefix *pfx = (const RawPrefix *) rawPfx; const RawPrefix *pfx = (const RawPrefix *) rawPfx;
@ -462,7 +463,7 @@ Prefix *Bgp_NextMpPrefix(Bgpmpiter *it)
cur->isAddPath = FALSE; cur->isAddPath = FALSE;
cur->pathId = 0; cur->pathId = 0;
cur->width = pfx->width; cur->width = pfx->width;
memcpy(cur->bytes, pfx->bytes, PFXLEN(pfx->width)); _smallbytecopy16(cur->bytes, pfx->bytes, PFXLEN(pfx->width));
} }
return cur; return cur;

@ -13,6 +13,7 @@
#include "sys/endian.h" #include "sys/endian.h"
#include "sys/ip.h" #include "sys/ip.h"
#include "numlib.h" #include "numlib.h"
#include "smallbytecopy.h"
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
@ -41,13 +42,13 @@ char *Bgp_PrefixToString(Afi afi, const RawPrefix *prefix, char *dest)
switch (afi) { switch (afi) {
case AFI_IP: case AFI_IP:
memset(&adr, 0, sizeof(adr)); memset(&adr, 0, sizeof(adr));
memcpy(&adr, prefix->bytes, PFXLEN(prefix->width)); _smallbytecopy4(adr.bytes, prefix->bytes, PFXLEN(prefix->width));
dest = Ipv4_AdrToString(&adr, dest); dest = Ipv4_AdrToString(&adr, dest);
break; break;
case AFI_IP6: case AFI_IP6:
memset(&adr6, 0, sizeof(adr6)); memset(&adr6, 0, sizeof(adr6));
memcpy(&adr6, prefix->bytes, PFXLEN(prefix->width)); _smallbytecopy16(adr6.bytes, prefix->bytes, PFXLEN(prefix->width));
dest = Ipv6_AdrToString(&adr6, dest); dest = Ipv6_AdrToString(&adr6, dest);
break; break;
@ -122,7 +123,7 @@ Judgement Bgp_StringToPrefix(const char *s, Prefix *dest)
dest->isAddPath = FALSE; dest->isAddPath = FALSE;
dest->width = width; dest->width = width;
memcpy(dest->bytes, adr.bytes, PFXLEN(width)); _smallbytecopy16(dest->bytes, adr.bytes, PFXLEN(width));
return OK; return OK;
} }

Loading…
Cancel
Save