version 1.1.1.1, 2012/02/21 22:14:23
|
version 1.1.1.3, 2023/09/27 11:11:38
|
Line 30
|
Line 30
|
* |
* |
*/ |
*/ |
|
|
#if (HAVE_CONFIG_H) | #include "common.h" |
#include "../include/config.h" | |
#endif | |
#if (!(_WIN32) || (__CYGWIN__)) | |
#include "../include/libnet.h" | |
#else | |
#include "../include/win32/libnet.h" | |
#endif | |
|
|
libnet_ptag_t |
libnet_ptag_t |
libnet_build_mpls(u_int32_t label, u_int8_t experimental, u_int8_t bos, | libnet_build_mpls(uint32_t label, uint8_t experimental, uint8_t bos, |
u_int8_t ttl, u_int8_t *payload, u_int32_t payload_s, libnet_t *l, | uint8_t ttl, 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_mpls_hdr mpls_hdr; |
struct libnet_mpls_hdr mpls_hdr; |
|
|
Line 72 libnet_ptag_t ptag)
|
Line 65 libnet_ptag_t ptag)
|
((bos & 0x01) << 8) | |
((bos & 0x01) << 8) | |
((ttl & 0xff)))); |
((ttl & 0xff)))); |
|
|
n = libnet_pblock_append(l, p, (u_int8_t *)&mpls_hdr, LIBNET_MPLS_H); | n = libnet_pblock_append(l, p, (uint8_t *)&mpls_hdr, LIBNET_MPLS_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; |
|
} |
|
} |
|
|
|
/* |
/* |
* The link offset is actually 4 bytes further into the header than |
* The link offset is actually 4 bytes further into the header than |
* before (the MPLS header adds this 4 bytes). We need to update the |
* before (the MPLS header adds this 4 bytes). We need to update the |
Line 109 bad:
|
Line 89 bad:
|
return (-1); |
return (-1); |
} |
} |
|
|
/* EOF */ | /** |
| * Local Variables: |
| * indent-tabs-mode: nil |
| * c-file-style: "stroustrup" |
| * End: |
| */ |