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