Interface Functions
The interface family of functions enables the application programmer to have a simple way to query and set parameters on network interfaces. The libdnet interface information structure (described in the datatypes section) employs the flags summarized in Table 6.2 and Table 6.3 to control function and datatype disposition.
CONSTANT | MEANING |
---|---|
| Ethernet |
| Software loopback |
CONSTANT | MEANING |
---|---|
| enable the interface |
| interface sits on a loopback network |
| interface is point to point |
| disable ARP on the interface |
| interface supports broadcast |
| interface supports multicast |
intf_t *intf_open(void);
intf_open() opens and initializes an interface handle for use in subsequent interface functions. Upon success, the function returns a valid intf_t descriptor; upon failure, the function returns NULL.
int intf_get(intf_t *i, struct intf_entry *entry);
intf_get() retrieves an interface configuration entry. To specify which interface, the application programmer should fill in the intf_name element of the entry structure to the canonical name of the interface desired. Upon success, the function returns 0; upon failure, the function returns −1 and sets errno.
int intf_get_src(intf_t *i, struct intf_entry *entry, struct
addr *src);
intf_get_src() retrieves the configuration for the interface whose primary address matches src. Upon success, the function returns 0; upon failure, the function returns −1 and sets errno.
int intf_get_dst(intf_t *i, struct intf_entry *entry, struct
addr *dst);
intf_get_dst() retrieves the configuration for the best interface with which to reach dst. Note that this function performs a TCP connect() to port 666 to the specified address. Upon success, the function returns 0; upon failure, the function returns −1 and sets errno.
int intf_set(intf_t *i, const struct intf_entry *entry);
intf_set() configures the specified network device to which entry refers. Upon success, the function returns 0; upon failure, the function returns −1 and sets errno.
int intf_loop(intf_t *i, intf_handler callback, void *arg);
int callback(const char *device, const struct intf_info *info,
void *arg);
intf_loop() iterates over all available interfaces on the system referenced by i, invoking the specified callback callback with the optional argument arg. Upon success, the function returns 0; upon failure, the function returns −1 and sets errno. The intf_loop() callback function format expects three arguments: a pointer to the device device, a pointer to the interface information structure info, and the optional argument arg.
intf_t *intf_close(intf_t *i);
intf_close() closes the underlying interface and frees any memory associated with i. The function returns NULL.
No comments:
Post a Comment