[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]
Kernel Extensions and Device Support Programming Concepts

Network Kernel Services

The Network kernel services are divided into the Address Family Domain and Network Interface Device Driver services, Routing and Interface services, Loopback services, Protocol services, and Communications Device Handler Interface services.

The following information is provided to assist you in learning more about network kernel services:

Address Family Domain and Network Interface Device Driver Kernel Services

The Address Family Domain and Network Interface Device Driver services enable address family domains (Protocols) and network interface drivers to add and remove themselves from network switch tables.

The if_attach service and if_detach services add and remove network interfaces from the Network Interface List. Protocols search this list to determine an appropriate interface on which to transmit a packet.

Protocols use the add_input_type and del_input_type services to notify network interface drivers that the protocol is available to handle packets of a certain type. The Network Interface Driver uses the find_input_type service to distribute packets to a protocol.

The add_netisr and del_netisr services add and delete network software interrupt handlers. Address families add and delete themselves from the Address Family Domain switch table by using the add_domain_af and del_domain_af services. The Address Family Domain switch table is a list of all available protocols that can be used in the socket subroutine.

The Address Family Domain and Network Interface Device Driver services are:

add_domain_af Adds an address family to the Address Family domain switch table.
add_input_type Adds a new input type to the Network Input table.
add_netisr Adds a network software interrupt service to the Network Interrupt table.
del_domain_af Deletes an address family from the Address Family domain switch table.
del_input_type Deletes an input type from the Network Input table.
del_netisr Deletes a network software interrupt service routine from the Network Interrupt table.
find_input_type Finds the given packet type in the Network Input Interface switch table and distributes the input packet according to the table entry for that type.
if_attach Adds a network interface to the network interface list.
if_detach Deletes a network interface from the network interface list.
ifunit Returns a pointer to the ifnet structure of the requested interface.
schednetisr Schedules or invokes a network software interrupt service routine.

Routing and Interface Address Kernel Services

The Routing and Interface Address services provide protocols with a means of establishing, accessing, and removing routes to remote hosts or gateways. Routes bind destinations to a particular network interface.

The interface address services accept a destination address or network and return an associated interface address. Protocols use these services to determine if an address is on a directly connected network.

The Routing and Interface Address services are:

ifa_ifwithaddr Locates an interface based on a complete address.
ifa_ifwithdstaddr Locates the point-to-point interface with a given destination address.
ifa_ifwithnet Locates an interface on a specific network.
if_down Marks an interface as down.
if_nostat Zeroes statistical elements of the interface array in preparation for an attach operation.
rtalloc Allocates a route.
rtfree Frees the routing table entry
rtinit Sets up a routing table entry, typically for a network interface.
rtredirect Forces a routing table entry with the specified destination to go through the given gateway.
rtrequest Carries out a request to change the routing table.

Loopback Kernel Services

The Loopback services enable networking code to be exercised without actually transmitting packets on a network. This is a useful tool for developing new protocols without introducing network variables. Loopback services can also be used to send packets to local addresses without using hardware loopback.

The Loopback services are:

loifp Returns the address of the software loopback interface structure.
looutput Sends data through a software loopback interface.

Protocol Kernel Services

Protocol kernel services provide a means of finding a particular address family as well as a raw protocol handler. The raw protocol handler basically passes raw packets up through sockets so that a protocol can be implemented in user space.

The Protocol kernel services are:

pfctlinput Starts the ctlinput function for each configured protocol.
pffindproto Returns the address of a protocol switch table entry.
raw_input Builds a raw_header structure for a packet and sends both to the raw protocol handler.
raw_usrreq Implements user requests for raw protocols.

Communications Device Handler Interface Kernel Services

The Communications Device Handler Interface services provide a standard interface between network interface drivers and communications device handlers. The net_attach and net_detach services open and close the device handler. Once the device handler has been opened, the net_xmit service can be used to transmit packets. Asynchronous start done notifications are recorded by the net_start_done service. The net_error service handles error conditions.

The Communications Device Handler Interface services are:

add_netopt This macro adds a network option structure to the list of network options.
del_netopt This macro deletes a network option structure from the list of network options.
net_attach Opens a communications I/O device handler.
net_detach Closes a communications I/O device handler.
net_error Handles errors for communication network interface drivers.
net_sleep Sleeps on the specified wait channel.
net_start Starts network IDs on a communications I/O device handler.
net_start_done Starts the done notification handler for communications I/O device handlers.
net_wakeup Wakes up all sleepers waiting on the specified wait channel.
net_xmit Transmits data using a communications I/O device handler.
net_xmit_trace Traces transmit packets. This kernel service was added for those network interfaces that do not use the net_xmit kernel service to trace transmit packets.

Related Information

Communications Physical Device Handler Model Overview .


[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]