From 15526d8c4ce87e2376e8ad5041b1fe870bd93f44 Mon Sep 17 00:00:00 2001 From: Dmitry Podgorny Date: Sun, 31 Oct 2021 00:48:33 +0300 Subject: [PATCH] Fix warnings and errors in samples - Use from glibc, because Linux 5.15 removes - Pack whole structure instead of individual fields - Network is 32bit value, avoid unsigned long to work on 64bit systems --- Samples/ipxrcv.c | 2 +- Samples/ipxsend.c | 2 +- Samples/rip.c | 22 ++++++++++------------ Samples/sap.c | 26 ++++++++++++-------------- 4 files changed, 24 insertions(+), 28 deletions(-) diff --git a/Samples/ipxrcv.c b/Samples/ipxrcv.c index 6a7317f..48e329d 100644 --- a/Samples/ipxrcv.c +++ b/Samples/ipxrcv.c @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/Samples/ipxsend.c b/Samples/ipxsend.c index cf6c196..41a1bb7 100644 --- a/Samples/ipxsend.c +++ b/Samples/ipxsend.c @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/Samples/rip.c b/Samples/rip.c index 12d6e85..8619283 100644 --- a/Samples/rip.c +++ b/Samples/rip.c @@ -1,16 +1,18 @@ +#include #include +#include #include -#include +#include #include #include #include struct rip_data { - unsigned long rip_net; - unsigned short rip_hops __attribute__ ((packed)); - unsigned short rip_ticks __attribute__ ((packed)); -}; - + uint32_t rip_net; + uint16_t rip_hops; + uint16_t rip_ticks; +} __attribute__ ((packed)); + int main(int argc, char **argv) { @@ -47,7 +49,7 @@ main(int argc, char **argv) } bptr = msg; result -= 2; - printf("RIP packet from: %08lX:%02X%02X%02X%02X%02X%02X\n", + printf("RIP packet from: %08X:%02X%02X%02X%02X%02X%02X\n", htonl(sipx.sipx_network), sipx.sipx_node[0], sipx.sipx_node[1], sipx.sipx_node[2], sipx.sipx_node[3], @@ -55,14 +57,10 @@ main(int argc, char **argv) bptr += 2; rp = (struct rip_data *) bptr; while (result >= sizeof(struct rip_data)) { - printf("\tNET: %08lX HOPS: %d\n", ntohl(rp->rip_net), + printf("\tNET: %08X HOPS: %d\n", ntohl(rp->rip_net), ntohs(rp->rip_hops)); result -= sizeof(struct rip_data); rp++; } } } - - - - diff --git a/Samples/sap.c b/Samples/sap.c index 594e52d..3f4158c 100644 --- a/Samples/sap.c +++ b/Samples/sap.c @@ -1,20 +1,22 @@ +#include #include +#include #include -#include +#include #include #include #include struct sap_data { - unsigned short sap_type __attribute__ ((packed)); - char sap_name[48] __attribute__ ((packed)); - unsigned long sap_net __attribute__ ((packed)); - unsigned char sap_node[6] __attribute__ ((packed)); - unsigned short sap_sock __attribute__ ((packed)); - unsigned short sap_hops __attribute__ ((packed)); -}; - + uint16_t sap_type; + char sap_name[48]; + uint32_t sap_net; + uint8_t sap_node[6]; + uint16_t sap_sock; + uint16_t sap_hops; +} __attribute__ ((packed)); + int main(int argc, char **argv) { @@ -76,7 +78,7 @@ main(int argc, char **argv) sp->sap_name[i] = '\0'; printf("NAME: %s TYPE: %x HOPS: %x\n", sp->sap_name, ntohs(sp->sap_type), ntohs(sp->sap_hops)); - printf("%lx:%x %x %x %x %x %x: %x\n", + printf("%x:%x %x %x %x %x %x: %x\n", ntohl(sp->sap_net), sp->sap_node[0], sp->sap_node[1], @@ -90,7 +92,3 @@ main(int argc, char **argv) } } } - - - -