.\" $OpenBSD: net_addrcmp.3,v 1.4 2007/05/31 19:19:30 jmc Exp $ .\" .\" Copyright (c) 1999 Theo de Raadt .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .Dd $Mdocdate: May 31 2007 $ .Dt NET_ADDRCMP 3 .Os .Sh NAME .Nm net_addrcmp .Nd compare socket address structures .Sh SYNOPSIS .Fd #include .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 .