xref: /386bsd/usr/share/man/cat4/networking.0 (revision a2142627)
1NETINTRO(4)               386BSD Programmer's Manual               NETINTRO(4)
2
3NNAAMMEE
4     nneettwwoorrkkiinngg - introduction to networking facilities
5
6SSYYNNOOPPSSIISS
7     ##iinncclluuddee <<ssyyss//ssoocckkeett..hh>>
8     ##iinncclluuddee <<nneett//rroouuttee..hh>>
9     ##iinncclluuddee <<nneett//iiff..hh>>
10
11DDEESSCCRRIIPPTTIIOONN
12     This section is a general introduction to the networking facilities
13     available in the system.  Documentation in this part of section 4 is
14     broken up into three areas: _p_r_o_t_o_c_o_l _f_a_m_i_l_i_e_s (domains), _p_r_o_t_o_c_o_l_s, and
15     _n_e_t_w_o_r_k _i_n_t_e_r_f_a_c_e_s.
16
17     All network protocols are associated with a specific _p_r_o_t_o_c_o_l _f_a_m_i_l_y. A
18     protocol family provides basic services to the protocol implementation to
19     allow it to function within a specific network environment.  These
20     services may include packet fragmentation and reassembly, routing,
21     addressing, and basic transport.  A protocol family may support multiple
22     methods of addressing, though the current protocol implementations do
23     not.  A protocol family is normally comprised of a number of protocols,
24     one per socket(2) type.  It is not required that a protocol family
25     support all socket types.  A protocol family may contain multiple
26     protocols supporting the same socket abstraction.
27
28     A protocol supports one of the socket abstractions detailed in socket(2).
29      A specific protocol may be accessed either by creating a socket of the
30     appropriate type and protocol family, or by requesting the protocol
31     explicitly when creating a socket.  Protocols normally accept only one
32     type of address format, usually determined by the addressing structure
33     inherent in the design of the protocol family/network architecture.
34     Certain semantics of the basic socket abstractions are protocol specific.
35     All protocols are expected to support the basic model for their
36     particular socket type, but may, in addition, provide non-standard
37     facilities or extensions to a mechanism.  For example, a protocol
38     supporting the SOCK_STREAM abstraction may allow more than one byte of
39     out-of-band data to be transmitted per out-of-band message.
40
41     A network interface is similar to a device interface.  Network interfaces
42     comprise the lowest layer of the networking subsystem, interacting with
43     the actual transport hardware.  An interface may support one or more
44     protocol families and/or address formats.  The SYNOPSIS section of each
45     network interface entry gives a sample specification of the related
46     drivers for use in providing a system description to the config(8)
47     program.  The DIAGNOSTICS section lists messages which may appear on the
48     console and/or in the system error log, /_v_a_r/_l_o_g/_m_e_s_s_a_g_e_s (see
49     syslogd(8)),  due to errors in device operation.
50
51PPRROOTTOOCCOOLLSS
52     The system currently supports the DARPA Internet protocols, the Xerox
53     Network Systems(tm) protocols, and some of the ISO OSI protocols.  Raw
54     socket interfaces are provided to the IP protocol layer of the DARPA
55     Internet, to the IMP link layer (1822), and to the IDP protocol of Xerox
56     NS. Consult the appropriate manual pages in this section for more
57     information regarding the support for each protocol family.
58
59AADDDDRREESSSSIINNGG
60     Associated with each protocol family is an address format.  All network
61     address adhere to a general structure, called a sockaddr, described
62     below. However, each protocol imposes finer and more specific structure,
63     generally renaming the variant, which is discussed in the protocol family
64     manual page alluded to above.
65
66               struct sockaddr {
67                   u_char  sa_len;
68                   u_char  sa_family;
69                   char    sa_data[14];
70           };
71
72     The field _s_a__l_e_n contains the total length of the of the structure, which
73     may exceed 16 bytes.  The following address values for _s_a__f_a_m_i_l_y are
74     known to the system (and additional formats are defined for possible
75     future implementation):
76
77     #define    AF_UNIX      1    /* local to host (pipes, portals) */
78     #define    AF_INET      2    /* internetwork: UDP, TCP, etc. */
79     #define    AF_IMPLINK   3    /* arpanet imp addresses */
80     #define    AF_NS        6    /* Xerox NS protocols */
81     #define    AF_CCITT     10   /* CCITT protocols, X.25 etc */
82     #define    AF_HYLINK    15   /* NSC Hyperchannel */
83     #define    AF_ISO       18   /* ISO protocols */
84
85RROOUUTTIINNGG
86     UNIX provides some packet routing facilities.  The kernel maintains a
87     routing information database, which is used in selecting the appropriate
88     network interface when transmitting packets.
89
90     A user process (or possibly multiple co-operating processes) maintains
91     this database by sending messages over a special kind of socket.  This
92     supplants fixed size ioctl(2) used in earlier releases.
93
94     This facility is described in route(4).
95
96IINNTTEERRFFAACCEESS
97     Each network interface in a system corresponds to a path through which
98     messages may be sent and received.  A network interface usually has a
99     hardware device associated with it, though certain interfaces such as the
100     loopback interface, lo(4),  do not.
101
102     The following ioctl calls may be used to manipulate network interfaces.
103     The ioctl is made on a socket (typically of type SOCK_DGRAM) in the
104     desired domain.  Most of the requests supported in earlier releases take
105     an _i_f_r_e_q structure as its parameter.  This structure has the form
106
107     struct  ifreq {
108     #define    IFNAMSIZ    16
109         char    ifr_name[IFNAMSIZE];        /* if name, e.g. "en0" */
110         union {
111             struct    sockaddr ifru_addr;
112             struct    sockaddr ifru_dstaddr;
113             struct    sockaddr ifru_broadaddr;
114             short     ifru_flags;
115             int       ifru_metric;
116             caddr_t   ifru_data;
117         } ifr_ifru;
118     #define ifr_addr      ifr_ifru.ifru_addr    /* address */
119     #define ifr_dstaddr   ifr_ifru.ifru_dstaddr /* other end of p-to-p link */
120     #define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
121     #define ifr_flags     ifr_ifru.ifru_flags   /* flags */
122     #define ifr_metric    ifr_ifru.ifru_metric  /* metric */
123     #define ifr_data      ifr_ifru.ifru_data    /* for use by interface */
124     };
125
126     Calls which are now depricated are:
127
128     SIOCSIFADDR     Set interface address for protocol family.  Following the
129                     address assignment, the ``initialization'' routine for
130
131
132                     the interface is called.
133
134     SIOCSIFDSTADDR  Set point to point address for protocol family and
135                     interface.
136
137     SIOCSIFBRDADDR  Set broadcast address for protocol family and interface.
138
139     Ioctl requests to obtain addresses and requests both to set and retreive
140     other data are still fully supported and use the _i_f_r_e_q structure:
141
142     SIOCGIFADDR     Get interface address for protocol family.
143
144     SIOCGIFDSTADDR  Get point to point address for protocol family and
145                     interface.
146
147     SIOCGIFBRDADDR  Get broadcast address for protocol family and interface.
148
149     SIOCSIFFLAGS    Set interface flags field.  If the interface is marked
150                     down, any processes currently routing packets through the
151                     interface are notified; some interfaces may be reset so
152                     that incoming packets are no longer received.  When
153                     marked up again, the interface is reinitialized.
154
155     SIOCGIFFLAGS    Get interface flags.
156
157     SIOCSIFMETRIC   Set interface routing metric.  The metric is used only by
158                     user-level routers.
159
160     SIOCGIFMETRIC   Get interface metric.
161
162     There are two requests that make use of a new structure:
163
164     SIOCAIFADDR     An interface may have more than one address associated
165                     with it in some protocols.  This request provides a means
166                     to add additional addresses (or modify characteristics of
167                     the primary address if the default address for the
168                     address family is specified).  Rather than making
169                     separate calls to set destination or broadcast addresses,
170                     or network masks (now an integral feature of multiple
171                     protocols) a separate structure is used to specify all
172                     three facets simultaneously (see below).  One would use a
173                     slightly tailored version of this struct specific to each
174                     family (replacing each sockaddr by one of the family-
175                     specific type).  Where the sockaddr itself is larger than
176                     the default size, one needs to modify the ioctl
177                     identifier itself to include the total size, as described
178                     in ioctl.
179
180     SIOCDIFADDR     This requests deletes the specified address from the list
181                     associated with an interface.  It also uses the
182                     _i_f__a_l_i_a_s_r_e_q structure to allow for the possibility of
183                     protocols allowing multiple masks or destination
184                     addresses, and also adopts the convention that
185                     specification of the default address means to delete the
186                     first address for the interface belonging to the address
187                     family in which the original socket was opened.
188
189     SIOCGIFCONF     Get interface configuration list.  This request takes an
190                     _i_f_c_o_n_f structure (see below) as a value-result parameter.
191                     The _i_f_c__l_e_n field should be initially set to the size of
192                     the buffer pointed to by _i_f_c__b_u_f. On return it will
193                     contain the length, in bytes, of the configuration list.
194
195     /*
196     * Structure used in SIOCAIFCONF request.
197     */
198     struct ifaliasreq {
199             char    ifra_name[IFNAMSIZ];   /* if name, e.g. "en0" */
200             struct  sockaddr        ifra_addr;
201             struct  sockaddr        ifra_broadaddr;
202             struct  sockaddr        ifra_mask;
203     };
204
205     /*
206     * Structure used in SIOCGIFCONF request.
207     * Used to retrieve interface configuration
208     * for machine (useful for programs which
209     * must know all networks accessible).
210     */
211     struct ifconf {
212         int   ifc_len;              /* size of associated buffer */
213         union {
214             caddr_t    ifcu_buf;
215             struct     ifreq *ifcu_req;
216         } ifc_ifcu;
217     #define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
218     #define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */
219     };
220
221SSEEEE AALLSSOO
222     socket(2),  ioctl(2),  intro(4),  config(8),  routed(8)
223
224HHIISSTTOORRYY
225     The nneettiinnttrroo manual appeared in 4.3BSD-Tahoe.
226
2274.2 Berkeley Distribution       March 28, 1991                               4
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265