Annotation of embedaddon/libnet/include/libnet/libnet-functions.h, revision 1.1.1.2

1.1       misho       1: /*
1.1.1.2 ! misho       2:  *  $Id: libnet-functions.h,v 1.43 2004/11/09 07:05:07 mike Exp $
1.1       misho       3:  *
                      4:  *  libnet-functions.h - function prototypes
                      5:  *
                      6:  *  Copyright (c) 1998 - 2004 Mike D. Schiffman <mike@infonexus.com>
                      7:  *  All rights reserved.
                      8:  *
                      9:  * Redistribution and use in source and binary forms, with or without
                     10:  * modification, are permitted provided that the following conditions
                     11:  * are met:
                     12:  * 1. Redistributions of source code must retain the above copyright
                     13:  *    notice, this list of conditions and the following disclaimer.
                     14:  * 2. Redistributions in binary form must reproduce the above copyright
                     15:  *    notice, this list of conditions and the following disclaimer in the
                     16:  *    documentation and/or other materials provided with the distribution.
                     17:  *
                     18:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
                     19:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     20:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     21:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
                     22:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     23:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     24:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     25:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     26:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     27:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     28:  * SUCH DAMAGE.
                     29:  *
                     30:  */
                     31: 
                     32: #ifndef __LIBNET_FUNCTIONS_H
                     33: #define __LIBNET_FUNCTIONS_H
                     34: /**
                     35:  * @file libnet-functions.h
                     36:  * @brief libnet exported function prototypes
                     37:  */
                     38: 
                     39: /**
                     40:  * Creates the libnet environment. It initializes the library and returns a 
                     41:  * libnet context. If the injection_type is LIBNET_LINK or LIBNET_LINK_ADV, the
                     42:  * function initializes the injection primitives for the link-layer interface
                     43:  * enabling the application programmer to build packets starting at the
                     44:  * data-link layer (which also provides more granular control over the IP
                     45:  * layer). If libnet uses the link-layer and the device argument is non-NULL,
                     46:  * the function attempts to use the specified network device for packet
                     47:  * injection. This is either a canonical string that references the device
                     48:  * (such as "eth0" for a 100MB Ethernet card on Linux or "fxp0" for a 100MB
                     49:  * Ethernet card on OpenBSD) or the dots and decimals representation of the
                     50:  * device's IP address (192.168.0.1). If device is NULL, libnet attempts to
                     51:  * find a suitable device to use. If the injection_type is LIBNET_RAW4 or
                     52:  * LIBNET_RAW4_ADV, the function initializes the injection primitives for the
                     53:  * IPv4 raw socket interface. The final argument, err_buf, should be a buffer
                     54:  * of size LIBNET_ERRBUF_SIZE and holds an error message if the function fails.
                     55:  * This function requires root privileges to execute successfully. Upon
                     56:  * success, the function returns a valid libnet context for use in later
                     57:  * function calls; upon failure, the function returns NULL.
                     58:  * @param injection_type packet injection type (LIBNET_LINK, LIBNET_LINK_ADV, LIBNET_RAW4, LIBNET_RAW4_ADV, LIBNET_RAW6, LIBNET_RAW6_ADV)
                     59:  * @param device the interface to use (NULL and libnet will choose one)
                     60:  * @param err_buf will contain an error message on failure
                     61:  * @return libnet context ready for use or NULL on error.
                     62:  */
                     63: libnet_t *
1.1.1.2 ! misho      64: libnet_init(int injection_type, const char *device, char *err_buf);
1.1       misho      65: 
                     66: /**
                     67:  * Shuts down the libnet session referenced by l. It closes the network 
                     68:  * interface and frees all internal memory structures associated with l.  
                     69:  * @param l pointer to a libnet context
                     70:  */
                     71: void
                     72: libnet_destroy(libnet_t *l);
                     73: 
                     74: /**
                     75:  * Clears the current packet referenced and frees all pblocks. Should be
                     76:  * called when the programmer want to send a completely new packet of
                     77:  * a different type using the same context.
                     78:  * @param l pointer to a libnet context
                     79:  */
                     80: void
                     81: libnet_clear_packet(libnet_t *l);
                     82: 
                     83: /**
                     84:  * Fills in a libnet_stats structure with packet injection statistics
                     85:  * (packets written, bytes written, packet sending errors).
                     86:  * @param l pointer to a libnet context
                     87:  * @param ls pointer to a libnet statistics structure
                     88:  */
                     89: void
                     90: libnet_stats(libnet_t *l, struct libnet_stats *ls);
                     91: 
                     92: /**
                     93:  * Returns the FILENO of the file descriptor used for packet injection.
                     94:  * @param l pointer to a libnet context
                     95:  * @return the file number of the file descriptor used for packet injection
                     96:  */
                     97: int 
                     98: libnet_getfd(libnet_t *l);
                     99: 
                    100: /**
                    101:  * Returns the canonical name of the device used for packet injection.
                    102:  * @param l pointer to a libnet context
                    103:  * @return the canonical name of the device used for packet injection. Note 
                    104:  * it can be NULL without being an error.
                    105:  */
1.1.1.2 ! misho     106: const char *
1.1       misho     107: libnet_getdevice(libnet_t *l);
                    108: 
                    109: /**
                    110:  * Returns the pblock buffer contents for the specified ptag; a
                    111:  * subsequent call to libnet_getpbuf_size() should be made to determine the
                    112:  * size of the buffer.
                    113:  * @param l pointer to a libnet context
                    114:  * @param ptag the ptag reference number
                    115:  * @return a pointer to the pblock buffer or NULL on error
                    116:  */
1.1.1.2 ! misho     117: uint8_t *
1.1       misho     118: libnet_getpbuf(libnet_t *l, libnet_ptag_t ptag);
                    119: 
                    120: /**
                    121:  * Returns the pblock buffer size for the specified ptag; a
                    122:  * previous call to libnet_getpbuf() should be made to pull the actual buffer
                    123:  * contents.
                    124:  * @param l pointer to a libnet context
                    125:  * @param ptag the ptag reference number
                    126:  * @return the size of the pblock buffer
                    127:  */ 
1.1.1.2 ! misho     128: uint32_t
1.1       misho     129: libnet_getpbuf_size(libnet_t *l, libnet_ptag_t ptag);
                    130: 
                    131: /**
                    132:  * Returns the last error set inside of the referenced libnet context. This
                    133:  * function should be called anytime a function fails or an error condition
                    134:  * is detected inside of libnet.
                    135:  * @param l pointer to a libnet context
                    136:  * @return an error string or NULL if no error has occured
                    137:  */ 
                    138: char *
                    139: libnet_geterror(libnet_t *l);
                    140: 
                    141: /**
                    142:  * Returns the sum of the size of all of the pblocks inside of l (this should
                    143:  * be the resuling packet size).
                    144:  * @param l pointer to a libnet context
                    145:  * @return the size of the packet in l
                    146:  */ 
1.1.1.2 ! misho     147: uint32_t
1.1       misho     148: libnet_getpacket_size(libnet_t *l);
                    149: 
                    150: /**
                    151:  * Seeds the psuedo-random number generator.
                    152:  * @param l pointer to a libnet context
                    153:  * @return 1 on success, -1 on failure
                    154:  */
                    155: int
                    156: libnet_seed_prand(libnet_t *l);
                    157: 
                    158: /**
                    159:  * Generates an unsigned psuedo-random value within the range specified by
                    160:  * mod.
                    161:  * LIBNET_PR2    0 - 1
                    162:  * LIBNET_PR8    0 - 255
                    163:  * LIBNET_PR16   0 - 32767
                    164:  * LIBNET_PRu16  0 - 65535
                    165:  * LIBNET_PR32   0 - 2147483647
                    166:  * LIBNET_PRu32  0 - 4294967295
                    167:  *
                    168:  * @param mod one the of LIBNET_PR* constants
                    169:  * @return 1 on success, -1 on failure
                    170:  */
1.1.1.2 ! misho     171: uint32_t
1.1       misho     172: libnet_get_prand(int mod);
                    173: 
                    174: /**
                    175:  * If a given protocol header is built with the checksum field set to "0", by
                    176:  * default libnet will calculate the header checksum prior to injection. If the
                    177:  * header is set to any other value, by default libnet will not calculate the
                    178:  * header checksum. To over-ride this behavior, use libnet_toggle_checksum().
                    179:  * Switches auto-checksumming on or off for the specified ptag. If mode is set
                    180:  * to LIBNET_ON, libnet will mark the specificed ptag to calculate a checksum 
                    181:  * for the ptag prior to injection. This assumes that the ptag refers to a 
                    182:  * protocol that has a checksum field. If mode is set to LIBNET_OFF, libnet
                    183:  * will clear the checksum flag and no checksum will be computed prior to 
                    184:  * injection. This assumes that the programmer will assign a value (zero or
                    185:  * otherwise) to the checksum field.  Often times this is useful if a
                    186:  * precomputed checksum or some other predefined value is going to be used.
                    187:  * Note that when libnet is initialized with LIBNET_RAW4, the IPv4 header
                    188:  * checksum will always be computed by the kernel prior to injection, 
                    189:  * regardless of what the programmer sets.
                    190:  * @param l pointer to a libnet context
                    191:  * @param ptag the ptag reference number
                    192:  * @param mode LIBNET_ON or LIBNET_OFF
                    193:  * @return 1 on success, -1 on failure
                    194:  */
                    195: int
                    196: libnet_toggle_checksum(libnet_t *l, libnet_ptag_t ptag, int mode);
                    197: 
                    198: /**
                    199:  * Takes a network byte ordered IPv4 address and returns a pointer to either a 
                    200:  * canonical DNS name (if it has one) or a string of dotted decimals. This may
                    201:  * incur a DNS lookup if the hostname and mode is set to LIBNET_RESOLVE. If
                    202:  * mode is set to LIBNET_DONT_RESOLVE, no DNS lookup will be performed and
                    203:  * the function will return a pointer to a dotted decimal string. The function
                    204:  * cannot fail -- if no canonical name exists, it will fall back on returning
                    205:  * a dotted decimal string. This function is non-reentrant.
                    206:  * @param in network byte ordered IPv4 address
                    207:  * @param use_name LIBNET_RESOLVE or LIBNET_DONT_RESOLVE
                    208:  * @return a pointer to presentation format string
                    209:  */
                    210: char *
1.1.1.2 ! misho     211: libnet_addr2name4(uint32_t in, uint8_t use_name);
1.1       misho     212: 
                    213: /**
                    214:  * Takes a dotted decimal string or a canonical DNS name and returns a 
                    215:  * network byte ordered IPv4 address. This may incur a DNS lookup if mode is
                    216:  * set to LIBNET_RESOLVE and host_name refers to a canonical DNS name. If mode
                    217:  * is set to LIBNET_DONT_RESOLVE no DNS lookup will occur. The function can
                    218:  * fail if DNS lookup fails or if mode is set to LIBNET_DONT_RESOLVE and
                    219:  * host_name refers to a canonical DNS name.
                    220:  * @param l pointer to a libnet context
                    221:  * @param host_name pointer to a string containing a presentation format host
                    222:  * name
                    223:  * @param use_name LIBNET_RESOLVE or LIBNET_DONT_RESOLVE
                    224:  * @return network byte ordered IPv4 address or -1 (2^32 - 1) on error 
                    225:  */
1.1.1.2 ! misho     226: uint32_t
        !           227: libnet_name2addr4(libnet_t *l, char *host_name, uint8_t use_name);
1.1       misho     228: 
                    229: extern const struct libnet_in6_addr in6addr_error;
                    230: 
                    231: /**
1.1.1.2 ! misho     232:  * Check a libnet_in6_addr structure for identity with in6addr_error.
        !           233:  * @param addr address to check
        !           234:  * @return 1 if addr is in6addr_error, 0 if it is not
        !           235:  */
        !           236: int
        !           237: libnet_in6_is_error(struct libnet_in6_addr addr);
        !           238: 
        !           239: /**
1.1       misho     240:  * Takes a dotted decimal string or a canonical DNS name and returns a 
                    241:  * network byte ordered IPv6 address. This may incur a DNS lookup if mode is
                    242:  * set to LIBNET_RESOLVE and host_name refers to a canonical DNS name. If mode
                    243:  * is set to LIBNET_DONT_RESOLVE no DNS lookup will occur. The function can
                    244:  * fail if DNS lookup fails or if mode is set to LIBNET_DONT_RESOLVE and
                    245:  * host_name refers to a canonical DNS name.
                    246:  * @param l pointer to a libnet context
                    247:  * @param host_name pointer to a string containing a presentation format host
                    248:  * name
                    249:  * @param use_name LIBNET_RESOLVE or LIBNET_DONT_RESOLVE
                    250:  * @return network byte ordered IPv6 address structure 
                    251:  */
                    252: struct libnet_in6_addr
1.1.1.2 ! misho     253: libnet_name2addr6(libnet_t *l, const char *host_name, uint8_t use_name);
1.1       misho     254: 
                    255: /**
                    256:  * Should document this baby right here.
                    257:  */
                    258: void
1.1.1.2 ! misho     259: libnet_addr2name6_r(struct libnet_in6_addr addr, uint8_t use_name,
1.1       misho     260: char *host_name, int host_name_len);
                    261: 
                    262: /**
                    263:  * Creates a new port list. Port list chains are useful for TCP and UDP-based
                    264:  * applications that need to send packets to a range of ports (contiguous or
                    265:  * otherwise). The port list chain, which token_list points to, should contain
                    266:  * a series of int8_tacters from the following list: "0123456789,-" of the
                    267:  * general format "x - y, z", where "xyz" are port numbers between 0 and 
                    268:  * 65,535. plist points to the front of the port list chain list for use in 
                    269:  * further libnet_plist_chain() functions. Upon success, the function returns
                    270:  * 1. Upon failure, the function returns -1 and libnet_geterror() can tell you
                    271:  * why.
                    272:  * @param l pointer to a libnet context
                    273:  * @param plist if successful, will refer to the portlist, if not, NULL
                    274:  * @param token_list string containing the port list primitive
                    275:  * @return 1 on success, -1 on failure
                    276:  */
                    277: int
                    278: libnet_plist_chain_new(libnet_t *l, libnet_plist_t **plist, char *token_list);
                    279: 
                    280: /**
                    281:  * Returns the next port list chain pair from the port list chain plist. bport
                    282:  * and eport contain the starting port number and ending port number, 
                    283:  * respectively. Upon success, the function returns 1 and fills in the port
                    284:  * variables; however, if the list is empty, the function returns 0 and sets 
                    285:  * both port variables to 0. Upon failure, the function returns -1.
                    286:  * @param plist previously created portlist
                    287:  * @param bport will contain the beginning port number or 0
                    288:  * @param eport will contain the ending port number or 0
                    289:  * @return 1 on success, 0 if empty, -1 on failure
                    290:  */
                    291: int
1.1.1.2 ! misho     292: libnet_plist_chain_next_pair(libnet_plist_t *plist, uint16_t *bport, 
        !           293: uint16_t *eport); 
