diff options
Diffstat (limited to 'src/lib/libc/net/byteorder.3')
-rw-r--r-- | src/lib/libc/net/byteorder.3 | 107 |
1 files changed, 66 insertions, 41 deletions
diff --git a/src/lib/libc/net/byteorder.3 b/src/lib/libc/net/byteorder.3 index aa11b22664..64a13d47ba 100644 --- a/src/lib/libc/net/byteorder.3 +++ b/src/lib/libc/net/byteorder.3 | |||
@@ -1,4 +1,4 @@ | |||
1 | .\" $OpenBSD: byteorder.3,v 1.6 1999/05/23 14:11:01 aaron Exp $ | 1 | .\" $OpenBSD: byteorder.3,v 1.7 1999/07/05 04:40:59 aaron Exp $ |
2 | .\" | 2 | .\" |
3 | .\" Copyright (c) 1983, 1991, 1993 | 3 | .\" Copyright (c) 1983, 1991, 1993 |
4 | .\" The Regents of the University of California. All rights reserved. | 4 | .\" The Regents of the University of California. All rights reserved. |
@@ -82,56 +82,86 @@ | |||
82 | .Ft u_int16_t | 82 | .Ft u_int16_t |
83 | .Fn swap16 "u_int16_t val16" | 83 | .Fn swap16 "u_int16_t val16" |
84 | .Sh DESCRIPTION | 84 | .Sh DESCRIPTION |
85 | These routines convert 16 and 32 bit quantities between different | 85 | These routines convert 16- and 32-bit quantities between different |
86 | byte orderings. The "swap" functions reverse the byte ordering of | 86 | byte orderings. The |
87 | .Dq swap | ||
88 | functions reverse the byte ordering of | ||
87 | the given quantity, the others converts either from/to the native | 89 | the given quantity, the others converts either from/to the native |
88 | byte order used by the host to/from either little- or big-endian (a.k.a | 90 | byte order used by the host to/from either little- or big-endian (a.k.a |
89 | network) order. | 91 | network) order. |
90 | .Pp | 92 | .Pp |
91 | Apart from the "swap" functions, the names can be described by this form: | 93 | Apart from the swap functions, the names can be described by this form: |
92 | {src-order}to{dst-order}{size}. | 94 | {src-order}to{dst-order}{size}. |
93 | Both {src-order} and {dst-order} can take the following forms: | 95 | Both {src-order} and {dst-order} can take the following forms: |
94 | .Bl -tag -width "be " | 96 | .Pp |
95 | .It Em h | 97 | .Bl -tag -width "be " -offset indent -compact |
96 | host order | 98 | .It h |
97 | .It Em n | 99 | Host order. |
98 | network order (big-endian) | 100 | .It n |
99 | .It Em be | 101 | Network order (big-endian). |
100 | big-endian (Most significant byte first) | 102 | .It be |
101 | .It Em le | 103 | Big-endian (most significant byte first). |
102 | little-endian (Least significant byte first) | 104 | .It le |
105 | Little-endian (least significant byte first). | ||
103 | .El | 106 | .El |
104 | .Pp | 107 | .Pp |
105 | One of the specified orderings must be "h". | 108 | One of the specified orderings must be |
106 | {Size} will take these forms: | 109 | .Sq h . |
107 | .Bl -tag -width "32 " | 110 | {size} will take these forms: |
108 | .It Em l | 111 | .Pp |
109 | long (32-bit, used in conjunction with forms involving "n") | 112 | .Bl -tag -width "32 " -offset indent -compact |
110 | .It Em s | 113 | .It l |
111 | short (16-bit, used in conjunction with forms involving "n") | 114 | Long (32-bit, used in conjunction with forms involving |
112 | .It Em 16 | 115 | .Sq n ) . |
113 | 16-bit | 116 | .It s |
114 | .It Em 32 | 117 | Short (16-bit, used in conjunction with forms involving |
115 | 32-bit | 118 | .Sq n ) . |
119 | .It 16 | ||
120 | 16-bit. | ||
121 | .It 32 | ||
122 | 32-bit. | ||
116 | .El | 123 | .El |
117 | .Pp | 124 | .Pp |
118 | The "swap" functions are of the form: swap{size}. | 125 | The swap functions are of the form: swap{size}. |
119 | .Pp | 126 | .Pp |
120 | Names involving "n" convert quantities between network | 127 | Names involving |
121 | byte order and host byte order. The last letter (s/l) is a mnemonic | 128 | .Sq n |
122 | for the traditional names for such quantities, short and long, | 129 | convert quantities between network |
123 | respectively. Today, the C concept of "short"/"long" integers | 130 | byte order and host byte order. The last letter |
124 | need not coincide with this traditional misunderstanding. | 131 | .Pf ( Sq s |
132 | or | ||
133 | .Sq l ) | ||
134 | is a mnemonic | ||
135 | for the traditional names for such quantities, | ||
136 | .Li short | ||
137 | and | ||
138 | .Li long , | ||
139 | respectively. Today, the C concept of | ||
140 | .Li short | ||
141 | and | ||
142 | .Li long | ||
143 | integers need not coincide with this traditional misunderstanding. | ||
125 | On machines which have a byte order which is the same as the network | 144 | On machines which have a byte order which is the same as the network |
126 | order, routines are defined as null macros. | 145 | order, routines are defined as null macros. |
127 | .Pp | 146 | .Pp |
128 | The functions involving either "be", "le" or "swap" use the numbers | 147 | The functions involving either |
129 | (16/32) for specifying the bitwidth of the quantities they operate on. | 148 | .Dq be , |
149 | .Dq le , | ||
150 | or | ||
151 | .Dq swap | ||
152 | use the numbers | ||
153 | 16 and 32 for specifying the bitwidth of the quantities they operate on. | ||
130 | Currently all supported architectures are either big- or little-endian | 154 | Currently all supported architectures are either big- or little-endian |
131 | so either the "be" or the "le" variants are implemented as null macros. | 155 | so either the |
156 | .Dq be | ||
157 | or | ||
158 | .Dq le | ||
159 | variants are implemented as null macros. | ||
132 | .Pp | 160 | .Pp |
133 | The routines mentioned above which have either {src-order} or {dst-order} | 161 | The routines mentioned above which have either {src-order} or {dst-order} |
134 | set to "n" are most often used in | 162 | set to |
163 | .Sq n | ||
164 | are most often used in | ||
135 | conjunction with Internet addresses and ports as returned by | 165 | conjunction with Internet addresses and ports as returned by |
136 | .Xr gethostbyname 3 | 166 | .Xr gethostbyname 3 |
137 | and | 167 | and |
@@ -142,14 +172,9 @@ and | |||
142 | .Sh HISTORY | 172 | .Sh HISTORY |
143 | The | 173 | The |
144 | .Nm byteorder | 174 | .Nm byteorder |
145 | functions appeared in | 175 | functions appeared in |
146 | .Bx 4.2 . | 176 | .Bx 4.2 . |
147 | .Sh BUGS | 177 | .Sh BUGS |
148 | On the | 178 | On the vax, alpha, i386, and so far mips, |
149 | .Tn vax , | ||
150 | .Tn alpha , | ||
151 | .Tn i386 , | ||
152 | and so far | ||
153 | .Tn mips | ||
154 | bytes are handled backwards from most everyone else in | 179 | bytes are handled backwards from most everyone else in |
155 | the world. This is not expected to be fixed in the near future. | 180 | the world. This is not expected to be fixed in the near future. |