---
name: "libnet-macros.h"
section: "3"
platform: "linux"
package: "libnet1-dev"
version: "1.1.6+dfsg-3.2"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/libnet-macros.h"
---

# libnet-macros.h(3)

libnet macros and symbolic constants

## NAME

libnet-macros.h -

libnet macros and symbolic constants

## SYNOPSIS

### Defines

\#define **LIBNET\_DONT\_RESOLVE**   0\
 \#define **LIBNET\_RESOLVE**   1\
 \#define **LIBNET\_ON**   0\
 \#define **LIBNET\_OFF**   1\
 \#define **IN6ADDR\_ERROR\_INIT**\
 \#define **LIBNET\_PR2**   0\
 \#define **LIBNET\_PR8**   1\
 \#define **LIBNET\_PR16**   2\
 \#define **LIBNET\_PRu16**   3\
 \#define **LIBNET\_PR32**   4\
 \#define **LIBNET\_PRu32**   5\
 \#define **LIBNET\_PRAND\_MAX**   0xffffffff\
 \#define **LIBNET\_MAX\_PACKET**   0xffff\
 \#define **IP\_MAXPACKET**   0xffff\
 \#define **ETHER\_ADDR\_LEN**   0x6\
 \#define **FDDI\_ADDR\_LEN**   0x6\
 \#define **TOKEN\_RING\_ADDR\_LEN**   0x6\
 \#define **LIBNET\_ORG\_CODE\_SIZE**   0x3\
 \#define **LIBNET\_ERRBUF\_SIZE**   0x100\
 \#define **LIBNET\_MAXOPTION\_SIZE**   0x28\
 \#define **FIX**(n)   (n)\
 \#define **UNFIX**(n)   (n)\
 \#define **LIBNET\_DO\_PAYLOAD**(l, p)\
 \#define **LIBNET\_CKSUM\_CARRY**(x)   (x = (x \>\> 16) + (x & 0xffff), (~(x + (x \>\> 16)) & 0xffff))\
 \#define **LIBNET\_OSPF\_AUTHCPY**(x, y)   memcpy((uint8\_t \*)x, (uint8\_t \*)y, sizeof(y))\
 \#define **LIBNET\_OSPF\_CKSUMBUF**(x, y)   memcpy((uint8\_t \*)x, (uint8\_t \*)y, sizeof(y))\
 \#define **LIBNET\_NTP\_DO\_LI\_VN\_MODE**(li, vn, md)   ((uint8\_t)((((li) \<\< 6) & 0xc0) \| (((vn) \<\< 3) & 0x38) \| ((md) & 0x7)))\
 \#define **LIBNET\_ISLOOPBACK**(p)   (strcmp((p)-\>ifr\_name, 'lo') == 0)\
 \#define **LIBNET\_ISADVMODE**(x)   (x & 0x08)\
 \#define **LIBNET\_LABEL\_SIZE**   64\
 \#define **LIBNET\_LABEL\_DEFAULT**   'cardshark'\
 \#define **CQ\_LOCK\_UNLOCKED**   (u\_int)0x00000000\
 \#define **CQ\_LOCK\_READ**   (u\_int)0x00000001\
 \#define **CQ\_LOCK\_WRITE**   (u\_int)0x00000002\
 \#define **for\_each\_context\_in\_cq**(l)   for (l = libnet\_cq\_head(); libnet\_cq\_last(); l = libnet\_cq\_next())\
 \#define **cq\_is\_wlocked**()   (l\_cqd.cq\_lock & CQ\_LOCK\_WRITE)\
 \#define **cq\_is\_rlocked**()   (l\_cqd.cq\_lock & CQ\_LOCK\_READ)\
 \#define **cq\_is\_locked**()   (l\_cqd.cq\_lock & (CQ\_LOCK\_READ \| CQ\_LOCK\_WRITE))\
 \#define **check\_cq\_lock**(x)   (l\_cqd.cq\_lock & x)\

## Detailed Description

libnet macros and symbolic constants

## Define Documentation

### #define for\_each\_context\_in\_cq(l) for (l = libnet\_cq\_head(); libnet\_cq\_last(); l = libnet\_cq\_next()) Provides an interface to iterate through the context queue of libnet contexts. Before calling this macro, be sure to set the queue using libnet\_cq\_head().

### #define IN6ADDR\_ERROR\_INIT Value:

```
{ { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,                                  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,                                  0xff, 0xff } } }
```

IPv6 error code

### #define LIBNET\_DO\_PAYLOAD(l, p) Value:

```
if (payload_s && !payload)                                                   {                                                                                snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,                                             '%s(): payload inconsistency0, __func__);                          goto bad;                                                                }                                                                            if (payload_s)                                                               {                                                                                n = libnet_pblock_append(l, p, payload, payload_s);                          if (n == (uint32_t) - 1)                                                     {                                                                                goto bad;                                                                }                                                                        }                                                                            .fi
```

### #define LIBNET\_DONT\_RESOLVE 0 Used for libnet's name resolution functions, specifies that no DNS lookups should be performed and the IP address should be kept in numeric form.

### #define LIBNET\_ERRBUF\_SIZE 0x100 The libnet error buffer is 256 bytes long.

### #define LIBNET\_MAX\_PACKET 0xffff The biggest an IP packet can be -- 65,535 bytes.

### #define LIBNET\_MAXOPTION\_SIZE 0x28 IP and TCP options can be up to 40 bytes long.

### #define LIBNET\_OFF 1 Used several places, to specify 'on' or 'one'

### #define LIBNET\_ON 0 Used several places, to specify 'on' or 'one'

### #define LIBNET\_PR2 0 Used for libnet\_get\_prand() to specify function disposition

### #define LIBNET\_RESOLVE 1 Used for libnet's name resolution functions, specifies that a DNS lookup can be performed if needed to resolve the IP address to a canonical form.

## Author

Generated automatically by Doxygen for libnet from the source code.
