--- embedaddon/libnet/src/libnet_build_ospf.c 2013/07/22 11:54:42 1.1.1.2 +++ embedaddon/libnet/src/libnet_build_ospf.c 2023/09/27 11:11:38 1.1.1.3 @@ -1,5 +1,5 @@ /* - * $Id: libnet_build_ospf.c,v 1.1.1.2 2013/07/22 11:54:42 misho Exp $ + * $Id: libnet_build_ospf.c,v 1.1.1.3 2023/09/27 11:11:38 misho Exp $ * * libnet * libnet_build_ospf.c - OSPF packet assembler @@ -33,14 +33,7 @@ * */ -#if (HAVE_CONFIG_H) -#include "../include/config.h" -#endif -#if (!(_WIN32) || (__CYGWIN__)) -#include "../include/libnet.h" -#else -#include "../include/win32/libnet.h" -#endif +#include "common.h" libnet_ptag_t libnet_build_ospfv2(uint16_t len, uint8_t type, uint32_t rtr_id, @@ -108,14 +101,24 @@ libnet_build_ospfv2_hello(uint32_t netmask, uint16_t i uint8_t priority, uint32_t dead_int, uint32_t des_rtr, uint32_t bkup_rtr, const uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag) { + return libnet_build_ospfv2_hello_neighbor(netmask, interval, opts, + priority, dead_int, des_rtr, bkup_rtr, 0, + payload, payload_s, l, ptag); +} + +libnet_ptag_t +libnet_build_ospfv2_hello_neighbor(uint32_t netmask, uint16_t interval, uint8_t opts, +uint8_t priority, uint32_t dead_int, uint32_t des_rtr, uint32_t bkup_rtr, uint32_t neighbor, +const uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag) +{ uint32_t n, h; libnet_pblock_t *p; struct libnet_ospf_hello_hdr hello_hdr; if (l == NULL) - { + { return (-1); - } + } n = LIBNET_OSPF_HELLO_H + payload_s; h = 0; @@ -129,7 +132,7 @@ const uint8_t *payload, uint32_t payload_s, libnet_t * { return (-1); } - + memset(&hello_hdr, 0, sizeof(hello_hdr)); hello_hdr.hello_nmask.s_addr = netmask; /* Netmask */ hello_hdr.hello_intrvl = htons(interval); /* # seconds since last packet sent */ @@ -138,7 +141,7 @@ const uint8_t *payload, uint32_t payload_s, libnet_t * hello_hdr.hello_dead_intvl = htonl(dead_int); /* Time til router is deemed down */ hello_hdr.hello_des_rtr.s_addr = des_rtr; /* Networks designated router */ hello_hdr.hello_bkup_rtr.s_addr = bkup_rtr; /* Networks backup router */ - /*hello_hdr.hello_nbr.s_addr = htonl(neighbor); */ + hello_hdr.hello_nbr.s_addr = htonl(neighbor); n = libnet_pblock_append(l, p, (uint8_t *)&hello_hdr, LIBNET_OSPF_HELLO_H); if (n == -1) @@ -148,15 +151,14 @@ const uint8_t *payload, uint32_t payload_s, libnet_t * /* boilerplate payload sanity check / append macro */ LIBNET_DO_PAYLOAD(l, p); - - return (ptag ? ptag : libnet_pblock_update(l, p, h, + + return (ptag ? ptag : libnet_pblock_update(l, p, h, LIBNET_PBLOCK_OSPF_HELLO_H)); bad: libnet_pblock_delete(l, p); return (-1); } - libnet_ptag_t libnet_build_ospfv2_dbd(uint16_t dgram_len, uint8_t opts, uint8_t type, uint32_t seqnum, const uint8_t *payload, uint32_t payload_s, libnet_t *l, @@ -208,7 +210,7 @@ bad: libnet_ptag_t -libnet_build_ospfv2_lsr(uint32_t type, uint lsid, uint32_t advrtr, +libnet_build_ospfv2_lsr(uint32_t type, uint32_t lsid, uint32_t advrtr, const uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag) { uint32_t n, h; @@ -302,7 +304,7 @@ bad: libnet_ptag_t -libnet_build_ospfv2_lsa(uint16_t age, uint8_t opts, uint8_t type, uint lsid, +libnet_build_ospfv2_lsa(uint16_t age, uint8_t opts, uint8_t type, uint32_t lsid, uint32_t advrtr, uint32_t seqnum, uint16_t sum, uint16_t len, const uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag) { @@ -467,7 +469,7 @@ bad: libnet_ptag_t -libnet_build_ospfv2_lsa_sum(uint32_t nmask, uint32_t metric, uint tos, +libnet_build_ospfv2_lsa_sum(uint32_t nmask, uint32_t metric, uint32_t tos, const uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag) { uint32_t n, h; @@ -516,7 +518,7 @@ bad: libnet_ptag_t -libnet_build_ospfv2_lsa_as(uint32_t nmask, uint metric, uint32_t fwdaddr, +libnet_build_ospfv2_lsa_as(uint32_t nmask, uint32_t metric, uint32_t fwdaddr, uint32_t tag, const uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag) { @@ -565,4 +567,9 @@ bad: return (-1); } -/* EOF */ +/** + * Local Variables: + * indent-tabs-mode: nil + * c-file-style: "stroustrup" + * End: + */