Coding Divert Sockets/Before You Begin

From Wikibooks, open books for an open world
Jump to: navigation, search

First, there are a couple (hopefully nothing new) include files you will need to know about.

sys/types.h and sys/socket.h[edit]

This pair of header files is probably the most important one out of all the header files when coding any type socket. sys/socket.h contains several important constants (AF_INET? It's in here, as are all the other address families) and several less important constants, famous and infamous socket functions (socket() anyone?). The main structure worthy of note here is sockaddr.

netinet/in_systm.h and netinet/in.h[edit]

netinet/in_systm.h defines network times (which has nothing to do with divert sockets, but it is required by netinet/in.h to compile properly.) netinet/in.h is the more important header here. It defines all transport-level protocol numbers (as found in RFC 1700), sockaddr_in, fun IPFW defines, and more stuff you probably have dealt with in normal sockets.

netinet/ip_fw.h[edit]

This header defines some structures we will send to instruct the IPFW program, later on in the book.

netinet/ip.h, netinet/tcp.h, and netinet/udp.h[edit]

These files define protocol structures (as if you didn't know.)