Index Index for
Section 9
Index Alphabetical
listing for I
Bottom of page Bottom of
page

if_alloc(9r)

NAME

if_alloc - Network: Allocates an ifnet structure large enough to hold an ether_driver structure

SYNOPSIS

struct ether_driver *if_alloc( char *name, int unit, u_int size );

ARGUMENTS

name Specifies the address of a buffer containing the device name. Usually this is a two- or three-character name representing the network device (such as tu). unit Specifies the unit number for the device. This number is obtained from the ctlr_num member of the device's controller data structure. size Specifies the size of the structure that should be allocated. Specify a size at least as large as the size of the ifnet data structure defined in /usr/include/net/if.h.

DESCRIPTION

The if_alloc() routine allocates a data structure of the requested size. It assumes that the first part of this data structure is an ifnet data structure. The if_alloc() routine initializes the if_name and if_unit members of the ifnet structure to contain the name and unit values passed in, respectively.

NOTES

A network device driver calls if_alloc() to allocate an ether_driver data structure for the network device.

EXAMPLE

The following example shows how to use if_alloc(): struct nd_softc { struct ether_driver *is_ed; ... } sc; static int nd_probe(struct controller *ctlr) { ... sc.is_ed = if_alloc("nd", ctlr->ctlr_num, sizeof(struct ether_driver)); if (sc.is_ed) return (0); .... }

RETURN VALUES

NULL if any of the arguments passed in are invalid, such as 0 for size or NULL for name. Upon success, the address of a memory buffer is returned to the caller of the size indicated, with the if_name and if_unit members of the ifnet structure initialized.

SEE ALSO

Routines: if_attach(9r), if_detach(9r), if_dealloc(9r)

Index Index for
Section 9
Index Alphabetical
listing for I
Top of page Top of
page