1.1       misho     294: 
                    295: /**
                    296:  * Runs through the port list and prints the contents of the port list chain
                    297:  * list to stdout.
                    298:  * @param plist previously created portlist
                    299:  * @return 1 on success, -1 on failure
                    300:  */
                    301: int
                    302: libnet_plist_chain_dump(libnet_plist_t *plist);
                    303: 
                    304: /**
                    305:  * Runs through the port list and prints the contents of the port list chain
                    306:  * list to string. This function uses strdup and is not re-entrant.  It also
                    307:  * has a memory leak and should not really be used.
                    308:  * @param plist previously created portlist
                    309:  * @return a printable string containing the port list contents on success
                    310:  * NULL on error
                    311:  */
                    312: char *
                    313: libnet_plist_chain_dump_string(libnet_plist_t *plist);
                    314: 
                    315: /**
                    316:  * Frees all memory associated with port list chain.
                    317:  * @param plist previously created portlist
                    318:  * @return 1 on success, -1 on failure
                    319:  */
                    320: int
                    321: libnet_plist_chain_free(libnet_plist_t *plist);
                    322: 
                    323: /**
                    324:  * @section PBF Packet Builder Functions
                    325:  *
                    326:  * The core of libnet is the platform-independent packet-building 
                    327:  * functionality. These functions enable an application programmer to build 
                    328:  * protocol headers (and data) in a simple and consistent manner without having
                    329:  * to worry (too much) about low-level network odds and ends. Each 
                    330:  * libnet_build() function builds a piece of a packet (generally a protocol 
                    331:  * header). While it is perfectly possible to build an entire, 
                    332:  * ready-to-transmit packet with a single call to a libnet_build() function, 
                    333:  * generally more than one builder-class function call is required to construct
                    334:  * a full packet. A complete wire-ready packet generally consists of more than 
                    335:  * one piece.
                    336:  * Every function that builds a protocol header takes a series of arguments 
                    337:  * roughly corresponding to the header values as they appear on the wire. This 
                    338:  * process is intuitive but often makes for functions with huge prototypes and 
                    339:  * large stack frames.
                    340:  * One important thing to note is that you must call these functions in order, 
                    341:  * corresponding to how they should appear on the wire (from the highest 
                    342:  * protocol layer on down). This building process is intuitive; it approximates
                    343:  * what happens in an operating system kernel. In other words, to build a 
                    344:  * Network Time Protocol (NTP) packet by using the link-layer interface, the 
                    345:  * application programmer would call the libnet_build() functions in the 
                    346:  * following order:
                    347:  * 1. libnet_build_ntp()
                    348:  * 2. libnet_build_udp()
                    349:  * 3. libnet_build_ipv4()
                    350:  * 4. libnet_build_ethernet()
                    351:  * This ordering is essential for libnet 1.1.x to properly link together the 
                    352:  * packet internally (previous libnet versions did not have the requirement).
                    353:  *
                    354:  * @subsection TPI The Payload Interface
                    355:  *
                    356:  * The payload interface specifies an optional way to include data directly 
                    357:  * after the protocol header in question. You can use this function for a 
                    358:  * variety of purposes, including the following:
                    359:  * - Including additional or arbitrary protocol header information that is not 
                    360:  *   available from a libnet interface
                    361:  * - Including a packet payload (data segment)
                    362:  * - Building another protocol header that is not available from a libnet 
                    363:  *   interface
                    364:  * To employ the interface, the application programmer should construct the i
1.1.1.2 ! misho     365:  * payload data and pass a const uint8_t * to this data and its size to the desired
1.1       misho     366:  * libnet_build() function. Libnet handles the rest.
                    367:  *
                    368:  * It is important to note that some functions (notably the IPv6 builders) do
                    369:  * use the payload interface to specify variable length but ostensibly 
                    370:  * non-optional data. See the individual libnet_build_ipv6*() functions for
                    371:  * more information.
                    372:  * 
                    373:  * @subsection PT Protocol Tags and Packet Builder Return Values
                    374:  *
                    375:  * Libnet uses the protocol tag (ptag) to identify individual pieces of a 
                    376:  * packet after being created. A new ptag results every time a libnet_build() 
                    377:  * function with an empty (0) ptag argument completes successfully. This new 
                    378:  * ptag now refers to the packet piece just created. The application 
                    379:  * programmer's responsibility is to save this value if he or she plans to 
                    380:  * modify this particular portion later on in the program. If the application 
                    381:  * programmer needs to modify some portion of that particular packet piece 
                    382:  * again, he or she calls the same libnet_build() function specifying the 
                    383:  * saved ptag argument. Libnet then searches for that packet piece and modifies
                    384:  * it rather than creating a new one. Upon failure for any reason, 
                    385:  * libnet_build() functions return -1; libnet_geterror() tells you why.
                    386:  */
                    387: 
                    388: /**
                    389:  * Builds an IEEE 802.1q VLAN tagging header. Depending on the value of
                    390:  * len_proto, the function wraps the 802.1q header inside either an IEEE 802.3
                    391:  * header or an RFC 894 Ethernet II (DIX) header (both resulting in an 18-byte
                    392:  * frame). If len is 1500 or less, most receiving protocol stacks parse the
                    393:  * frame as an IEEE 802.3 encapsulated frame. If len is one of the Ethernet type
                    394:  * values, most protocol stacks parse the frame as an RFC 894 Ethernet II
                    395:  * encapsulated frame. Note the length value is calculated without the 802.1q
                    396:  * header of 18 bytes.
                    397:  * @param dst pointer to a six byte source ethernet address
                    398:  * @param src pointer to a six byte destination ethernet address
                    399:  * @param tpi tag protocol identifier
                    400:  * @param priority priority
                    401:  * @param cfi canonical format indicator
                    402:  * @param vlan_id vlan identifier
                    403:  * @param len_proto length (802.3) protocol (Ethernet II) 
                    404:  * @param payload optional payload or NULL
                    405:  * @param payload_s payload length or 0
                    406:  * @param l pointer to a libnet context
                    407:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                    408:  * @return protocol tag value on success, -1 on error
                    409:  */
                    410: libnet_ptag_t
