Provided by: manpages-zh_1.5.2-1_all bug

NAME ()

       ip - Linux IPv4

SYNOPSIS()

       #include <sys/socket.h>
       #include <net/netinet.h>

       tcp_socket = socket(PF_INET, SOCK_STREAM, 0);
       raw_socket = socket(PF_INET, SOCK_RAW, protocol);
       udp_socket = socket(PF_INET, SOCK_DGRAM, protocol);

DESCRIPTION()

       Linux  RFC791  RFC1122  Internet ,4.  ip  RFC1112 .IP.

        BSD (socket) , socket(7)

       IP   socket(PF_INET,   socket_type,   protocol)  socket(2)  socket_type
       SOCK_STREAM tcp(7) SOCK_DGRAM udp(7) SOCK_RAW raw(7)  IP  protocol   IP
       (header)  IP  TCP,  protocol 0 IPPROTO_TCP UDP, protocol 0 IPPROTO_UDP.
       SOCK_RAW  RFC1700  IANA IP .

       , bind(2) (,)IP  bind INADDR_ANY ,  listen(2) connect(2) , INADDR_ANY

        S0_REUSEADDR  TCP  TCP

ADDRESS FORMAT()

        IP  IP  IP , udp(7) tcp(7) raw sin_port IP

              struct sockaddr_in {
              sa_family_t sin_family; /* : AF_INET */
              u_int16_t sin_port; /*  */
              struct in_addr sin_addr; /* internet */
              };

              /* Internet. */
              struct in_addr {
              u_int32_t s_addr; /*  */
              };

       sin_family  AF_INET.     Linux   2.2   EINVAL   sin_port   1024       0
       CAP_NET_BIND_SERVICE bind(2) rawIPv4, tcp(7) udp(7)

       sin_addr  IP .  struct in_addr addr in_addr inet_aton(3), inet_addr(3),
       inet_makeaddr(3) gethostbyname(3) IPv4 .  SO_BROADCAST

        htons(3) /

         INADDR_LOOPBACK  (127.0.0.1)  INADDR_ANY  (0.0.0.0)  INADDR_BROADCAST
       (255.255.255.255) INADDR_ANY .

SOCKET OPTIONS()

       IP setsockopt(2) getsockopt(2) IP SOL_IP ,0,.

       IP_OPTIONS
                IP  setsockopt(2)   IP  .  IPv4  40  RFC791 SOCK_STREAM  IP IP
              accept_source_route sysctl timestamp IP IP_OPTIONS getsockopt(2)
              IP

       IP_PKTINFO
               pktinfo () IP_PKTINFO .

              struct in_pktinfo
              {
              unsigned int ipi_ifindex; /*  */
              struct in_addr ipi_spec_dst; /*  */
              struct in_addr ipi_addr; /*  */
              };

              ipi_ifindex   ipi_spec_dst   ipi_addr   sendmsg  (2)  IP_PKTINFO
              ipi_ifindex ipi_spec_dst

       IP_RECVTOS
               IP_TOS , /

       IP_RECVTTL
               time to live IP_RECVTTL SOCK_STREAM

       IP_RECVOPTS
               IP_OPTIONS  IP SOCK_STREAM

       IP_RETOPTS
               IP_RECVOPTS

       IP_TOS IP Type-Of-Service TOS TOS  TOS IPTOS_LOWDELAY  IPTOS_THROUGHPUT
              IPTOS_RELIABILITY  IPTOS_MINCOST ""  TOS ,Linux IPTOS_LOWDELAY ,
              .   0 CAP_NET_ADMIN .  ( SOL_SOCKET, SO_PRIORITY )( socket(7) ).

       IP_TTL .

       IP_HDRINCL
              ,  ip .  SOCK_RAW .  raw(7) ., IP_OPTIONS , IP_TOS .

       IP_RECVERR
              .   ,  .   ,  MSG_ERRQUEUE   recvmsg(2)   .    sock_extended_err
              IP_RECVERR , SOL_IP.  .  .

              IP   sock_extended_err   ICMP   ee_origin   SO_EE_ORIGIN_ICMP  ,
              SO_EE_ORIGIN_LOCAL .  ee_type ee_code  ICMP .  ee_info  EMSGSIZE
              MTU.  ee_data .  ,IP (IP_OPTIONS, IP_TTL, )..

                 SOCK_STREAM   IP_RECVERR   .,.     TCP  ,.   :  ,TCP,.   TCP;
              MSG_ERRQUEUE SOCK_STREAM .  , SO_ERROR .

              (raw), IP_RECVERR ICMP,.

              .  IP_RECVERR off().

       IP_PMTU_DISCOVER
              Path  MTU  Discovery  setting(MTU).   ,Linux   RFC1191Path   MTU
              Discovery(MTU).   don't  .   SOCK_STREAM  ip_no_pmtu_disc sysctl
              SOCK_STREAM , MTU.  ( EMSGSIZE ),MTU.

              Path MTU discovery(MTU)

              IP_PMTUDISC_WANT          .
              IP_PMTUDISC_DONT          Path MTU Discovery(MTU).
              IP_PMTUDISC_DO            Path MTU Discovery(MTU).

               PMTU MTU, path MTU(MTU).  connect(2) , IP_MTU   path  MTU(MTU)(
              EMSGSIZE )..  , MTU ( IP_RECVERR) .   MTU .

               MTU ,.   UDP .

               MTU , (64K),  MTU .

              MTU, connect(2) , IP_MTU getsockopt(2) MTU.

       IP_MTU MTU...  getsockopt(2) .

       IP_ROUTER_ALERT
              IPIP RouterAlert option.  raw socket, RSVP .  ,., .  .

       IP_MULTICAST_TTL
              .  TTL.  1,, ..

       IP_MULTICAST_LOOP
              .

       IP_ADD_MEMBERSHIP
              .  struct ip_mreqn .

              struct ip_mreqn
              {
              struct in_addr imr_multiaddr; /* IP */
              struct in_addr imr_address; /* IP */
              int imr_ifindex; /*  */
              };

              imr_multiaddr  .   .  imr_address ; INADDR_ANY ,.  imr_ifindex /
              imr_multiaddr ,0.

              , ip_mreq .  ip_mreqn , imr_ifindex .  setsockopt(2) .

       IP_DROP_MEMBERSHIP
              .  ip_mreqn ip_mreq , IP_ADD_MEMBERSHIP .

       IP_MULTICAST_IF
              .  ip_mreqn ip_mreq , IP_ADD_MEMBERSHIP .

              , ENOPROTOOPT .

