libnet10 (3) - Linux Manuals
libnet10: "libpwrite" Network Routine Library
NAME
libnet - "libpwrite" Network Routine LibraryDESCRIPTION
The Network Library provides a simple API for commonly used low-level network functions (mainly packet injection). Using libnet, it is easy to build and write arbitrary network packets. It provides a portable framework for low-level network packet writing and handling (use libnet in conjunction with libpcap and you can write some really cool stuff). Libnet includes packet creation at the IP layer and at the link layer as well as a host of supplementary and complementary functionality.For a much more verbose treatment of libnet, including verbosely commented examples, please see the online web-based documentation at http://www.packetfactory.net/libnet/manual/.
SYNOPSIS
#include <libnet.h> PACKET MEMORY MANAGEMENT ROUTINES int libnet_init_packet(size_t p_size, u_char **buf); int libnet_destroy_packet(u_char **buf); int libnet_init_packet_arena(struct libnet_arena **arena, int p_size,
u_short p_num); u_char *libnet_next_packet_from_arena(struct libnet_arena **arena,
int p_size); int libnet_destroy_packet_arena(struct libnet_arena **arena); ADDRESS RESOLUTION ROUTINES u_char *libnet_host_lookup(u_long in, u_short use_name); void libnet_host_lookup_r(u_long in, u_short use_name, u_char *buf); u_long libnet_name_resolve(u_char *hostname, u_short use_name); u_long libnet_get_ipaddr(struct libnet_link_int *l, const u_char *device,
const u_char *buf); struct ether_addr *libnet_get_hwaddr(struct libnet_link_int *l,
const u_char *device, const u_char *buf); PACKET INJECTION FRAMEWORK ROUTINES int libnet_open_raw_sock(int protocol); int libnet_close_raw_sock(int fd); int libnet_select_device(struct sockaddr_in *sin, u_char **device,
u_char *ebuf); struct libnet_link_int *libnet_open_link_interface(char *device, char *ebuf); int libnet_close_link_interface(struct libnet_link_int *l); int libnet_write_ip(int sock, u_char *packet, int len); int libnet_write_link_layer(struct libnet_link_int *l, const u_char *device,
u_char *buf, int len); int libnet_do_checksum(u_char *buf, int protocol, int len); u_short libnet_ip_check(u_short *buf, int len); PACKET BUILDER ROUTINES int libnet_build_arp(u_short hrd, u_short pro, u_short hln, u_short pln,
u_short op, u_char *sha, u_char *spa, u_char *tha,
u_char *tpa, const u_char *payload, int payload_s,
u_char *buf); int libnet_build_dns(u_short id, u_short flags, u_short num_q,
u_short num_anws_rr, u_short num_auth_rr,
u_short num_addi_rr, const u_char *payload, int payload_s,
u_char *buf); int libnet_build_ethernet(u_char *daddr, u_char *saddr, u_short id,
const u_char *payload, int payload_s, u_char *buf); int libnet_build_icmp_echo(u_char type, u_char code, u_short id,
u_short seq, const u_char *payload, int payload_s,
u_char *buf); int libnet_build_icmp_mask(u_char type, u_char code, u_short id,
u_short seq, u_long mask, const u_char *payload,
int payload_s, u_char *buf); int libnet_build_icmp_unreach(u_char type, u_char code,
u_short orig_len, u_char orig_tos, u_short orig_id,
u_short orig_frag, u_char orig_ttl, u_char orig_prot,
u_long orig_src, u_long orig_dst, const u_char *orig_payload,
int payload_s, u_char *buf); int libnet_build_icmp_timeexceed(u_char type, u_char code,
u_short orig_len, u_char orig_tos, u_short orig_id,
u_short orig_frag, u_char orig_ttl, u_char orig_prot,
u_long orig_src, u_long orig_dst, const u_char *orig_payload,
int payload_s, u_char *buf); int libnet_build_icmp_redirect(u_char type, u_char code, u_long gateway
u_short orig_len, u_char orig_tos, u_short orig_id,
u_short orig_frag, u_char orig_ttl, u_char orig_prot,
u_long orig_src, u_long orig_dst, const u_char *orig_payload,
int payload_s, u_char *buf); int libnet_build_icmp_timestamp(u_char type, u_char code, u_short id,
u_short seq, n_time otime, n_time rtime, n_time ttime,
const u_char *payload, int payload_s, u_char *buf); int libnet_build_igmp(u_char type, u_char code, u_long ip,