1INTRO(4N)                                                            INTRO(4N)
2
3
4

NAME

6       networking - introduction to networking facilities
7

SYNOPSIS

9       #include <sys/socket.h>
10       #include <net/route.h>
11       #include <net/if.h>
12

DESCRIPTION

14       This  section  briefly describes the networking facilities available in
15       the system.  Documentation in this part of section 4 is broken up  into
16       three areas: protocol families (domains), protocols, and network inter‐
17       faces.  Entries describing a protocol family are marked  ``4F,''  while
18       entries  describing  protocol  use are marked ``4P.''  Hardware support
19       for network interfaces are found among the standard ``4'' entries.
20
21       All network protocols are associated with a specific  protocol  family.
22       A  protocol  family provides basic services to the protocol implementa‐
23       tion to allow it to function within  a  specific  network  environment.
24       These  services  may include packet fragmentation and reassembly, rout‐
25       ing, addressing, and basic transport.  A protocol  family  may  support
26       multiple methods of addressing, though the current protocol implementa‐
27       tions do not.  A protocol family is normally comprised of a  number  of
28       protocols,  one per socket(2) type.  It is not required that a protocol
29       family support all socket types.  A protocol family may contain  multi‐
30       ple protocols supporting the same socket abstraction.
31
32       A  protocol  supports  one  of  the  socket  abstractions  detailed  in
33       socket(2).  A specific protocol may be accessed either  by  creating  a
34       socket  of  the  appropriate type and protocol family, or by requesting
35       the protocol explicitly when creating  a  socket.   Protocols  normally
36       accept  only  one  type  of  address  format, usually determined by the
37       addressing structure inherent in the design of the protocol family/net‐
38       work  architecture.  Certain semantics of the basic socket abstractions
39       are protocol specific.  All protocols are expected to support the basic
40       model  for  their particular socket type, but may, in addition, provide
41       non-standard facilities or extensions to a mechanism.  For  example,  a
42       protocol supporting the SOCK_STREAM abstraction may allow more than one
43       byte of out-of-band data to be transmitted per out-of-band message.
44
45       A network interface is similar to a device interface.   Network  inter‐
46       faces  comprise the lowest layer of the networking subsystem, interact‐
47       ing with the actual transport hardware.  An interface may  support  one
48       or more protocol families and/or address formats.  The SYNOPSIS section
49       of each network interface entry gives a  sample  specification  of  the
50       related  drivers  for  use  in  providing  a  system description to the
51       /sys/conf/config script.  The DIAGNOSTICS section lists messages  which
52       may appear on the console and/or in the system error log, /usr/adm/mes‐
53       sages (see syslogd(8)), due to errors in device operation.
54

PROTOCOLS

56       The system currently supports the  DARPA  Internet  protocols  and  the
57       Xerox  Network  Systems(tm)  protocols.  Raw socket interfaces are pro‐
58       vided to the IP protocol layer of the DARPA Internet, to the  IMP  link
59       layer  (1822), and to the IDP protocol of Xerox NS.  Consult the appro‐
60       priate manual pages in this section for more information regarding  the
61       support for each protocol family.
62

ADDRESSING

64       Associated with each protocol family is an address format.  The follow‐
65       ing address formats are used by the system (and additional formats  are
66       defined for possible future implementation):
67
68       #define AF_UNIX           1      /* local to host (pipes, portals) */
69       #define AF_INET           2      /* internetwork: UDP, TCP, etc. */
70       #define AF_IMPLINK        3      /* arpanet imp addresses */
71       #define AF_PUP            4      /* pup protocols: e.g. BSP */
72       #define AF_NS             6      /* Xerox NS protocols */
73       #define AF_HYLINK         15     /* NSC Hyperchannel */
74

ROUTING

76       The  network  facilities provided limited packet routing.  A simple set
77       of data structures comprise a ``routing table'' used in  selecting  the
78       appropriate  network  interface  when transmitting packets.  This table
79       contains a single entry for each route to a specific network  or  host.
80       A  user  process, the routing daemon, maintains this data base with the
81       aid of two socket-specific ioctl(2) commands, SIOCADDRT and  SIOCDELRT.
82       The  commands allow the addition and deletion of a single routing table
83       entry, respectively.  Routing table manipulations may only  be  carried
84       out by super-user.
85
86       A   routing   table  entry  has  the  following  form,  as  defined  in
87       <net/route.h>;
88
89       struct rtentry {
90              u_long    rt_hash;
91              struct    sockaddr rt_dst;
92              struct    sockaddr rt_gateway;
93              short     rt_flags;
94              short     rt_refcnt;
95              u_long    rt_use;
96              struct    ifnet *rt_ifp;
97       };
98
99       with rt_flags defined from,
100
101       #define RTF_UP            0x1    /* route usable */
102       #define RTF_GATEWAY       0x2    /* destination is a gateway */
103       #define RTF_HOST          0x4    /* host entry (net otherwise) */
104       #define RTF_DYNAMIC       0x10   /* created dynamically (by redirect) */
105
106       Routing table entries come in three flavors: for a specific  host,  for
107       all  hosts  on  a  specific network, for any destination not matched by
108       entries of the first two types (a wildcard route).  When the system  is
109       booted  and addresses are assigned to the network interfaces, each pro‐
110       tocol family installs a routing table entry for each interface when  it
111       is  ready  for  traffic.   Normally  the  protocol  specifies the route
112       through each interface as a ``direct'' connection  to  the  destination
113       host or network.  If the route is direct, the transport layer of a pro‐
114       tocol family usually requests the packet be sent to the same host spec‐
115       ified  in the packet.  Otherwise, the interface is requested to address
116       the packet to the gateway listed in the routing entry (i.e. the  packet
117       is forwarded).
118
119       Routing  table  entries installed by a user process may not specify the
120       hash, reference count, use, or interface fields; these are filled in by
121       the  routing  routines.   If  a  route  is  in  use  when it is deleted
122       (rt_refcnt is non-zero), the routing entry  will  be  marked  down  and
123       removed  from  the  routing table, but the resources associated with it
124       will not be reclaimed until all references to  it  are  released.   The
125       routing  code  returns  EEXIST  if  requested  to duplicate an existing
126       entry, ESRCH if requested to delete a non-existent entry, or ENOBUFS if
127       insufficient  resources  were  available  to install a new route.  User
128       processes read the routing tables through the  /dev/kmem  device.   The
129       rt_use field contains the number of packets sent along the route.
130
131       When routing a packet, the kernel will first attempt to find a route to
132       the destination host.  Failing that, a search is made for  a  route  to
133       the  network  of  the  destination.   Finally,  any  route to a default
134       (``wildcard'') gateway is chosen.  If multiple routes  are  present  in
135       the  table,  the first route found will be used.  If no entry is found,
136       the destination is declared to be unreachable.
137
138       A wildcard routing entry is specified with a zero  destination  address
139       value.   Wildcard  routes are used only when the system fails to find a
140       route to the destination host and network.  The combination of wildcard
141       routes  and  routing  redirects can provide an economical mechanism for
142       routing traffic.
143

