diff options
Diffstat (limited to 'src/lib/libc/net/net_addrcmp.3')
| -rw-r--r-- | src/lib/libc/net/net_addrcmp.3 | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/src/lib/libc/net/net_addrcmp.3 b/src/lib/libc/net/net_addrcmp.3 new file mode 100644 index 0000000000..f1ce4c8cd1 --- /dev/null +++ b/src/lib/libc/net/net_addrcmp.3 | |||
| @@ -0,0 +1,91 @@ | |||
| 1 | .\" $OpenBSD: net_addrcmp.3,v 1.3 2001/08/07 06:53:27 deraadt Exp $ | ||
| 2 | .\" | ||
| 3 | .\" Copyright (c) 1999 Theo de Raadt | ||
| 4 | .\" | ||
| 5 | .\" Redistribution and use in source and binary forms, with or without | ||
| 6 | .\" modification, are permitted provided that the following conditions | ||
| 7 | .\" are met: | ||
| 8 | .\" 1. Redistributions of source code must retain the above copyright | ||
| 9 | .\" notice, this list of conditions and the following disclaimer. | ||
| 10 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
| 11 | .\" notice, this list of conditions and the following disclaimer in the | ||
| 12 | .\" documentation and/or other materials provided with the distribution. | ||
| 13 | .\" | ||
| 14 | .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
| 15 | .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
| 16 | .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
| 17 | .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| 18 | .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 19 | .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| 20 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| 21 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| 22 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
| 23 | .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 24 | .\" | ||
| 25 | .Dd July 3, 1999 | ||
| 26 | .Dt NET_ADDRCMP 3 | ||
| 27 | .Os | ||
| 28 | .Sh NAME | ||
| 29 | .Nm net_addrcmp | ||
| 30 | .Nd compare socket address structures | ||
| 31 | .Sh SYNOPSIS | ||
| 32 | .Fd #include <netdb.h> | ||
| 33 | .Ft int | ||
| 34 | .Fn net_addrcmp "struct sockaddr *sa1" "struct sockaddr *sa2" | ||
| 35 | .Sh DESCRIPTION | ||
| 36 | The | ||
| 37 | .Fn net_addrcmp | ||
| 38 | function compares two socket address structures, | ||
| 39 | .Fa sa1 | ||
| 40 | and | ||
| 41 | .Fa sa2 . | ||
| 42 | .Sh RETURN VALUES | ||
| 43 | If | ||
| 44 | .Fa sa1 | ||
| 45 | and | ||
| 46 | .Fa sa2 | ||
| 47 | are for the same address, | ||
| 48 | .Fn net_addrcmp | ||
| 49 | returns 0. | ||
| 50 | .Pp | ||
| 51 | The | ||
| 52 | .Fa sa_len | ||
| 53 | fields are compared first. | ||
| 54 | If they do not match, | ||
| 55 | .Fn net_addrcmp | ||
| 56 | returns \-1 or 1 if | ||
| 57 | .Li sa1->sa_len | ||
| 58 | is less than or greater than | ||
| 59 | .Li sa2->sa_len , | ||
| 60 | respectively. | ||
| 61 | .Pp | ||
| 62 | Next, the | ||
| 63 | .Fa sa_family | ||
| 64 | members are compared. | ||
| 65 | If they do not match, | ||
| 66 | .Fn net_addrcmp | ||
| 67 | returns \-1 or 1 if | ||
| 68 | .Li sa1->sa_family | ||
| 69 | is less than or greater than | ||
| 70 | .Li sa2->sa_family , | ||
| 71 | respectively. | ||
| 72 | .Pp | ||
| 73 | Lastly, if each socket address structure's | ||
| 74 | .Fa sa_len | ||
| 75 | and | ||
| 76 | .Fa sa_family | ||
| 77 | fields match, | ||
| 78 | the protocol-specific data (the | ||
| 79 | .Fa sa_data | ||
| 80 | field) is compared. | ||
| 81 | If there's a match, both | ||
| 82 | .Fa sa1 | ||
| 83 | and | ||
| 84 | .Fa sa2 | ||
| 85 | must refer to the same address, and 0 is returned; otherwise, a value >0 | ||
| 86 | or <0 is returned. | ||
| 87 | .Sh HISTORY | ||
| 88 | A | ||
| 89 | .Fn net_addrcmp | ||
| 90 | function was added in | ||
| 91 | .Ox 2.5 . | ||
