home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tolkit45.zip / os2tk45 / som / include / soms.h < prev    next >
C/C++ Source or Header  |  1999-02-22  |  22KB  |  700 lines

  1. /*
  2.  *   COMPONENT_NAME: somu
  3.  *
  4.  *   ORIGINS: 27
  5.  *
  6.  *
  7.  *    25H7912  (C)  COPYRIGHT International Business Machines Corp. 1992,1996,1996  
  8.  *   All Rights Reserved
  9.  *   Licensed Materials - Property of IBM
  10.  *   US Government Users Restricted Rights - Use, duplication or
  11.  *   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  12.  */
  13. /* @(#) 2.7 src/soms/soms.h, somu, som2.1 12/26/95 18:15:20 [7/30/96 14:49:46] */
  14.  
  15. /*
  16.  */
  17.  
  18. #ifndef _soms_h
  19. #define _soms_h
  20.  
  21. /* Sockets errnos */
  22. #define SOMS_NOERROR         0    /* no error */
  23. #define SOMS_EWOULDBLOCK     1    /* operation would block */
  24. #define SOMS_EDEADLK         SOMS_EWOULDBLOCK
  25. #define SOMS_EAGAIN         SOMS_EWOULDBLOCK
  26. #define SOMS_EINPROGRESS     2    /* operation now in progress */
  27. #define SOMS_EALREADY         3    /* operation already in progress */
  28. #define SOMS_ENOTSOCK         4    /* socket operation on non-socket */
  29. #define SOMS_EDESTADDRREQ     5    /* destination address required */
  30. #define SOMS_EMSGSIZE         6    /* message too long */
  31. #define SOMS_EPROTOTYPE         7    /* wrong protocol type for socket */
  32. #define SOMS_ENOPROTOOPT     8    /* protocol not available */
  33. #define SOMS_EPROTONOSUPPORT     9    /* protocol not supported */
  34. #define SOMS_ESOCKTNOSUPPORT    10    /* socket type not supported */
  35. #define SOMS_EOPNOTSUPP        11    /* operation not supported on socket */
  36. #define SOMS_EPFNOSUPPORT    12    /* protocol family not supported */
  37. #define SOMS_EAFNOSUPPORT    13    /* address family not supported */
  38. #define SOMS_EADDRINUSE        14    /* address already in use */
  39. #define SOMS_EADDRNOTAVAIL    15    /* can't assign requested address */
  40. #define SOMS_ENETDOWN        16    /* network is down */
  41. #define SOMS_ENETUNREACH    17    /* network is unreachable */
  42. #define SOMS_ENETRESET        18    /* network dropped connection on reset*/
  43. #define SOMS_ECONNABORTED    19    /* software caused connection abort */
  44. #define SOMS_ECONNRESET        20    /* connection reset by peer */
  45. #define SOMS_ENOBUFS        21    /* no buffers available */
  46. #define SOMS_EISCONN        22    /* socket is already connected */
  47. #define SOMS_ENOTCONN        23    /* socket is not connected */
  48. #define SOMS_ESHUTDOWN        24    /* can't send after socket shutdown */
  49. #define SOMS_ETOOMANYREFS    25    /* too many references */
  50. #define SOMS_ETIMEDOUT        26    /* connection timed out */
  51. #define SOMS_ECONNREFUSED    27    /* connection refused */
  52. #define SOMS_ELOOP        28    /* too many levels of symbolic links */
  53. #define SOMS_ENAMETOOLONG    29    /* file name too long */
  54. #define SOMS_EHOSTDOWN        30    /* host is down */
  55. #define SOMS_EHOSTUNREACH    31    /* no route to host */
  56. #define SOMS_ENOTEMPTY        32    /* directory not empty */
  57. #define SOMS_EBADF        33    /* bad socket descriptor */
  58. #define SOMS_EINTR        34    /* socket call interrupted */
  59. #define SOMS_EFAULT        35    /* bad address */
  60. #define SOMS_EINVAL        36    /* invalid argument */
  61. #define SOMS_EMFILE        37    /* no more socket descriptors */
  62. #define SOMS_ENODEV        38    /* no such device */
  63. #define SOMS_UNKNOWNERROR    39    /* unknown error */
  64. #define SOMS_HOST_NOT_FOUND    40
  65. #define SOMS_TRY_AGAIN        41
  66. #define SOMS_NO_RECOVERY    42
  67. #define SOMS_NO_ADDRESS        43
  68.  
  69. #ifndef bzero
  70. #define bzero(p,n) memset((p),0,(n))
  71. #endif
  72.  
  73. #ifndef bcopy
  74. #define bcopy(s,d,n) memcpy((d),(s),(n))
  75. #endif
  76.  
  77.  
  78. /* Sockets data definitions */
  79.  
  80. /*
  81.  * Definitions from sys/param.h
  82.  */
  83. #ifndef MAXHOSTNAMELEN
  84. #define MAXHOSTNAMELEN    32
  85. #endif
  86.  
  87.  
  88.  
  89. /*
  90.  * Definitions from sys/uio.h
  91.  */
  92.  
  93. struct Sockets_iovec {
  94.     char    *iov_base;    /* base memory address            */
  95. /* WIN16PORT CHG5 must be an int for psl */
  96. #ifdef _WIN16
  97.     int    iov_len;    /* length of transfer for this area    */
  98. #else
  99.     long    iov_len;    /* length of transfer for this area    */
  100. #endif
  101. };
  102.  
  103.  
  104. /*
  105.  * Definitions from sys/time.h
  106.  */
  107.  
  108. struct Sockets_timeval {
  109.     long    tv_sec;        /* seconds */
  110.     long    tv_usec;    /* microseconds */
  111. };
  112.  
  113.  
  114. /*
  115.  * Structure used by kernel to pass protocol
  116.  * information in raw sockets.
  117.  */
  118. struct Sockets_sockproto {
  119.     unsigned short    sp_family;        /* address family */
  120.     unsigned short    sp_protocol;        /* protocol */
  121. };
  122.  
  123.  
  124. /*
  125.  * 4.3 compat sockaddr
  126.  */
  127. struct Sockets_sockaddr {
  128.     unsigned short    sa_family;        /* address family */
  129.     char    sa_data[14];        /* up to 14 bytes of direct address */
  130. };
  131.  
  132. /*
  133.  * 4.3-compat message header
  134.  */
  135. struct Sockets_msghdr {
  136.     char    *msg_name;        /* optional address */
  137. /* WIN16PORT CHG5 must be an int for psl */
  138. #ifdef _WIN16
  139.     int    msg_namelen;        /* size of address */
  140. #else
  141.     long    msg_namelen;        /* size of address */
  142. #endif
  143.     struct    Sockets_iovec *msg_iov;        /* scatter/gather array */
  144.     long    msg_iovlen;        /* # elements in msg_iov */
  145.     char    *msg_accrights;        /* access rights sent/received */
  146.     long    msg_accrightslen;
  147. };
  148.  
  149. /*
  150.  * Internet address (a structure for historical reasons)
  151.  */
  152. struct Sockets_in_addr {
  153.     unsigned long s_addr;
  154. };
  155.  
  156.  
  157. /*
  158.  * Socket address, internet style.
  159.  */
  160. struct Sockets_sockaddr_in {
  161.     unsigned short    sin_family;
  162.     unsigned short    sin_port;
  163.     struct    Sockets_in_addr sin_addr;
  164.     char    sin_zero[8];
  165. };
  166.  
  167. /*
  168.  * Structure used to describe IP options.
  169.  * Used to store options internally, to pass them to a process,
  170.  * or to restore options retrieved earlier.
  171.  * The ip_dst is used for the first-hop gateway when using a source route
  172.  * (this gets put into the header proper).
  173.  */
  174. struct Sockets_ip_opts {
  175.     struct    Sockets_in_addr ip_dst;        /* first hop, 0 w/o src rt */
  176.     char    ip_opts[40];        /* actually variable in size */
  177. };
  178.  
  179. /*
  180.  * Structure used for manipulating linger option.
  181.  */
  182. struct    Sockets_linger {
  183.     long    l_onoff;        /* option on/off */
  184.     long    l_linger;        /* linger time */
  185. };
  186.  
  187.  
  188. /*
  189.  * Definitions from netdb.h
  190.  */
  191.  
  192. /*
  193.  * Structures returned by network
  194.  * data base library.  All addresses
  195.  * are supplied in host order, and
  196.  * returned in network order (suitable
  197.  * for use in system calls).
  198.  */
  199. struct    Sockets_hostent {
  200.     char    *h_name;    /* official name of host */
  201.     char    **h_aliases;    /* alias list */
  202. /* WIN16PORT CHG7 */
  203. #ifdef _WIN16
  204.     int    h_addrtype;    /* host address type */
  205.     int     h_length;    /* length of address */
  206. #else
  207.     long    h_addrtype;    /* host address type */
  208.     long    h_length;    /* length of address */
  209. #endif
  210.     char    **h_addr_list;    /* list of addresses from name server */
  211. #define    h_addr    h_addr_list[0]    /* address, for backward compatiblity */
  212. };
  213.  
  214. /*
  215.  * Assumption here is that a network number
  216.  * fits in 32 bits -- probably a poor one.
  217.  */
  218. struct    Sockets_netent {
  219.     char        *n_name;    /* official name of net */
  220.     char        **n_aliases;    /* alias list */
  221.     long        n_addrtype;    /* net address type */
  222.     unsigned long    n_net;        /* network # */
  223. };
  224.  
  225. struct    Sockets_servent {
  226.     char    *s_name;    /* official service name */
  227.     char    **s_aliases;    /* alias list */
  228.     long    s_port;        /* port # */
  229.     char    *s_proto;    /* protocol to use */
  230. };
  231.  
  232. struct    Sockets_protoent {
  233.     char    *p_name;    /* official protocol name */
  234.     char    **p_aliases;    /* alias list */
  235.     long    p_proto;    /* protocol # */
  236. };
  237.  
  238. typedef    struct Sockets_fd_set {
  239.     unsigned long    fds_bits[64];
  240. } Sockets_fd_set;
  241.  
  242.  
  243. /*
  244.  * Definitions from sys/ioctl.h
  245.  */
  246. /* WIN16PORT CHG1 */
  247. #if (defined(_OS2) || !defined(_H_IOCTL) || defined(_WIN16))
  248.  
  249. #ifndef _IO
  250. /*
  251.  * Ioctl's have the command encoded in the lower word,
  252.  * and the size of any in or out parameters in the upper
  253.  * word.  The high 2 bits of the upper word are used
  254.  * to encode the in/out status of the parameter; for now
  255.  * we restrict parameters to at most 128 bytes.
  256.  */
  257. #define    IOCPARM_MASK    0x7f        /* parameters must be < 128 bytes */
  258. #define    IOC_VOID    0x20000000    /* no parameters */
  259. #define    IOC_OUT        0x40000000    /* copy out parameters */
  260. #define    IOC_IN        0x80000000    /* copy in parameters */
  261. #define    IOC_INOUT    (IOC_IN|IOC_OUT)
  262. /* the 0x20000000 is so we can distinguish new ioctl's from old */
  263. #define    _IO(x,y)    (IOC_VOID|(x<<8)|y)
  264. #define    _IOR(x,y,t)    (IOC_OUT|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)
  265. #define    _IOW(x,y,t)    (IOC_IN|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)
  266. /* this should be _IORW, but stdio got there first */
  267. #define    _IOWR(x,y,t)    (IOC_INOUT|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)
  268. #endif /* _IO */
  269.  
  270. /* another local */
  271.  
  272. #define    FIONREAD    _IOR('f', 127, int)    /* get # bytes to read */
  273. #define    FIONBIO        _IOW('f', 126, int)    /* set/clear non-blocking i/o */
  274. #define    FIOASYNC    _IOW('f', 125, int)    /* set/clear async i/o */
  275.  
  276. #define    FIOSETOWN    _IOW('f', 124, int)    /* set owner */
  277. #define    FIOGETOWN    _IOR('f', 123, int)    /* get owner */
  278.  
  279. /* socket i/o controls */
  280. #define    SIOCSHIWAT    _IOW('s',  0, int)        /* set high watermark */
  281. #define    SIOCGHIWAT    _IOR('s',  1, int)        /* get high watermark */
  282. #define    SIOCSLOWAT    _IOW('s',  2, int)        /* set low watermark */
  283. #define    SIOCGLOWAT    _IOR('s',  3, int)        /* get low watermark */
  284. #define    SIOCATMARK    _IOR('s',  7, int)        /* at oob mark? */
  285. #define    SIOCSPGRP    _IOW('s',  8, int)        /* set process group */
  286. #define    SIOCGPGRP    _IOR('s',  9, int)        /* get process group */
  287.  
  288. #define    SIOCADDRT    _IOW('r', 10, struct ortentry)    /* add route */
  289. #define    SIOCDELRT    _IOW('r', 11, struct ortentry)    /* delete route */
  290.  
  291. #define    SIOCSIFADDR    _IOW('i', 12, struct oifreq)    /* set ifnet address */
  292. #define    OSIOCGIFADDR    _IOWR('i',13, struct oifreq)    /* get ifnet address */
  293. #define    SIOCGIFADDR    _IOWR('i',33, struct oifreq)    /* get ifnet address */
  294. #define    SIOCSIFDSTADDR    _IOW('i', 14, struct oifreq)    /* set p-p address */
  295. #define    OSIOCGIFDSTADDR    _IOWR('i',15, struct oifreq)    /* get p-p address */
  296. #define    SIOCGIFDSTADDR    _IOWR('i',34, struct oifreq)    /* get p-p address */
  297. #define    SIOCSIFFLAGS    _IOW('i', 16, struct oifreq)    /* set ifnet flags */
  298. #define    SIOCGIFFLAGS    _IOWR('i',17, struct oifreq)    /* get ifnet flags */
  299. #define    OSIOCGIFBRDADDR    _IOWR('i',18, struct oifreq)    /* get broadcast addr */
  300. #define    SIOCGIFBRDADDR    _IOWR('i',35, struct oifreq)    /* get broadcast addr */
  301. #define    SIOCSIFBRDADDR    _IOW('i',19, struct oifreq)    /* set broadcast addr */
  302. #define    OSIOCGIFCONF    _IOWR('i',20, struct ifconf)    /* get ifnet list */
  303. #define    SIOCGIFCONF    _IOWR('i',36, struct ifconf)    /* get ifnet list */
  304. #define    OSIOCGIFNETMASK    _IOWR('i',21, struct oifreq)    /* get net addr mask */
  305. #define    SIOCGIFNETMASK    _IOWR('i',37, struct oifreq)    /* get net addr mask */
  306. #define    SIOCSIFNETMASK    _IOW('i',22, struct oifreq)    /* set net addr mask */
  307. #define    SIOCGIFMETRIC    _IOWR('i',23, struct oifreq)    /* get IF metric */
  308. #define    SIOCSIFMETRIC    _IOW('i',24, struct oifreq)    /* set IF metric */
  309. #define    SIOCDIFADDR    _IOW('i',25, struct oifreq)    /* delete IF addr */
  310. #define    SIOCAIFADDR    _IOW('i',26, struct ifaliasreq)    /* add/chg IF alias */
  311. #define    SIOCSIFSUBCHAN    _IOW('i',27, struct oifreq)    /* set subchannel adr.*/
  312. #define    SIOCSIFNETDUMP    _IOW('i',28, struct oifreq)    /* set netdump fastwrt*/
  313.  
  314. #define    SIOCSARP    _IOW('i', 30, struct arpreq)    /* set arp entry */
  315. #define    OSIOCGARP    _IOWR('i',31, struct arpreq)    /* get arp entry */
  316. #define    SIOCGARP    _IOWR('i',38, struct arpreq)    /* get arp entry */
  317. #define    SIOCDARP    _IOW('i', 32, struct arpreq)    /* delete arp entry */
  318.  
  319. #define    SIOCADDNETID    _IOW('i',87, struct oifreq)    /* set netids */
  320. #define    SIOCSIFMTU    _IOW('i',88, struct oifreq)    /* set mtu */
  321. #define    SIOCGIFMTU    _IOWR('i',86, struct oifreq)    /* get mtu */
  322. #define    SIOCSIFREMMTU    _IOW('i',89, struct oifreq)    /* set remmtu */
  323.  
  324. #define SIOCSNETOPT     _IOW('i', 90, struct optreq) /* set network option */
  325. #define SIOCGNETOPT     _IOWR('i', 91, struct optreq) /* get network option */
  326. #define SIOCDNETOPT     _IOWR('i', 92, struct optreq) /* set default */
  327.  
  328. #define    SIOCSX25XLATE    _IOW('i', 99, struct oifreq)    /* set xlate tab */
  329. #define    SIOCGX25XLATE    _IOWR('i',100, struct oifreq)    /* get xlate tab */
  330. #define    SIOCDX25XLATE    _IOW('i', 101, struct oifreq)    /* delete xlate tab */
  331.  
  332. #endif /* _H_IOCTL */
  333.  
  334.  
  335. /*
  336.  * Definitions from sys/select.h
  337.  */
  338.  
  339. /* WIN16PORT CHG1 */
  340. #if (defined(_OS2) || !defined(_H_SELECT) || defined(_WIN16)) 
  341.  
  342. #ifndef NBBY
  343. #define NBBY    8
  344. #endif
  345.  
  346. /*
  347.  * Timeout values.
  348.  */
  349. #ifndef NO_TIMEOUT
  350. #define    NO_TIMEOUT    0    /* don't wait for a response        */
  351. #endif
  352.  
  353. #ifndef INF_TIMEOUT
  354. #define    INF_TIMEOUT    -1    /* wait until a response is received    */
  355. #endif
  356.  
  357. /*
  358.  * Number of file descriptors (bits).
  359.  * Apply to nfdsmsgs parameter of SELECT system
  360.  * call &/or return value from SELECT.
  361.  */
  362. #ifndef NFDS
  363. #define NFDS(x)        ((x) & 0x0000FFFF)
  364. #endif /* NFDS */
  365.  
  366. /*
  367.  * Lower half of word.
  368.  * Used in hashing algorithm for devsel_hash chain.
  369.  */
  370. #ifndef LOW_HALF
  371. #define    LOW_HALF(x)    NFDS(x)
  372. #endif /* LOW_HALF */
  373.  
  374. /*
  375.  * Number of message queues.
  376.  * Apply to nfdsmsgs parameter of SELECT system
  377.  * call &/or return value from SELECT.
  378.  */
  379. #ifndef NMSGS
  380. #define NMSGS(x)    (((x) >> 16) & 0x0000FFFF)
  381. #endif /* NMSGS */
  382.  
  383. /*
  384.  * Upper half of word.
  385.  * Used in hashing algorithm for devsel_hash chain.
  386.  */
  387. #ifndef HIGH_HALF
  388. #define    HIGH_HALF(x)    NMSGS(x)
  389. #endif /* HIGH_HALF */
  390.  
  391. /*
  392.  * Macro used to define a sellist structure
  393.  * for the SELECT system call.
  394.  */
  395. #ifndef SELLIST
  396. #define    SELLIST(F,M)        \
  397. struct                \
  398. {                \
  399.     unsigned int   fdsmask[F];    \
  400.     int   msgids[M];    \
  401. }
  402. #endif /* SELLIST */
  403.  
  404. /*
  405.  * Select uses bit masks of file descriptors.
  406.  * These macros manipulate such bit fields.
  407.  * FD_SETSIZE may be defined by the user to the maximum valued file
  408.  * descriptor to be selected; the default here should be >= OPEN_MAX
  409.  */
  410. #ifndef    FD_SETSIZE
  411. #define    FD_SETSIZE    2048
  412. #endif
  413.  
  414. #ifndef NFDBITS
  415. #define NFDBITS    (sizeof(unsigned long) * NBBY)    /* bits per mask */
  416. #endif 
  417.  
  418. #ifndef howmany
  419. #define    howmany(x, y)    (((x)+((y)-1))/(y))
  420. #endif
  421.  
  422. #ifdef NEVER
  423. typedef    struct Sockets_fd_set {
  424.     unsigned long    fds_bits[howmany(FD_SETSIZE, NFDBITS)];
  425. } Sockets_fd_set;
  426. #endif
  427.  
  428.  
  429. #ifndef FD_SET
  430. /* WIN16MERGE ADD3 Specify long for bitwise operation */
  431. #define    FD_SET(n, p)    ((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS)))
  432. #endif
  433.  
  434. #ifndef FD_CLR
  435. /* WIN16MERGE ADD3 Specify long for bitwise operation */
  436. #define    FD_CLR(n, p)    ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS)))
  437. #endif
  438.  
  439. #ifndef FD_ISSET
  440. /* WIN16MERGE ADD3 Specify long for bitwise operation */
  441. #define    FD_ISSET(n, p)    ((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS)))
  442. #endif
  443.  
  444. #ifndef FD_ZERO
  445. #define FD_ZERO(p)    bzero((char *)(p), sizeof(*(p)))
  446. #endif
  447.  
  448. #endif /* _H_SELECT */
  449.  
  450.  
  451. /*
  452.  * Definitions from netinet/in.h
  453.  */
  454.  
  455. /* WIN16PORT CHG1 */
  456. #if (defined(_OS2) || !defined(_H_IN) || defined(_WIN16)) 
  457. /*
  458.  * Protocols
  459.  */
  460. #define    IPPROTO_IP        0        /* dummy for IP */
  461. #define    IPPROTO_ICMP        1        /* control message protocol */
  462. #define    IPPROTO_GGP        3        /* gateway^2 (deprecated) */
  463. #define    IPPROTO_TCP        6        /* tcp */
  464. #define    IPPROTO_EGP        8        /* exterior gateway protocol */
  465. #define    IPPROTO_PUP        12        /* pup */
  466. #define    IPPROTO_UDP        17        /* user datagram protocol */
  467. #define    IPPROTO_IDP        22        /* xns idp */
  468. #define    IPPROTO_TP        29         /* tp-4 w/ class negotiation */
  469. #define    IPPROTO_EON        80        /* ISO cnlp */
  470.  
  471. #define    IPPROTO_RAW        255        /* raw IP packet */
  472. #define    IPPROTO_MAX        256
  473.  
  474.  
  475. /*
  476.  * Local port number conventions:
  477.  * Ports < IPPORT_RESERVED are reserved for
  478.  * privileged processes (e.g. root).
  479.  * Ports > IPPORT_USERRESERVED are reserved
  480.  * for servers, not necessarily privileged.
  481.  */
  482. #define    IPPORT_RESERVED        1024
  483. #define    IPPORT_USERRESERVED    5000
  484. #define    IPPORT_TIMESERVER    37
  485.  
  486.  
  487.  
  488. /*
  489.  * Definitions of bits in internet address integers.
  490.  * On subnets, the decomposition of addresses to host and net parts
  491.  * is done according to subnet mask, not the masks here.
  492.  */
  493. #define    IN_CLASSA(i)        (((long)(i) & 0x80000000) == 0)
  494. #define    IN_CLASSA_NET        0xff000000
  495. #define    IN_CLASSA_NSHIFT    24
  496. #define    IN_CLASSA_HOST        0x00ffffff
  497. #define    IN_CLASSA_MAX        128
  498.  
  499. #define    IN_CLASSB(i)        (((long)(i) & 0xc0000000) == 0x80000000)
  500. #define    IN_CLASSB_NET        0xffff0000
  501. #define    IN_CLASSB_NSHIFT    16
  502. #define    IN_CLASSB_HOST        0x0000ffff
  503. #define    IN_CLASSB_MAX        65536
  504.  
  505. #define    IN_CLASSC(i)        (((long)(i) & 0xe0000000) == 0xc0000000)
  506. #define    IN_CLASSC_NET        0xffffff00
  507. #define    IN_CLASSC_NSHIFT    8
  508. #define    IN_CLASSC_HOST        0x000000ff
  509.  
  510. #define    IN_CLASSD(i)        (((long)(i) & 0xf0000000) == 0xe0000000)
  511. #define    IN_MULTICAST(i)        IN_CLASSD(i)
  512.  
  513. #define    IN_EXPERIMENTAL(i)    (((long)(i) & 0xe0000000) == 0xe0000000)
  514. #define    IN_BADCLASS(i)        (((long)(i) & 0xf0000000) == 0xf0000000)
  515.  
  516. #define    INADDR_ANY        (unsigned long)0x00000000
  517. #define INADDR_LOOPBACK        (unsigned long)0x7f000001    /* local loopback */
  518. #define    INADDR_BROADCAST    (unsigned long)0xffffffff    /* must be masked */
  519. #ifndef _KERNEL
  520. #define    INADDR_NONE        0xffffffff        /* -1 return */
  521. #endif
  522.  
  523. #define    IN_LOOPBACKNET        127            /* official! */
  524.  
  525.  
  526. /*
  527.  * Options for use with [gs]etsockopt at the IP level.
  528.  * First word of comment is data type; bool is stored in int.
  529.  */
  530. #define    IP_OPTIONS    1    /* buf/ip_opts; set/get IP per-packet options */
  531. #define    IP_HDRINCL    2    /* int; header is included with data (raw) */
  532. #define    IP_TOS        3    /* int; IP type of service and precedence */
  533. #define    IP_TTL        4    /* int; IP time to live */
  534. #define    IP_RECVOPTS    5    /* bool; receive all IP options w/datagram */
  535. #define    IP_RECVRETOPTS    6    /* bool; receive IP options for response */
  536. #define    IP_RECVDSTADDR    7    /* bool; receive IP dst addr w/datagram */
  537. #define    IP_RETOPTS    8    /* ip_opts; set/get IP per-packet options */
  538.  
  539. #endif /* _H_IN */
  540.  
  541.  
  542. /*
  543.  * Definitions from sys/socket.h
  544.  */
  545.  
  546. /* WIN16PORT CHG1 */
  547. #if (defined(_OS2) || !defined(_H_SOCKET) || defined(_WIN16)) 
  548.  
  549. /*
  550.  * Types
  551.  */
  552. #define    SOCK_STREAM    1        /* stream socket */
  553. #define    SOCK_DGRAM    2        /* datagram socket */
  554. #define    SOCK_RAW    3        /* raw-protocol interface */
  555. #define    SOCK_RDM    4        /* reliably-delivered message */
  556. #define    SOCK_SEQPACKET    5        /* sequenced packet stream */
  557.  
  558. /*
  559.  * Option flags per-socket.
  560.  */
  561. #define    SO_DEBUG    0x0001        /* turn on debugging info recording */
  562. #define    SO_ACCEPTCONN    0x0002        /* socket has had listen() */
  563. #define    SO_REUSEADDR    0x0004        /* allow local address reuse */
  564. #define    SO_KEEPALIVE    0x0008        /* keep connections alive */
  565. #define    SO_DONTROUTE    0x0010        /* just use interface addresses */
  566. #define    SO_BROADCAST    0x0020        /* permit sending of broadcast msgs */
  567. #define    SO_USELOOPBACK    0x0040        /* bypass hardware when possible */
  568. #define    SO_LINGER    0x0080        /* linger on close if data present */
  569. #define    SO_OOBINLINE    0x0100        /* leave received OOB data in line */
  570.  
  571. /*
  572.  * Additional options, not kept in so_options.
  573.  */
  574. #define SO_SNDBUF    0x1001        /* send buffer size */
  575. #define SO_RCVBUF    0x1002        /* receive buffer size */
  576. #define SO_SNDLOWAT    0x1003        /* send low-water mark */
  577. #define SO_RCVLOWAT    0x1004        /* receive low-water mark */
  578. #define SO_SNDTIMEO    0x1005        /* send timeout */
  579. #define SO_RCVTIMEO    0x1006        /* receive timeout */
  580. #define    SO_ERROR    0x1007        /* get error status and clear */
  581. #define    SO_TYPE        0x1008        /* get socket type */
  582.  
  583.  
  584.  
  585. /*
  586.  * Level number for (get/set)sockopt() to apply to socket itself.
  587.  */
  588. #define    SOL_SOCKET    0xffff        /* options for socket level */
  589.  
  590. /*
  591.  * Address families.
  592.  */
  593. #define    AF_UNSPEC    0        /* unspecified */
  594. #define    AF_UNIX        1        /* local to host (pipes, portals) */
  595. #define    AF_INET        2        /* internetwork: UDP, TCP, etc. */
  596. #define    AF_IMPLINK    3        /* arpanet imp addresses */
  597. #define    AF_PUP        4        /* pup protocols: e.g. BSP */
  598. #define    AF_CHAOS    5        /* mit CHAOS protocols */
  599. #define    AF_NS        6        /* XEROX NS protocols */
  600. #define    AF_ISO        7        /* ISO protocols */
  601. #define    AF_OSI        AF_ISO
  602. #define    AF_ECMA        8        /* european computer manufacturers */
  603. #define    AF_DATAKIT    9        /* datakit protocols */
  604. #define    AF_CCITT    10        /* CCITT protocols, X.25 etc */
  605. #define    AF_SNA        11        /* IBM SNA */
  606. #define AF_DECnet    12        /* DECnet */
  607. #define AF_DLI        13        /* DEC Direct data link interface */
  608. #define AF_LAT        14        /* LAT */
  609. #define    AF_HYLINK    15        /* NSC Hyperchannel */
  610. #define    AF_APPLETALK    16        /* Apple Talk */
  611. #define    AF_ROUTE    17        /* Internal Routing Protocol */
  612. #define    AF_LINK        18        /* Link layer interface */
  613. #define    pseudo_AF_XTP    19        /* eXpress Transfer Protocol (no AF) */
  614. #define AF_INTF        20        /* Debugging use only */
  615. #define AF_RIF        21        /* raw interface */
  616. #define PF_INTF         AF_INTF        /* Used by sysx/intf */
  617.  
  618. #define    AF_NETWARE    22
  619. #define    AF_MAX        30
  620.  
  621.  
  622. /*
  623.  * Protocol families, same as address families for now.
  624.  */
  625. #define    PF_UNSPEC    AF_UNSPEC
  626. #define    PF_UNIX        AF_UNIX
  627. #define    PF_INET        AF_INET
  628. #define    PF_IMPLINK    AF_IMPLINK
  629. #define    PF_PUP        AF_PUP
  630. #define    PF_CHAOS    AF_CHAOS
  631. #define    PF_NS        AF_NS
  632. #define    PF_ISO        AF_ISO
  633. #define    PF_OSI        AF_ISO
  634. #define    PF_ECMA        AF_ECMA
  635. #define    PF_DATAKIT    AF_DATAKIT
  636. #define    PF_CCITT    AF_CCITT
  637. #define    PF_SNA        AF_SNA
  638. #define PF_DECnet    AF_DECnet
  639. #define PF_DLI        AF_DLI
  640. #define PF_LAT        AF_LAT
  641. #define    PF_HYLINK    AF_HYLINK
  642. #define    PF_APPLETALK    AF_APPLETALK
  643. #define    PF_ROUTE    AF_ROUTE
  644. #define    PF_LINK        AF_LINK
  645. #define    PF_XTP        pseudo_AF_XTP    /* really just proto family, no AF */
  646. #define PF_INTF        AF_INTF
  647. #define PF_RIF        AF_RIF
  648.  
  649. #define    PF_MAX        AF_MAX
  650.  
  651. /*
  652.  * Maximum queue length specifiable by listen.
  653.  */
  654. #define    SOMAXCONN    10
  655.  
  656. #define    MSG_OOB        0x1        /* process out-of-band data */
  657. #define    MSG_PEEK    0x2        /* peek at incoming message */
  658. #define    MSG_DONTROUTE    0x4        /* send without using routing tables */
  659. #define    MSG_EOR        0x8        /* data completes record */
  660. #define    MSG_TRUNC    0x10        /* data discarded before delivery */
  661. #define    MSG_CTRUNC    0x20        /* control data lost before delivery */
  662. #define    MSG_WAITALL    0x40        /* wait for full request or error */
  663.  
  664. #define MSG_MAXIOVLEN   16              /* may not need this */
  665.  
  666. #endif /* _H_SOCKET */
  667.  
  668.  
  669. /* Sockets typedefs */
  670. typedef struct Sockets_sockaddr Sockets_sockaddr;
  671. typedef struct Sockets_sockaddr_in Sockets_sockaddr_in;
  672. typedef struct Sockets_in_addr  Sockets_in_addr;
  673. typedef struct Sockets_iovec    Sockets_iovec;
  674. typedef struct Sockets_msghdr   Sockets_msghdr;
  675. typedef struct Sockets_timeval  Sockets_timeval;
  676. typedef struct Sockets_hostent  Sockets_hostent;
  677. typedef struct Sockets_servent  Sockets_servent;
  678.  
  679. #define SOM_DONT_USE_SHORT_NAMES
  680.  
  681. #define sockaddr Sockets_sockaddr
  682. #define sockaddr_in Sockets_sockaddr_in
  683. #define in_addr  Sockets_in_addr
  684. #define iovec    Sockets_iovec
  685. #define msghdr   Sockets_msghdr
  686. #define timeval  Sockets_timeval
  687. #define hostent  Sockets_hostent
  688. #define servent  Sockets_servent
  689. #define fd_set   Sockets_fd_set
  690.  
  691. #ifdef __cplusplus
  692.  #include <somssock.xh>
  693. #else
  694.  #include <somssock.h>
  695. #endif
  696.  
  697. #undef SOM_DONT_USE_SHORT_NAMES
  698.  
  699. #endif /* _soms_h */
  700.