DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

ether(SLIB)


ether: ether_ntoa, ether_aton, ether_ntohost, ether_hostton, ether_line -- IEEE-address mapping operations

Syntax

cc ... -lsocket

#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>

char * ether_ntoa(ea) struct ether_addr *ea;

struct ether_addr * ether_aton(s) const char *s;

int ether_ntohost(hn, ea) const char *hn; struct ether_addr *ea;

int ether_hostton(hn, ea) const char *hn; struct ether_addr *ea;

int ether_line(l, ea, hn) const char *l; struct ether_addr *ea; char *hn;

Description

These routines convert 48-bit IEEE (Ethernet) addresses to and from their ASCII representations or their corresponding host names.

The function ether_ntoa converts a 48-bit address (pointed to by ea) to its ASCII representation. It returns a pointer to the ASCII string. The representation is of the form ``x : x : x : x : x : x'' where x is a hexadecimal number (with leading 0) between 0 and ff.

The function ether_aton converts an ASCII string back to a 48-bit adddress; the function returns NULL if the string cannot be scanned successfully.

The function ether_ntohost maps a 48-bit address (pointed to by ea) to its associated hostname. The string pointed to by hn must be long enough to hold the hostname and a NULL character.

The function ether_hostton maps a hostname string to its corresponding 48-bit address. This function modifies the address pointed to by ea.

The function ether_line scans a line (pointed to by l) and sets the hostname and the address (pointed to by ea). The string pointed to by hn must be long enough to hold the hostname and a null character. The format of the scanned line is documented in ethers(SFF). If unsuccesful, the function returns the number of missing fields.

Diagnostics

All functions that return int return 0 for success and -1 for failure, except where noted.

Limitations

Both ether_aton and ether_ntoa return pointers to static buffers; the data pointed by these pointers must be copied or it will be overwritten by successive calls to these routines.

Files


/etc/ethers
the database of addresses and hostnames

See also

ethers(SFF)
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003