1.1.1.2 ! misho     411: libnet_build_802_1q(const uint8_t *dst, const uint8_t *src, uint16_t tpi,
        !           412: uint8_t priority, uint8_t cfi, uint16_t vlan_id, uint16_t len_proto,
        !           413: const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho     414: 
                    415: /**
                    416:  * Builds an IEEE 802.1x extended authentication protocol header.
                    417:  * @param eap_ver the EAP version
                    418:  * @param eap_type the EAP type
                    419:  * @param length frame length
                    420:  * @param payload optional payload or NULL
                    421:  * @param payload_s payload length or 0
                    422:  * @param l pointer to a libnet context
                    423:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                    424:  * @return protocol tag value on success, -1 on error
                    425:  */
                    426: libnet_ptag_t
1.1.1.2 ! misho     427: libnet_build_802_1x(uint8_t eap_ver, uint8_t eap_type, uint16_t length, 
        !           428: const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho     429: 
                    430: /**
                    431:  * Builds an IEEE 802.2 LLC header.
                    432:  * @param dsap destination service access point
                    433:  * @param ssap source service access point
                    434:  * @param control control field
                    435:  * @param payload optional payload or NULL
                    436:  * @param payload_s payload length or 0
                    437:  * @param l pointer to a libnet context
                    438:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                    439:  * @return protocol tag value on success, -1 on error
                    440:  */
                    441: libnet_ptag_t
1.1.1.2 ! misho     442: libnet_build_802_2(uint8_t dsap, uint8_t ssap, uint8_t control,
        !           443: const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho     444: 
                    445: /**
                    446:  * Builds an IEEE 802.2 LLC SNAP header.
                    447:  * @param dsap destination service access point
                    448:  * @param ssap source service access point
                    449:  * @param control control field
                    450:  * @param oui Organizationally Unique Identifier
                    451:  * @param type upper layer protocol
                    452:  * @param payload optional payload or NULL
                    453:  * @param payload_s payload length or 0
                    454:  * @param l pointer to a libnet context
                    455:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                    456:  * @return protocol tag value on success, -1 on error
                    457:  */
                    458: libnet_ptag_t
1.1.1.2 ! misho     459: libnet_build_802_2snap(uint8_t dsap, uint8_t ssap, uint8_t control, 
        !           460: uint8_t *oui, uint16_t type, const uint8_t* payload, uint32_t payload_s,
1.1       misho     461: libnet_t *l, libnet_ptag_t ptag); 
                    462: 
                    463: /**
                    464:  * Builds an IEEE 802.3 header. The 802.3 header is almost identical to the 
                    465:  * RFC 894 Ethernet II header, the exception being that the field immediately
                    466:  * following the source address holds the frame's length (as opposed to the
                    467:  * layer 3 protocol). You should only use this function when libnet is
                    468:  * initialized with the LIBNET_LINK interface.
                    469:  * @param dst destination ethernet address
                    470:  * @param src source ethernet address
                    471:  * @param len frame length sans header
                    472:  * @param payload optional payload or NULL
                    473:  * @param payload_s payload length or 0
                    474:  * @param l pointer to a libnet context
                    475:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                    476:  * @return protocol tag value on success, -1 on error
                    477:  */
                    478: libnet_ptag_t
1.1.1.2 ! misho     479: libnet_build_802_3(const uint8_t *dst, const uint8_t *src, uint16_t len, 
        !           480: const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho     481: 
                    482: /**
                    483:  * Builds an Ethernet header. The RFC 894 Ethernet II header is almost 
                    484:  * identical to the IEEE 802.3 header, with the exception that the field 
                    485:  * immediately following the source address holds the layer 3 protocol (as
                    486:  * opposed to frame's length). You should only use this function when 
                    487:  * libnet is initialized with the LIBNET_LINK interface. 
                    488:  * @param dst destination ethernet address
                    489:  * @param src source ethernet address
                    490:  * @param type upper layer protocol type
                    491:  * @param payload optional payload or NULL
                    492:  * @param payload_s payload length or 0
                    493:  * @param l pointer to a libnet context
                    494:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                    495:  * @return protocol tag value on success, -1 on error
                    496:  */
                    497: libnet_ptag_t
1.1.1.2 ! misho     498: libnet_build_ethernet(const uint8_t *dst, const uint8_t *src, uint16_t type, 
        !           499: const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho     500: 
                    501: /**
                    502:  * Autobuilds an Ethernet header. The RFC 894 Ethernet II header is almost 
                    503:  * identical to the IEEE 802.3 header, with the exception that the field 
                    504:  * immediately following the source address holds the layer 3 protocol (as
                    505:  * opposed to frame's length). You should only use this function when 
                    506:  * libnet is initialized with the LIBNET_LINK interface. 
                    507:  * @param dst destination ethernet address
                    508:  * @param type upper layer protocol type
                    509:  * @param l pointer to a libnet context
                    510:  * @return protocol tag value on success, -1 on error
                    511:  */
                    512: libnet_ptag_t
1.1.1.2 ! misho     513: libnet_autobuild_ethernet(const uint8_t *dst, uint16_t type, libnet_t *l);
1.1       misho     514: 
                    515: /**
                    516:  * Builds a Fiber Distributed Data Interface (FDDI) header.
                    517:  * @param fc class format and priority
1.1.1.2 ! misho     518:  * @param dst destination fddi address
        !           519:  * @param src source fddi address
1.1       misho     520:  * @param dsap destination service access point
                    521:  * @param ssap source service access point
                    522:  * @param cf cf
                    523:  * @param oui 3 byte IEEE organizational code
                    524:  * @param type upper layer protocol 
                    525:  * @param payload optional payload or NULL
                    526:  * @param payload_s payload length or 0
                    527:  * @param l pointer to a libnet context
                    528:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                    529:  * @return protocol tag value on success, -1 on error
                    530:  */
                    531: libnet_ptag_t
1.1.1.2 ! misho     532: libnet_build_fddi(uint8_t fc, const uint8_t *dst, const uint8_t *src, uint8_t dsap,
        !           533: uint8_t ssap, uint8_t cf, const uint8_t *oui, uint16_t type, const uint8_t* payload,
        !           534: uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho     535: 
                    536: /**
                    537:  * Autobuilds a Fiber Distributed Data Interface (FDDI) header.
                    538:  * @param fc class format and priority
1.1.1.2 ! misho     539:  * @param dst destination fddi address
1.1       misho     540:  * @param dsap destination service access point
                    541:  * @param ssap source service access point
                    542:  * @param cf cf
                    543:  * @param oui IEEE organizational code
                    544:  * @param type upper layer protocol 
                    545:  * @param l pointer to a libnet context
                    546:  * @return protocol tag value on success, -1 on error
                    547:  */
                    548: libnet_ptag_t
1.1.1.2 ! misho     549: libnet_autobuild_fddi(uint8_t fc, const uint8_t *dst, uint8_t dsap, uint8_t ssap,
        !           550: uint8_t cf, const uint8_t *oui, uint16_t type, libnet_t *l);
1.1       misho     551: 
                    552: /**
                    553:  * Builds an Address Resolution Protocol (ARP) header.  Depending on the op 
                    554:  * value, the function builds one of several different types of RFC 826 or
                    555:  * RFC 903 RARP packets.
                    556:  * @param hrd hardware address format
                    557:  * @param pro protocol address format
                    558:  * @param hln hardware address length
                    559:  * @param pln protocol address length
                    560:  * @param op ARP operation type
                    561:  * @param sha sender's hardware address
                    562:  * @param spa sender's protocol address
                    563:  * @param tha target hardware address
                    564:  * @param tpa targer protocol address
                    565:  * @param payload optional payload or NULL
                    566:  * @param payload_s payload length or 0
                    567:  * @param l pointer to a libnet context
                    568:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                    569:  * @return protocol tag value on success, -1 on error
                    570:  */
                    571: libnet_ptag_t
1.1.1.2 ! misho     572: libnet_build_arp(uint16_t hrd, uint16_t pro, uint8_t hln, uint8_t pln,
        !           573: uint16_t op, const uint8_t *sha, const uint8_t *spa, const uint8_t *tha, const uint8_t *tpa,
        !           574: const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho     575: 
                    576: /**
                    577:  * Autouilds an Address Resolution Protocol (ARP) header.  Depending on the op 
                    578:  * value, the function builds one of several different types of RFC 826 or
                    579:  * RFC 903 RARP packets.
                    580:  * @param op ARP operation type
                    581:  * @param sha sender's hardware address
                    582:  * @param spa sender's protocol address
                    583:  * @param tha target hardware address
                    584:  * @param tpa targer protocol address
                    585:  * @param l pointer to a libnet context
                    586:  * @return protocol tag value on success, -1 on error
                    587:  */
                    588: libnet_ptag_t
1.1.1.2 ! misho     589: libnet_autobuild_arp(uint16_t op, const uint8_t *sha, const uint8_t *spa, const uint8_t *tha,
        !           590: uint8_t *tpa, libnet_t *l);
1.1       misho     591: 
                    592: /**
                    593:  * Builds an RFC 793 Transmission Control Protocol (TCP) header.
                    594:  * @param sp source port
                    595:  * @param dp destination port
                    596:  * @param seq sequence number
                    597:  * @param ack acknowledgement number
                    598:  * @param control control flags
                    599:  * @param win window size
                    600:  * @param sum checksum (0 for libnet to autofill)
                    601:  * @param urg urgent pointer
1.1.1.2 ! misho     602:  * @param len total length of the TCP packet (for checksum calculation)
        !           603:  * @param payload
1.1       misho     604:  * @param payload_s payload length or 0
                    605:  * @param l pointer to a libnet context
                    606:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                    607:  * @return protocol tag value on success, -1 on error
                    608:  */
                    609: libnet_ptag_t
1.1.1.2 ! misho     610: libnet_build_tcp(uint16_t sp, uint16_t dp, uint32_t seq, uint32_t ack,
        !           611: uint8_t control, uint16_t win, uint16_t sum, uint16_t urg, uint16_t len, 
        !           612: const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho     613: 
                    614: /**
                    615:  * Builds an RFC 793 Transmission Control Protocol (TCP) options header.
                    616:  * The function expects options to be a valid TCP options string of size 
                    617:  * options_s, which is no larger than 40 bytes (the maximum size of an 
                    618:  * options string). The function checks to ensure that the packet consists of 
                    619:  * a TCP header preceded by an IPv4 header, and that the addition of the
                    620:  * options string would not result in a packet larger than 65,535 bytes
                    621:  * (IPMAXPACKET). The function counts up the number of 32-bit words in the
                    622:  * options string and adjusts the TCP header length value as necessary.
                    623:  * @param options byte string of TCP options
                    624:  * @param options_s length of options string
                    625:  * @param l pointer to a libnet context
                    626:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                    627:  * @return protocol tag value on success, -1 on error
                    628:  */
                    629: libnet_ptag_t
1.1.1.2 ! misho     630: libnet_build_tcp_options(const uint8_t *options, uint32_t options_s, libnet_t *l,
1.1       misho     631: libnet_ptag_t ptag);
                    632: 
                    633: /**
                    634:  * Builds an RFC 768 User Datagram Protocol (UDP) header.
                    635:  * @param sp source port
                    636:  * @param dp destination port
                    637:  * @param len total length of the UDP packet
                    638:  * @param sum checksum (0 for libnet to autofill)
                    639:  * @param payload optional payload or NULL
                    640:  * @param payload_s payload length or 0
                    641:  * @param l pointer to a libnet context
                    642:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                    643:  * @return protocol tag value on success, -1 on error
                    644:  */
                    645: libnet_ptag_t
1.1.1.2 ! misho     646: libnet_build_udp(uint16_t sp, uint16_t dp, uint16_t len, uint16_t sum,
        !           647: const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho     648: 
                    649: /**
                    650:  * Builds a Cisco Discovery Protocol (CDP) header. Cisco Systems designed CDP
                    651:  * to aid in the network management of adjacent Cisco devices. The CDP protocol
                    652:  * specifies data by using a type/length/value (TLV) setup. The first TLV can
                    653:  * specified by using the functions type, length, and value arguments. To
                    654:  * specify additional TLVs, the programmer could either use the payload 
                    655:  * interface or libnet_build_data() to construct them.
                    656:  * @param version CDP version
                    657:  * @param ttl time to live (time information should be cached by recipient)
                    658:  * @param sum checksum (0 for libnet to autofill)
                    659:  * @param type type of data contained in value
1.1.1.2 ! misho     660:  * @param value_s length of value argument
1.1       misho     661:  * @param value the CDP information string
                    662:  * @param payload optional payload or NULL
                    663:  * @param payload_s payload length or 0
                    664:  * @param l pointer to a libnet context
                    665:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                    666:  * @return protocol tag value on success, -1 on error
                    667:  */
                    668: libnet_ptag_t
1.1.1.2 ! misho     669: libnet_build_cdp(uint8_t version, uint8_t ttl, uint16_t sum, uint16_t type,
        !           670: uint16_t value_s, const uint8_t *value, const uint8_t* payload, uint32_t payload_s,
1.1       misho     671: libnet_t *l, libnet_ptag_t ptag);
                    672: 
                    673: /**
                    674:  * Builds an IP version 4 RFC 792 Internet Control Message Protocol (ICMP)
                    675:  * echo request/reply header
                    676:  * @param type type of ICMP packet (should be ICMP_ECHOREPLY or ICMP_ECHO)
                    677:  * @param code code of ICMP packet (should be 0)
                    678:  * @param sum checksum (0 for libnet to autofill)
                    679:  * @param id identification number
                    680:  * @param seq packet sequence number
                    681:  * @param payload optional payload or NULL
                    682:  * @param payload_s payload length or 0
                    683:  * @param l pointer to a libnet context
                    684:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                    685:  * @return protocol tag value on success, -1 on error
                    686:  */
                    687: libnet_ptag_t
1.1.1.2 ! misho     688: libnet_build_icmpv4_echo(uint8_t type, uint8_t code, uint16_t sum,
        !           689: uint16_t id, uint16_t seq, const uint8_t* payload, uint32_t payload_s,
1.1       misho     690: libnet_t *l, libnet_ptag_t ptag);
                    691: 
                    692: /**
                    693:  * Builds an IP version 4 RFC 792 Internet Control Message Protocol (ICMP)
                    694:  * IP netmask request/reply header.
                    695:  * @param type type of ICMP packet (should be ICMP_MASKREQ or ICMP_MASKREPLY)
                    696:  * @param code code of ICMP packet (should be 0)
                    697:  * @param sum checksum (0 for libnet to autofill)
                    698:  * @param id identification number
                    699:  * @param seq packet sequence number
                    700:  * @param mask subnet mask
                    701:  * @param payload optional payload or NULL
                    702:  * @param payload_s payload length or 0
                    703:  * @param l pointer to a libnet context
                    704:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                    705:  * @return protocol tag value on success, -1 on error
                    706:  */
                    707: libnet_ptag_t
1.1.1.2 ! misho     708: libnet_build_icmpv4_mask(uint8_t type, uint8_t code, uint16_t sum,
        !           709: uint16_t id, uint16_t seq, uint32_t mask, const uint8_t* payload,
        !           710: uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho     711: 
                    712: /**
                    713:  * Builds an IP version 4 RFC 792 Internet Control Message Protocol (ICMP)
                    714:  * unreachable header. The IP header that caused the error message should be 
                    715:  * built by a previous call to libnet_build_ipv4().
                    716:  * @param type type of ICMP packet (should be ICMP_UNREACH)
                    717:  * @param code code of ICMP packet (should be one of the 16 unreachable codes)
                    718:  * @param sum checksum (0 for libnet to autofill)
                    719:  * @param payload optional payload or NULL
                    720:  * @param payload_s payload length or 0
                    721:  * @param l pointer to a libnet context
                    722:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                    723:  * @return protocol tag value on success, -1 on error
                    724:  */
                    725: libnet_ptag_t
1.1.1.2 ! misho     726: libnet_build_icmpv4_unreach(uint8_t type, uint8_t code, uint16_t sum,
        !           727: const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho     728: 
                    729: /**
                    730:  * Builds an IP version 4 RFC 792 Internet Message Control Protocol (ICMP) 
                    731:  * redirect header.  The IP header that caused the error message should be 
                    732:  * built by a previous call to libnet_build_ipv4().
                    733:  * @param type type of ICMP packet (should be ICMP_REDIRECT)
                    734:  * @param code code of ICMP packet (should be one of the four redirect codes)
                    735:  * @param sum checksum (0 for libnet to autofill)
1.1.1.2 ! misho     736:  * @param gateway
1.1       misho     737:  * @param payload optional payload or NULL
                    738:  * @param payload_s payload length or 0
                    739:  * @param l pointer to a libnet context
                    740:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                    741:  * @return protocol tag value on success, -1 on error
                    742:  */
                    743: libnet_ptag_t
1.1.1.2 ! misho     744: libnet_build_icmpv4_redirect(uint8_t type, uint8_t code, uint16_t sum,
        !           745: uint32_t gateway, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
1.1       misho     746: libnet_ptag_t ptag);
                    747: 
                    748: /**
                    749:  * Builds an IP version 4 RFC 792 Internet Control Message Protocol (ICMP) time
                    750:  * exceeded header.  The IP header that caused the error message should be 
                    751:  * built by a previous call to libnet_build_ipv4().
                    752:  * @param type type of ICMP packet (should be ICMP_TIMXCEED)
                    753:  * @param code code of ICMP packet (ICMP_TIMXCEED_INTRANS / ICMP_TIMXCEED_REASS)
                    754:  * @param sum checksum (0 for libnet to autofill)
                    755:  * @param payload optional payload or NULL
                    756:  * @param payload optional payload or NULL
                    757:  * @param payload_s payload length or 0
                    758:  * @param l pointer to a libnet context
                    759:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                    760:  * @return protocol tag value on success, -1 on error
                    761:  */
                    762: libnet_ptag_t
1.1.1.2 ! misho     763: libnet_build_icmpv4_timeexceed(uint8_t type, uint8_t code, uint16_t sum,
        !           764: const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho     765: 
                    766: /**
                    767:  * Builds an IP version 4 RFC 792 Internet Control Message Protocol (ICMP)
                    768:  * timestamp request/reply header.
                    769:  * @param type type of ICMP packet (should be ICMP_TSTAMP or ICMP_TSTAMPREPLY)
                    770:  * @param code code of ICMP packet (should be 0)
                    771:  * @param sum checksum (0 for libnet to autofill)
                    772:  * @param id identification number
                    773:  * @param seq sequence number
                    774:  * @param otime originate timestamp
                    775:  * @param rtime receive timestamp
                    776:  * @param ttime transmit timestamp
                    777:  * @param payload optional payload or NULL
                    778:  * @param payload_s payload length or 0
                    779:  * @param l pointer to a libnet context
                    780:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                    781:  * @return protocol tag value on success, -1 on error
                    782:  */
                    783: libnet_ptag_t
1.1.1.2 ! misho     784: libnet_build_icmpv4_timestamp(uint8_t type, uint8_t code, uint16_t sum,
        !           785: uint16_t id, uint16_t seq, uint32_t otime, uint32_t rtime, uint32_t ttime,
        !           786: const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
        !           787: 
        !           788: /**
        !           789:  * Builds an IP version 6 RFC 4443 Internet Control Message Protocol (ICMP)
        !           790:  * echo or echo reply header.
        !           791:  * @param type type of ICMP packet (should be ICMP6_ECHO_REQUEST or ICMP6_ECHO_REPLY)
        !           792:  * @param code code of ICMP packet (should be zero)
        !           793:  * @param sum checksum (0 for libnet to autofill)
        !           794:  * @param id echo id number
        !           795:  * @param seq echo sequence number
        !           796:  * @param payload optional payload or NULL
        !           797:  * @param payload_s payload length or 0
        !           798:  * @param l pointer to a libnet context
        !           799:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
        !           800:  * @return protocol tag value on success, -1 on error
        !           801:  */
        !           802: libnet_ptag_t libnet_build_icmpv6_echo(uint8_t type, uint8_t code, uint16_t
        !           803:         sum, uint16_t id, uint16_t seq, uint8_t *payload, uint32_t payload_s,
        !           804:         libnet_t *l, libnet_ptag_t ptag);
        !           805: 
        !           806: /**
        !           807:  * Builds an IP version 6 RFC 4443 Internet Control Message Protocol (ICMP)
        !           808:  * unreachable header. The IP header that caused the error message should be 
        !           809:  * built by a previous call to libnet_build_ipv6().
        !           810:  * @param type type of ICMP packet (should be ICMP6_DST_UNREACH)
        !           811:  * @param code code of ICMP packet (should be one of the 5 ICMP6_DST_UNREACH_* codes)
        !           812:  * @param sum checksum (0 for libnet to autofill)
        !           813:  * @param payload optional payload or NULL
        !           814:  * @param payload_s payload length or 0
        !           815:  * @param l pointer to a libnet context
        !           816:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
        !           817:  * @return protocol tag value on success, -1 on error
        !           818:  */
        !           819: libnet_ptag_t
        !           820: libnet_build_icmpv6_unreach(uint8_t type, uint8_t code, uint16_t sum,
        !           821: uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
        !           822: 
        !           823: /**
        !           824:  * Builds an IP version 6 RFC 2461 Internet Control Message Protocol (ICMP)
        !           825:  * NDP neighbour solicitation header. Could be used with
        !           826:  * libnet_build_icmpv6_ndp_opt() and ICMPV6_NDP_OPT_SLLA.
        !           827:  * @param type type of ICMP packet (should be ND_NEIGHBOR_SOLICIT)
        !           828:  * @param code code of ICMP packet (should be zero)
        !           829:  * @param sum checksum (0 for libnet to autofill)
        !           830:  * @param target target ipv6 address
        !           831:  * @param payload optional payload or NULL
        !           832:  * @param payload_s payload length or 0
        !           833:  * @param l pointer to a libnet context
        !           834:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
        !           835:  * @return protocol tag value on success, -1 on error
        !           836:  */
        !           837: libnet_ptag_t libnet_build_icmpv6_ndp_nsol(uint8_t type, uint8_t code,
        !           838:         uint16_t sum, struct libnet_in6_addr target, uint8_t *payload, uint32_t
        !           839:         payload_s, libnet_t* l, libnet_ptag_t ptag);
        !           840: 
        !           841: /**
        !           842:  * Builds an IP version 6 RFC 2461 Internet Control Message Protocol (ICMP)
        !           843:  * NDP neighbour advertisement header. Could be used with
        !           844:  * libnet_build_icmpv6_ndp_opt() and ND_OPT_TARGET_LINKADDR.
        !           845:  * @param type type of ICMP packet (should be ND_NEIGHBOR_ADVERT)
        !           846:  * @param code code of ICMP packet (should be zero)
        !           847:  * @param sum checksum (0 for libnet to autofill)
        !           848:  * @param flags should be a bitwise or of any applicable ND_NA_FLAG_* flags
        !           849:  * @param target target ipv6 address
        !           850:  * @param payload optional payload or NULL
        !           851:  * @param payload_s payload length or 0
        !           852:  * @param l pointer to a libnet context
        !           853:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
        !           854:  * @return protocol tag value on success, -1 on error
        !           855:  */
        !           856: libnet_ptag_t libnet_build_icmpv6_ndp_nadv(uint8_t type, uint8_t code,
        !           857:         uint16_t sum, uint32_t flags, struct libnet_in6_addr target, uint8_t
        !           858:         *payload, uint32_t payload_s, libnet_t* l, libnet_ptag_t ptag);
        !           859: 
        !           860: /**
        !           861:  * Builds ICMPv6 NDP options.
        !           862:  * @param type one of ND_OPT_* types
        !           863:  * @param option option data
        !           864:  * @param option_s size of option data (will be padded out to an 8-byte boundary)
        !           865:  * @param l pointer to a libnet context
        !           866:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
        !           867:  * @return protocol tag value on success, -1 on error
        !           868:  */
        !           869: libnet_ptag_t libnet_build_icmpv6_ndp_opt(uint8_t type, uint8_t* option,
        !           870:         uint32_t option_s, libnet_t* l, libnet_ptag_t ptag);
1.1       misho     871: 
                    872: /**
                    873:  * Builds an RFC 1112 Internet Group Memebership Protocol (IGMP) header.
                    874:  * @param type packet type
1.1.1.2 ! misho     875:  * @param reserved (should be 0 for IGMPv1)
1.1       misho     876:  * @param sum checksum (0 for libnet to autofill)
1.1.1.2 ! misho     877:  * @param ip IPv4 address (in standard/network byte order)
1.1       misho     878:  * @param payload optional payload or NULL
                    879:  * @param payload_s payload length or 0
                    880:  * @param l pointer to a libnet context
                    881:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                    882:  * @return protocol tag value on success, -1 on error
1.1.1.2 ! misho     883:  * 
        !           884:  * @note 'reserved' was previously called 'code', which it is not, in any IGMP version.
1.1       misho     885:  */
                    886: libnet_ptag_t
1.1.1.2 ! misho     887: libnet_build_igmp(uint8_t type, uint8_t reserved, uint16_t sum, uint32_t ip,
        !           888: const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho     889: 
                    890: /**
                    891:  * Builds a version 4 RFC 791 Internet Protocol (IP) header.
1.1.1.2 ! misho     892:  *
        !           893:  * @param ip_len total length of the IP packet including all subsequent data (subsequent
        !           894:  *   data includes any IP options and IP options padding)
1.1       misho     895:  * @param tos type of service bits
                    896:  * @param id IP identification number
                    897:  * @param frag fragmentation bits and offset
                    898:  * @param ttl time to live in the network
                    899:  * @param prot upper layer protocol
                    900:  * @param sum checksum (0 for libnet to autofill)
                    901:  * @param src source IPv4 address (little endian)
                    902:  * @param dst destination IPv4 address (little endian)
                    903:  * @param payload optional payload or NULL
                    904:  * @param payload_s payload length or 0
                    905:  * @param l pointer to a libnet context
                    906:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                    907:  * @return protocol tag value on success, -1 on error
                    908:  */
                    909: libnet_ptag_t 
1.1.1.2 ! misho     910: libnet_build_ipv4(uint16_t ip_len, uint8_t tos, uint16_t id, uint16_t frag,
        !           911: uint8_t ttl, uint8_t prot, uint16_t sum, uint32_t src, uint32_t dst,
        !           912: const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho     913: 
                    914: /**
                    915:  * Builds an version 4 Internet Protocol (IP) options header. The function 
                    916:  * expects options to be a valid IP options string of size options_s, no larger
1.1.1.2 ! misho     917:  * than 40 bytes (the maximum size of an options string).
        !           918:  *
        !           919:  * When building a chain, the options must be built, then the IPv4 header.
        !           920:  *
        !           921:  * When updating a chain, if the block following the options is an IPv4 header,
        !           922:  * it's total length and header length will be updated if the options block
        !           923:  * size changes.
        !           924:  *
        !           925:  * @param options byte string of IP options (it will be padded up to be an integral
        !           926:  *   multiple of 32-bit words).
1.1       misho     927:  * @param options_s length of options string
                    928:  * @param l pointer to a libnet context
                    929:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                    930:  * @return protocol tag value on success, -1 on error
                    931:  */
                    932: libnet_ptag_t 
1.1.1.2 ! misho     933: libnet_build_ipv4_options(const uint8_t *options, uint32_t options_s, libnet_t *l,
1.1       misho     934: libnet_ptag_t ptag);
                    935: 
                    936: /**
1.1.1.2 ! misho     937:  * Autobuilds a version 4 Internet Protocol (IP) header. The function is useful
        !           938:  * to build an IP header quickly when you do not need a granular level of
1.1       misho     939:  * control. The function takes the same len, prot, and dst arguments as 
                    940:  * libnet_build_ipv4(). The function does not accept a ptag argument, but it
                    941:  * does return a ptag. In other words, you can use it to build a new IP header
                    942:  * but not to modify an existing one.
                    943:  * @param len total length of the IP packet including all subsequent data
                    944:  * @param prot upper layer protocol
                    945:  * @param dst destination IPv4 address (little endian)
                    946:  * @param l pointer to a libnet context
                    947:  * @return protocol tag value on success, -1 on error
                    948:  */
                    949: libnet_ptag_t
1.1.1.2 ! misho     950: libnet_autobuild_ipv4(uint16_t len, uint8_t prot, uint32_t dst, libnet_t *l);
1.1       misho     951: 
                    952: /**
                    953:  * Builds a version 6 RFC 2460 Internet Protocol (IP) header.
                    954:  * @param tc traffic class
                    955:  * @param fl flow label
                    956:  * @param len total length of the IP packet
                    957:  * @param nh next header
                    958:  * @param hl hop limit
                    959:  * @param src source IPv6 address
                    960:  * @param dst destination IPv6 address
                    961:  * @param payload optional payload or NULL
                    962:  * @param payload_s payload length or 0
                    963:  * @param l pointer to a libnet context
                    964:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                    965:  * @return protocol tag value on success, -1 on error
                    966:  */
                    967: libnet_ptag_t
1.1.1.2 ! misho     968: libnet_build_ipv6(uint8_t tc, uint32_t fl, uint16_t len, uint8_t nh,
        !           969: uint8_t hl, struct libnet_in6_addr src, struct libnet_in6_addr dst, 
        !           970: const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho     971: 
                    972: /**
                    973:  * Builds a version 6 RFC 2460 Internet Protocol (IP) fragmentation header.
                    974:  * @param nh next header
                    975:  * @param reserved unused value... OR IS IT!
                    976:  * @param frag fragmentation bits (ala ipv4)
                    977:  * @param id packet identification
                    978:  * @param payload optional payload or NULL
                    979:  * @param payload_s payload length or 0
                    980:  * @param l pointer to a libnet context
                    981:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                    982:  * @return protocol tag value on success, -1 on error
                    983:  */
                    984: libnet_ptag_t
1.1.1.2 ! misho     985: libnet_build_ipv6_frag(uint8_t nh, uint8_t reserved, uint16_t frag,
        !           986: uint32_t id, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
1.1       misho     987: libnet_ptag_t ptag);
                    988: 
                    989: /**
                    990:  * Builds a version 6 RFC 2460 Internet Protocol (IP) routing header. This
                    991:  * function is special in that it uses the payload interface to include the 
                    992:  * "type-specific data"; that is the routing information. Most often this will
                    993:  * be a number of 128-bit IPv6 addresses. The application programmer will build
                    994:  * a byte string of IPv6 address and pass them to the function using the
                    995:  * payload interface.
                    996:  * @param nh next header
                    997:  * @param len length of the header in 8-byte octets not including the first 8 octets
1.1.1.2 ! misho     998:  * @param rtype routing header type
1.1       misho     999:  * @param segments number of routing segments that follow
                   1000:  * @param payload optional payload of routing information
                   1001:  * @param payload_s payload length
                   1002:  * @param l pointer to a libnet context
                   1003:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1004:  * @return protocol tag value on success, -1 on error
                   1005:  */
                   1006: libnet_ptag_t
1.1.1.2 ! misho    1007: libnet_build_ipv6_routing(uint8_t nh, uint8_t len, uint8_t rtype,
        !          1008: uint8_t segments, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
1.1       misho    1009: libnet_ptag_t ptag);
                   1010: 
                   1011: /**
                   1012:  * Builds a version 6 RFC 2460 Internet Protocol (IP) destination options
                   1013:  * header. This function is special in that it uses the payload interface to
                   1014:  * include the options data. The application programmer will build an IPv6 
                   1015:  * options byte string and pass it to the function using the payload interface.
                   1016:  * @param nh next header
                   1017:  * @param len length of the header in 8-byte octets not including the first 8 octets
                   1018:  * @param payload options payload
                   1019:  * @param payload_s payload length
                   1020:  * @param l pointer to a libnet context
                   1021:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1022:  * @return protocol tag value on success, -1 on error
                   1023:  */
                   1024: libnet_ptag_t
1.1.1.2 ! misho    1025: libnet_build_ipv6_destopts(uint8_t nh, uint8_t len, const uint8_t* payload,
        !          1026: uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho    1027: 
                   1028: /**
                   1029:  * Builds a version 6 RFC 2460 Internet Protocol (IP) hop by hop options
                   1030:  * header. This function is special in that it uses the payload interface to
                   1031:  * include the options data. The application programmer will build an IPv6
                   1032:  * hop by hop options byte string and pass it to the function using the payload
                   1033:  * interface.
                   1034:  * @param nh next header
                   1035:  * @param len length of the header in 8-byte octets not including the first 8 octets
                   1036:  * @param payload options payload
                   1037:  * @param payload_s payload length
                   1038:  * @param l pointer to a libnet context
                   1039:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1040:  * @return protocol tag value on success, -1 on error
                   1041:  */
                   1042: libnet_ptag_t
1.1.1.2 ! misho    1043: libnet_build_ipv6_hbhopts(uint8_t nh, uint8_t len, const uint8_t* payload,
        !          1044: uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho    1045: 
                   1046: /**
1.1.1.2 ! misho    1047:  * Autobuilds a version 6 RFC 2460 Internet Protocol (IP) header. The function
        !          1048:  * is useful to build an IP header quickly when you do not need a granular
        !          1049:  * level of control. The function takes the same len, nh, and dst arguments
        !          1050:  * as libnet_build_ipv4(). The function does not accept a ptag argument, but it
        !          1051:  * does return a ptag. In other words, you can use it to build a new IP header
        !          1052:  * but not to modify an existing one.
        !          1053:  * This function requires libnet_get_ipaddr6(), which is not yet implemented
        !          1054:  * for Win32 platforms.
1.1       misho    1055:  * @param len length
                   1056:  * @param nh next header
                   1057:  * @param dst destination IPv6 address
                   1058:  * @param l pointer to a libnet context
                   1059:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1060:  * @return protocol tag value on success, -1 on error
                   1061:  */
                   1062: libnet_ptag_t
1.1.1.2 ! misho    1063: libnet_autobuild_ipv6(uint16_t len, uint8_t nh, struct libnet_in6_addr dst,
        !          1064: libnet_t *l, libnet_ptag_t ptag);
1.1       misho    1065: 
                   1066: /**
                   1067:  * Builds a Cisco Inter-Switch Link (ISL) header.
                   1068:  * @param dhost destination address (should be 01:00:0c:00:00)
                   1069:  * @param type type of frame
                   1070:  * @param user user defined data
                   1071:  * @param shost source mac address
                   1072:  * @param len total length of the encapuslated packet less 18 bytes
                   1073:  * @param snap SNAP information (0xaaaa03 + vendor code)
                   1074:  * @param vid 15 bit VLAN ID, 1 bit BPDU or CDP indicator
1.1.1.2 ! misho    1075:  * @param portindex port index
1.1       misho    1076:  * @param reserved used for FDDI and token ring
                   1077:  * @param payload optional payload or NULL
                   1078:  * @param payload_s payload length or 0
                   1079:  * @param l pointer to a libnet context
                   1080:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1081:  * @return protocol tag value on success, -1 on error
                   1082:  */
                   1083: libnet_ptag_t
1.1.1.2 ! misho    1084: libnet_build_isl(uint8_t *dhost, uint8_t type, uint8_t user,
        !          1085: uint8_t *shost, uint16_t len, const uint8_t *snap, uint16_t vid,
        !          1086: uint16_t portindex, uint16_t reserved, const uint8_t* payload,
        !          1087: uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho    1088: 
                   1089: /**
                   1090:  * Builds an Internet Protocol Security Encapsulating Security Payload header.
                   1091:  * @param spi security parameter index
                   1092:  * @param seq ESP sequence number
                   1093:  * @param iv initialization vector
                   1094:  * @param payload optional payload or NULL
                   1095:  * @param payload_s payload length or 0
                   1096:  * @param l pointer to a libnet context
                   1097:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1098:  * @return protocol tag value on success, -1 on error
                   1099:  */
                   1100: libnet_ptag_t
1.1.1.2 ! misho    1101: libnet_build_ipsec_esp_hdr(uint32_t spi, uint32_t seq, uint32_t iv,
        !          1102: const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho    1103: 
                   1104: /**
                   1105:  * Builds an Internet Protocol Security Encapsulating Security Payload footer.
                   1106:  * @param len padding length
                   1107:  * @param nh next header
                   1108:  * @param auth authentication data
                   1109:  * @param payload optional payload or NULL
                   1110:  * @param payload_s payload length or 0
                   1111:  * @param l pointer to a libnet context
                   1112:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1113:  * @return protocol tag value on success, -1 on error
                   1114:  */
                   1115: libnet_ptag_t
1.1.1.2 ! misho    1116: libnet_build_ipsec_esp_ftr(uint8_t len, uint8_t nh, int8_t *auth,
        !          1117: const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho    1118: 
                   1119: /**
                   1120:  * Builds an Internet Protocol Security Authentication header.
                   1121:  * @param nh next header
                   1122:  * @param len payload length
                   1123:  * @param res reserved
                   1124:  * @param spi security parameter index
                   1125:  * @param seq sequence number
                   1126:  * @param auth authentication data
                   1127:  * @param payload optional payload or NULL
                   1128:  * @param payload_s payload length or 0
                   1129:  * @param l pointer to a libnet context
                   1130:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1131:  * @return protocol tag value on success, -1 on error
                   1132:  */
                   1133: libnet_ptag_t
1.1.1.2 ! misho    1134: libnet_build_ipsec_ah(uint8_t nh, uint8_t len, uint16_t res,
        !          1135: uint32_t spi, uint32_t seq, uint32_t auth, const uint8_t* payload,
        !          1136: uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho    1137: 
                   1138: /**
                   1139:  * Builds an RFC 1035 version 4 DNS header. Additional DNS payload information
                   1140:  * should be specified using the payload interface.
1.1.1.2 ! misho    1141:  * @param h_len
1.1       misho    1142:  * @param id DNS packet id
                   1143:  * @param flags control flags
                   1144:  * @param num_q number of questions
                   1145:  * @param num_anws_rr number of answer resource records
                   1146:  * @param num_auth_rr number of authority resource records
                   1147:  * @param num_addi_rr number of additional resource records
                   1148:  * @param payload optional payload or NULL
                   1149:  * @param payload_s payload length or 0
                   1150:  * @param l pointer to a libnet context
                   1151:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1152:  * @return protocol tag value on success, -1 on error
                   1153:  */
                   1154: libnet_ptag_t
1.1.1.2 ! misho    1155: libnet_build_dnsv4(uint16_t h_len, uint16_t id, uint16_t flags,
        !          1156: uint16_t num_q, uint16_t num_anws_rr, uint16_t num_auth_rr,
        !          1157: uint16_t num_addi_rr, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
1.1       misho    1158: libnet_ptag_t ptag);
                   1159: 
                   1160: /**
                   1161:  * Builds a Routing Information Protocol header (RFCs 1058 and 2453).
                   1162:  * @param cmd command
                   1163:  * @param version protocol version
                   1164:  * @param rd version one: 0, version two: routing domain
                   1165:  * @param af address family
                   1166:  * @param rt version one: 0, version two: route tag
                   1167:  * @param addr IPv4 address
                   1168:  * @param mask version one: 0, version two: subnet mask
                   1169:  * @param next_hop version one: 0, version two: next hop address
                   1170:  * @param metric routing metric
                   1171:  * @param payload optional payload or NULL
                   1172:  * @param payload_s payload length or 0
                   1173:  * @param l pointer to a libnet context
                   1174:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1175:  * @return protocol tag value on success, -1 on error
                   1176:  */
                   1177: libnet_ptag_t
1.1.1.2 ! misho    1178: libnet_build_rip(uint8_t cmd, uint8_t version, uint16_t rd, uint16_t af,
        !          1179: uint16_t rt, uint32_t addr, uint32_t mask, uint32_t next_hop,
        !          1180: uint32_t metric, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
1.1       misho    1181: libnet_ptag_t ptag);
                   1182: 
                   1183: /**
                   1184:  * Builds an Remote Procedure Call (Version 2) Call message header as
                   1185:  * specified in RFC 1831. This builder provides the option for
                   1186:  * specifying the record marking which is required when used with
                   1187:  * streaming protocols (TCP).
                   1188:  * @param rm record marking indicating the position in a stream, 0 otherwise
                   1189:  * @param xid transaction identifier used to link calls and replies
                   1190:  * @param prog_num remote program specification typically between 0 - 1fffffff
                   1191:  * @param prog_vers remote program version specification
                   1192:  * @param procedure procedure to be performed by remote program
                   1193:  * @param cflavor authentication credential type
                   1194:  * @param clength credential length (should be 0)
                   1195:  * @param cdata opaque credential data (currently unused)
                   1196:  * @param vflavor authentication verifier type
                   1197:  * @param vlength verifier length (should be 0)
                   1198:  * @param vdata opaque verifier data (currently unused)
                   1199:  * @param payload optional payload or NULL
                   1200:  * @param payload_s payload length or 0
                   1201:  * @param l pointer to a libnet context
                   1202:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1203:  * @return protocol tag value on success, -1 on error
                   1204:  */
                   1205: libnet_ptag_t
1.1.1.2 ! misho    1206: libnet_build_rpc_call(uint32_t rm, uint32_t xid, uint32_t prog_num,
        !          1207: uint32_t prog_vers, uint32_t procedure, uint32_t cflavor, uint32_t clength,
        !          1208: uint8_t *cdata, uint32_t vflavor, uint32_t vlength, const uint8_t *vdata,
        !          1209: const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho    1210: 
                   1211: /**
                   1212:  * Builds an IEEE 802.1d Spanning Tree Protocol (STP) configuration header.
                   1213:  * STP frames are usually encapsulated inside of an 802.2 + 802.3 frame 
                   1214:  * combination.
                   1215:  * @param id protocol id
                   1216:  * @param version protocol version
                   1217:  * @param bpdu_type bridge protocol data unit type
                   1218:  * @param flags flags
                   1219:  * @param root_id root id
                   1220:  * @param root_pc root path cost
                   1221:  * @param bridge_id bridge id
                   1222:  * @param port_id port id
                   1223:  * @param message_age message age
                   1224:  * @param max_age max age
                   1225:  * @param hello_time hello time
                   1226:  * @param f_delay forward delay
                   1227:  * @param payload optional payload or NULL
                   1228:  * @param payload_s payload length or 0
                   1229:  * @param l pointer to a libnet context
                   1230:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1231:  * @return protocol tag value on success, -1 on error
                   1232:  */
                   1233: libnet_ptag_t
1.1.1.2 ! misho    1234: libnet_build_stp_conf(uint16_t id, uint8_t version, uint8_t bpdu_type,
        !          1235: uint8_t flags, const uint8_t *root_id, uint32_t root_pc, const uint8_t *bridge_id,
        !          1236: uint16_t port_id, uint16_t message_age, uint16_t max_age, 
        !          1237: uint16_t hello_time, uint16_t f_delay, const uint8_t* payload,
        !          1238: uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho    1239: 
                   1240: /**
                   1241:  * Builds an IEEE 802.1d Spanning Tree Protocol (STP) topology change
                   1242:  * notification header. STP frames are usually encapsulated inside of an
                   1243:  * 802.2 + 802.3 frame combination.
                   1244:  * @param id protocol id
                   1245:  * @param version protocol version
                   1246:  * @param bpdu_type bridge protocol data unit type
                   1247:  * @param payload optional payload or NULL
                   1248:  * @param payload_s payload length or 0
                   1249:  * @param l pointer to a libnet context
                   1250:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1251:  * @return protocol tag value on success, -1 on error
                   1252:  */
                   1253: libnet_ptag_t
1.1.1.2 ! misho    1254: libnet_build_stp_tcn(uint16_t id, uint8_t version, uint8_t bpdu_type,
        !          1255: const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho    1256: 
                   1257: /**
                   1258:  * Builds a token ring header.
                   1259:  * @param ac access control
                   1260:  * @param fc frame control
                   1261:  * @param dst destination address
                   1262:  * @param src source address
                   1263:  * @param dsap destination service access point
                   1264:  * @param ssap source service access point
                   1265:  * @param cf control field
                   1266:  * @param oui Organizationally Unique Identifier
                   1267:  * @param type upper layer protocol type
                   1268:  * @param payload optional payload or NULL
                   1269:  * @param payload_s payload length or 0
                   1270:  * @param l pointer to a libnet context
                   1271:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1272:  * @return protocol tag value on success, -1 on error
                   1273:  */
                   1274: libnet_ptag_t
1.1.1.2 ! misho    1275: libnet_build_token_ring(uint8_t ac, uint8_t fc, const uint8_t *dst, const uint8_t *src,
        !          1276: uint8_t dsap, uint8_t ssap, uint8_t cf, const uint8_t *oui, uint16_t type,
        !          1277: const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho    1278: 
                   1279: /**
                   1280:  * Auto-builds a token ring header.
                   1281:  * @param ac access control
                   1282:  * @param fc frame control
                   1283:  * @param dst destination address
                   1284:  * @param dsap destination service access point
                   1285:  * @param ssap source service access point
                   1286:  * @param cf control field
                   1287:  * @param oui Organizationally Unique Identifier
                   1288:  * @param type upper layer protocol type
                   1289:  * @param l pointer to a libnet context
                   1290:  * @return protocol tag value on success, -1 on error
                   1291:  */
                   1292: libnet_ptag_t
1.1.1.2 ! misho    1293: libnet_autobuild_token_ring(uint8_t ac, uint8_t fc, const uint8_t *dst, 
        !          1294: uint8_t dsap, uint8_t ssap, uint8_t cf, const uint8_t *oui, uint16_t type,
1.1       misho    1295: libnet_t *l);
                   1296: 
                   1297: /**
                   1298:  * Builds an RFC 2338 Virtual Router Redundacy Protool (VRRP) header. Use the
                   1299:  * payload interface to specify address and autthentication information. To
                   1300:  * build a "legal" packet, the destination IPv4 address should be the multicast  * address 224.0.0.18, the IP TTL should be set to 255, and the IP protocol
                   1301:  * should be set to 112.
                   1302:  * @param version VRRP version (should be 2)
                   1303:  * @param type VRRP packet type (should be 1 -- ADVERTISEMENT)
                   1304:  * @param vrouter_id virtual router identification
                   1305:  * @param priority priority (higher numbers indicate higher priority)
                   1306:  * @param ip_count number of IPv4 addresses contained in this advertisement
                   1307:  * @param auth_type type of authentication (0, 1, 2 -- see RFC)
                   1308:  * @param advert_int interval between advertisements
                   1309:  * @param sum checksum (0 for libnet to autofill)
                   1310:  * @param payload optional payload or NULL
                   1311:  * @param payload_s payload length or 0
                   1312:  * @param l pointer to a libnet context
                   1313:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1314:  * @return protocol tag value on success, -1 on error
                   1315:  */
                   1316: libnet_ptag_t
1.1.1.2 ! misho    1317: libnet_build_vrrp(uint8_t version, uint8_t type, uint8_t vrouter_id,
        !          1318: uint8_t priority, uint8_t ip_count, uint8_t auth_type, uint8_t advert_int,
        !          1319: uint16_t sum, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
1.1       misho    1320: libnet_ptag_t ptag);
                   1321: 
                   1322: /**
                   1323:  * Builds an RFC 3032 Multi-Protocol Label Switching (MPLS) header.
                   1324:  * @param label 20-bit label value
                   1325:  * @param experimental 3-bit reserved field
                   1326:  * @param bos 1-bit bottom of stack identifier
                   1327:  * @param ttl time to live
                   1328:  * @param payload optional payload or NULL
                   1329:  * @param payload_s payload length or 0
                   1330:  * @param l pointer to a libnet context
                   1331:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1332:  * @return protocol tag value on success, -1 on error
                   1333:  */
                   1334: libnet_ptag_t
1.1.1.2 ! misho    1335: libnet_build_mpls(uint32_t label, uint8_t experimental, uint8_t bos,
        !          1336: uint8_t ttl, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
1.1       misho    1337: libnet_ptag_t ptag);
                   1338: 
                   1339: /**
                   1340:  * Builds an RFC 958 Network Time Protocol (NTP) header.
                   1341:  * @param leap_indicator the leap indicator
                   1342:  * @param version NTP protocol version
                   1343:  * @param mode NTP mode
                   1344:  * @param stratum stratum
                   1345:  * @param poll polling interval
                   1346:  * @param precision precision
1.1.1.2 ! misho    1347:  * @param delay_int delay interval
1.1       misho    1348:  * @param delay_frac delay fraction
                   1349:  * @param dispersion_int dispersion interval
                   1350:  * @param dispersion_frac dispersion fraction
                   1351:  * @param reference_id reference id
                   1352:  * @param ref_ts_int reference timestamp integer
                   1353:  * @param ref_ts_frac reference timestamp fraction
                   1354:  * @param orig_ts_int original timestamp integer
                   1355:  * @param orig_ts_frac original timestamp fraction
                   1356:  * @param rec_ts_int receiver timestamp integer
                   1357:  * @param rec_ts_frac reciever timestamp fraction
                   1358:  * @param xmt_ts_int transmit timestamp integer
                   1359:  * @param xmt_ts_frac transmit timestamp integer
                   1360:  * @param payload optional payload or NULL
                   1361:  * @param payload_s payload length or 0
                   1362:  * @param l pointer to a libnet context
                   1363:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1364:  * @return protocol tag value on success, -1 on error
                   1365:  */
                   1366: libnet_ptag_t
1.1.1.2 ! misho    1367: libnet_build_ntp(uint8_t leap_indicator, uint8_t version, uint8_t mode,
        !          1368: uint8_t stratum, uint8_t poll, uint8_t precision, uint16_t delay_int,
        !          1369: uint16_t delay_frac, uint16_t dispersion_int, uint16_t dispersion_frac,
        !          1370: uint32_t reference_id, uint32_t ref_ts_int, uint32_t ref_ts_frac,
        !          1371: uint32_t orig_ts_int, uint32_t orig_ts_frac, uint32_t rec_ts_int,
        !          1372: uint32_t rec_ts_frac, uint32_t xmt_ts_int, uint32_t xmt_ts_frac,
        !          1373: const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho    1374: 
                   1375: /**
1.1.1.2 ! misho    1376:  * @param len
        !          1377:  * @param type
        !          1378:  * @param rtr_id
        !          1379:  * @param area_id
        !          1380:  * @param sum
        !          1381:  * @param autype
1.1       misho    1382:  * @param payload optional payload or NULL
                   1383:  * @param payload_s payload length or 0
                   1384:  * @param l pointer to a libnet context
                   1385:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1386:  * @return protocol tag value on success, -1 on error
                   1387:  */
                   1388: libnet_ptag_t
1.1.1.2 ! misho    1389: libnet_build_ospfv2(uint16_t len, uint8_t type, uint32_t rtr_id,
        !          1390: uint32_t area_id, uint16_t sum, uint16_t autype, const uint8_t* payload,
        !          1391: uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho    1392: 
                   1393: /**
1.1.1.2 ! misho    1394:  * @param netmask
        !          1395:  * @param interval
        !          1396:  * @param opts
        !          1397:  * @param priority
        !          1398:  * @param dead_int
        !          1399:  * @param des_rtr
        !          1400:  * @param bkup_rtr
1.1       misho    1401:  * @param payload optional payload or NULL
                   1402:  * @param payload_s payload length or 0
                   1403:  * @param l pointer to a libnet context
                   1404:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1405:  * @return protocol tag value on success, -1 on error
                   1406:  */
                   1407: libnet_ptag_t
1.1.1.2 ! misho    1408: libnet_build_ospfv2_hello(uint32_t netmask, uint16_t interval, uint8_t opts,
        !          1409: uint8_t priority, uint dead_int, uint32_t des_rtr, uint32_t bkup_rtr,
        !          1410: const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho    1411:  
                   1412: /**
1.1.1.2 ! misho    1413:  * @param dgram_len
        !          1414:  * @param opts
        !          1415:  * @param type
        !          1416:  * @param seqnum
1.1       misho    1417:  * @param payload optional payload or NULL
                   1418:  * @param payload_s payload length or 0
                   1419:  * @param l pointer to a libnet context
                   1420:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1421:  * @return protocol tag value on success, -1 on error
                   1422:  */
                   1423: libnet_ptag_t
1.1.1.2 ! misho    1424: libnet_build_ospfv2_dbd(uint16_t dgram_len, uint8_t opts, uint8_t type,
        !          1425: uint seqnum, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
1.1       misho    1426: libnet_ptag_t ptag);
                   1427:  
                   1428: /**
1.1.1.2 ! misho    1429:  * @param type
        !          1430:  * @param lsid
        !          1431:  * @param advrtr
1.1       misho    1432:  * @param payload optional payload or NULL
                   1433:  * @param payload_s payload length or 0
                   1434:  * @param l pointer to a libnet context
                   1435:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1436:  * @return protocol tag value on success, -1 on error
                   1437:  */
                   1438: libnet_ptag_t
1.1.1.2 ! misho    1439: libnet_build_ospfv2_lsr(uint type, uint lsid, uint32_t advrtr,
        !          1440: const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho    1441:  
                   1442: /**
1.1.1.2 ! misho    1443:  * @param num
1.1       misho    1444:  * @param payload optional payload or NULL
                   1445:  * @param payload_s payload length or 0
                   1446:  * @param l pointer to a libnet context
                   1447:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1448:  * @return protocol tag value on success, -1 on error
                   1449:  */
                   1450: libnet_ptag_t
1.1.1.2 ! misho    1451: libnet_build_ospfv2_lsu(uint num, const uint8_t* payload, uint32_t payload_s,
1.1       misho    1452: libnet_t *l, libnet_ptag_t ptag);
                   1453: 
                   1454: /**
1.1.1.2 ! misho    1455:  * @param age
        !          1456:  * @param opts
        !          1457:  * @param type
        !          1458:  * @param lsid
        !          1459:  * @param advrtr
        !          1460:  * @param seqnum
        !          1461:  * @param sum
        !          1462:  * @param len
1.1       misho    1463:  * @param payload optional payload or NULL
                   1464:  * @param payload_s payload length or 0
                   1465:  * @param l pointer to a libnet context
                   1466:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1467:  * @return protocol tag value on success, -1 on error
                   1468:  */
                   1469: libnet_ptag_t
1.1.1.2 ! misho    1470: libnet_build_ospfv2_lsa(uint16_t age, uint8_t opts, uint8_t type,
        !          1471: uint lsid, uint32_t advrtr, uint seqnum, uint16_t sum, uint16_t len,
        !          1472: const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho    1473:  
                   1474: /**
1.1.1.2 ! misho    1475:  * @param flags
        !          1476:  * @param num
        !          1477:  * @param id
        !          1478:  * @param data
        !          1479:  * @param type
        !          1480:  * @param tos
        !          1481:  * @param metric
1.1       misho    1482:  * @param payload optional payload or NULL
                   1483:  * @param payload_s payload length or 0
                   1484:  * @param l pointer to a libnet context
                   1485:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1486:  * @return protocol tag value on success, -1 on error
                   1487:  */
                   1488: libnet_ptag_t
1.1.1.2 ! misho    1489: libnet_build_ospfv2_lsa_rtr(uint16_t flags, uint16_t num, uint id,
        !          1490: uint data, uint8_t type, uint8_t tos, uint16_t metric, const uint8_t* payload,
        !          1491: uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho    1492:  
                   1493: /**
1.1.1.2 ! misho    1494:  * @param nmask
        !          1495:  * @param rtrid
1.1       misho    1496:  * @param payload optional payload or NULL
                   1497:  * @param payload_s payload length or 0
                   1498:  * @param l pointer to a libnet context
                   1499:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1500:  * @return protocol tag value on success, -1 on error
                   1501:  */
                   1502: libnet_ptag_t
1.1.1.2 ! misho    1503: libnet_build_ospfv2_lsa_net(uint32_t nmask, uint rtrid, const uint8_t* payload,
        !          1504: uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho    1505:  
                   1506: /**
1.1.1.2 ! misho    1507:  * @param nmask
        !          1508:  * @param metric
        !          1509:  * @param tos
1.1       misho    1510:  * @param payload optional payload or NULL
                   1511:  * @param payload_s payload length or 0
                   1512:  * @param l pointer to a libnet context
                   1513:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1514:  * @return protocol tag value on success, -1 on error
                   1515:  */
                   1516: libnet_ptag_t
1.1.1.2 ! misho    1517: libnet_build_ospfv2_lsa_sum(uint32_t nmask, uint metric, uint tos,
        !          1518: const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho    1519:  
                   1520: /**
1.1.1.2 ! misho    1521:  * @param nmask
        !          1522:  * @param metric
        !          1523:  * @param fwdaddr
        !          1524:  * @param tag
1.1       misho    1525:  * @param payload optional payload or NULL
                   1526:  * @param payload_s payload length or 0
                   1527:  * @param l pointer to a libnet context
                   1528:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1529:  * @return protocol tag value on success, -1 on error
                   1530:  */
                   1531: libnet_ptag_t
1.1.1.2 ! misho    1532: libnet_build_ospfv2_lsa_as(uint32_t nmask, uint metric, uint32_t fwdaddr,
        !          1533: uint tag, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
1.1       misho    1534: libnet_ptag_t ptag);
                   1535: 
                   1536: /**
                   1537:  * Builds a generic libnet protocol header. This is useful for including an
                   1538:  * optional payload to a packet that might need to change repeatedly inside
1.1.1.2 ! misho    1539:  * of a loop. This won't work for TCP or IP payload, they have special types
        !          1540:  * (this is probably a bug).
1.1       misho    1541:  * @param payload optional payload or NULL
                   1542:  * @param payload_s payload length or 0
                   1543:  * @param l pointer to a libnet context
                   1544:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1545:  * @return protocol tag value on success, -1 on error
                   1546:  */
                   1547: libnet_ptag_t
1.1.1.2 ! misho    1548: libnet_build_data(const uint8_t* payload, uint32_t payload_s, libnet_t *l,
1.1       misho    1549: libnet_ptag_t ptag);
                   1550: 
                   1551: /**
1.1.1.2 ! misho    1552:  * @param opcode
        !          1553:  * @param htype
        !          1554:  * @param hlen
        !          1555:  * @param hopcount
        !          1556:  * @param xid
        !          1557:  * @param secs
        !          1558:  * @param flags
        !          1559:  * @param cip
        !          1560:  * @param yip
        !          1561:  * @param sip
        !          1562:  * @param gip
        !          1563:  * @param chaddr client hardware address, length is hlen
        !          1564:  * @param sname server host name, a null terminated string
        !          1565:  * @param file boot file name, a null terminated string
1.1       misho    1566:  * @param payload optional payload or NULL
                   1567:  * @param payload_s payload length or 0
                   1568:  * @param l pointer to a libnet context
                   1569:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1570:  * @return protocol tag value on success, -1 on error
                   1571:  */
                   1572: libnet_ptag_t
1.1.1.2 ! misho    1573: libnet_build_dhcpv4(uint8_t opcode, uint8_t htype, uint8_t hlen,
        !          1574: uint8_t hopcount, uint32_t xid, uint16_t secs, uint16_t flags,
        !          1575: uint32_t cip, uint32_t yip,  uint32_t sip, uint32_t gip, const uint8_t *chaddr,
        !          1576: const char *sname, const char *file, const uint8_t* payload, uint32_t payload_s, 
1.1       misho    1577: libnet_t *l, libnet_ptag_t ptag);
                   1578: 
                   1579: /**
1.1.1.2 ! misho    1580:  * @param opcode
        !          1581:  * @param htype
        !          1582:  * @param hlen
        !          1583:  * @param hopcount
        !          1584:  * @param xid
        !          1585:  * @param secs
        !          1586:  * @param flags
        !          1587:  * @param cip
        !          1588:  * @param yip
        !          1589:  * @param sip
        !          1590:  * @param gip
        !          1591:  * @param chaddr client hardware address, length is hlen
        !          1592:  * @param sname server host name, a null terminated string
        !          1593:  * @param file boot file name, a null terminated string
1.1       misho    1594:  * @param payload optional payload or NULL
                   1595:  * @param payload_s payload length or 0
                   1596:  * @param l pointer to a libnet context
                   1597:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1598:  * @return protocol tag value on success, -1 on error
                   1599:  */
                   1600: libnet_ptag_t
1.1.1.2 ! misho    1601: libnet_build_bootpv4(uint8_t opcode, uint8_t htype, uint8_t hlen,
        !          1602: uint8_t hopcount, uint32_t xid, uint16_t secs, uint16_t flags,
        !          1603: uint32_t cip, uint32_t yip,  uint32_t sip, uint32_t gip, const uint8_t *chaddr,
        !          1604: const char *sname, const char *file, const uint8_t* payload, uint32_t payload_s, 
1.1       misho    1605: libnet_t *l, libnet_ptag_t ptag);
                   1606: 
                   1607: /**
1.1.1.2 ! misho    1608:  * @param fv see libnet_build_gre().
        !          1609:  * @return size, see libnet_build_gre().
1.1       misho    1610:  */
1.1.1.2 ! misho    1611: uint32_t
        !          1612: libnet_getgre_length(uint16_t fv);
1.1       misho    1613: 
                   1614: /**
                   1615:  * Generic Routing Encapsulation (GRE - RFC 1701) is used to encapsulate any
                   1616:  * protocol. Hence, the IP part of the packet is usually referred as "delivery
                   1617:  * header". It is then followed by the GRE header and finally the encapsulated
                   1618:  * packet (IP or whatever).
                   1619:  * As GRE is very modular, the first GRE header describes the structure of the
                   1620:  * header, using bits and flag to specify which fields will be present in the
                   1621:  * header.
1.1.1.2 ! misho    1622:  * @param fv the 16 0 to 7: which fields are included in the header (checksum,
        !          1623:  *   seq. number, key, ...), bits 8 to 12: flag, bits 13 to 15: version.
1.1       misho    1624:  * @param type which protocol is encapsulated (PPP, IP, ...)
                   1625:  * @param sum checksum (0 for libnet to autofill).
                   1626:  * @param offset byte offset from the start of the routing field to the first byte of the SRE
                   1627:  * @param key inserted by the encapsulator to authenticate the source
                   1628:  * @param seq sequence number used by the receiver to sort the packets
                   1629:  * @param len size of the GRE packet
1.1.1.2 ! misho    1630:  * @param payload
1.1       misho    1631:  * @param payload_s payload length or 0
                   1632:  * @param l pointer to a libnet context
                   1633:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1634:  * @return protocol tag value on success, -1 on error
                   1635:  */
                   1636: libnet_ptag_t
1.1.1.2 ! misho    1637: libnet_build_gre(uint16_t fv, uint16_t type, uint16_t sum,
        !          1638: uint16_t offset, uint32_t key, uint32_t seq, uint16_t len,
        !          1639: const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho    1640: 
                   1641: /**
                   1642:  * Generic Routing Encapsulation (GRE - RFC 1701) is used to encapsulate any
                   1643:  * protocol. Hence, the IP part of the packet is usually referred as "delivery
                   1644:  * header". It is then followed by the GRE header and finally the encapsulated
                   1645:  * packet (IP or whatever).
                   1646:  * As GRE is very modular, the first GRE header describes the structure of the
                   1647:  * header, using bits and flag to specify which fields will be present in the
                   1648:  * header.
                   1649:  * @param fv the 16 0 to 7: which fields are included in the header (checksum, seq. number, key, ...), bits 8 to 12: flag, bits 13 to 15: version.
                   1650:  * @param type which protocol is encapsulated (PPP, IP, ...)
                   1651:  * @param sum checksum (0 for libnet to autofill).
                   1652:  * @param offset byte offset from the start of the routing field to the first byte of the SRE
                   1653:  * @param key inserted by the encapsulator to authenticate the source
                   1654:  * @param seq sequence number used by the receiver to sort the packets
                   1655:  * @param len size of the GRE packet
1.1.1.2 ! misho    1656:  * @param payload optional payload or NULL
1.1       misho    1657:  * @param payload_s payload length or 0
                   1658:  * @param l pointer to a libnet context
                   1659:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1660:  * @return protocol tag value on success, -1 on error
                   1661:  */
                   1662: libnet_ptag_t
1.1.1.2 ! misho    1663: libnet_build_egre(uint16_t fv, uint16_t type, uint16_t sum,
        !          1664: uint16_t offset, uint32_t key, uint32_t seq, uint16_t len,
        !          1665: const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho    1666: 
                   1667: /**
1.1.1.2 ! misho    1668:  * @param af
        !          1669:  * @param offset
        !          1670:  * @param length
        !          1671:  * @param routing
1.1       misho    1672:  * @param payload optional payload or NULL
                   1673:  * @param payload_s payload length or 0
                   1674:  * @param l pointer to a libnet context
                   1675:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1676:  * @return protocol tag value on success, -1 on error
                   1677:  */
                   1678: libnet_ptag_t
1.1.1.2 ! misho    1679: libnet_build_gre_sre(uint16_t af, uint8_t offset, uint8_t length,
        !          1680: uint8_t *routing, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
1.1       misho    1681: libnet_ptag_t ptag);
                   1682: 
                   1683: /**
                   1684:  * @param l pointer to a libnet context
                   1685:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1686:  * @return protocol tag value on success, -1 on error
                   1687:  */
                   1688: libnet_ptag_t
                   1689: libnet_build_gre_last_sre(libnet_t *l, libnet_ptag_t ptag);
                   1690: 
                   1691: /**
                   1692:  * Builds an RFC 1771 Border Gateway Protocol 4 (BGP-4) header. The primary
                   1693:  * function of a BGP speaking system is to exchange network reachability
                   1694:  * information with other BGP systems. This network reachability information
                   1695:  * includes information on the list of  Autonomous Systems (ASs) that
                   1696:  * reachability information traverses.  This information is sufficient to
                   1697:  * construct a graph of AS connectivity from which routing loops may be pruned
                   1698:  * and some policy decisions at the AS level may be enforced.
                   1699:  * This function builds the base BGP header which is used as a preamble before
                   1700:  * any other BGP header. For example, a BGP KEEPALIVE message may be built with
                   1701:  * only this function, while an error notification requires a subsequent call
                   1702:  * to libnet_build_bgp4_notification.
                   1703:  * @param marker a value the receiver can predict (if the message type is not BGP OPEN, or no authentication is used, these 16 bytes are normally set as all ones)
                   1704:  * @param len total length of the BGP message, including the header
                   1705:  * @param type type code of the message (OPEN, UPDATE, NOTIFICATION or KEEPALIVE)
                   1706:  * @param payload optional payload or NULL
                   1707:  * @param payload_s payload length or 0
                   1708:  * @param l pointer to a libnet context
                   1709:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1710:  * @return protocol tag value on success, -1 on error
                   1711:  */
                   1712: libnet_ptag_t
1.1.1.2 ! misho    1713: libnet_build_bgp4_header(uint8_t marker[LIBNET_BGP4_MARKER_SIZE],
        !          1714: uint16_t len, uint8_t type, const uint8_t* payload, uint32_t payload_s,
1.1       misho    1715: libnet_t *l, libnet_ptag_t ptag);
                   1716: 
                   1717: /**
                   1718:  * Builds an RFC 1771 Border Gateway Protocol 4 (BGP-4) OPEN header. This is
                   1719:  * the first message sent by each side of a BGP connection. The optional
                   1720:  * parameters options should be constructed using the payload interface (see
                   1721:  * RFC 1771 for the options structures).
                   1722:  * @param version protocol version (should be set to 4)
                   1723:  * @param src_as Autonomous System of the sender
                   1724:  * @param hold_time used to compute the maximum allowed time between the receipt of KEEPALIVE, and/or UPDATE messages by the sender
                   1725:  * @param bgp_id BGP identifier of the sender
                   1726:  * @param opt_len total length of the  optional parameters field in bytes
                   1727:  * @param payload optional payload or NULL
                   1728:  * @param payload_s payload length or 0
                   1729:  * @param l pointer to a libnet context
                   1730:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1731:  * @return protocol tag value on success, -1 on error
                   1732:  */
                   1733: libnet_ptag_t
1.1.1.2 ! misho    1734: libnet_build_bgp4_open(uint8_t version, uint16_t src_as, uint16_t hold_time,
        !          1735: uint32_t bgp_id, uint8_t opt_len, const uint8_t* payload, uint32_t payload_s,
1.1       misho    1736: libnet_t *l, libnet_ptag_t ptag);
                   1737: 
                   1738: /**
                   1739:  * Builds an RFC 1771 Border Gateway Protocol 4 (BGP-4) update header. Update
                   1740:  * messages are used to transfer routing information between BGP peers.
                   1741:  * @param unfeasible_rt_len indicates the length of the (next) "withdrawn routes" field in bytes
                   1742:  * @param withdrawn_rt list of IP addresses prefixes for the routes that are being withdrawn; each IP address prefix is built as a 2-tuple <length (1 byte), prefix (variable)>
                   1743:  * @param total_path_attr_len indicates the length of the (next) "path attributes" field in bytes
                   1744:  * @param path_attributes each attribute is a 3-tuple <type (2 bytes), length, value>
                   1745:  * @param info_len indicates the length of the (next) "network layer reachability information" field in bytes (needed for internal memory size calculation)
                   1746:  * @param reachability_info 2-tuples <length (1 byte), prefix (variable)>.
                   1747:  * @param payload optional payload or NULL
                   1748:  * @param payload_s payload length or 0
                   1749:  * @param l pointer to a libnet context
                   1750:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1751:  * @return protocol tag value on success, -1 on error
                   1752:  */
                   1753: libnet_ptag_t
1.1.1.2 ! misho    1754: libnet_build_bgp4_update(uint16_t unfeasible_rt_len, const uint8_t *withdrawn_rt,
        !          1755: uint16_t total_path_attr_len, const uint8_t *path_attributes, uint16_t info_len,
        !          1756: uint8_t *reachability_info, const uint8_t* payload, uint32_t payload_s,
1.1       misho    1757: libnet_t *l, libnet_ptag_t ptag);
                   1758: 
                   1759: /**
                   1760:  * Builds an RFC 1771 Border Gateway Protocol 4 (BGP-4) notification header.
                   1761:  * A NOTIFICATION message is sent when an error condition is detected. Specific
                   1762:  * error information may be passed through the payload interface.
                   1763:  * @param err_code type of notification
                   1764:  * @param err_subcode more specific information about the reported error.
                   1765:  * @param payload optional payload or NULL
                   1766:  * @param payload_s payload length or 0
                   1767:  * @param l pointer to a libnet context
                   1768:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1769:  * @return protocol tag value on success, -1 on error
                   1770:  */
                   1771: libnet_ptag_t
1.1.1.2 ! misho    1772: libnet_build_bgp4_notification(uint8_t err_code, uint8_t err_subcode,
        !          1773: const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho    1774: 
                   1775: /**
                   1776:  * Builds a Sebek header. The Sebek protocol was designed by the Honeynet
                   1777:  * Project as a transport mechanism for post-intrusion forensic data. More
                   1778:  * information may be found here: http://www.honeynet.org/papers/sebek.pdf.
                   1779:  * @param magic identify packets that should be hidden 
                   1780:  * @param version protocol version, currently 1 
                   1781:  * @param type type of record (read data is type 0, write data is type 1) 
                   1782:  * @param counter PDU counter used to identify when packet are lost 
                   1783:  * @param time_sec seconds since EPOCH according to the honeypot 
                   1784:  * @param time_usec residual microseconds 
                   1785:  * @param pid PID 
                   1786:  * @param uid UID 
                   1787:  * @param fd FD 
1.1.1.2 ! misho    1788:  * @param cmd 12 first characters of the command 
1.1       misho    1789:  * @param length length in bytes of the PDU's body 
                   1790:  * @param payload optional payload or NULL
                   1791:  * @param payload_s payload length or 0
                   1792:  * @param l pointer to a libnet context
                   1793:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1794:  * @return protocol tag value on success, -1 on error
                   1795:  */
                   1796: libnet_ptag_t
1.1.1.2 ! misho    1797: libnet_build_sebek(uint32_t magic, uint16_t version, uint16_t type, 
        !          1798: uint32_t counter, uint32_t time_sec, uint32_t time_usec, uint32_t pid,
        !          1799: uint32_t uid, uint32_t fd, uint8_t cmd[SEBEK_CMD_LENGTH], uint32_t length, 
        !          1800: const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
        !          1801: 
        !          1802: /**
        !          1803:  * Builds a HSRP header. HSRP is a Cisco propietary protocol defined in
        !          1804:  * RFC 2281
        !          1805:  * @param version version of the HSRP messages
        !          1806:  * @param opcode type of message
        !          1807:  * @param state current state of the router
        !          1808:  * @param hello_time period in seconds between hello messages
        !          1809:  * @param hold_time seconds that the current hello message is valid
        !          1810:  * @param priority priority for the election proccess
        !          1811:  * @param group standby group
        !          1812:  * @param reserved reserved field
        !          1813:  * @param authdata password
        !          1814:  * @param virtual_ip virtual ip address
        !          1815:  * @param payload optional payload or NULL
        !          1816:  * @param payload_s payload length or 0
        !          1817:  * @param l pointer to a libnet context
        !          1818:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
        !          1819:  * @return protocol tag value on success, -1 on error
        !          1820:  */
        !          1821: libnet_ptag_t
        !          1822: libnet_build_hsrp(uint8_t version, uint8_t opcode, uint8_t state, 
        !          1823: uint8_t hello_time, uint8_t hold_time, uint8_t priority, uint8_t group,
        !          1824: uint8_t reserved, uint8_t authdata[HSRP_AUTHDATA_LENGTH], uint32_t virtual_ip,
        !          1825: const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho    1826: 
                   1827: /**
                   1828:  * Builds a link layer header for an initialized l. The function
                   1829:  * determines the proper link layer header format from how l was initialized.
                   1830:  * The function current supports Ethernet and Token Ring link layers.
                   1831:  * @param dst the destination MAC address
                   1832:  * @param src the source MAC address
                   1833:  * @param oui Organizationally Unique Identifier (unused for Ethernet)
                   1834:  * @param type the upper layer protocol type
                   1835:  * @param payload optional payload or NULL
                   1836:  * @param payload_s payload length or 0
                   1837:  * @param l pointer to a libnet context
                   1838:  * @param ptag protocol tag to modify an existing header, 0 to build a new one
                   1839:  * @return protocol tag value on success, -1 on error
                   1840:  */
                   1841: libnet_ptag_t
1.1.1.2 ! misho    1842: libnet_build_link(const uint8_t *dst, const uint8_t *src, const uint8_t *oui, uint16_t type, 
        !          1843: const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1.1       misho    1844: 
                   1845: /**
                   1846:  * Automatically builds a link layer header for an initialized l. The function
                   1847:  * determines the proper link layer header format from how l was initialized.
                   1848:  * The function current supports Ethernet and Token Ring link layers.
                   1849:  * @param dst the destination MAC address
                   1850:  * @param oui Organizationally Unique Identifier (unused for Ethernet)
                   1851:  * @param type the upper layer protocol type
                   1852:  * @param l pointer to a libnet context
                   1853:  * @return protocol tag value on success, -1 on error
                   1854:  */
                   1855: libnet_ptag_t
1.1.1.2 ! misho    1856: libnet_autobuild_link(const uint8_t *dst, const uint8_t *oui, uint16_t type,
1.1       misho    1857: libnet_t *l);
                   1858: 
                   1859: /**
                   1860:  * Writes a prebuilt packet to the network. The function assumes that l was
                   1861:  * previously initialized (via a call to libnet_init()) and that a 
                   1862:  * previously constructed packet has been built inside this context (via one or
                   1863:  * more calls to the libnet_build* family of functions) and is ready to go.
                   1864:  * Depending on how libnet was initialized, the function will write the packet
                   1865:  * to the wire either via the raw or link layer interface. The function will
                   1866:  * also bump up the internal libnet stat counters which are retrievable via
                   1867:  * libnet_stats().
                   1868:  * @param l pointer to a libnet context
                   1869:  * @return the number of bytes written, -1 on error
                   1870:  */
                   1871: int
                   1872: libnet_write(libnet_t *l);
                   1873: 
                   1874: /**
                   1875:  * Returns the IP address for the device libnet was initialized with. If
                   1876:  * libnet was initialized without a device (in raw socket mode) the function
                   1877:  * will attempt to find one. If the function fails and returns -1 a call to 
                   1878:  * libnet_geterrror() will tell you why.
                   1879:  * @param l pointer to a libnet context
                   1880:  * @return a big endian IP address suitable for use in a libnet_build function or -1
                   1881:  */
                   1882: 
1.1.1.2 ! misho    1883: uint32_t
1.1       misho    1884: libnet_get_ipaddr4(libnet_t *l);
                   1885: 
                   1886: /**
1.1.1.2 ! misho    1887:  * Returns the IPv6 address for the device libnet was initialized with. If
        !          1888:  * libnet was initialized without a device (in raw socket mode) the function
        !          1889:  * will attempt to find one. If the function fails and returns in6addr_error, a
        !          1890:  * call to libnet_geterrror() will tell you why.
        !          1891:  * This function is not yet implemented for Win32 platforms.
1.1       misho    1892:  * @param l pointer to a libnet context
                   1893:  * @return well, nothing yet
                   1894:  */
                   1895: struct libnet_in6_addr
                   1896: libnet_get_ipaddr6(libnet_t *l);
                   1897: 
                   1898: /**
                   1899:  * Returns the MAC address for the device libnet was initialized with. If
                   1900:  * libnet was initialized without a device the function will attempt to find
                   1901:  * one. If the function fails and returns NULL a call to libnet_geterror() will
                   1902:  * tell you why.
                   1903:  * @param l pointer to a libnet context
                   1904:  * @return a pointer to the MAC address or NULL
                   1905:  */
                   1906: struct libnet_ether_addr *
                   1907: libnet_get_hwaddr(libnet_t *l);
                   1908: 
                   1909: /**
                   1910:  * Takes a colon separated hexidecimal address (from the command line) and
                   1911:  * returns a bytestring suitable for use in a libnet_build function. Note this
                   1912:  * function performs an implicit malloc and the return value should be freed
                   1913:  * after its use.
                   1914:  * @param s the string to be parsed
                   1915:  * @param len the resulting size of the returned byte string
                   1916:  * @return a byte string or NULL on failure
                   1917:  */
1.1.1.2 ! misho    1918: uint8_t *
        !          1919: libnet_hex_aton(const char *s, int *len);
        !          1920: 
        !          1921: /**
        !          1922:  * Returns the version of libnet.
        !          1923:  * @return the libnet version
        !          1924:  */
        !          1925: const char *
        !          1926: libnet_version(void);
1.1       misho    1927: 
                   1928: /**
                   1929:  * [Advanced Interface]
                   1930:  * Yanks a prebuilt, wire-ready packet from the given libnet context. If
                   1931:  * libnet was configured to do so (which it is by default) the packet will have
                   1932:  * all checksums written in. This function is part of the advanced interface
                   1933:  * and is only available when libnet is initialized in advanced mode. It is
                   1934:  * important to note that the function performs an implicit malloc() and a
                   1935:  * corresponding call to libnet_adv_free_packet() should be made to free the
                   1936:  * memory packet occupies. If the function fails libnet_geterror() can tell you
                   1937:  * why.
                   1938:  * @param l pointer to a libnet context
                   1939:  * @param packet will contain the wire-ready packet
                   1940:  * @param packet_s will contain the packet size
                   1941:  * @return 1 on success, -1 on failure  
                   1942:  */
                   1943: int
1.1.1.2 ! misho    1944: libnet_adv_cull_packet(libnet_t *l, uint8_t **packet, uint32_t *packet_s);
1.1       misho    1945: 
                   1946: /**
                   1947:  * [Advanced Interface] 
                   1948:  * Pulls the header from the specified ptag from the given libnet context. This
                   1949:  * function is part of the advanced interface and is only available when libnet
                   1950:  * is initialized in advanced mode. If the function fails libnet_geterror() can
                   1951:  * tell you why.
                   1952:  * @param l pointer to a libnet context
                   1953:  * @param ptag the ptag referencing the header to pull
                   1954:  * @param header will contain the header
                   1955:  * @param header_s will contain the header size
                   1956:  * @return 1 on success, -1 on failure  
                   1957:  */
                   1958: int
1.1.1.2 ! misho    1959: libnet_adv_cull_header(libnet_t *l, libnet_ptag_t ptag, uint8_t **header,
        !          1960: uint32_t *header_s);
1.1       misho    1961: 
                   1962: /**
                   1963:  * [Advanced Interface] 
                   1964:  * Writes a packet the network at the link layer. This function is useful to
                   1965:  * write a packet that has been constructed by hand by the application
                   1966:  * programmer or, more commonly, to write a packet that has been returned by
                   1967:  * a call to libnet_adv_cull_packet(). This function is part of the advanced
                   1968:  * interface and is only available when libnet is initialized in advanced mode.
                   1969:  * If the function fails libnet_geterror() can tell you why.
                   1970:  * @param l pointer to a libnet context
                   1971:  * @param packet a pointer to the packet to inject
                   1972:  * @param packet_s the size of the packet
                   1973:  * @return the number of bytes written, or -1 on failure
                   1974:  */
                   1975: int
1.1.1.2 ! misho    1976: libnet_adv_write_link(libnet_t *l, const uint8_t *packet, uint32_t packet_s);
        !          1977: 
        !          1978: /**
        !          1979:  * [Advanced Interface] 
        !          1980:  * Writes a packet the network at the raw socket layer. This function is useful
        !          1981:  * to write a packet that has been constructed by hand by the application
        !          1982:  * programmer or, more commonly, to write a packet that has been returned by
        !          1983:  * a call to libnet_adv_cull_packet(). This function is part of the advanced
        !          1984:  * interface and is only available when libnet is initialized in advanced mode.
        !          1985:  * If the function fails libnet_geterror() can tell you why.
        !          1986:  * @param l pointer to a libnet context
        !          1987:  * @param packet a pointer to the packet to inject
        !          1988:  * @param packet_s the size of the packet
        !          1989:  * @return the number of bytes written, or -1 on failure
        !          1990:  */
        !          1991: int
        !          1992: libnet_adv_write_raw_ipv4(libnet_t *l, const uint8_t *packet, uint32_t packet_s);
1.1       misho    1993: 
                   1994: /**
                   1995:  * [Advanced Interface] 
                   1996:  * Frees the memory allocated when libnet_adv_cull_packet() is called.
                   1997:  * @param l pointer to a libnet context
                   1998:  * @param packet a pointer to the packet to free
                   1999:  */
                   2000: void
1.1.1.2 ! misho    2001: libnet_adv_free_packet(libnet_t *l, uint8_t *packet);
1.1       misho    2002: 
                   2003: /**
                   2004:  * [Context Queue] 
                   2005:  * Adds a new context to the libnet context queue. If no queue exists, this
                   2006:  * function will create the queue and add the specified libnet context as the
                   2007:  * first entry on the list. The functions checks to ensure niether l nor label
                   2008:  * are NULL, and that label doesn't refer to an existing context already in the
                   2009:  * queue. Additionally, l should refer to a libnet context previously
                   2010:  * initialized with a call to libnet_init(). If the context queue in write
                   2011:  * locked, this function will fail.
                   2012:  * @param l pointer to a libnet context
                   2013:  * @param label a canonical name given to recognize the new context, no longer than LIBNET_LABEL_SIZE
                   2014:  * @return 1 on success, -1 on failure
                   2015: */
                   2016: int 
                   2017: libnet_cq_add(libnet_t *l, char *label);
                   2018: 
                   2019: /**
                   2020:  * [Context Queue] 
                   2021:  * Removes a specified context from the libnet context queue by specifying the
                   2022:  * libnet context pointer. Note the function will remove the specified context
                   2023:  * from the context queue and cleanup internal memory from the queue, it is up
                   2024:  * to the application programmer to free the returned libnet context with a
                   2025:  * call to libnet_destroy(). Also, as it is not necessary to keep the libnet
                   2026:  * context pointer when initially adding it to the context queue, most
                   2027:  * application programmers will prefer to refer to entries on the context
                   2028:  * queue by canonical name and would use libnet_cq_remove_by_label(). If the
                   2029:  * context queue is write locked, this function will fail.
                   2030:  * @param l pointer to a libnet context
                   2031:  * @return the pointer to the removed libnet context, NULL on failure
                   2032:  */
                   2033: libnet_t *
                   2034: libnet_cq_remove(libnet_t *l);
                   2035: 
                   2036: /** 
                   2037:  * [Context Queue] 
                   2038:  * Removes a specified context from the libnet context queue by specifying the
                   2039:  * canonical name. Note the function will remove the specified context from
                   2040:  * the context queue and cleanup internal memory from the queue, it is up to 
                   2041:  * the application programmer to free the returned libnet context with a call
                   2042:  * to libnet_destroy(). If the context queue is write locked, this function
                   2043:  * will fail.
                   2044:  * @param label canonical name of the context to remove
                   2045:  * @return the pointer to the removed libnet context, NULL on failure
                   2046:  */   
                   2047: libnet_t *
                   2048: libnet_cq_remove_by_label(char *label);
                   2049:  
                   2050: /**
                   2051:  * [Context Queue] 
                   2052:  * Returns the canonical label associated with the context.
                   2053:  * @param l pointer to a libnet context
                   2054:  * @return pointer to the libnet context's label
                   2055:  */   
1.1.1.2 ! misho    2056: const char *
1.1       misho    2057: libnet_cq_getlabel(libnet_t *l);
                   2058:  
                   2059: /**
                   2060:  * [Context Queue] 
                   2061:  * Locates a libnet context from the queue, indexed by a canonical label.
                   2062:  * @param label canonical label of the libnet context to retrieve
                   2063:  * @return the expected libnet context, NULL on failure
                   2064:  */
                   2065: libnet_t *
                   2066: libnet_cq_find_by_label(char *label);
                   2067:   
                   2068: /**
                   2069:  * [Context Queue] 
                   2070:  * Destroys the entire context queue, calling libnet_destroy() on each
                   2071:  * member context.
                   2072:  */
                   2073: void
1.1.1.2 ! misho    2074: libnet_cq_destroy(void);
1.1       misho    2075: 
                   2076: /**
                   2077:  * [Context Queue] 
                   2078:  * Intiailizes the interator interface and set a write lock on the entire
                   2079:  * queue. This function is intended to be called just prior to interating
                   2080:  * through the entire list of contexts (with the probable intent of inject a
                   2081:  * series of packets in rapid succession). This function is often used as
                   2082:  * per the following:
                   2083:  *
                   2084:  *    for (l = libnet_cq_head(); libnet_cq_last(); l = libnet_cq_next())
                   2085:  *    {
                   2086:  *         ...
                   2087:  *    }
                   2088:  *
                   2089:  * Much of the time, the application programmer will use the iterator as it is
                   2090:  * written above; as such, libnet provides a macro to do exactly that,
                   2091:  * for_each_context_in_cq(l). Warning: do not call the iterator more than once
                   2092:  * in a single loop.
                   2093:  * @return the head of the context queue
                   2094:  */
                   2095: libnet_t *
1.1.1.2 ! misho    2096: libnet_cq_head(void);
1.1       misho    2097: 
                   2098: /**
                   2099:  * [Context Queue] 
                   2100:  * Check whether the iterator is at the last context in the queue.
                   2101:  * @return 1 if at the end of the context queue, 0 otherwise
                   2102:  */
                   2103: int
1.1.1.2 ! misho    2104: libnet_cq_last(void);
1.1       misho    2105: 
                   2106: /**
                   2107:  * [Context Queue] 
                   2108:  * Get next context from the context queue.
1.1.1.2 ! misho    2109:  * @return the next context from the context queue
1.1       misho    2110:  */
                   2111: libnet_t *
1.1.1.2 ! misho    2112: libnet_cq_next(void);
1.1       misho    2113: 
                   2114: /**
                   2115:  * [Context Queue] 
                   2116:  * Function returns the number of libnet contexts that are in the queue.
                   2117:  * @return the number of libnet contexts currently in the queue
                   2118:  */
1.1.1.2 ! misho    2119: uint32_t
        !          2120: libnet_cq_size(void);
        !          2121: 
        !          2122: /**
        !          2123:  * [Context Queue]
        !          2124:  */
        !          2125: uint32_t
        !          2126: libnet_cq_end_loop(void);
1.1       misho    2127: 
                   2128: /**
                   2129:  * [Diagnostic] 
                   2130:  * Prints the contents of the given context.
                   2131:  * @param l pointer to a libnet context
                   2132:  */
                   2133: void
                   2134: libnet_diag_dump_context(libnet_t *l);
                   2135: 
                   2136: /**
                   2137:  * [Diagnostic] 
                   2138:  * Prints the contents of every pblock.
                   2139:  * @param l pointer to a libnet context
                   2140:  */
                   2141: void
                   2142: libnet_diag_dump_pblock(libnet_t *l);
                   2143: 
                   2144: /**
                   2145:  * [Diagnostic] 
                   2146:  * Returns the canonical name of the pblock type.
                   2147:  * @param type pblock type
                   2148:  * @return a string representing the pblock type type or "unknown" for an unknown value
                   2149:  */
                   2150: char *
1.1.1.2 ! misho    2151: libnet_diag_dump_pblock_type(uint8_t type);
1.1       misho    2152: 
                   2153: /**
                   2154:  * [Diagnostic] 
                   2155:  * Function prints the contents of the supplied buffer to the supplied
                   2156:  * stream pointer. Will swap endianness based disposition of mode variable.
                   2157:  * Useful to be used in conjunction with the advanced interface and a culled
                   2158:  * packet.
                   2159:  * @param packet the packet to print
                   2160:  * @param len length of the packet in bytes
1.1.1.2 ! misho    2161:  * @param swap 1 to swap byte order, 0 to not.
        !          2162:  *   Counter-intuitively, it is necessary to swap in order to see the byte
        !          2163:  *   order as it is on the wire (this may be a bug).
1.1       misho    2164:  * @param stream a stream pointer to print to
                   2165:  */
                   2166: void
1.1.1.2 ! misho    2167: libnet_diag_dump_hex(const uint8_t *packet, uint32_t len, int swap, FILE *stream);
1.1       misho    2168: 
                   2169: /*
                   2170:  * [Internal] 
                   2171:  */
                   2172: int
1.1.1.2 ! misho    2173: libnet_write_raw_ipv4(libnet_t *l, const uint8_t *packet, uint32_t size);
1.1       misho    2174: 
                   2175: /*
                   2176:  * [Internal] 
                   2177:  */
                   2178: int
1.1.1.2 ! misho    2179: libnet_write_raw_ipv6(libnet_t *l, const uint8_t *packet, uint32_t size);
1.1       misho    2180: 
                   2181: /*
                   2182:  * [Internal] 
                   2183:  */
                   2184: int
1.1.1.2 ! misho    2185: libnet_write_link(libnet_t *l, const uint8_t *packet, uint32_t size);
1.1       misho    2186: 
                   2187: #if ((__WIN32__) && !(__CYGWIN__))
                   2188: /*
                   2189:  * [Internal] 
                   2190:  */
                   2191: SOCKET
                   2192: libnet_open_raw4(libnet_t *l);
                   2193: #else
                   2194: /*
                   2195:  * [Internal] 
                   2196:  */
                   2197: int
                   2198: libnet_open_raw4(libnet_t *l);
                   2199: #endif
                   2200: 
                   2201: /*
                   2202:  * [Internal] 
                   2203:  */
                   2204: int
                   2205: libnet_close_raw4(libnet_t *l);
                   2206: 
                   2207: /*
                   2208:  * [Internal] 
                   2209:  */
                   2210: int
                   2211: libnet_open_raw6(libnet_t *l);
                   2212:        
                   2213: /*
                   2214:  * [Internal] 
                   2215:  */
                   2216: int
                   2217: libnet_close_raw6(libnet_t *l);
                   2218: 
                   2219: /*
                   2220:  * [Internal] 
                   2221:  */
                   2222: int
                   2223: libnet_select_device(libnet_t *l);
                   2224: 
                   2225: /*
                   2226:  * [Internal] 
                   2227:  */
                   2228: int
                   2229: libnet_open_link(libnet_t *l);
                   2230: 
                   2231: /*
                   2232:  * [Internal] 
                   2233:  */
                   2234: int
                   2235: libnet_close_link(libnet_t *l);
                   2236: 
                   2237: /*
1.1.1.2 ! misho    2238:  * [Internal]
        !          2239:  *   THIS FUNCTION IS BROKEN. IT WILL SEGFAULT OR CORRUPT MEMORY, OR JUST SILENTLY DO THE
        !          2240:  *   WRONG THING IF NOT CALLED CORRECTLY, AND CALLING IT CORRECTLY IS UNDOCUMENTED, AND
        !          2241:  *   ALMOST IMPOSSIBLE. YOU HAVE BEEN WARNED.
1.1       misho    2242:  */
                   2243: int
1.1.1.2 ! misho    2244: libnet_do_checksum(libnet_t *l, uint8_t *iphdr, int protocol, int h_len);
        !          2245: 
        !          2246: /* Calculate internet checksums.
        !          2247:  *
        !          2248:  * IP (TCP, UDP, IGMP, ICMP, etc...) checksums usually need information from
        !          2249:  * the IP header to construct the "pseudo header", this function takes a
        !          2250:  * pointer to that header, the buffer boundaries, the "h_len" (see pblock_t for
        !          2251:  * a description, it is increasinly unused, though, and I'm trying to remove it
        !          2252:  * altogether), and the protocol number for the protocol that is to be
        !          2253:  * checksummed.
        !          2254:  *
        !          2255:  * Finding that protocol requires that the IP header be well-formed... so this
        !          2256:  * won't work well for invalid packets. But then, what is the valid checksum
        !          2257:  * for a valid packet, anyhow?
        !          2258:  *
        !          2259:  * This doesn't work well for non-inet checksums, sorry, that's an original design
        !          2260:  * flaw. pblock_t needs a pointer in it, to a packet assembly function that can be
        !          2261:  * called at runtime to do assembly and checksumming.
        !          2262:  */
        !          2263: int
        !          2264: libnet_inet_checksum(libnet_t *l, uint8_t *iphdr, int protocol, int h_len, const uint8_t *beg, const uint8_t * end);
1.1       misho    2265: 
                   2266: /*
                   2267:  * [Internal] 
                   2268:  */
1.1.1.2 ! misho    2269: uint32_t
        !          2270: libnet_compute_crc(uint8_t *buf, uint32_t len);
1.1       misho    2271: 
                   2272: /*
                   2273:  * [Internal] 
                   2274:  */
1.1.1.2 ! misho    2275: uint16_t
        !          2276: libnet_ip_check(uint16_t *addr, int len);
1.1       misho    2277: 
                   2278: /*
                   2279:  * [Internal] 
                   2280:  */
                   2281: int
1.1.1.2 ! misho    2282: libnet_in_cksum(uint16_t *addr, int len);
1.1       misho    2283: 
                   2284: /*
                   2285:  * [Internal] 
                   2286:  * If ptag is 0, function will create a pblock for the protocol unit type,
                   2287:  * append it to the list and return a pointer to it.  If ptag is not 0,
                   2288:  * function will search the pblock list for the specified protocol block 
                   2289:  * and return a pointer to it.
                   2290:  */
                   2291: libnet_pblock_t *
1.1.1.2 ! misho    2292: libnet_pblock_probe(libnet_t *l, libnet_ptag_t ptag, uint32_t b_len, 
        !          2293: uint8_t type);
1.1       misho    2294: 
                   2295: /*
                   2296:  * [Internal] 
                   2297:  * Function creates the pblock list if l->protocol_blocks == NULL or appends
                   2298:  * an entry to the doubly linked list.
                   2299:  */
                   2300: libnet_pblock_t *
1.1.1.2 ! misho    2301: libnet_pblock_new(libnet_t *l, uint32_t b_len);
1.1       misho    2302: 
                   2303: /*
                   2304:  * [Internal] 
                   2305:  * Function swaps two pblocks in memory.
                   2306:  */
                   2307: int
                   2308: libnet_pblock_swap(libnet_t *l, libnet_ptag_t ptag1, libnet_ptag_t ptag2);
                   2309: 
                   2310: /*
                   2311:  * [Internal] 
1.1.1.2 ! misho    2312:  * Function inserts ptag2 before ptag1 in the doubly linked list.
1.1       misho    2313:  */
                   2314: int
                   2315: libnet_pblock_insert_before(libnet_t *l, libnet_ptag_t ptag1,
                   2316: libnet_ptag_t ptag2);
                   2317: 
                   2318: /*
                   2319:  * [Internal] 
                   2320:  * Function removes a pblock from context 
                   2321:  */
                   2322: void
                   2323: libnet_pblock_delete(libnet_t *l, libnet_pblock_t *p);
                   2324: 
                   2325: /*
                   2326:  * [Internal] 
                   2327:  * Function updates the pblock meta-inforation.  Internally it updates the
                   2328:  * ptag with a monotonically increasing variable kept in l.  This way each
                   2329:  * pblock has a succesively increasing ptag identifier.
                   2330:  */
                   2331: libnet_ptag_t
1.1.1.2 ! misho    2332: libnet_pblock_update(libnet_t *l, libnet_pblock_t *p, uint32_t h, uint8_t type);
1.1       misho    2333: 
                   2334: 
                   2335: /*
                   2336:  * [Internal] 
                   2337:  * Function locates a given block by it's ptag. 
                   2338:  */
                   2339: libnet_pblock_t *
                   2340: libnet_pblock_find(libnet_t *l, libnet_ptag_t ptag);
                   2341: 
                   2342: /*
                   2343:  * [Internal] 
                   2344:  * Function copies protocol block data over.
                   2345:  */
                   2346: int
1.1.1.2 ! misho    2347: libnet_pblock_append(libnet_t *l, libnet_pblock_t *p, const void *buf, uint32_t len);
1.1       misho    2348: 
                   2349: /*
                   2350:  * [Internal] 
                   2351:  * Function sets pblock flags.
                   2352:  */
                   2353: void
1.1.1.2 ! misho    2354: libnet_pblock_setflags(libnet_pblock_t *p, uint8_t flags);
1.1       misho    2355: 
                   2356: /*
                   2357:  * [Internal] 
                   2358:  * Function returns the protocol number for the protocol block type.  If
                   2359:  * the type is unknown, the function defaults to returning IPPROTO_IP.
                   2360:  */
                   2361: int
1.1.1.2 ! misho    2362: libnet_pblock_p2p(uint8_t type);
1.1       misho    2363: 
                   2364: /*
                   2365:  * [Internal] 
1.1.1.2 ! misho    2366:  * Function assembles the protocol blocks into a packet, checksums are
        !          2367:  * calculated if that was requested.
1.1       misho    2368:  */
                   2369: int
1.1.1.2 ! misho    2370: libnet_pblock_coalesce(libnet_t *l, uint8_t **packet, uint32_t *size);
1.1       misho    2371: 
                   2372: #if !(__WIN32__)
                   2373: /*
                   2374:  * [Internal] 
                   2375:  * By testing if we can retrieve the FLAGS of an iface
                   2376:  * we can know if it exists or not and if it is up.
                   2377:  */
                   2378: int
                   2379: libnet_check_iface(libnet_t *l);
                   2380: #endif
                   2381: 
                   2382: #if defined(__WIN32__)
                   2383: /*
                   2384:  * [Internal] 
                   2385:  */
                   2386: BYTE *
                   2387: libnet_win32_get_remote_mac(libnet_t *l, DWORD IP);
                   2388: 
                   2389: /*
                   2390:  * [Internal] 
                   2391:  */
                   2392: int
                   2393: libnet_close_link_interface(libnet_t *l);
                   2394: 
                   2395: /*
                   2396:  * [Internal] 
                   2397:  */
                   2398: BYTE * 
                   2399: libnet_win32_read_arp_table(DWORD IP);
                   2400: #endif
                   2401: #endif  /* __LIBNET_FUNCTIONS_H */
                   2402: 
                   2403: /* EOF */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>