ChorusOS 4.0 Network Administration Guide

Device Creation

Ethernet connections only require corresponding devices if you configure Ethernet interfaces using the dhclient(1M) or rarp(1M) utility. Both of these utilities require a Berkeley Packet Filter (BPF).

It is also possible that your applications require a BPF device for raw access to network packets.

In order to create the BPF device, you can include commands of the following form in the sysadm.ini file that you build into the system image for your target:

# Create the BPF device
mkdev bpf unit
# Create the associated special file
mknod /dev/bpfunit c 23 unit

where unit is the number that makes the interface unique. Note that mknod(1M) is used to create special files. The c refers to the fact that BPF devices are character devices, and 23 is, by convention, the major number used for BPF devices.


Example 3-2 BPF Device Creation

The following example sysadm.ini fragment creates an interface for an Ethernet device and the loopback interface needed for IP communication. It then creates a BPF device needed by dhclient(1M) and rarp(1M).

#
# Set the file creation mask to 0 during system configuration
#
umask 0

#
# Create an Ethernet interface for the first available device
#
# Since no dtree *pathname* is provided, the system uses the first
# device it finds
#
mkdev ifeth 0

#
# Create a loopback interface
# 
# Note that the loopback device is not attached to a device in
# the dtree, so no *pathname* argument is provided here, either
#
mkdev lo 0

#
# Create a Berkeley Packet Filter device and special file
#
# The BPF device is used by either the rarp or dhclient command to
# configure the Ethernet interface
#
mkdev bpf 0
mknod /dev/bpf c 23 0