ns_attach Network Service

Purpose

Attaches a network device to the network subsystem.

Syntax

#include <sys/ndd.h>

int ns_attach (nddp)
       struct ndd * nddp;

Parameters

Item Description
nddp Specifies a pointer to an ndd structure describing the device to be attached.

Description

The ns_attach network service places the device into the available network service (NS) device chain. The network device driver (NDD) should be prepared to be opened after the ns_attach network service is called.

Note: The ndd structure is allocated and initialized by the device. It should be pinned.

Examples

The following example illustrates the ns_attach network service:

struct ndd ndd;
ndd.ndd_name = "en0";
ndd.ndd_addrlen = 6;
ndd.ndd_hdrlen = 14;
ndd.ndd_mtu = ETHERMTU;
ndd.ndd_mintu = 60;
ndd.ndd_type = NDD_ETHER;
ndd.ndd_flags = 
   NDD_BROADCAST | NDD_SIMPLEX;
ndd.ndd_open = entopen;
ndd.ndd_output = entwrite;
ndd.ndd_ctl = entctl;
ndd.ndd_close = entclose;   
.
.
.
ns_attach(&ndd);

Return Values

Item Description
0 Indicates the operation was successful.
EEXIST Indicates the device is already in the available NS device chain.