diff options
Diffstat (limited to 'src/lib/libc/net/ethers.3')
| -rw-r--r-- | src/lib/libc/net/ethers.3 | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/src/lib/libc/net/ethers.3 b/src/lib/libc/net/ethers.3 new file mode 100644 index 0000000000..aa7249dc47 --- /dev/null +++ b/src/lib/libc/net/ethers.3 | |||
| @@ -0,0 +1,124 @@ | |||
| 1 | .\" $OpenBSD: ethers.3,v 1.20 2008/12/07 10:10:33 weerd Exp $ | ||
| 2 | .\" | ||
| 3 | .\" Written by roland@frob.com. Public domain. | ||
| 4 | .\" | ||
| 5 | .Dd $Mdocdate: December 7 2008 $ | ||
| 6 | .Dt ETHERS 3 | ||
| 7 | .Os | ||
| 8 | .Sh NAME | ||
| 9 | .Nm ether_aton , | ||
| 10 | .Nm ether_ntoa , | ||
| 11 | .Nm ether_ntohost , | ||
| 12 | .Nm ether_hostton , | ||
| 13 | .Nm ether_line | ||
| 14 | .Nd get ethers entry | ||
| 15 | .Sh SYNOPSIS | ||
| 16 | .Fd #include <sys/types.h> | ||
| 17 | .Fd #include <sys/socket.h> | ||
| 18 | .Fd #include <net/if.h> | ||
| 19 | .Fd #include <netinet/in.h> | ||
| 20 | .Fd #include <netinet/if_ether.h> | ||
| 21 | .Ft char * | ||
| 22 | .Fn ether_ntoa "struct ether_addr *e" | ||
| 23 | .Ft struct ether_addr * | ||
| 24 | .Fn ether_aton "const char *s" | ||
| 25 | .Ft int | ||
| 26 | .Fn ether_ntohost "char *hostname" "struct ether_addr *e" | ||
| 27 | .Ft int | ||
| 28 | .Fn ether_hostton "const char *hostname" "struct ether_addr *e" | ||
| 29 | .Ft int | ||
| 30 | .Fn ether_line "const char *l" "struct ether_addr *e" "char *hostname" | ||
| 31 | .Sh DESCRIPTION | ||
| 32 | Ethernet addresses are represented by the | ||
| 33 | following structure: | ||
| 34 | .Bd -literal -offset indent | ||
| 35 | struct ether_addr { | ||
| 36 | u_int8_t ether_addr_octet[6]; | ||
| 37 | }; | ||
| 38 | .Ed | ||
| 39 | .Pp | ||
| 40 | The | ||
| 41 | .Fn ether_ntoa | ||
| 42 | function converts this structure into an | ||
| 43 | .Tn ASCII | ||
| 44 | string of the form | ||
| 45 | .Dq xx:xx:xx:xx:xx:xx , | ||
| 46 | consisting of 6 hexadecimal numbers separated | ||
| 47 | by colons. | ||
| 48 | It returns a pointer to a static buffer that is reused for each call. | ||
| 49 | The | ||
| 50 | .Fn ether_aton | ||
| 51 | converts an | ||
| 52 | .Tn ASCII | ||
| 53 | string of the same form and to a structure | ||
| 54 | containing the 6 octets of the address. | ||
| 55 | It returns a pointer to a static structure that is reused for each call. | ||
| 56 | .Fn ether_aton | ||
| 57 | will return NULL if the string does not represent a valid address. | ||
| 58 | .Pp | ||
| 59 | The | ||
| 60 | .Fn ether_ntohost | ||
| 61 | and | ||
| 62 | .Fn ether_hostton | ||
| 63 | functions interrogate the database mapping host names to Ethernet | ||
| 64 | addresses, | ||
| 65 | .Pa /etc/ethers . | ||
| 66 | The | ||
| 67 | .Fn ether_ntohost | ||
| 68 | function looks up the given Ethernet address and writes the associated | ||
| 69 | host name into the character buffer passed. | ||
| 70 | This buffer should be | ||
| 71 | .Dv MAXHOSTNAMELEN | ||
| 72 | characters in size. | ||
| 73 | The | ||
| 74 | .Fn ether_hostton | ||
| 75 | function looks up the given host name and writes the associated | ||
| 76 | Ethernet address into the structure passed. | ||
| 77 | Both functions return | ||
| 78 | zero if they find the requested host name or address, and \-1 if not. | ||
| 79 | .Pp | ||
| 80 | Each call reads | ||
| 81 | .Pa /etc/ethers | ||
| 82 | from the beginning; if a | ||
| 83 | .Ql + | ||
| 84 | appears alone on a line in the file, then | ||
| 85 | .Fn ether_hostton | ||
| 86 | will consult the | ||
| 87 | .Pa ethers.byname | ||
| 88 | YP map, and | ||
| 89 | .Fn ether_ntohost | ||
| 90 | will consult the | ||
| 91 | .Pa ethers.byaddr | ||
| 92 | YP map. | ||
| 93 | .Pp | ||
| 94 | The | ||
| 95 | .Fn ether_line | ||
| 96 | function parses a line from the | ||
| 97 | .Pa /etc/ethers | ||
| 98 | file and fills in the passed | ||
| 99 | .Li struct ether_addr | ||
| 100 | and character buffer with the Ethernet address and host name on the line. | ||
| 101 | It returns zero if the line was successfully parsed and \-1 if not. | ||
| 102 | The character buffer should be | ||
| 103 | .Dv MAXHOSTNAMELEN | ||
| 104 | characters in size. | ||
| 105 | .Sh FILES | ||
| 106 | .Bl -tag -width /etc/ethers -compact | ||
| 107 | .It Pa /etc/ethers | ||
| 108 | .El | ||
| 109 | .Sh SEE ALSO | ||
| 110 | .Xr ethers 5 | ||
| 111 | .Sh HISTORY | ||
| 112 | The | ||
| 113 | .Fn ether_ntoa , | ||
| 114 | .Fn ether_aton , | ||
| 115 | .Fn ether_ntohost , | ||
| 116 | .Fn ether_hostton , | ||
| 117 | and | ||
| 118 | .Fn ether_line | ||
| 119 | functions were adopted from SunOS and appeared in | ||
| 120 | .Nx 0.9 b. | ||
| 121 | .Sh BUGS | ||
| 122 | The data space used by these functions is static; if future use | ||
| 123 | requires the data, it should be copied before any subsequent calls to | ||
| 124 | these functions overwrite it. | ||