INTERFACES

145       Each network interface in a system corresponds to a path through  which
146       messages  may  be sent and received.  A network interface usually has a
147       hardware device associated with it, though certain interfaces  such  as
148       the loopback interface, lo(4), do not.
149
150       The following ioctl calls may be used to manipulate network interfaces.
151       The ioctl is made on a socket (typically of  type  SOCK_DGRAM)  in  the
152       desired domain.  Unless specified otherwise, the request takes an ifre‐
153       quest structure as its parameter.  This structure has the form
154
155       struct    ifreq {
156       #define   IFNAMSIZ  16
157            char ifr_name[IFNAMSIZ];      /* if name, e.g. "en0" */
158            union {
159                 struct    sockaddr ifru_addr;
160                 struct    sockaddr ifru_dstaddr;
161                 struct    sockaddr ifru_broadaddr;
162                 short     ifru_flags;
163                 int  ifru_metric;
164                 caddr_t   ifru_data;
165            } ifr_ifru;
166       #define   ifr_addr  ifr_ifru.ifru_addr  /* address */
167       #define   ifr_dstaddr    ifr_ifru.ifru_dstaddr    /* other end of p-to-p link */
168       #define   ifr_broadaddr  ifr_ifru.ifru_broadaddr  /* broadcast address */
169       #define   ifr_flags ifr_ifru.ifru_flags /* flags */
170       #define   ifr_metric     ifr_ifru.ifru_metric     /* metric */
171       #define   ifr_data  ifr_ifru.ifru_data  /* for use by interface */
172       };
173
174       SIOCSIFADDR
175              Set  interface  address  for  protocol  family.   Following  the
176              address  assignment,  the  ``initialization''  routine  for  the
177              interface is called.
178
179       SIOCGIFADDR
180              Get interface address for protocol family.
181
182       SIOCSIFDSTADDR
183              Set point to point address for protocol family and interface.
184
185       SIOCGIFDSTADDR
186              Get point to point address for protocol family and interface.
187
188       SIOCSIFBRDADDR
189              Set broadcast address for protocol family and interface.
190
191       SIOCGIFBRDADDR
192              Get broadcast address for protocol family and interface.
193
194       SIOCSIFFLAGS
195              Set interface flags field.  If the interface is marked down, any
196              processes  currently  routing  packets through the interface are
197              notified; some interfaces may be reset so that incoming  packets
198              are  no longer received.  When marked up again, the interface is
199              reinitialized.
200
201       SIOCGIFFLAGS
202              Get interface flags.
203
204       SIOCSIFMETRIC
205              Set interface routing metric.  The metric is used only by  user-
206              level routers.
207
208       SIOCGIFMETRIC
209              Get interface metric.
210
211       SIOCGIFCONF
212              Get  interface configuration list.  This request takes an ifconf
213              structure (see below) as a value-result parameter.  The  ifc_len
214              field  should be initially set to the size of the buffer pointed
215              to by ifc_buf.  On return it will contain the length, in  bytes,
216              of the configuration list.
217
218       /*
219        * Structure used in SIOCGIFCONF request.
220        * Used to retrieve interface configuration
221        * for machine (useful for programs which
222        * must know all networks accessible).
223        */
224       struct    ifconf {
225            int  ifc_len;       /* size of associated buffer */
226            union {
227                 caddr_t   ifcu_buf;
228                 struct    ifreq *ifcu_req;
229            } ifc_ifcu;
230       #define   ifc_buf   ifc_ifcu.ifcu_buf   /* buffer address */
231       #define   ifc_req   ifc_ifcu.ifcu_req   /* array of structures returned */
232       };
233

SEE ALSO

235       socket(2), ioctl(2), intro(4), config(8), routed(8C)
236
237
238
2394.2 Berkeley Distribution       August 1, 1987                       INTRO(4N)
Impressum