mirror of
https://codeberg.org/1414codeforge/ubgpsuite.git
synced 2025-06-05 21:29:11 +02:00
[lonetix/*,tools/bgpgrep/*] Correct handling of extended timestamps during filtering, decode and dump
This commit is contained in:
@ -65,6 +65,12 @@ static void FixBgpAttributeTableForRib(Bgpattrtab tab, Boolean isRibv2)
|
||||
}
|
||||
}
|
||||
|
||||
static void NormalizeExtendedTimestamp(void)
|
||||
{
|
||||
S.timestampSecs += S.timestampMicrosecs / 1000000;
|
||||
S.timestampMicrosecs %= 1000000;
|
||||
}
|
||||
|
||||
static void OutputBgp4mp(const Mrthdr *hdr, Bgpattrtab tab)
|
||||
{
|
||||
S.lenientBgpErrors = TRUE;
|
||||
@ -90,8 +96,10 @@ void BgpgrepD_Bgp4mp(void)
|
||||
S.peerAs = BGP4MP_GETPEERADDR(hdr->subtype, &S.peerAddr, bgp4mp);
|
||||
S.timestampSecs = beswap32(hdr->timestamp);
|
||||
S.timestampMicrosecs = 0;
|
||||
if (hdr->subtype == MRT_BGP4MP_ET)
|
||||
if (hdr->type == MRT_BGP4MP_ET) {
|
||||
S.timestampMicrosecs = beswap32(((const Mrthdrex *) hdr)->microsecs);
|
||||
NormalizeExtendedTimestamp();
|
||||
}
|
||||
|
||||
// Dump MRT data
|
||||
Bgp_UnwrapBgp4mp(&S.rec, &S.msg, /*flags=*/BGPF_UNOWNED);
|
||||
|
@ -43,13 +43,13 @@ static Uint32 ParseFrac(const char *s, const char *p, char **ep)
|
||||
if (res != NCVENOERR)
|
||||
FATALF("%s: Expecting fractional portion of a second after '.'", s);
|
||||
|
||||
int ndigs = endp - p;
|
||||
double frac = pow(10, ndigs);
|
||||
int ndigs = endp - p;
|
||||
long double frac = pow(10, ndigs);
|
||||
|
||||
if (ep)
|
||||
*ep = endp;
|
||||
|
||||
return (Uint32) trunc((n / frac) * 100000.0);
|
||||
return (Uint32) truncl(n / frac * 1000000.0L);
|
||||
}
|
||||
|
||||
static Boolean ParseRfc3339(const char *s, Timestampop *dest)
|
||||
|
Reference in New Issue
Block a user