summaryrefslogtreecommitdiff
path: root/lib/libc/net/net_addrcmp.3
blob: 8f7de8ef4459028950d717af63c9e3befd467a86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
.Dd July 3, 1999
.Dt NET_ADDRCMP 3
.Os
.Sh NAME
.Nm net_addrcmp
.Nd compare socket address structures
.Sh SYNOPSIS
.Fd #include <netdb.h>
.Ft int
.Fn net_addrcmp "struct sockaddr *sa1" "struct sockaddr *sa2"
.Sh DESCRIPTION
The
.Fn net_addrcmp
function compares two socket address structures,
.Fa sa1
and
.Fa sa2 .
.Sh RETURN VALUES
If
.Fa sa1
and
.Fa sa2
are for the same address,
.Fn net_addrcmp
returns 0.
.Pp
The
.Fa sa_len
fields are compared first.
If they do not match,
.Fn net_addrcmp
returns \-1 or 1 if
.Li sa1->sa_len
is less than or greater than
.Li sa2->sa_len ,
respectively.
.Pp
Next, the
.Fa sa_family
members are compared.
If they do not match,
.Fn net_addrcmp
returns \-1 or 1 if
.Li sa1->sa_family
is less than or greater than
.Li sa2->sa_family ,
respectively.
.Pp
Lastly, if each socket address structure's
.Fa sa_len
and
.Fa sa_family
fields match,
the protocol-specific data (the
.Fa sa_data
field) is compared.
If there's a match, both
.Fa sa1
and
.Fa sa2
must refer to the same address, and 0 is returned; otherwise, a value >0
or <0 is returned.
.Sh HISTORY
A
.Fn net_addrcmp
function was added in
.Ox 2.5 .