ip(7) CLIX ip(7)
NAME
ip - Internet Protocol (IP) STREAMS multiplexor
DESCRIPTION
The ip driver is a ``cloneable'' (see clone) STREAMS multiplexing driver
that provides the services of the Internet Protocol (IP) to applications,
other protocols on the host machine, and gateway functionality to other
hosts and networks. IP is the connectionless network layer protocol of
the Department of Defense (DoD) Internet Protocol suite.
The ip driver communicates on its upper streams using the AT&T Transport
Provider Interface (TPI). Adherence to TPI allows applications to
interface with ip using the AT&T Transport Layer Interface (TLI). The ip
driver provides the T_CLTS connectionless protocol service (as specified
by TPI/TLI) to its upstream clients. The ip driver communicates on its
lower streams using the AT&T Logical Link Interface (LLI), expecting that
its lower streams are bound to either DOD_SAP (0x800) or TRLR_SAP (0x1001,
with tren pushed) before they are linked.
The address contained in bind requests sent to ip should consist of one
byte that indicates the protocol type to be bound to the ip stream. This
byte should correspond to the value desired in the protocol field of the
IP header on frames transmitted on the device. This value is also needed
in incoming frames that will be received on the stream. Some protocol
types are listed in /etc/protocols.
Datagrams to be transmitted by ip are passed to ip by unit datagram
requests. If no options are specified in the TLI unit datagram request, a
default IP header is prepended to the datagram and sent to the destination
address passed in the address field of the unit datagram request. The
address format for unit datagram requests without options is the inet_addr
structure described in <sys/dod/inet.h>.
struct inet_addr {
unchar uc[4];
};
The address should be filled-in using network order. For example the
destination address 129.135.200.7 would be filled-in using the following
code:
struct inet_addr ina;
ina.uc[0] = 129;
ina.uc[1] = 135;
ina.uc[2] = 200;
ina.uc[3] = 7;
The ip driver clients can pass the IP header to be sent with the datagram
in the options field of unit datagram requests. If the IP header is
2/94 - Intergraph Corporation 1
ip(7) CLIX ip(7)
passed with the unit datagram request, the destination address is assumed
to be in the appropriate place in the IP header field of the unit datagram
request's options, not in the address field. The destination address
passed in the address field is ignored if options are present. The length
of the options passed into ip must be the size of the ip_udopt structure.
The following is the format of the ip_udopt structure, as defined in
<sys/dod/ip.h>:
struct ip_udopt{
long flags;
struct ip_hdr hdr;
};
The flags member is a bit field indicating which fields of the IP header
have been filled and passed to ip in the options field of the unit
datagram request. Before transmitting the datagram, ip fills any unfilled
fields with default values. Bitmasks for the flags member are in
<sys/dod/ip.h>. The ip driver checks the IP header fields passed to ip
for validity. If illegal header field values are passed to ip, a unit
datagram error indication is sent upstream by ip and the bitmask of the
first invalid field encountered is returned in the flags member of the
ip_udopt structure.
The destination address field must be filled-in and the destination
address bit must be set in flags when options are passed-in because ip
will try to use that address and not the nonoption destination address.
The IP header length field must be filled-in and the corresponding bit
must be set in flags when options are passed-in. The checksum member of
the IP header may not be passed into ip. If the fragment field of the IP
header is passed to ip, the identification field must also be filled-in.
IP header options follow the default IP header and may be contained in the
options array of the ip_hdr structure passed to ip in the options part of
the unit datagram request. If IP header options are to be transmitted
with the frame, the appropriate IP header length must be filled-in and
passed to ip. The ip driver will not return a unit datagram error
indication if there are errors encountered in the IP header options
passed-in to ip. The offending datagram will be thrown away, and an ICMP
error message will be sent to the local ip. There is no bit in the flags
member of the ip_udopt structure indicating the presence of IP header
options.
The following is the format of the ip_hdr structure, as defined in
<sys/dod/iph.h>:
struct ip_hdr {
unchar ihlen:4; /* Header Length */
unchar ver:4; /* IP Version */
tos_u tos; /* Type of Service */
unchat len[2]; /* Total Length */
unchar id[2]; /* Identification */
2 Intergraph Corporation - 2/94
ip(7) CLIX ip(7)
unchar frag[2]; /* Flags/Frag. Offset */
unchar ttl; /* Time to Live */
unchar proto; /* Protocol */
unchar xsum[2]; /* Checksum */
ina_t src; /* Source Address */
ina_t dst; /* Destination Address */
unchar options[IPH_MAX_OPT_SZ];
};
The ip device supports the transmission of datagrams from one to 10240
bytes long and the reception of datagrams from one to 65535 bytes long.
The ip driver fragments transmit datagrams that are larger than the
maximum frame size for the network on which they are to be transmitted
into many adequately sized frames. The ip driver also reassembles
fragmented datagrams to be received locally.
The ip driver returns all frames received locally with a protocol field in
the IP header that matches the protocol bound to the stream. The unit
datagram indication returned by ip provides options with each returned
datagram containing an ip_udopt structure. The flags member is set to
IP_HDR_UDOPT (all flags set) and the complete IP header of the received
datagram contained in the hdr member. The length of the returned options
equals the size of the received IP header. Therefore, the options length
may be less than the size of the ip_udopt structure if the size of the
received IP header is less than the maximum size.
The ip driver supports ioctl() requests to get and set ip configuration
parameters and to manipulate and retrieve the routing information tables.
The ioctl() requests to get and set configuration parameters use the I_STR
ioctl() call described in streamio. The ic_cmd member of the strioctl
structure should be set to the appropriate command value for the operation
to be performed. These command values are defined in <sys/dod/ip.h>. The
ic_timeout member of the strioctl structure should be set to the desired
timeout. The ic_len and ic_dp members of the strioctl structure should be
the size of the ip_ifreq structure defined in <sys/dod/ip.h> and a pointer
to an ip_ifreq structure, respectively, for all but the I_IFGETCONF
command. In each case, the ifr_name member of ip_ifreq pointed to by
ic_dp should contain the name of the network interface (ip lower stream)
to work on. The contents of the ifr_ifru union member aew determined by
the command performed.
The available commands are as follows:
I_IFSETADDR
Set the address for an interface. The address for the named
interface to use is set to the value sent to ip in the
ifr_ifru.ifru_addr member.
I_IFGETADDR
Get the address from an interface. The address that the named
2/94 - Intergraph Corporation 3
ip(7) CLIX ip(7)
interface is currently using will be returned from ip in the
ifr_ifru.ifru_addr member.
I_IFSETBRDADDR
Set the broadcast address for an interface. The broadcast address
for the named interface to use is set to the value sent to ip in
the ifr_ifru.ifru_addr member.
I_IFGETBRDADDR
Get the broadcast address from an interface. The broadcast address
that the named interface is currently using will be returned from
ip in the ifr_ifru.ifru_addr member.
I_IFSETNETMASK
Set the subnetwork address mask for an interface. The subnetwork
address mask for the named interface to use is set to the value
sent to ip in the ifr_ifru.ifru_addr member.
I_IFGETNETMASK
Get the subnetwork address mask from an interface. The subnetwork
address mask that the named interface is currently using will be
returned to ip in the ifr_ifru.ifru_addr member.
I_IFSETMETRIC
Set the routing metric for an interface. The routing metric that
the named interface will use is set to the value sent to ip in the
ifr_ifru.ifru_metric member.
I_IFGETMETRIC
Get the routing metric from an interface. The routing metric that
the named interface is currently using will be returned to ip in
the ifr_ifru.ifru_metric member.
I_IFSETFLAGS
Set flags on an interface. Set the flags member on the named
interface to the value sent to ip in the ifr_ifru.ifru_flags
member.
I_IFGETFLAGS
Get flags from an interface. Return the flags member of the named
interface in the ifr_ifru.ifru_flags member.
The flags that may be set by applications through the ioctl() mechanism
are specified by the constant IPL_VALID_FLAGS in <sys/dod/ip.h>. The
flags are as follows:
#define IPL_UP_FL 0x0001 /* Allow/disallow use of interface */
#define IPL_BCAST_FL 0x0002 /* Indicate broadcast address set up */
#define IPL_NOARP_F 0x0080 /* Use/do not use arp on interface */
#define IPL_MASKREP_FL 0x0100 /* Resp. to ICMP addr. mask requests */
#define IPL_VALID_FLAGS 0x0183
4 Intergraph Corporation - 2/94
ip(7) CLIX ip(7)
The I_IFGETCONF command is used to get the Internet address specified on
all ip interfaces. To do this, ic_dp should point to an array of ip_ifreq
structures and length should reflect the size of the buffer in bytes. The
ip driver returns the name and address of each interface presently
configured and the length, in bytes, of the resulting buffer.
The ip driver also supports ioctl() requests to allow modification of the
routing table maintained in the kernel for ip. Routing information
ioctl() requests all use I_STR ioctl(). The ic_cmd member of the strioctl
structure should be set to the appropriate command value for the operation
to be performed. The routing information requests allow adding and
deleting entries in the table, getting individual entries from the table,
and retrieving the entire table. The ri_entry structure is used to
perform the requests. It is defined in ri.h, as shown in the following
example:
struct ri_entry {
ina_t lan;
ina_t rtr;
short flags;
short proto;
struct ip_lstr *lstr;
};
The lan member is the Internet address for the entry. The rtr member is
the Internet address of the router through which datagrams should be sent
that are destined for the local area network (LAN) in the lan member. The
proto member is the number used to represent the protocol that was used to
determine the route for the LAN. Constant definitions in ri.h exist for
all presently known routing information protocols. The lstr member is
used internally by ip and its value in routing entries may not be set by
applications.
The flags member is a bit field indicating the state of the entry. The
RI_LOCAL_FL tells ip that the LAN is directly connected to this host and,
therefore, datagrams may be sent directly to hosts on that LAN without
routing. Other flags should be set only by ip itself. The following
ioctl() requests are supported:
I_RIADD Add an entry to the routing table. You must be superuser to
perform this request. The ic_len and ic_dp members should be
the size of the ri_entry structure and a pointer to an ri_entry
structure, respectively. The ioctl() function fails if there
are not enough streams resources or there was a conflict with
another entry in the table.
I_RIDEL Delete an entry from the routing table. You must be superuser
to perform this request. The ic_len and ic_dp members should be
the size of the ri_entry structure and a pointer to an ri_entry
structure, respectively. The ioctl() function fails if an entry
did not exist in the table for the specified LAN or if the
2/94 - Intergraph Corporation 5
ip(7) CLIX ip(7)
RI_LOCAL_FL flag was set in the table entry but not set in the
request.
I_RIGET Get an entry from the routing table. The ic_len and ic_dp
members should be the size of the ri_entry structure and a
pointer to an ri_entry structure, respectively. The lan member
tells ip which entry to return. The ioctl() function fails if
an entry did not exist in the table for the specified LAN.
I_RITBL Get the routing table. The ic_len and ic_dp members should be
the size of as many ri_entry structures as there are entries in
the table and a pointer to a buffer that large, respectively.
The ioctl() function fails if the buffer is not large enough to
hold all the entries, and errno is set to the number of entries
currently in the table. Otherwise, the buffer contains an array
of ri_entry structures, one for each entry in the table.
The ip driver also supports the ARP ioctl() requests described in arp.
FILES
/dev/ip Special device file for the IP protocol
<sys/dod/ip.h> Definitions for the ip device
<sys/dod/iph.h> Definitions for the IP protocol
<sys/dod/ipopt.h> Definitions for IP protocol header options
<sys/dod/icmp.h> Definitions for the ICMP protocol
<sys/dod/inet.h> Internet address definitions
<sys/dod/dod_ut.h> Internet utility and address definitions
<sys/dod/ri.h> Routing table definitions
NOTES
The incd command is used at boot time and to configure the STREAMS drivers
and modules that implement network protocols, including ip. Manual
configuration is not usually necessary.
The routed command is usually responsible for maintaining the kernel
routing information tables from information gathered by routing
information protocols running on the network. Manual manipulation of
these tables is necessary only in rare circumstances or in installations
where no routing information protcol is in use.
RELATED INFORMATION
6 Intergraph Corporation - 2/94
ip(7) CLIX ip(7)
Commands: ifconfig(8), incd(8), route(8), routed(8)
Function: ioctl(2)
Files: arp(7), clone(7), et(7), icmp(7), streamio(7), tcp(7), tren(7),
udp(7)
AT&T UNIX System V Network Programmer's Guide
2/94 - Intergraph Corporation 7