From: Jeremy Sowden Date: Mon, 21 Aug 2023 19:42:29 +0000 (+0100) Subject: printpkt, raw2packet_BASE: keep gateway address in NBO X-Git-Tag: ulogd-2.0.9~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=57fed71654ca7e3eb06d87bf1110970262339b5a;p=thirdparty%2Fulogd2.git printpkt, raw2packet_BASE: keep gateway address in NBO Everywhere else ipv4 addresses are left in NBO until output. The only exception is the IP2HBIN filter, which is explicitly intended to convert from NBO to HBO. Signed-off-by: Jeremy Sowden Signed-off-by: Florian Westphal --- diff --git a/filter/raw2packet/ulogd_raw2packet_BASE.c b/filter/raw2packet/ulogd_raw2packet_BASE.c index 9117d27..1442348 100644 --- a/filter/raw2packet/ulogd_raw2packet_BASE.c +++ b/filter/raw2packet/ulogd_raw2packet_BASE.c @@ -645,7 +645,7 @@ static int _interp_icmp(struct ulogd_pluginstance *pi, struct icmphdr *icmph, break; case ICMP_REDIRECT: case ICMP_PARAMETERPROB: - okey_set_u32(&ret[KEY_ICMP_GATEWAY], ntohl(icmph->un.gateway)); + okey_set_u32(&ret[KEY_ICMP_GATEWAY], icmph->un.gateway); break; case ICMP_DEST_UNREACH: if (icmph->code == ICMP_FRAG_NEEDED) { diff --git a/util/printpkt.c b/util/printpkt.c index 11126b3..09a2194 100644 --- a/util/printpkt.c +++ b/util/printpkt.c @@ -260,8 +260,9 @@ static int printpkt_ipv4(struct ulogd_key *res, char *buf) ikey_get_u16(&res[KEY_ICMP_ECHOSEQ])); break; case ICMP_PARAMETERPROB: + paddr = ikey_get_u32(&res[KEY_ICMP_GATEWAY]); buf_cur += sprintf(buf_cur, "PARAMETER=%u ", - ikey_get_u32(&res[KEY_ICMP_GATEWAY]) >> 24); + *(uint8_t *) &paddr); break; case ICMP_REDIRECT: paddr = ikey_get_u32(&res[KEY_ICMP_GATEWAY]);