xref: /openbsd-src/lib/libc/net/inet_lnaof.3 (revision b51b5e421456c4a79b846603016ad08a2f29cfc2)
1*b51b5e42Sjmc.\"	$OpenBSD: inet_lnaof.3,v 1.4 2019/08/30 20:06:07 jmc Exp $
244d9059eSguenther.\"	$NetBSD: inet.3,v 1.7 1997/06/18 02:25:24 lukem Exp $
344d9059eSguenther.\"
444d9059eSguenther.\" Copyright (c) 1983, 1990, 1991, 1993
544d9059eSguenther.\"	The Regents of the University of California.  All rights reserved.
644d9059eSguenther.\"
744d9059eSguenther.\" Redistribution and use in source and binary forms, with or without
844d9059eSguenther.\" modification, are permitted provided that the following conditions
944d9059eSguenther.\" are met:
1044d9059eSguenther.\" 1. Redistributions of source code must retain the above copyright
1144d9059eSguenther.\"    notice, this list of conditions and the following disclaimer.
1244d9059eSguenther.\" 2. Redistributions in binary form must reproduce the above copyright
1344d9059eSguenther.\"    notice, this list of conditions and the following disclaimer in the
1444d9059eSguenther.\"    documentation and/or other materials provided with the distribution.
1544d9059eSguenther.\" 3. Neither the name of the University nor the names of its contributors
1644d9059eSguenther.\"    may be used to endorse or promote products derived from this software
1744d9059eSguenther.\"    without specific prior written permission.
1844d9059eSguenther.\"
1944d9059eSguenther.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2044d9059eSguenther.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2144d9059eSguenther.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2244d9059eSguenther.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2344d9059eSguenther.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2444d9059eSguenther.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2544d9059eSguenther.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2644d9059eSguenther.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2744d9059eSguenther.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2844d9059eSguenther.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2944d9059eSguenther.\" SUCH DAMAGE.
3044d9059eSguenther.\"
3144d9059eSguenther.\"     @(#)inet.3	8.1 (Berkeley) 6/4/93
3244d9059eSguenther.\"
33*b51b5e42Sjmc.Dd $Mdocdate: August 30 2019 $
3444d9059eSguenther.Dt INET_LNAOF 3
3544d9059eSguenther.Os
3644d9059eSguenther.Sh NAME
3744d9059eSguenther.Nm inet_makeaddr ,
3844d9059eSguenther.Nm inet_netof ,
3944d9059eSguenther.Nm inet_lnaof
4044d9059eSguenther.Nd routines for manipulating classful Internet Protocol version 4 (IPv4) addresses
4144d9059eSguenther.Sh SYNOPSIS
4244d9059eSguenther.In arpa/inet.h
4344d9059eSguenther.Ft struct in_addr
4444d9059eSguenther.Fn inet_makeaddr "in_addr_t net" "in_addr_t lna"
4544d9059eSguenther.Ft in_addr_t
4644d9059eSguenther.Fn inet_netof "struct in_addr in"
4744d9059eSguenther.Ft in_addr_t
4844d9059eSguenther.Fn inet_lnaof "struct in_addr in"
4944d9059eSguenther.Sh DESCRIPTION
5044d9059eSguentherAs originally designed,
5144d9059eSguentherIP version 4 split each address into a network part and local network
5244d9059eSguentheraddress part, encoding that split into the address itself.
5344d9059eSguentherIt is frequency-encoded;
5444d9059eSguentherthe most-significant bit is clear in Class A addresses,
5544d9059eSguentherin which the high-order 8 bits are the network number.
5644d9059eSguentherClass B addresses use the high-order 16 bits as the network field,
5744d9059eSguentherand Class C addresses have a 24-bit network part.
5844d9059eSguenther.Pp
5944d9059eSguentherThe routine
6044d9059eSguenther.Fn inet_makeaddr
6144d9059eSguenthertakes an Internet network number and a local
6244d9059eSguenthernetwork address and constructs an Internet address
6344d9059eSguentherfrom it.
6444d9059eSguenther.Pp
6544d9059eSguentherThe routines
6644d9059eSguenther.Fn inet_netof
6744d9059eSguentherand
6844d9059eSguenther.Fn inet_lnaof
6944d9059eSguentherbreak apart Internet host addresses, returning
7044d9059eSguentherthe network number and local network address part,
7144d9059eSguentherrespectively.
7244d9059eSguenther.Pp
7344d9059eSguentherAll Internet addresses are returned in network
7444d9059eSguentherorder (bytes ordered from left to right).
7544d9059eSguentherAll network numbers and local address parts are
7644d9059eSguentherreturned as machine format integer values.
7744d9059eSguenther.Sh SEE ALSO
78342ed90eSschwarze.Xr gethostbyname 3 ,
7944d9059eSguenther.Xr inet_addr 3 ,
80*b51b5e42Sjmc.Xr inet_net_ntop 3 ,
81342ed90eSschwarze.Xr hosts 5
8244d9059eSguenther.Sh HISTORY
8344d9059eSguentherThe
8444d9059eSguenther.Nm inet_makeaddr ,
8544d9059eSguenther.Nm inet_lnaof ,
8644d9059eSguentherand
8744d9059eSguenther.Nm inet_netof
8844d9059eSguentherfunctions appeared in
8944d9059eSguenther.Bx 4.2 .
90