version 1.1.1.1, 2012/02/21 22:14:23
|
version 1.1.1.2, 2013/07/22 11:54:42
|
Line 43
|
Line 43
|
#endif |
#endif |
|
|
libnet_ptag_t |
libnet_ptag_t |
libnet_build_ospfv2(u_int16_t len, u_int8_t type, u_int32_t rtr_id, | libnet_build_ospfv2(uint16_t len, uint8_t type, uint32_t rtr_id, |
u_int32_t area_id, u_int16_t sum, u_int16_t autype, u_int8_t *payload, | uint32_t area_id, uint16_t sum, uint16_t autype, const uint8_t *payload, |
u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag) | uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag) |
{ |
{ |
u_int32_t n, h; | uint32_t n, h; |
libnet_pblock_t *p; |
libnet_pblock_t *p; |
struct libnet_ospf_hdr ospf_hdr; |
struct libnet_ospf_hdr ospf_hdr; |
|
|
Line 73 u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
|
Line 73 u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
|
ospf_hdr.ospf_v = 2; /* OSPF version 2 */ |
ospf_hdr.ospf_v = 2; /* OSPF version 2 */ |
ospf_hdr.ospf_type = type; /* Type of pkt */ |
ospf_hdr.ospf_type = type; /* Type of pkt */ |
ospf_hdr.ospf_len = htons(h); /* Pkt len */ |
ospf_hdr.ospf_len = htons(h); /* Pkt len */ |
ospf_hdr.ospf_rtr_id.s_addr = htonl(rtr_id); /* Router ID */ | ospf_hdr.ospf_rtr_id.s_addr = rtr_id; /* Router ID */ |
ospf_hdr.ospf_area_id.s_addr = htonl(area_id); /* Area ID */ | ospf_hdr.ospf_area_id.s_addr = area_id; /* Area ID */ |
ospf_hdr.ospf_sum = (sum ? htons(sum) : 0); | ospf_hdr.ospf_sum = sum; |
ospf_hdr.ospf_auth_type = htons(autype); /* Type of auth */ |
ospf_hdr.ospf_auth_type = htons(autype); /* Type of auth */ |
|
|
n = libnet_pblock_append(l, p, (u_int8_t *)&ospf_hdr, LIBNET_OSPF_H); | n = libnet_pblock_append(l, p, (uint8_t *)&ospf_hdr, LIBNET_OSPF_H); |
if (n == -1) |
if (n == -1) |
{ |
{ |
goto bad; |
goto bad; |
} |
} |
|
|
if ((payload && !payload_s) || (!payload && payload_s)) | /* boilerplate payload sanity check / append macro */ |
{ | LIBNET_DO_PAYLOAD(l, p); |
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, | |
"%s(): payload inconsistency\n", __func__); | |
goto bad; | |
} | |
| |
if (payload && payload_s) | |
{ | |
n = libnet_pblock_append(l, p, payload, payload_s); | |
if (n == -1) | |
{ | |
goto bad; | |
} | |
} | |
|
|
if (sum == 0) |
if (sum == 0) |
{ |
{ |
Line 117 bad:
|
Line 104 bad:
|
|
|
|
|
libnet_ptag_t |
libnet_ptag_t |
libnet_build_ospfv2_hello(u_int32_t netmask, u_int16_t interval, u_int8_t opts, | libnet_build_ospfv2_hello(uint32_t netmask, uint16_t interval, uint8_t opts, |
u_int8_t priority, u_int32_t dead_int, u_int32_t des_rtr, u_int32_t bkup_rtr, | uint8_t priority, uint32_t dead_int, uint32_t des_rtr, uint32_t bkup_rtr, |
u_int32_t neighbor, u_int8_t *payload, u_int32_t payload_s, libnet_t *l, | const uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag) |
libnet_ptag_t ptag) | |
{ |
{ |
u_int32_t n, h; | uint32_t n, h; |
libnet_pblock_t *p; |
libnet_pblock_t *p; |
struct libnet_ospf_hello_hdr hello_hdr; |
struct libnet_ospf_hello_hdr hello_hdr; |
|
|
Line 145 libnet_ptag_t ptag)
|
Line 131 libnet_ptag_t ptag)
|
} |
} |
|
|
memset(&hello_hdr, 0, sizeof(hello_hdr)); |
memset(&hello_hdr, 0, sizeof(hello_hdr)); |
hello_hdr.hello_nmask.s_addr = htonl(netmask); /* Netmask */ | hello_hdr.hello_nmask.s_addr = netmask; /* Netmask */ |
hello_hdr.hello_intrvl = htons(interval); /* # seconds since last packet sent */ |
hello_hdr.hello_intrvl = htons(interval); /* # seconds since last packet sent */ |
hello_hdr.hello_opts = opts; /* OSPF_* options */ |
hello_hdr.hello_opts = opts; /* OSPF_* options */ |
hello_hdr.hello_rtr_pri = priority; /* If 0, can't be backup */ |
hello_hdr.hello_rtr_pri = priority; /* If 0, can't be backup */ |
hello_hdr.hello_dead_intvl = htonl(dead_int); /* Time til router is deemed down */ |
hello_hdr.hello_dead_intvl = htonl(dead_int); /* Time til router is deemed down */ |
hello_hdr.hello_des_rtr.s_addr = htonl(des_rtr); /* Networks designated router */ | hello_hdr.hello_des_rtr.s_addr = des_rtr; /* Networks designated router */ |
hello_hdr.hello_bkup_rtr.s_addr = htonl(bkup_rtr); /* Networks backup 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, (u_int8_t *)&hello_hdr, LIBNET_OSPF_HELLO_H); | n = libnet_pblock_append(l, p, (uint8_t *)&hello_hdr, LIBNET_OSPF_HELLO_H); |
if (n == -1) |
if (n == -1) |
{ |
{ |
goto bad; |
goto bad; |
} |
} |
|
|
if ((payload && !payload_s) || (!payload && payload_s)) | /* boilerplate payload sanity check / append macro */ |
{ | LIBNET_DO_PAYLOAD(l, p); |
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, | |
"%s(): payload inconsistency\n", __func__); | |
goto bad; | |
} | |
|
|
if (payload && payload_s) |
|
{ |
|
n = libnet_pblock_append(l, p, payload, payload_s); |
|
if (n == -1) |
|
{ |
|
goto bad; |
|
} |
|
} |
|
|
|
return (ptag ? ptag : libnet_pblock_update(l, p, h, |
return (ptag ? ptag : libnet_pblock_update(l, p, h, |
LIBNET_PBLOCK_OSPF_HELLO_H)); |
LIBNET_PBLOCK_OSPF_HELLO_H)); |
bad: |
bad: |
Line 185 bad:
|
Line 158 bad:
|
|
|
|
|
libnet_ptag_t |
libnet_ptag_t |
libnet_build_ospfv2_dbd(u_int16_t dgram_len, u_int8_t opts, u_int8_t type, | libnet_build_ospfv2_dbd(uint16_t dgram_len, uint8_t opts, uint8_t type, |
u_int32_t seqnum, u_int8_t *payload, u_int32_t payload_s, libnet_t *l, | uint32_t seqnum, const uint8_t *payload, uint32_t payload_s, libnet_t *l, |
libnet_ptag_t ptag) |
libnet_ptag_t ptag) |
{ |
{ |
u_int32_t n, h; | uint32_t n, h; |
libnet_pblock_t *p; |
libnet_pblock_t *p; |
struct libnet_dbd_hdr dbd_hdr; |
struct libnet_dbd_hdr dbd_hdr; |
|
|
Line 217 libnet_ptag_t ptag)
|
Line 190 libnet_ptag_t ptag)
|
dbd_hdr.dbd_type = type; /* Type of exchange occuring */ |
dbd_hdr.dbd_type = type; /* Type of exchange occuring */ |
dbd_hdr.dbd_seq = htonl(seqnum); /* DBD sequence number */ |
dbd_hdr.dbd_seq = htonl(seqnum); /* DBD sequence number */ |
|
|
n = libnet_pblock_append(l, p, (u_int8_t *)&dbd_hdr, LIBNET_OSPF_DBD_H); | n = libnet_pblock_append(l, p, (uint8_t *)&dbd_hdr, LIBNET_OSPF_DBD_H); |
if (n == -1) |
if (n == -1) |
{ |
{ |
goto bad; |
goto bad; |
} |
} |
|
|
if ((payload && !payload_s) || (!payload && payload_s)) | /* boilerplate payload sanity check / append macro */ |
{ | LIBNET_DO_PAYLOAD(l, p); |
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, | |
"%s(): payload inconsistency\n", __func__); | |
goto bad; | |
} | |
| |
if (payload && payload_s) | |
{ | |
n = libnet_pblock_append(l, p, payload, payload_s); | |
if (n == -1) | |
{ | |
goto bad; | |
} | |
} | |
|
|
return (ptag ? ptag : libnet_pblock_update(l, p, h, |
return (ptag ? ptag : libnet_pblock_update(l, p, h, |
LIBNET_PBLOCK_OSPF_DBD_H)); |
LIBNET_PBLOCK_OSPF_DBD_H)); |
Line 248 bad:
|
Line 208 bad:
|
|
|
|
|
libnet_ptag_t |
libnet_ptag_t |
libnet_build_ospfv2_lsr(u_int32_t type, u_int lsid, u_int32_t advrtr, | libnet_build_ospfv2_lsr(uint32_t type, uint lsid, uint32_t advrtr, |
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag) | const uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag) |
{ |
{ |
u_int32_t n, h; | uint32_t n, h; |
libnet_pblock_t *p; |
libnet_pblock_t *p; |
struct libnet_lsr_hdr lsr_hdr; |
struct libnet_lsr_hdr lsr_hdr; |
|
|
Line 278 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, l
|
Line 238 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, l
|
lsr_hdr.lsr_lsid = htonl(lsid); /* Link State ID */ |
lsr_hdr.lsr_lsid = htonl(lsid); /* Link State ID */ |
lsr_hdr.lsr_adrtr.s_addr = htonl(advrtr); /* Advertising router */ |
lsr_hdr.lsr_adrtr.s_addr = htonl(advrtr); /* Advertising router */ |
|
|
n = libnet_pblock_append(l, p, (u_int8_t *)&lsr_hdr, LIBNET_OSPF_LSR_H); | n = libnet_pblock_append(l, p, (uint8_t *)&lsr_hdr, LIBNET_OSPF_LSR_H); |
if (n == -1) |
if (n == -1) |
{ |
{ |
goto bad; |
goto bad; |
} |
} |
|
|
if ((payload && !payload_s) || (!payload && payload_s)) | /* boilerplate payload sanity check / append macro */ |
{ | LIBNET_DO_PAYLOAD(l, p); |
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, | |
"%s(): payload inconsistency\n", __func__); | |
goto bad; | |
} | |
| |
if (payload && payload_s) | |
{ | |
n = libnet_pblock_append(l, p, payload, payload_s); | |
if (n == -1) | |
{ | |
goto bad; | |
} | |
} | |
|
|
return (ptag ? ptag : libnet_pblock_update(l, p, h, |
return (ptag ? ptag : libnet_pblock_update(l, p, h, |
LIBNET_PBLOCK_OSPF_LSR_H)); |
LIBNET_PBLOCK_OSPF_LSR_H)); |
Line 309 bad:
|
Line 256 bad:
|
|
|
|
|
libnet_ptag_t |
libnet_ptag_t |
libnet_build_ospfv2_lsu(u_int32_t num, u_int8_t *payload, u_int32_t payload_s, | libnet_build_ospfv2_lsu(uint32_t num, const uint8_t *payload, uint32_t payload_s, |
libnet_t *l, libnet_ptag_t ptag) |
libnet_t *l, libnet_ptag_t ptag) |
{ |
{ |
u_int32_t n, h; | uint32_t n, h; |
libnet_pblock_t *p; |
libnet_pblock_t *p; |
struct libnet_lsu_hdr lh_hdr; |
struct libnet_lsu_hdr lh_hdr; |
|
|
Line 337 libnet_t *l, libnet_ptag_t ptag)
|
Line 284 libnet_t *l, libnet_ptag_t ptag)
|
memset(&lh_hdr, 0, sizeof(lh_hdr)); |
memset(&lh_hdr, 0, sizeof(lh_hdr)); |
lh_hdr.lsu_num = htonl(num); /* Number of LSAs that will be bcasted */ |
lh_hdr.lsu_num = htonl(num); /* Number of LSAs that will be bcasted */ |
|
|
n = libnet_pblock_append(l, p, (u_int8_t *)&lh_hdr, LIBNET_OSPF_LSU_H); | n = libnet_pblock_append(l, p, (uint8_t *)&lh_hdr, LIBNET_OSPF_LSU_H); |
if (n == -1) |
if (n == -1) |
{ |
{ |
goto bad; |
goto bad; |
} |
} |
|
|
if ((payload && !payload_s) || (!payload && payload_s)) | /* boilerplate payload sanity check / append macro */ |
{ | LIBNET_DO_PAYLOAD(l, p); |
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, | |
"%s(): payload inconsistency\n", __func__); | |
goto bad; | |
} | |
| |
if (payload && payload_s) | |
{ | |
n = libnet_pblock_append(l, p, payload, payload_s); | |
if (n == -1) | |
{ | |
goto bad; | |
} | |
} | |
|
|
return (ptag ? ptag : libnet_pblock_update(l, p, h, |
return (ptag ? ptag : libnet_pblock_update(l, p, h, |
LIBNET_PBLOCK_OSPF_LSU_H)); |
LIBNET_PBLOCK_OSPF_LSU_H)); |
Line 368 bad:
|
Line 302 bad:
|
|
|
|
|
libnet_ptag_t |
libnet_ptag_t |
libnet_build_ospfv2_lsa(u_int16_t age, u_int8_t opts, u_int8_t type, u_int lsid, | libnet_build_ospfv2_lsa(uint16_t age, uint8_t opts, uint8_t type, uint lsid, |
u_int32_t advrtr, u_int32_t seqnum, u_int16_t sum, u_int16_t len, | uint32_t advrtr, uint32_t seqnum, uint16_t sum, uint16_t len, |
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag) | const uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag) |
{ |
{ |
u_int32_t n, h; | uint32_t n, h; |
libnet_pblock_t *p; |
libnet_pblock_t *p; |
struct libnet_lsa_hdr lsa_hdr; |
struct libnet_lsa_hdr lsa_hdr; |
|
|
Line 401 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, l
|
Line 335 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, l
|
lsa_hdr.lsa_id = htonl(lsid); |
lsa_hdr.lsa_id = htonl(lsid); |
lsa_hdr.lsa_adv.s_addr = htonl(advrtr); |
lsa_hdr.lsa_adv.s_addr = htonl(advrtr); |
lsa_hdr.lsa_seq = htonl(seqnum); |
lsa_hdr.lsa_seq = htonl(seqnum); |
lsa_hdr.lsa_sum = (sum ? htons(sum) : 0); | lsa_hdr.lsa_sum = sum; |
lsa_hdr.lsa_len = htons(h); |
lsa_hdr.lsa_len = htons(h); |
|
|
n = libnet_pblock_append(l, p, (u_int8_t *)&lsa_hdr, LIBNET_OSPF_LSA_H); | n = libnet_pblock_append(l, p, (uint8_t *)&lsa_hdr, LIBNET_OSPF_LSA_H); |
if (n == -1) |
if (n == -1) |
{ |
{ |
goto bad; |
goto bad; |
} |
} |
|
|
if ((payload && !payload_s) || (!payload && payload_s)) | /* boilerplate payload sanity check / append macro */ |
{ | LIBNET_DO_PAYLOAD(l, p); |
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, | |
"%s(): payload inconsistency\n", __func__); | |
goto bad; | |
} | |
| |
if (payload && payload_s) | |
{ | |
n = libnet_pblock_append(l, p, payload, payload_s); | |
if (n == -1) | |
{ | |
goto bad; | |
} | |
} | |
|
|
if (sum == 0) |
if (sum == 0) |
{ |
{ |
Line 444 bad:
|
Line 365 bad:
|
|
|
|
|
libnet_ptag_t |
libnet_ptag_t |
libnet_build_ospfv2_lsa_rtr(u_int16_t flags, u_int16_t num, u_int32_t id, | libnet_build_ospfv2_lsa_rtr(uint16_t flags, uint16_t num, uint32_t id, |
u_int32_t data, u_int8_t type, u_int8_t tos, u_int16_t metric, | uint32_t data, uint8_t type, uint8_t tos, uint16_t metric, |
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag) | const uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag) |
{ |
{ |
u_int32_t n, h; | uint32_t n, h; |
libnet_pblock_t *p; |
libnet_pblock_t *p; |
struct libnet_rtr_lsa_hdr rtr_lsa_hdr; |
struct libnet_rtr_lsa_hdr rtr_lsa_hdr; |
|
|
Line 479 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, l
|
Line 400 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, l
|
rtr_lsa_hdr.rtr_tos_num = tos; |
rtr_lsa_hdr.rtr_tos_num = tos; |
rtr_lsa_hdr.rtr_metric = htons(metric); |
rtr_lsa_hdr.rtr_metric = htons(metric); |
|
|
n = libnet_pblock_append(l, p, (u_int8_t *)&rtr_lsa_hdr, | n = libnet_pblock_append(l, p, (uint8_t *)&rtr_lsa_hdr, |
LIBNET_OSPF_LS_RTR_H); |
LIBNET_OSPF_LS_RTR_H); |
if (n == -1) |
if (n == -1) |
{ |
{ |
goto bad; |
goto bad; |
} |
} |
|
|
if ((payload && !payload_s) || (!payload && payload_s)) | /* boilerplate payload sanity check / append macro */ |
{ | LIBNET_DO_PAYLOAD(l, p); |
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, | |
"%s(): payload inconsistency\n", __func__); | |
goto bad; | |
} | |
| |
if (payload && payload_s) | |
{ | |
n = libnet_pblock_append(l, p, payload, payload_s); | |
if (n == -1) | |
{ | |
goto bad; | |
} | |
} | |
|
|
return (ptag ? ptag : libnet_pblock_update(l, p, h, |
return (ptag ? ptag : libnet_pblock_update(l, p, h, |
LIBNET_PBLOCK_LS_RTR_H)); |
LIBNET_PBLOCK_LS_RTR_H)); |
Line 511 bad:
|
Line 419 bad:
|
|
|
|
|
libnet_ptag_t |
libnet_ptag_t |
libnet_build_ospfv2_lsa_net(u_int32_t nmask, u_int32_t rtrid, | libnet_build_ospfv2_lsa_net(uint32_t nmask, uint32_t rtrid, |
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag) | const uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag) |
{ |
{ |
u_int32_t n, h; | uint32_t n, h; |
libnet_pblock_t *p; |
libnet_pblock_t *p; |
struct libnet_net_lsa_hdr net_lsa_hdr; |
struct libnet_net_lsa_hdr net_lsa_hdr; |
|
|
Line 540 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, l
|
Line 448 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, l
|
net_lsa_hdr.net_nmask.s_addr = htonl(nmask); |
net_lsa_hdr.net_nmask.s_addr = htonl(nmask); |
net_lsa_hdr.net_rtr_id = htonl(rtrid); |
net_lsa_hdr.net_rtr_id = htonl(rtrid); |
|
|
n = libnet_pblock_append(l, p, (u_int8_t *)&net_lsa_hdr, | n = libnet_pblock_append(l, p, (uint8_t *)&net_lsa_hdr, |
LIBNET_OSPF_LS_NET_H); |
LIBNET_OSPF_LS_NET_H); |
if (n == -1) |
if (n == -1) |
{ |
{ |
goto bad; |
goto bad; |
} |
} |
|
|
if ((payload && !payload_s) || (!payload && payload_s)) | /* boilerplate payload sanity check / append macro */ |
{ | LIBNET_DO_PAYLOAD(l, p); |
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, | |
"%s(): payload inconsistency\n", __func__); | |
goto bad; | |
} | |
| |
if (payload && payload_s) | |
{ | |
n = libnet_pblock_append(l, p, payload, payload_s); | |
if (n == -1) | |
{ | |
goto bad; | |
} | |
} | |
|
|
return (ptag ? ptag : libnet_pblock_update(l, p, h, |
return (ptag ? ptag : libnet_pblock_update(l, p, h, |
LIBNET_PBLOCK_LS_NET_H)); |
LIBNET_PBLOCK_LS_NET_H)); |
Line 572 bad:
|
Line 467 bad:
|
|
|
|
|
libnet_ptag_t |
libnet_ptag_t |
libnet_build_ospfv2_lsa_sum(u_int32_t nmask, u_int32_t metric, u_int tos, | libnet_build_ospfv2_lsa_sum(uint32_t nmask, uint32_t metric, uint tos, |
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag) | const uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag) |
{ |
{ |
u_int32_t n, h; | uint32_t n, h; |
libnet_pblock_t *p; |
libnet_pblock_t *p; |
struct libnet_sum_lsa_hdr sum_lsa_hdr; |
struct libnet_sum_lsa_hdr sum_lsa_hdr; |
|
|
Line 602 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, l
|
Line 497 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, l
|
sum_lsa_hdr.sum_metric = htonl(metric); |
sum_lsa_hdr.sum_metric = htonl(metric); |
sum_lsa_hdr.sum_tos_metric = htonl(tos); |
sum_lsa_hdr.sum_tos_metric = htonl(tos); |
|
|
n = libnet_pblock_append(l, p, (u_int8_t *)&sum_lsa_hdr, | n = libnet_pblock_append(l, p, (uint8_t *)&sum_lsa_hdr, |
LIBNET_OSPF_LS_SUM_H); |
LIBNET_OSPF_LS_SUM_H); |
if (n == -1) |
if (n == -1) |
{ |
{ |
goto bad; |
goto bad; |
} |
} |
|
|
if ((payload && !payload_s) || (!payload && payload_s)) | /* boilerplate payload sanity check / append macro */ |
{ | LIBNET_DO_PAYLOAD(l, p); |
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, | |
"%s(): payload inconsistency\n", __func__); | |
goto bad; | |
} | |
| |
if (payload && payload_s) | |
{ | |
n = libnet_pblock_append(l, p, payload, payload_s); | |
if (n == -1) | |
{ | |
goto bad; | |
} | |
} | |
|
|
return (ptag ? ptag : libnet_pblock_update(l, p, h, |
return (ptag ? ptag : libnet_pblock_update(l, p, h, |
LIBNET_PBLOCK_LS_SUM_H)); |
LIBNET_PBLOCK_LS_SUM_H)); |
Line 634 bad:
|
Line 516 bad:
|
|
|
|
|
libnet_ptag_t |
libnet_ptag_t |
libnet_build_ospfv2_lsa_as(u_int32_t nmask, u_int metric, u_int32_t fwdaddr, | libnet_build_ospfv2_lsa_as(uint32_t nmask, uint metric, uint32_t fwdaddr, |
u_int32_t tag, u_int8_t *payload, u_int32_t payload_s, libnet_t *l, | uint32_t tag, const uint8_t *payload, uint32_t payload_s, libnet_t *l, |
libnet_ptag_t ptag) |
libnet_ptag_t ptag) |
{ |
{ |
u_int32_t n, h; | uint32_t n, h; |
libnet_pblock_t *p; |
libnet_pblock_t *p; |
struct libnet_as_lsa_hdr as_lsa_hdr; |
struct libnet_as_lsa_hdr as_lsa_hdr; |
|
|
Line 666 libnet_ptag_t ptag)
|
Line 548 libnet_ptag_t ptag)
|
as_lsa_hdr.as_fwd_addr.s_addr = htonl(fwdaddr); |
as_lsa_hdr.as_fwd_addr.s_addr = htonl(fwdaddr); |
as_lsa_hdr.as_rte_tag = htonl(tag); |
as_lsa_hdr.as_rte_tag = htonl(tag); |
|
|
n = libnet_pblock_append(l, p, (u_int8_t *)&as_lsa_hdr, | n = libnet_pblock_append(l, p, (uint8_t *)&as_lsa_hdr, |
LIBNET_OSPF_LS_AS_EXT_H); |
LIBNET_OSPF_LS_AS_EXT_H); |
if (n == -1) |
if (n == -1) |
{ |
{ |
goto bad; |
goto bad; |
} |
} |
|
|
if ((payload && !payload_s) || (!payload && payload_s)) | /* boilerplate payload sanity check / append macro */ |
{ | LIBNET_DO_PAYLOAD(l, p); |
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, | |
"%s(): payload inconsistency\n", __func__); | |
goto bad; | |
} | |
| |
if (payload && payload_s) | |
{ | |
n = libnet_pblock_append(l, p, payload, payload_s); | |
if (n == -1) | |
{ | |
goto bad; | |
} | |
} | |
|
|
return (ptag ? ptag : libnet_pblock_update(l, p, h, |
return (ptag ? ptag : libnet_pblock_update(l, p, h, |
LIBNET_PBLOCK_LS_AS_EXT_H)); |
LIBNET_PBLOCK_LS_AS_EXT_H)); |