SYSCTLS

       IP sysctl .sysctl /proc/sys/net/ipv4/* sysctl(2) .

       ip_default_ttl
              .  IP_TTL .

       ip_forward
              IP.IP

       ip_dynaddr
              .  IP .0,1,2.

       ip_autoconfig

       ip_local_port_range
              ,.  .  ().  ,,.  >1024,>4096 .

       ip_no_pmtu_disc
              ,TCPMTU.  ( ICMP) (,MTU),MTU.  ,MTU, .

       ipfrag_high_thresh, ipfrag_low_thresh
              IP ipfrag_high_thresh , ipfrag_low_thresh .  .

       ip_always_defrag
              [kernel 2.2.13;, CONFIG_IP_ALWAYS_DEFRAG ]

              (0), (IP, )(),

              ; , .  .   CPU

              .

       neigh/*
               arp(7)

IOCTLS

        socket(7)   ioctl ip.

       ioctl ipchains ipfw(7) .

       ioctl netdevice(7) .

NOTES()

        SO_BROADCAST  -  Linux .  ., ..

       BSD IP_RCVDSTADDR IP_RECVIF .Linux IP_PKTINFO .

ERRORS()

       ENOBUFS,EPERMEACCES.)

       ENOTCONN
              ,.

       EINVAL .  , blackhole() .

       EMSGSIZE
               MTU,.

       EACCES .  : SO_BROADCAST .   .  CAP_NET_ADMIN 0.   CAP_NET_BIND_SERVICE
              0.

       EADDRINUSE
              .

       ENOMEM  ENOBUFS
              .

       ENOPROTOOPT  EOPNOTSUPP
              .

       EPERM  ,.

       EADDRNOTAVAIL
              .

       EAGAIN .

       ESOCKTNOSUPPORT
              .

       EISCONN
               connect(2).

       EALREADY
              .

       ECONNABORTED
               accept(2) .

       EPIPE  .

       ENOENT  SIOCGSTAMP .

       EHOSTUNREACH
              .  ICMP.

       ENODEV IP.

       ENOPKG .

       ENOBUFS, ENOMEM
              .  , ,100%

       ; tcp(7), raw(7), udp(7) socket(7).

VERSIONS()

       IP_PKTINFO,    IP_MTU,    IP_PMTU_DISCOVER,    IP_PKTINFO,   IP_RECVERR
       IP_ROUTER_ALERT Linux 2.2.

       struct ip_mreqn Linux 2.2.Linux 2.0 ip_mreq.

       sysctlLinux 2.2.

COMPATIBILITY()

       Linux   2.0,   socket(PF_INET,   SOCK_RAW,   protocol)   packet(7)   .,
       socket(PF_PACKET, SOCK_RAW, protocol) .  sockaddr_ll sockaddr_pkt .

BUGS

       .

       IPARPioctl.

AUTHORS()

       manAndi Kleen.

SEE ALSO()

       sendmsg(2),  recvmsg(2), socket(7), netlink(7), tcp(7), udp(7), raw(7),
       ipfw(7).

       RFC791:IP.
       RFC1122:IPv4.
       RFC1812:IPv4.

[]

       riser <boomer@ccidnet.com>

[]

       2001/07/19

linuxman:

       http://cmpp.linuxforum.net