Content-type: text/html Manpage of LIBPNET6

LIBPNET6

Section: LIBPNET6 API Reference (3)
Updated: March 30, 2003
Index Return to Main Contents

 

NAME


 - libpnet6's functionality regarding UDP datagrams. See pnet6(3) for an introduction to libpnet6.

 

SYNOPSIS

# include <pnet6.h>
# include <pnet6tlp.h>

This document describes the functions in libpnet6 that you can use with UDP datagrams.

NOTE: in order to be able to follow this, some familiarity with IP datagrams and the TCP/IP protocol is required (and assumed in this document). Please, read through pnet6-ip(3), first if you need to know the format and functions necessary to work with raw IP datagrams.

 

OVERVIEW

Libpnet6 provides a few simple functions to facilitate the construction of UDP datagrams for use with IPv4 and IPv6 sockets. Such datagrams can then be sent on a raw socket, making it possible to construct your own datagrams.

 

DESCRIPTION

A UDP datagram has a header, which is represented by the following struct in libpnet6:

typedef struct _udp_header { 
    pnet_ushort         uh_sport;   /* Source port        */
    pnet_ushort         uh_dport;   /* Destination port   */
    pnet_ushort         uh_ulen ;   /* Datagram length    */
    pnet_ushort         uh_sum  ;   /* Datagram checksum  */
} pnet_udp;

The fiels in this header can be accessed by appropriate macros and functions. This is the preferable way to access them, as issues regarding byte ordering are resolved internally by the functions.

Accessor Functions

int pnetUDP_Build(pnet_udp * udp, pnet_ushort sport, pnet_ushort dport, pnet_ushort len, pnet_ushort cksum );

Fills in the given datagram struct, using the correct byte ordering and packing of data. Never fails, altough it returns 0 as a sign of success.

int pnetUDP_Send( PNETSOCK ps, PNETADDR pa, void * pip, pnet_udp * udp, int do_cksum, byte * buf, int buflen );

Sends a correctly filled in UDP datagram on the given socket, with destination address the given address. pip is a pointer to a valid IPv4 or IPv6 datagram; udp must have been built by pnetUDP_Build(). The last two arguments are the actual data to be sent as the UDP datagram's payload, and its length. This length does not include any of the UDP or IP headers that are prepended to it.

UDP does not require that the checksum be set for a datagram. If you do want libpnet6 to calculate the checksum, then set do_cksum to a value other than 0.

pnet_ushort pnetUDP_ComputeChecksum( void * pip, pnet_udp * udp);

Computes the checksum for this UDP datagram. Here again, pip is a pointer to a valid IPv4 or IPv6 datagram; udp must have been built by pnetUDP_Build(), or be a valid datagram otherwise.

This function assumes that the payload of the UDP datagram follows in contiguous memory immediately after the udp header itself. Also, the length of the IP datagram must be correct to account for the length of the UDP header and its payload.

For more details on computing the checksum for datagrams, see pnet6-ip(3).

 

REMARKS

 

SEE ALSO

pnet6(3), pnet6-addr(3), pnet6-api(3), pnet6-aux(3), pnet6-if(3), pnet6-ip(3), pnet6-log(3), pnet6-pkt(3), pnet6-raw(3), pnet6-socket(3), pnet6-tcp(3), pnet6-threads(3), pnet6-udp(3).

 

VERSION

The current version of libpnet6 is highly experimental.

You can always get the most recent version from http://pnet6.sourceforge.net.

 

BUGS

??  

AUTHOR

Peter Bozarov. Send mail to kingofgib (at) users.sourceforge.net


 

Index

NAME
SYNOPSIS
OVERVIEW
DESCRIPTION
REMARKS
SEE ALSO
VERSION
BUGS
AUTHOR

This document was created by man2html, using the manual pages.
Time: 06:22:19 GMT, May 26, 2003