home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / oslib / oslib_1 / OSLib / Computer / h / socket < prev   
Encoding:
Text File  |  1995-08-22  |  33.2 KB  |  1,043 lines

  1. #ifndef socket_H
  2. #define socket_H
  3.  
  4. /* C header file for Socket
  5.  * written by DefMod (Jul 24 1995) on Tue Aug 22 14:42:20 1995
  6.  * Jonathan Coxhead, Acorn Computers Ltd
  7.  */
  8.  
  9. #ifndef types_H
  10. #include "types.h"
  11. #endif
  12.  
  13. #ifndef os_H
  14. #include "os.h"
  15. #endif
  16.  
  17. /**********************************
  18.  * SWI names and SWI reason codes *
  19.  **********************************/
  20. #undef  Socket_Creat
  21. #define Socket_Creat                            0x41200
  22. #undef  XSocket_Creat
  23. #define XSocket_Creat                           0x61200
  24. #undef  Socket_Bind
  25. #define Socket_Bind                             0x41201
  26. #undef  XSocket_Bind
  27. #define XSocket_Bind                            0x61201
  28. #undef  Socket_Listen
  29. #define Socket_Listen                           0x41202
  30. #undef  XSocket_Listen
  31. #define XSocket_Listen                          0x61202
  32. #undef  Socket_Accept
  33. #define Socket_Accept                           0x41203
  34. #undef  XSocket_Accept
  35. #define XSocket_Accept                          0x61203
  36. #undef  Socket_Connect
  37. #define Socket_Connect                          0x41204
  38. #undef  XSocket_Connect
  39. #define XSocket_Connect                         0x61204
  40. #undef  Socket_Recv
  41. #define Socket_Recv                             0x41205
  42. #undef  XSocket_Recv
  43. #define XSocket_Recv                            0x61205
  44. #undef  Socket_Recvfrom
  45. #define Socket_Recvfrom                         0x41206
  46. #undef  XSocket_Recvfrom
  47. #define XSocket_Recvfrom                        0x61206
  48. #undef  Socket_Recvmsg
  49. #define Socket_Recvmsg                          0x41207
  50. #undef  XSocket_Recvmsg
  51. #define XSocket_Recvmsg                         0x61207
  52. #undef  Socket_Send
  53. #define Socket_Send                             0x41208
  54. #undef  XSocket_Send
  55. #define XSocket_Send                            0x61208
  56. #undef  Socket_Sendto
  57. #define Socket_Sendto                           0x41209
  58. #undef  XSocket_Sendto
  59. #define XSocket_Sendto                          0x61209
  60. #undef  Socket_Sendmsg
  61. #define Socket_Sendmsg                          0x4120A
  62. #undef  XSocket_Sendmsg
  63. #define XSocket_Sendmsg                         0x6120A
  64. #undef  Socket_Shutdown
  65. #define Socket_Shutdown                         0x4120B
  66. #undef  XSocket_Shutdown
  67. #define XSocket_Shutdown                        0x6120B
  68. #undef  Socket_Setsockopt
  69. #define Socket_Setsockopt                       0x4120C
  70. #undef  XSocket_Setsockopt
  71. #define XSocket_Setsockopt                      0x6120C
  72. #undef  Socket_Getsockopt
  73. #define Socket_Getsockopt                       0x4120D
  74. #undef  XSocket_Getsockopt
  75. #define XSocket_Getsockopt                      0x6120D
  76. #undef  Socket_Getpeername
  77. #define Socket_Getpeername                      0x4120E
  78. #undef  XSocket_Getpeername
  79. #define XSocket_Getpeername                     0x6120E
  80. #undef  Socket_Getsockname
  81. #define Socket_Getsockname                      0x4120F
  82. #undef  XSocket_Getsockname
  83. #define XSocket_Getsockname                     0x6120F
  84. #undef  Socket_Close
  85. #define Socket_Close                            0x41210
  86. #undef  XSocket_Close
  87. #define XSocket_Close                           0x61210
  88. #undef  Socket_Select
  89. #define Socket_Select                           0x41211
  90. #undef  XSocket_Select
  91. #define XSocket_Select                          0x61211
  92. #undef  Socket_Ioctl
  93. #define Socket_Ioctl                            0x41212
  94. #undef  XSocket_Ioctl
  95. #define XSocket_Ioctl                           0x61212
  96. #undef  Socket_Read
  97. #define Socket_Read                             0x41213
  98. #undef  XSocket_Read
  99. #define XSocket_Read                            0x61213
  100. #undef  Socket_Write
  101. #define Socket_Write                            0x41214
  102. #undef  XSocket_Write
  103. #define XSocket_Write                           0x61214
  104. #undef  Socket_Stat
  105. #define Socket_Stat                             0x41215
  106. #undef  XSocket_Stat
  107. #define XSocket_Stat                            0x61215
  108. #undef  Socket_Readv
  109. #define Socket_Readv                            0x41216
  110. #undef  XSocket_Readv
  111. #define XSocket_Readv                           0x61216
  112. #undef  Socket_Writev
  113. #define Socket_Writev                           0x41217
  114. #undef  XSocket_Writev
  115. #define XSocket_Writev                          0x61217
  116. #undef  Socket_Gettsize
  117. #define Socket_Gettsize                         0x41218
  118. #undef  XSocket_Gettsize
  119. #define XSocket_Gettsize                        0x61218
  120. #undef  Event_Internet
  121. #define Event_Internet                          0x13
  122. #undef  EventInternet_Async
  123. #define EventInternet_Async                     0x1
  124. #undef  EventInternet_Urgent
  125. #define EventInternet_Urgent                    0x2
  126. #undef  EventInternet_Broken
  127. #define EventInternet_Broken                    0x3
  128. #undef  EventInternet_RARPReply
  129. #define EventInternet_RARPReply                 0x4
  130.  
  131. /************************************
  132.  * Structure and union declarations *
  133.  ************************************/
  134. typedef struct socket_sockaddr_in               socket_sockaddr_in;
  135. typedef union  socket_sockaddr                  socket_sockaddr;
  136. typedef struct socket_linger                    socket_linger;
  137. typedef struct socket_timeval                   socket_timeval;
  138. typedef struct socket_ifreq                     socket_ifreq;
  139. typedef struct socket_ifconf                    socket_ifconf;
  140. typedef struct socket_s_                        *socket_s;
  141. typedef struct socket_iovec                     socket_iovec;
  142. typedef struct socket_msghdr                    socket_msghdr;
  143.  
  144. /********************
  145.  * Type definitions *
  146.  ********************/
  147. typedef short socket_af;
  148.  
  149. typedef int socket_sock;
  150.  
  151. typedef int socket_ipproto;
  152.  
  153. typedef int socket_level;
  154.  
  155. struct socket_sockaddr_in
  156.    {  socket_af af;
  157.       short port;
  158.       bits addr;
  159.       byte data [8];
  160.    };
  161.  
  162. union socket_sockaddr
  163.    {  struct
  164.       {  socket_af af;
  165.          byte data [14];
  166.       }
  167.       sockaddr;
  168.       socket_sockaddr_in sockaddr_in;
  169.    };
  170.  
  171. struct socket_linger
  172.    {  int onoff;
  173.       int linger;
  174.    };
  175.  
  176. struct socket_timeval
  177.    {  int sec;
  178.       int usec;
  179.    };
  180.  
  181. typedef int socket_so;
  182.  
  183. typedef short socket_if_flags;
  184.  
  185. struct socket_ifreq
  186.    {  char name [16];
  187.       union
  188.       {  socket_sockaddr sockaddr;
  189.          socket_sockaddr broadaddr;
  190.          socket_if_flags flags;
  191.          int metric;
  192.          byte *data;
  193.          byte reserved [16];
  194.       }
  195.       u;
  196.    };
  197.  
  198. struct socket_ifconf
  199.    {  int len;
  200.       union
  201.       {  byte *buf;
  202.          socket_ifreq *req;
  203.       }
  204.       u;
  205.    };
  206.  
  207. typedef bits socket_ioctl_no;
  208.       /*Bits 0, ..., 7: operation; 8, ..., 15: s/i/f; 16, ..., 23: size; 24, ..., 31: calling convention*/
  209.  
  210. typedef bits socket_msg_flags;
  211.  
  212. struct socket_iovec
  213.    {  byte *base;
  214.       int len;
  215.    };
  216.  
  217. struct socket_msghdr
  218.    {  byte *name;
  219.       int namelen;
  220.       socket_iovec *iov;
  221.       int iov_count;
  222.       byte *accrights;
  223.       int accrightslen;
  224.    };
  225.  
  226. typedef int socket_shutdown_type;
  227.  
  228. typedef byte socket_fdset;
  229.  
  230. typedef int socket_event_type;
  231.  
  232. /************************
  233.  * Constant definitions *
  234.  ************************/
  235. #define socket_AF_INET                          ((socket_af) 0x2u)
  236. #define socket_SOCK_STREAM                      ((socket_sock) 0x1u)
  237.       /*T C P*/
  238. #define socket_SOCK_DGRAM                       ((socket_sock) 0x2u)
  239.       /*U D P*/
  240. #define socket_SOCK_RAW                         ((socket_sock) 0x3u)
  241.       /*I P*/
  242. #define socket_IPPROTO_IP                       ((socket_ipproto) 0x0u)
  243.       /*Dummy for internet protocol*/
  244. #define socket_IPPROTO_ICMP                     ((socket_ipproto) 0x1u)
  245.       /*Control message protocol*/
  246. #define socket_IPPROTO_TCP                      ((socket_ipproto) 0x6u)
  247.       /*Transmission control protocol*/
  248. #define socket_IPPROTO_UDP                      ((socket_ipproto) 0x11u)
  249.       /*User datagram protocol*/
  250. #define socket_IPPROTO_RAW                      ((socket_ipproto) 0xFFu)
  251.       /*Raw internet protocol packet*/
  252. #define socket_SOL_SOCKET                       ((socket_level) 0xFFFFu)
  253. #define socket_EBADF                            0x9u
  254.       /*Bad descriptor*/
  255. #define socket_EAGAIN                           0xBu
  256.       /*No more ports*/
  257. #define socket_EFAULT                           0xEu
  258.       /*Bad address*/
  259. #define socket_EINVAL                           0x16u
  260.       /*Invalid argument*/
  261. #define socket_EWOULDBLOCK                      0x23u
  262.       /*Operation would block*/
  263. #define socket_EINPROGRESS                      0x24u
  264.       /*Operation now in progress*/
  265. #define socket_EALREADY                         0x25u
  266.       /*Operation already in progress*/
  267. #define socket_ENOTSOCK                         0x26u
  268.       /*Socket operation on non-socket*/
  269. #define socket_EDESTADDRREQ                     0x27u
  270.       /*Destination address required*/
  271. #define socket_EMSGSIZE                         0x28u
  272.       /*Message too long*/
  273. #define socket_EPROTOTYPE                       0x29u
  274.       /*Protocol wrong type for socket*/
  275. #define socket_ENOPROTOOPT                      0x2Au
  276.       /*Protocol not available*/
  277. #define socket_EPROTONOSUPPORT                  0x2Bu
  278.       /*Protocol not supported*/
  279. #define socket_ESOCKTNOSUPPORT                  0x2Cu
  280.       /*Socket type not supported*/
  281. #define socket_EOPNOTSUPP                       0x2Du
  282.       /*Operation not supported on socket*/
  283. #define socket_EPFNOSUPPORT                     0x2Eu
  284.       /*Protocol family not supported*/
  285. #define socket_EAFNOSUPPORT                     0x2Fu
  286.       /*Address family not supported by protocol family*/
  287. #define socket_EADDRINUSE                       0x30u
  288.       /*Address already in use*/
  289. #define socket_EADDRNOTAVAIL                    0x31u
  290.       /*Can't assign requested address*/
  291. #define socket_ENETDOWN                         0x32u
  292.       /*Network is down*/
  293. #define socket_ENETUNREACH                      0x33u
  294.       /*Network is unreachable*/
  295. #define socket_ENETRESET                        0x34u
  296.       /*Network dropped connection on reset*/
  297. #define socket_ECONNABORTED                     0x35u
  298.       /*Software caused connection abort*/
  299. #define socket_ECONNRESET                       0x36u
  300.       /*Connection reset by peer*/
  301. #define socket_ENOBUFS                          0x37u
  302.       /*No buffer space available*/
  303. #define socket_EISCONN                          0x38u
  304.       /*Socket is already connected*/
  305. #define socket_ENOTCONN                         0x39u
  306.       /*Socket is not connected*/
  307. #define socket_ESHUTDOWN                        0x3Au
  308.       /*Can't send after socket shutdown*/
  309. #define socket_ETOOMANYREFS                     0x3Bu
  310.       /*Too many references: can't splice*/
  311. #define socket_ETIMEDOUT                        0x3Cu
  312.       /*Connection timed out*/
  313. #define socket_ECONNREFUSED                     0x3Du
  314.       /*Connection refused*/
  315. #define socket_EHOSTDOWN                        0x40u
  316.       /*Host is down*/
  317. #define socket_EHOSTUNREACH                     0x41u
  318.       /*No route to host*/
  319. #define socket_SO_ACCEPTCONN                    ((socket_so) 0x2u)
  320. #define socket_SO_REUSEADDR                     ((socket_so) 0x4u)
  321. #define socket_SO_KEEPALIVE                     ((socket_so) 0x8u)
  322. #define socket_SO_DONTROUTE                     ((socket_so) 0x10u)
  323. #define socket_SO_BROADCAST                     ((socket_so) 0x20u)
  324. #define socket_SO_USELOOPBACK                   ((socket_so) 0x40u)
  325. #define socket_SO_LINGER                        ((socket_so) 0x80u)
  326. #define socket_SO_OOBINLINE                     ((socket_so) 0x100u)
  327. #define socket_SO_SNDBUF                        ((socket_so) 0x1001u)
  328. #define socket_SO_RCVBUF                        ((socket_so) 0x1002u)
  329. #define socket_SO_SNDLOWAT                      ((socket_so) 0x1003u)
  330. #define socket_SO_RCVLOWAT                      ((socket_so) 0x1004u)
  331. #define socket_SO_SNDTIMEO                      ((socket_so) 0x1005u)
  332. #define socket_SO_RCVTIMEO                      ((socket_so) 0x1006u)
  333. #define socket_SO_ERROR                         ((socket_so) 0x1007u)
  334. #define socket_SO_TYPE                          ((socket_so) 0x1008u)
  335. #define socket_IF_NAME_LIMIT                    16
  336. #define socket_IF_UP                            ((socket_if_flags) 0x1u)
  337.       /*Interface is up*/
  338. #define socket_IF_BROADCAST                     ((socket_if_flags) 0x2u)
  339.       /*Broadcast address valid*/
  340. #define socket_IF_DEBUG                         ((socket_if_flags) 0x4u)
  341.       /*Turn on debugging*/
  342. #define socket_IF_LOOPBACK                      ((socket_if_flags) 0x8u)
  343.       /*Is a loopback net*/
  344. #define socket_IF_POINT_TO_POINT                ((socket_if_flags) 0x10u)
  345.       /*Interface is point-to-point link*/
  346. #define socket_IF_NO_TRAILERS                   ((socket_if_flags) 0x20u)
  347.       /*Avoid use of trailers*/
  348. #define socket_IF_RUNNING                       ((socket_if_flags) 0x40u)
  349.       /*Resources allocated*/
  350. #define socket_IF_NO_ARP                        ((socket_if_flags) 0x80u)
  351.       /*No address resolution protocol*/
  352. #define socket_SIOCSHIWAT                       ((socket_ioctl_no) 0x80047300u)
  353.       /*set high watermark (Int)*/
  354. #define socket_SIOCGHIWAT                       ((socket_ioctl_no) 0x40047301u)
  355.       /*get high watermark (Int)*/
  356. #define socket_SIOCSLOWAT                       ((socket_ioctl_no) 0x80047302u)
  357.       /*set low watermark (Int)*/
  358. #define socket_SIOCGLOWAT                       ((socket_ioctl_no) 0x40047303u)
  359.       /*get low watermark (Int)*/
  360. #define socket_SIOCATMARK                       ((socket_ioctl_no) 0x40047307u)
  361.       /*at oob mark? (Int)*/
  362. #define socket_SIOCSIFADDR                      ((socket_ioctl_no) 0x8020690Cu)
  363.       /*set ifnet address (Socket_Ifreq)*/
  364. #define socket_SIOCGIFADDR                      ((socket_ioctl_no) 0xC020690Du)
  365.       /*get ifnet address (Socket_Ifreq)*/
  366. #define socket_SIOCSIFDSTADDR                   ((socket_ioctl_no) 0x8020690Eu)
  367.       /*set p-p address (Socket_Ifreq)*/
  368. #define socket_SIOCGIFDSTADDR                   ((socket_ioctl_no) 0xC020690Fu)
  369.       /*get p-p address (Socket_Ifreq)*/
  370. #define socket_SIOCSIFFLAGS                     ((socket_ioctl_no) 0x80206910u)
  371.       /*set ifnet flags (Socket_Ifreq)*/
  372. #define socket_SIOCGIFFLAGS                     ((socket_ioctl_no) 0xC0206911u)
  373.       /*get ifnet flags (Socket_Ifreq)*/
  374. #define socket_SIOCGIFBRDADDR                   ((socket_ioctl_no) 0xC0206912u)
  375.       /*get broadcast addr (Socket_Ifreq)*/
  376. #define socket_SIOCSIFBRDADDR                   ((socket_ioctl_no) 0x80206913u)
  377.       /*set broadcast addr (Socket_Ifreq)*/
  378. #define socket_SIOCGIFCONF                      ((socket_ioctl_no) 0xC0086914u)
  379.       /*get ifnet list (Socket_Ifconf)*/
  380. #define socket_SIOCGIFNETMASK                   ((socket_ioctl_no) 0xC0206915u)
  381.       /*get net addr mask (Socket_Ifreq)*/
  382. #define socket_SIOCSIFNETMASK                   ((socket_ioctl_no) 0x80206916u)
  383.       /*set net addr mask (Socket_Ifreq)*/
  384. #define socket_SIOCGIFMETRIC                    ((socket_ioctl_no) 0xC0206917u)
  385.       /*get IF metric (Socket_Ifreq)*/
  386. #define socket_SIOCSIFMETRIC                    ((socket_ioctl_no) 0x80206918u)
  387.       /*set IF metric (Socket_Ifreq)*/
  388. #define socket_FIONREAD                         ((socket_ioctl_no) 0x4004667Fu)
  389.       /*get number of bytes to read (Int)*/
  390. #define socket_FIONBIO                          ((socket_ioctl_no) 0x8004667Eu)
  391.       /*set/clear non-blocking i/o (Int)*/
  392. #define socket_FIOASYNC                         ((socket_ioctl_no) 0x8004667Du)
  393.       /*set/clear async i/o (Int)*/
  394. #define socket_MSG_OOB                          ((socket_msg_flags) 0x1u)
  395. #define socket_MSG_PEEK                         ((socket_msg_flags) 0x2u)
  396. #define socket_MSG_DONTROUTE                    ((socket_msg_flags) 0x4u)
  397. #define socket_SHUTDOWN_RECV                    ((socket_shutdown_type) 0x0u)
  398. #define socket_SHUTDOWN_SEND                    ((socket_shutdown_type) 0x1u)
  399. #define socket_SHUTDOWN_ALL                     ((socket_shutdown_type) 0x2u)
  400. #define socket_ASYNC_EVENT                      ((socket_event_type) 0x1u)
  401. #define socket_URGENT_EVENT                     ((socket_event_type) 0x2u)
  402. #define socket_BROKEN_EVENT                     ((socket_event_type) 0x3u)
  403.  
  404. /*************************
  405.  * Function declarations *
  406.  *************************/
  407.  
  408. #ifdef __cplusplus
  409.    extern "C" {
  410. #endif
  411.  
  412. /* ------------------------------------------------------------------------
  413.  * Function:      socket_creat()
  414.  *
  415.  * Description:   Creates an endpoint for communication
  416.  *
  417.  * Input:         af - value of R0 on entry
  418.  *                sock - value of R1 on entry
  419.  *                proto - value of R2 on entry
  420.  *
  421.  * Output:        s - value of R0 on exit (X version only)
  422.  *
  423.  * Returns:       R0 (non-X version only)
  424.  *
  425.  * Other notes:   Calls SWI 0x41200.
  426.  */
  427.  
  428. extern os_error *xsocket_creat (socket_af af,
  429.       socket_sock sock,
  430.       socket_ipproto proto,
  431.       socket_s *s);
  432. __swi (0x41200) socket_s socket_creat (socket_af af,
  433.       socket_sock sock,
  434.       socket_ipproto proto);
  435.  
  436. /* ------------------------------------------------------------------------
  437.  * Function:      socket_bind()
  438.  *
  439.  * Description:   Binds a name to a socket
  440.  *
  441.  * Input:         s - value of R0 on entry
  442.  *                sockaddr - value of R1 on entry
  443.  *                namelen - value of R2 on entry
  444.  *
  445.  * Other notes:   Calls SWI 0x41201.
  446.  */
  447.  
  448. extern os_error *xsocket_bind (socket_s s,
  449.       socket_sockaddr const *sockaddr,
  450.       int namelen);
  451. __swi (0x41201) void socket_bind (socket_s s,
  452.       socket_sockaddr const *sockaddr,
  453.       int namelen);
  454.  
  455. /* ------------------------------------------------------------------------
  456.  * Function:      socket_listen()
  457.  *
  458.  * Description:   Listens for connections on a socket
  459.  *
  460.  * Input:         s - value of R0 on entry
  461.  *                backlog - value of R1 on entry
  462.  *
  463.  * Other notes:   Calls SWI 0x41202.
  464.  */
  465.  
  466. extern os_error *xsocket_listen (socket_s s,
  467.       int backlog);
  468. __swi (0x41202) void socket_listen (socket_s s,
  469.       int backlog);
  470.  
  471. /* ------------------------------------------------------------------------
  472.  * Function:      socket_accept()
  473.  *
  474.  * Description:   Accepts a connection on a socket
  475.  *
  476.  * Input:         s - value of R0 on entry
  477.  *                sockaddr - value of R1 on entry
  478.  *                addrlen - value of R2 on entry
  479.  *
  480.  * Output:        ns - value of R0 on exit (X version only)
  481.  *
  482.  * Returns:       R0 (non-X version only)
  483.  *
  484.  * Other notes:   Calls SWI 0x41203.
  485.  */
  486.  
  487. extern os_error *xsocket_accept (socket_s s,
  488.       socket_sockaddr *sockaddr,
  489.       int *addrlen,
  490.       socket_s *ns);
  491. __swi (0x41203) socket_s socket_accept (socket_s s,
  492.       socket_sockaddr *sockaddr,
  493.       int *addrlen);
  494.  
  495. /* ------------------------------------------------------------------------
  496.  * Function:      socket_connect()
  497.  *
  498.  * Description:   Initiates a connection on a socket
  499.  *
  500.  * Input:         s - value of R0 on entry
  501.  *                sockaddr - value of R1 on entry
  502.  *                namelen - value of R2 on entry
  503.  *
  504.  * Other notes:   Calls SWI 0x41204.
  505.  */
  506.  
  507. extern os_error *xsocket_connect (socket_s s,
  508.       socket_sockaddr *sockaddr,
  509.       int namelen);
  510. __swi (0x41204) void socket_connect (socket_s s,
  511.       socket_sockaddr *sockaddr,
  512.       int namelen);
  513.  
  514. /* ------------------------------------------------------------------------
  515.  * Function:      socket_recv()
  516.  *
  517.  * Description:   Receives data from a connected socket
  518.  *
  519.  * Input:         s - value of R0 on entry
  520.  *                buf - value of R1 on entry
  521.  *                len - value of R2 on entry
  522.  *                flags - value of R3 on entry
  523.  *
  524.  * Output:        cc - value of R0 on exit (X version only)
  525.  *
  526.  * Returns:       R0 (non-X version only)
  527.  *
  528.  * Other notes:   Calls SWI 0x41205.
  529.  */
  530.  
  531. extern os_error *xsocket_recv (socket_s s,
  532.       byte *buf,
  533.       int len,
  534.       socket_msg_flags flags,
  535.       int *cc);
  536. __swi (0x41205) int socket_recv (socket_s s,
  537.       byte *buf,
  538.       int len,
  539.       socket_msg_flags flags);
  540.  
  541. /* ------------------------------------------------------------------------
  542.  * Function:      socket_recvfrom()
  543.  *
  544.  * Description:   Receives data from a socket
  545.  *
  546.  * Input:         s - value of R0 on entry
  547.  *                buf - value of R1 on entry
  548.  *                len - value of R2 on entry
  549.  *                flags - value of R3 on entry
  550.  *                from - value of R4 on entry
  551.  *                fromlen - value of R5 on entry
  552.  *
  553.  * Output:        cc - value of R0 on exit (X version only)
  554.  *
  555.  * Returns:       R0 (non-X version only)
  556.  *
  557.  * Other notes:   Calls SWI 0x41206.
  558.  */
  559.  
  560. extern os_error *xsocket_recvfrom (socket_s s,
  561.       byte *buf,
  562.       int len,
  563.       socket_msg_flags flags,
  564.       socket_sockaddr *from,
  565.       int *fromlen,
  566.       int *cc);
  567. extern int socket_recvfrom (socket_s s,
  568.       byte *buf,
  569.       int len,
  570.       socket_msg_flags flags,
  571.       socket_sockaddr *from,
  572.       int *fromlen);
  573.  
  574. /* ------------------------------------------------------------------------
  575.  * Function:      socket_recvmsg()
  576.  *
  577.  * Description:   Receives a message from a socket
  578.  *
  579.  * Input:         s - value of R0 on entry
  580.  *                msg - value of R1 on entry
  581.  *                flags - value of R2 on entry
  582.  *
  583.  * Output:        cc - value of R0 on exit (X version only)
  584.  *
  585.  * Returns:       R0 (non-X version only)
  586.  *
  587.  * Other notes:   Calls SWI 0x41207.
  588.  */
  589.  
  590. extern os_error *xsocket_recvmsg (socket_s s,
  591.       socket_msghdr *msg,
  592.       socket_msg_flags flags,
  593.       int *cc);
  594. __swi (0x41207) int socket_recvmsg (socket_s s,
  595.       socket_msghdr *msg,
  596.       socket_msg_flags flags);
  597.  
  598. /* ------------------------------------------------------------------------
  599.  * Function:      socket_send()
  600.  *
  601.  * Description:   Sends data from a connected socket
  602.  *
  603.  * Input:         s - value of R0 on entry
  604.  *                msg - value of R1 on entry
  605.  *                len - value of R2 on entry
  606.  *                flags - value of R3 on entry
  607.  *
  608.  * Output:        cc - value of R0 on exit (X version only)
  609.  *
  610.  * Returns:       R0 (non-X version only)
  611.  *
  612.  * Other notes:   Calls SWI 0x41208.
  613.  */
  614.  
  615. extern os_error *xsocket_send (socket_s s,
  616.       byte const *msg,
  617.       int len,
  618.       socket_msg_flags flags,
  619.       int *cc);
  620. __swi (0x41208) int socket_send (socket_s s,
  621.       byte const *msg,
  622.       int len,
  623.       socket_msg_flags flags);
  624.  
  625. /* ------------------------------------------------------------------------
  626.  * Function:      socket_sendto()
  627.  *
  628.  * Description:   Sends data from a socket
  629.  *
  630.  * Input:         s - value of R0 on entry
  631.  *                msg - value of R1 on entry
  632.  *                len - value of R2 on entry
  633.  *                flags - value of R3 on entry
  634.  *                to - value of R4 on entry
  635.  *                tolen - value of R5 on entry
  636.  *
  637.  * Output:        cc - value of R0 on exit (X version only)
  638.  *
  639.  * Returns:       R0 (non-X version only)
  640.  *
  641.  * Other notes:   Calls SWI 0x41209.
  642.  */
  643.  
  644. extern os_error *xsocket_sendto (socket_s s,
  645.       byte const *msg,
  646.       int len,
  647.       socket_msg_flags flags,
  648.       socket_sockaddr const *to,
  649.       int tolen,
  650.       int *cc);
  651. extern int socket_sendto (socket_s s,
  652.       byte const *msg,
  653.       int len,
  654.       socket_msg_flags flags,
  655.       socket_sockaddr const *to,
  656.       int tolen);
  657.  
  658. /* ------------------------------------------------------------------------
  659.  * Function:      socket_sendmsg()
  660.  *
  661.  * Description:   Sends a message from a socket
  662.  *
  663.  * Input:         s - value of R0 on entry
  664.  *                msg - value of R1 on entry
  665.  *                flags - value of R2 on entry
  666.  *
  667.  * Output:        cc - value of R0 on exit (X version only)
  668.  *
  669.  * Returns:       R0 (non-X version only)
  670.  *
  671.  * Other notes:   Calls SWI 0x4120A.
  672.  */
  673.  
  674. extern os_error *xsocket_sendmsg (socket_s s,
  675.       socket_msghdr const *msg,
  676.       socket_msg_flags flags,
  677.       int *cc);
  678. __swi (0x4120A) int socket_sendmsg (socket_s s,
  679.       socket_msghdr const *msg,
  680.       socket_msg_flags flags);
  681.  
  682. /* ------------------------------------------------------------------------
  683.  * Function:      socket_shutdown()
  684.  *
  685.  * Description:   Shuts down part of a full-duplex connection
  686.  *
  687.  * Input:         s - value of R0 on entry
  688.  *                type - value of R1 on entry
  689.  *
  690.  * Other notes:   Calls SWI 0x4120B.
  691.  */
  692.  
  693. extern os_error *xsocket_shutdown (socket_s s,
  694.       socket_shutdown_type type);
  695. __swi (0x4120B) void socket_shutdown (socket_s s,
  696.       socket_shutdown_type type);
  697.  
  698. /* ------------------------------------------------------------------------
  699.  * Function:      socket_setsockopt()
  700.  *
  701.  * Description:   Set options on sockets
  702.  *
  703.  * Input:         s - value of R0 on entry
  704.  *                level - value of R1 on entry
  705.  *                optname - value of R2 on entry
  706.  *                optval - value of R3 on entry
  707.  *                optlen - value of R4 on entry
  708.  *
  709.  * Other notes:   Calls SWI 0x4120C.
  710.  */
  711.  
  712. extern os_error *xsocket_setsockopt (socket_s s,
  713.       socket_level level,
  714.       socket_so optname,
  715.       byte const *optval,
  716.       int optlen);
  717. extern void socket_setsockopt (socket_s s,
  718.       socket_level level,
  719.       socket_so optname,
  720.       byte const *optval,
  721.       int optlen);
  722.  
  723. /* ------------------------------------------------------------------------
  724.  * Function:      socket_getsockopt()
  725.  *
  726.  * Description:   Get options on sockets
  727.  *
  728.  * Input:         s - value of R0 on entry
  729.  *                level - value of R1 on entry
  730.  *                optname - value of R2 on entry
  731.  *                optval - value of R3 on entry
  732.  *                optlen - value of R4 on entry
  733.  *
  734.  * Other notes:   Calls SWI 0x4120D.
  735.  */
  736.  
  737. extern os_error *xsocket_getsockopt (socket_s s,
  738.       socket_level level,
  739.       socket_so optname,
  740.       byte *optval,
  741.       int *optlen);
  742. extern void socket_getsockopt (socket_s s,
  743.       socket_level level,
  744.       socket_so optname,
  745.       byte *optval,
  746.       int *optlen);
  747.  
  748. /* ------------------------------------------------------------------------
  749.  * Function:      socket_getpeername()
  750.  *
  751.  * Description:   Gets name of connected peer
  752.  *
  753.  * Input:         s - value of R0 on entry
  754.  *                sockaddr - value of R1 on entry
  755.  *                namelen - value of R2 on entry
  756.  *
  757.  * Other notes:   Calls SWI 0x4120E.
  758.  */
  759.  
  760. extern os_error *xsocket_getpeername (socket_s s,
  761.       socket_sockaddr *sockaddr,
  762.       int *namelen);
  763. __swi (0x4120E) void socket_getpeername (socket_s s,
  764.       socket_sockaddr *sockaddr,
  765.       int *namelen);
  766.  
  767. /* ------------------------------------------------------------------------
  768.  * Function:      socket_getsockname()
  769.  *
  770.  * Description:   Gets socket name
  771.  *
  772.  * Input:         s - value of R0 on entry
  773.  *                sockaddr - value of R1 on entry
  774.  *                namelen - value of R2 on entry
  775.  *
  776.  * Other notes:   Calls SWI 0x4120F.
  777.  */
  778.  
  779. extern os_error *xsocket_getsockname (socket_s s,
  780.       socket_sockaddr *sockaddr,
  781.       int *namelen);
  782. __swi (0x4120F) void socket_getsockname (socket_s s,
  783.       socket_sockaddr *sockaddr,
  784.       int *namelen);
  785.  
  786. /* ------------------------------------------------------------------------
  787.  * Function:      socket_close()
  788.  *
  789.  * Description:   Closes an open socket
  790.  *
  791.  * Input:         s - value of R0 on entry
  792.  *
  793.  * Other notes:   Calls SWI 0x41210.
  794.  */
  795.  
  796. extern os_error *xsocket_close (socket_s s);
  797. __swi (0x41210) void socket_close (socket_s s);
  798.  
  799. /* ------------------------------------------------------------------------
  800.  * Function:      socket_select()
  801.  *
  802.  * Description:   Synchronous socket i/o multiplexing
  803.  *
  804.  * Input:         nfds - value of R0 on entry
  805.  *                readfds - value of R1 on entry
  806.  *                writefds - value of R2 on entry
  807.  *                exceptfds - value of R3 on entry
  808.  *                timeout - value of R4 on entry
  809.  *
  810.  * Output:        nfound - value of R0 on exit (X version only)
  811.  *
  812.  * Returns:       R0 (non-X version only)
  813.  *
  814.  * Other notes:   Calls SWI 0x41211.
  815.  */
  816.  
  817. extern os_error *xsocket_select (int nfds,
  818.       socket_fdset const *readfds,
  819.       socket_fdset const *writefds,
  820.       socket_fdset const *exceptfds,
  821.       socket_timeval const *timeout,
  822.       int *nfound);
  823. extern int socket_select (int nfds,
  824.       socket_fdset const *readfds,
  825.       socket_fdset const *writefds,
  826.       socket_fdset const *exceptfds,
  827.       socket_timeval const *timeout);
  828.  
  829. /* ------------------------------------------------------------------------
  830.  * Function:      socket_ioctl()
  831.  *
  832.  * Description:   Controls an open socket
  833.  *
  834.  * Input:         s - value of R0 on entry
  835.  *                flags - value of R1 on entry
  836.  *                argp - value of R2 on entry
  837.  *
  838.  * Other notes:   Calls SWI 0x41212.
  839.  */
  840.  
  841. extern os_error *xsocket_ioctl (socket_s s,
  842.       socket_ioctl_no flags,
  843.       byte *argp);
  844. __swi (0x41212) void socket_ioctl (socket_s s,
  845.       socket_ioctl_no flags,
  846.       byte *argp);
  847.  
  848. /* ------------------------------------------------------------------------
  849.  * Function:      socket_read()
  850.  *
  851.  * Description:   Receives data from a connected socket
  852.  *
  853.  * Input:         s - value of R0 on entry
  854.  *                buf - value of R1 on entry
  855.  *                len - value of R2 on entry
  856.  *
  857.  * Output:        cc - value of R0 on exit (X version only)
  858.  *
  859.  * Returns:       R0 (non-X version only)
  860.  *
  861.  * Other notes:   Calls SWI 0x41213.
  862.  */
  863.  
  864. extern os_error *xsocket_read (socket_s s,
  865.       byte *buf,
  866.       int len,
  867.       int *cc);
  868. __swi (0x41213) int socket_read (socket_s s,
  869.       byte *buf,
  870.       int len);
  871.  
  872. /* ------------------------------------------------------------------------
  873.  * Function:      socket_write()
  874.  *
  875.  * Description:   Sends data from a connected socket
  876.  *
  877.  * Input:         s - value of R0 on entry
  878.  *                msg - value of R1 on entry
  879.  *                len - value of R2 on entry
  880.  *
  881.  * Output:        cc - value of R0 on exit (X version only)
  882.  *
  883.  * Returns:       R0 (non-X version only)
  884.  *
  885.  * Other notes:   Calls SWI 0x41214.
  886.  */
  887.  
  888. extern os_error *xsocket_write (socket_s s,
  889.       byte const *msg,
  890.       int len,
  891.       int *cc);
  892. __swi (0x41214) int socket_write (socket_s s,
  893.       byte const *msg,
  894.       int len);
  895.  
  896. /* ------------------------------------------------------------------------
  897.  * Function:      socket_stat()
  898.  *
  899.  * Description:   Not implemented
  900.  *
  901.  * Other notes:   Calls SWI 0x41215.
  902.  */
  903.  
  904. extern os_error *xsocket_stat (void);
  905. __swi (0x41215) void socket_stat (void);
  906.  
  907. /* ------------------------------------------------------------------------
  908.  * Function:      socket_readv()
  909.  *
  910.  * Description:   Receives data from a connected socket
  911.  *
  912.  * Input:         s - value of R0 on entry
  913.  *                iov - value of R1 on entry
  914.  *                iov_count - value of R2 on entry
  915.  *
  916.  * Output:        cc - value of R0 on exit (X version only)
  917.  *
  918.  * Returns:       R0 (non-X version only)
  919.  *
  920.  * Other notes:   Calls SWI 0x41216.
  921.  */
  922.  
  923. extern os_error *xsocket_readv (socket_s s,
  924.       socket_iovec *iov,
  925.       int iov_count,
  926.       int *cc);
  927. __swi (0x41216) int socket_readv (socket_s s,
  928.       socket_iovec *iov,
  929.       int iov_count);
  930.  
  931. /* ------------------------------------------------------------------------
  932.  * Function:      socket_writev()
  933.  *
  934.  * Description:   Sends data from a connected socket
  935.  *
  936.  * Input:         s - value of R0 on entry
  937.  *                iov - value of R1 on entry
  938.  *                iov_count - value of R2 on entry
  939.  *
  940.  * Output:        cc - value of R0 on exit (X version only)
  941.  *
  942.  * Returns:       R0 (non-X version only)
  943.  *
  944.  * Other notes:   Calls SWI 0x41217.
  945.  */
  946.  
  947. extern os_error *xsocket_writev (socket_s s,
  948.       socket_iovec const *iov,
  949.       int iov_count,
  950.       int *cc);
  951. __swi (0x41217) int socket_writev (socket_s s,
  952.       socket_iovec const *iov,
  953.       int iov_count);
  954.  
  955. /* ------------------------------------------------------------------------
  956.  * Function:      socket_gettsize()
  957.  *
  958.  * Description:   Gets the size of the socket table
  959.  *
  960.  * Output:        size - value of R0 on exit (X version only)
  961.  *
  962.  * Returns:       R0 (non-X version only)
  963.  *
  964.  * Other notes:   Calls SWI 0x41218.
  965.  */
  966.  
  967. extern os_error *xsocket_gettsize (int *size);
  968. __swi (0x41218) int socket_gettsize (void);
  969.  
  970. /* ------------------------------------------------------------------------
  971.  * Function:      event_internet()
  972.  *
  973.  * Description:   Internet event
  974.  *
  975.  * Input:         event_type - value of R1 on entry
  976.  *                s - value of R2 on entry
  977.  *
  978.  * Other notes:   Calls SWI 0x22 with R0 = 0x13.
  979.  */
  980.  
  981. extern os_error *xevent_internet (socket_event_type event_type,
  982.       socket_s s);
  983. extern void event_internet (socket_event_type event_type,
  984.       socket_s s);
  985.  
  986. /* ------------------------------------------------------------------------
  987.  * Function:      eventinternet_async()
  988.  *
  989.  * Description:   A socket has input waiting to be read
  990.  *
  991.  * Input:         s - value of R2 on entry
  992.  *
  993.  * Other notes:   Calls SWI 0x22 with R0 = 0x13, R1 = 0x1.
  994.  */
  995.  
  996. extern os_error *xeventinternet_async (socket_s s);
  997. extern void eventinternet_async (socket_s s);
  998.  
  999. /* ------------------------------------------------------------------------
  1000.  * Function:      eventinternet_urgent()
  1001.  *
  1002.  * Description:   An urgent event has occurred
  1003.  *
  1004.  * Input:         s - value of R2 on entry
  1005.  *
  1006.  * Other notes:   Calls SWI 0x22 with R0 = 0x13, R1 = 0x2.
  1007.  */
  1008.  
  1009. extern os_error *xeventinternet_urgent (socket_s s);
  1010. extern void eventinternet_urgent (socket_s s);
  1011.  
  1012. /* ------------------------------------------------------------------------
  1013.  * Function:      eventinternet_broken()
  1014.  *
  1015.  * Description:   A socket connection is broken
  1016.  *
  1017.  * Input:         s - value of R2 on entry
  1018.  *
  1019.  * Other notes:   Calls SWI 0x22 with R0 = 0x13, R1 = 0x3.
  1020.  */
  1021.  
  1022. extern os_error *xeventinternet_broken (socket_s s);
  1023. extern void eventinternet_broken (socket_s s);
  1024.  
  1025. /* ------------------------------------------------------------------------
  1026.  * Function:      eventinternet_rarp_reply()
  1027.  *
  1028.  * Description:   A RevARP server has replied to a RevARP request
  1029.  *
  1030.  * Input:         addr - value of R2 on entry
  1031.  *
  1032.  * Other notes:   Calls SWI 0x22 with R0 = 0x13, R1 = 0x4.
  1033.  */
  1034.  
  1035. extern os_error *xeventinternet_rarp_reply (bits addr);
  1036. extern void eventinternet_rarp_reply (bits addr);
  1037.  
  1038. #ifdef __cplusplus
  1039.    }
  1040. #endif
  1041.  
  1042. #endif
  1043.