home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 19 / Amiga Plus Leser CD 19.iso / Tools / MorphOS / cvs-1.11.2 / source / amiga / netinclude / libraries / bsdsocket.h
Encoding:
C/C++ Source or Header  |  2002-11-18  |  33.7 KB  |  1,030 lines

  1. /*
  2.  *    $Id: bsdsocket.h,v 1.13 2002/10/30 15:53:27 obarthel Exp $
  3.  *
  4.  *    :ts=8
  5.  *
  6.  *    Copyright © 2001-2002 by Olaf Barthel. All Rights Reserved.
  7.  */
  8.  
  9. #ifndef _LIBRARIES_BSDSOCKET_H
  10. #define _LIBRARIES_BSDSOCKET_H
  11.  
  12. /****************************************************************************/
  13.  
  14. #ifndef EXEC_PORTS_H
  15. #include <exec/ports.h>
  16. #endif /* EXEC_PORTS_H */
  17.  
  18. #ifndef UTILITY_TAGITEM_H
  19. #include <utility/tagitem.h>
  20. #endif /* UTILITY_TAGITEM_H */
  21.  
  22. #ifndef DOS_H
  23. #include <dos/dos.h>
  24. #endif /* DOS_H */
  25.  
  26. /****************************************************************************/
  27.  
  28. #ifndef _SYS_SOCKET_H_
  29. #include <sys/socket.h>
  30. #endif /* _SYS_SOCKET_H_ */
  31.  
  32. #ifndef _NETINET_IN_H_
  33. #include <netinet/in.h>
  34. #endif /* _NETINET_IN_H_ */
  35.  
  36. #ifndef _NET_IF_H_
  37. #include <net/if.h>
  38. #endif /* _NET_IF_H_ */
  39.  
  40. #ifndef _SYS_MBUF_H_
  41. #include <sys/mbuf.h>
  42. #endif /* _SYS_MBUF_H_ */
  43.  
  44. /****************************************************************************/
  45.  
  46. /*
  47.  * Parameters for SocketBaseTagList().
  48.  */
  49.  
  50. /* Argument passed by reference or by value. */
  51. #define SBTF_VAL 0x0000
  52. #define SBTF_REF 0x8000
  53.  
  54. /* Code value. */
  55. #define SBTB_CODE 1
  56. #define SBTS_CODE 0x3FFF
  57. #define SBTM_CODE(td) (((td) >> SBTB_CODE) & SBTS_CODE)
  58.  
  59. /* Get/Set (read/write) selection. */
  60. #define SBTF_GET 0
  61. #define SBTF_SET 1
  62.  
  63. /* Macros for passing the individual tag item parameters. */
  64. #define SBTM_GETREF(code) \
  65.     (TAG_USER | SBTF_REF | (((code) & SBTS_CODE) << SBTB_CODE))
  66. #define SBTM_GETVAL(code) \
  67.     (TAG_USER | (((code) & SBTS_CODE) << SBTB_CODE))
  68. #define SBTM_SETREF(code) \
  69.     (TAG_USER | SBTF_REF | (((code) & SBTS_CODE) << SBTB_CODE) | SBTF_SET)
  70. #define SBTM_SETVAL(code) \
  71.     (TAG_USER | (((code) & SBTS_CODE) << SBTB_CODE) | SBTF_SET)
  72.  
  73. /* Masks defining the signals for Task notification */
  74. #define SBTC_BREAKMASK        1
  75. #define SBTC_SIGIOMASK        2
  76. #define SBTC_SIGURGMASK        3
  77. #define SBTC_SIGEVENTMASK    4
  78.  
  79. /* Current value of the errno and h_errno variables */
  80. #define SBTC_ERRNO        6
  81. #define SBTC_HERRNO        7
  82.  
  83. /* Current size of the socket descriptor table */
  84. #define SBTC_DTABLESIZE        8
  85.  
  86. /* Link library fd allocation callback; don't use this in
  87.  * new code!
  88.  */
  89. #define SBTC_FDCALLBACK        9
  90.  
  91. /* Callback actions; don't use these in new code! */
  92. #define FDCB_FREE  0
  93. #define FDCB_ALLOC 1
  94. #define FDCB_CHECK 2
  95.  
  96. /* syslog variables */
  97. #define SBTC_LOGSTAT        10
  98. #define SBTC_LOGTAGPTR        11
  99. #define SBTC_LOGFACILITY    12
  100. #define SBTC_LOGMASK        13
  101.  
  102. /* Error strings */
  103. #define SBTC_ERRNOSTRPTR    14
  104. #define SBTC_HERRNOSTRPTR    15
  105. #define SBTC_IOERRNOSTRPTR    16
  106. #define SBTC_S2ERRNOSTRPTR    17
  107. #define SBTC_S2WERRNOSTRPTR    18
  108.  
  109. /* errno pointer & size */
  110. #define SBTC_ERRNOBYTEPTR    21
  111. #define SBTC_ERRNOWORDPTR    22
  112. #define SBTC_ERRNOLONGPTR    24
  113. #define SBTC_ERRNOPTR(size) \
  114.     ((size == sizeof(long))        ? SBTC_ERRNOLONGPTR :    \
  115.     ((size == sizeof(short))    ? SBTC_ERRNOWORDPTR :    \
  116.     ((size == sizeof(char))        ? SBTC_ERRNOBYTEPTR :    \
  117.     0)))
  118.  
  119. /* 'h_errno' pointer (with sizeof(h_errno) == sizeof(long)) */
  120. #define SBTC_HERRNOLONGPTR    25
  121.  
  122. /* Release string pointer */
  123. #define SBTC_RELEASESTRPTR    29
  124.  
  125. /*
  126.  * Extensions to the original AmiTCP API
  127.  */
  128.  
  129. /* Number of Berkeley packet filter channels available. */
  130. #define SBTC_NUM_PACKET_FILTER_CHANNELS 40
  131.  
  132. /* Whether or not the routing API is supported. */
  133. #define SBTC_HAVE_ROUTING_API 41
  134.  
  135. /* Enable/Disable UDP checksums? */
  136. #define SBTC_UDP_CHECKSUM 42
  137.  
  138. /* Enable/Disable IP packet forwarding? */
  139. #define SBTC_IP_FORWARDING 43
  140.  
  141. /* Get/set the default IP packet TTL value. */
  142. #define SBTC_IP_DEFAULT_TTL 44
  143.  
  144. /* Respond to ICMP mask requests? */
  145. #define SBTC_ICMP_MASK_REPLY 45
  146.  
  147. /* Enable/Disable sending of redirection messages? */
  148. #define SBTC_ICMP_SEND_REDIRECTS 46
  149.  
  150. /* Whether or not the interface API is supported. */
  151. #define SBTC_HAVE_INTERFACE_API 47
  152.  
  153. /* How ICMP echo messages should be processed. */
  154. #define SBTC_ICMP_PROCESS_ECHO 48
  155.  
  156. /* How ICMP time stamp messages should be processed. */
  157. #define SBTC_ICMP_PROCESS_TSTAMP 49
  158.  
  159. /* Whether or not the monitoring API is supported. */
  160. #define SBTC_HAVE_MONITORING_API 50
  161.  
  162. /* Whether or not library bases can be shared by different
  163.    callers. */
  164. #define SBTC_CAN_SHARE_LIBRARY_BASES 51
  165.  
  166. /* Set the name of the log output file or get a pointer
  167.    to the current file name. */
  168. #define SBTC_LOG_FILE_NAME 52
  169.  
  170. /* Whether or not the status API is supported. */
  171. #define SBTC_HAVE_STATUS_API 53
  172.  
  173. /* Whether or not the DNS API is supported. */
  174. #define SBTC_HAVE_DNS_API 54
  175.  
  176. /* Set or get a pointer to the currently installed log hook. */
  177. #define SBTC_LOG_HOOK 55
  178.  
  179. /* Get the system status, with regard to whether the TCP/IP stack
  180.    has access to network interfaces and name resolution servers. */
  181. #define SBTC_SYSTEM_STATUS 56
  182.  
  183. /* Get or set the signal mask used to send a notification when
  184.    the address of an interface has changed. */
  185. #define SBTC_SIG_ADDRESS_CHANGE_MASK 57
  186.  
  187. /* If the IP filter API is supported, which version of that API
  188.    would it be? */
  189. #define SBTC_IPF_API_VERSION 58
  190.  
  191. /* Whether or not the local database access API is supported. */
  192. #define SBTC_HAVE_LOCAL_DATABASE_API 59
  193.  
  194. /* Whether or not the address conversion API is supported. */
  195. #define SBTC_HAVE_ADDRESS_CONVERSION_API 60
  196.  
  197. /* Whether or not the kernel memory API is supported. */
  198. #define SBTC_HAVE_KERNEL_MEMORY_API 61
  199.  
  200. /* Get or set the IP filter hook which is invoked whenever a
  201.    datagram has arrived or is about to be sent. */
  202. #define SBTC_IP_FILTER_HOOK 62
  203.  
  204. /* Whether or not the server API is supported. */
  205. #define SBTC_HAVE_SERVER_API 63
  206.  
  207. /* Query the number of bytes received so far. */
  208. #define SBTC_GET_BYTES_RECEIVED 64
  209.  
  210. /* Query the number of bytes sent so far. */
  211. #define SBTC_GET_BYTES_SENT 65
  212.  
  213. /****************************************************************************/
  214.  
  215. /*
  216.  * Flags returned by a SocketBaseTagList() 'SBTC_SYSTEM_STATUS' query.
  217.  */
  218.  
  219. #define SBSYSSTAT_Interfaces        (1L<<0)    /* Interfaces are available,
  220.                            configured and
  221.                            operational. */
  222. #define SBSYSSTAT_PTP_Interfaces    (1L<<1)    /* Point-to-point interfaces
  223.                            are available, configured
  224.                            and operational. */
  225. #define SBSYSSTAT_BCast_Interfaces    (1L<<2)    /* Broadcast interfaces are
  226.                            available, configured and
  227.                            operational. */
  228. #define SBSYSSTAT_Resolver        (1L<<3)    /* Domain name servers are
  229.                            known and available */
  230. #define SBSYSSTAT_Routes        (1L<<4)    /* Routing information is
  231.                            configured */
  232. #define SBSYSSTAT_DefaultRoute        (1L<<5)    /* A default route is
  233.                            configured */
  234.  
  235. /****************************************************************************/
  236.  
  237. /*
  238.  * Data structures for use with the log hook.
  239.  */
  240.  
  241. struct LogHookMessage
  242. {
  243.     LONG    lhm_Size;    /* Size of this data structure in bytes. */
  244.     LONG    lhm_Priority;    /* Log entry priority (LOG_EMERG..LOG_DEBUG) */
  245.     struct DateStamp
  246.         lhm_Date;    /* Time and date when this log entry was
  247.                    added. */
  248.     STRPTR    lhm_Tag;    /* Name of the facility which added this entry;
  249.                    this can be NULL. */
  250.     ULONG    lhm_ID;        /* ID of the facility which added this entry;
  251.                    this can be zero. */
  252.     STRPTR    lhm_Message;    /* NUL-terminated string which contains the
  253.                    log message to be displayed. */
  254. };
  255.  
  256. /****************************************************************************/
  257.  
  258. /*
  259.  * Options for configuring how ICMP echo and time stamp
  260.  * requests should be processed.
  261.  */
  262. #define IR_Process    0    /* Process the request and respond to it */
  263. #define IR_Ignore    1    /* Ignore the request, but feed it into the
  264.                    raw IP packet processing framework */
  265. #define IR_Drop        2    /* Ignore the request and treat it as if
  266.                    it had a checksum error */
  267.  
  268. /****************************************************************************/
  269.  
  270. /*
  271.  * For use with ReleaseSocket() and ReleaseCopyOfSocket().
  272.  */
  273.  
  274. #define UNIQUE_ID (-1)
  275.  
  276. /****************************************************************************/
  277.  
  278. /*
  279.  * Event masks returned by GetSocketEvents().
  280.  */
  281.  
  282. #define FD_ACCEPT    0x01    /* there is a connection to accept() */
  283. #define FD_CONNECT    0x02    /* connect() completed */
  284. #define FD_OOB        0x04    /* socket has out-of-band data */
  285. #define FD_READ        0x08    /* socket is readable */
  286. #define FD_WRITE    0x10    /* socket is writeable */
  287. #define FD_ERROR    0x20    /* asynchronous error on socket */
  288. #define FD_CLOSE    0x40    /* connection closed (graceful or not) */
  289.  
  290. /****************************************************************************/
  291.  
  292. /*
  293.  * Tags for use with the routing API.
  294.  */
  295.  
  296. #define RTA_BASE (TAG_USER+1600)
  297.  
  298. #define RTA_Destination        (RTA_BASE+1)    /* Route destination
  299.                            address */
  300. #define RTA_Gateway        (RTA_BASE+2)    /* Gateway address */
  301. #define RTA_DefaultGateway    (RTA_BASE+3)    /* Default gateway address */
  302. #define RTA_DestinationHost    (RTA_BASE+4)    /* Route destination
  303.                            address; destination is
  304.                            assumed to be a host and
  305.                            not a network */
  306. #define RTA_DestinationNet    (RTA_BASE+5)    /* Route destination
  307.                            address; destination is
  308.                            assumed to be a network
  309.                            and not a host */
  310.  
  311. /****************************************************************************/
  312.  
  313. /*
  314.  * Tags for use with the interface management API,
  315.  * specifically the AddInterfaceTagList() call.
  316.  */
  317. #define IFA_BASE (TAG_USER+1700)
  318.  
  319. #define IFA_IPType        (IFA_BASE+1)    /* IP packet type */
  320. #define IFA_ARPType        (IFA_BASE+2)    /* ARP packet type */
  321. #define IFA_NumReadRequests    (IFA_BASE+3)    /* Number of read requests
  322.                            to queue */
  323. #define IFA_NumWriteRequests    (IFA_BASE+4)    /* Number of write requests
  324.                            to queue */
  325. #define IFA_NumARPRequests    (IFA_BASE+5)    /* Number of ARP requests
  326.                            to queue */
  327. #define IFA_PacketFilterMode    (IFA_BASE+6)    /* Operating mode of the
  328.                            Berkeley packet filter */
  329. #define IFA_PointToPoint    (IFA_BASE+7)    /* Whether or not this
  330.                            interface is of the
  331.                            point-to-point type */
  332. #define IFA_Reserved0        (IFA_BASE+8)    /* This tag is reserved for
  333.                            future use */
  334. #define IFA_Multicast        (IFA_BASE+9)    /* Whether or not this
  335.                            interface is allowed to
  336.                            send multicast packets */
  337. #define IFA_DownGoesOffline    (IFA_BASE+10)    /* Whether or not this
  338.                            interface will go offline
  339.                            when it is taken down */
  340. #define IFA_ReportOffline    (IFA_BASE+11)    /* Whether or not this
  341.                            interface will cause a
  342.                            notification message to
  343.                            be logged when it goes
  344.                            offline */
  345. #define IFA_RequiresInitDelay    (IFA_BASE+12)    /* Whether or not this
  346.                            interface requires a short
  347.                            delay to precede the
  348.                            device initialization */
  349. #define IFA_CopyMode        (IFA_BASE+13)    /* Special data copy options
  350.                            for this interface */
  351. #define IFA_HardwareAddress    (IFA_BASE+14)    /* Set the interface hardware
  352.                            address to a certain
  353.                            value. */
  354. #define IFA_SetDebugMode    (IFA_BASE+15)    /* Enable or disable debugging
  355.                            mode for this interface. */
  356.  
  357. /****************************************************************************/
  358.  
  359. /* This is used with the 'IFA_HardwareAddress' tag above. */
  360. struct InterfaceHardwareAddress
  361. {
  362.     LONG    iha_Length;    /* Number of bits in address */
  363.     UBYTE *    iha_Address;    /* Points to first address byte */
  364. };
  365.  
  366. /****************************************************************************/
  367.  
  368. /*
  369.  * Options available for use with the IFA_PacketFilterMode tag.
  370.  */
  371. #define PFM_Nothing    0    /* Filter is disabled for this interface. */
  372. #define PFM_Local    1    /* Filter is enabled; only packets intended
  373.                    for this interface are filtered */
  374. #define PFM_IPandARP    2    /* Filter is enabled; all IP and ARP packets
  375.                    are filtered, even if they are not intended
  376.                    for this interface */
  377. #define PFM_Everything    3    /* Filter is enabled; all packets are filtered
  378.                    that pass by, regardless of their type and
  379.                    contents */
  380.  
  381. /****************************************************************************/
  382.  
  383. /*
  384.  * Options available for use with the IFA_CopyMode tag.
  385.  */
  386. #define CM_SlowWordCopy    0    /* Disables the S2_CopyFromBuff16 SANA-II
  387.                    buffer management option (default). */
  388. #define CM_FastWordCopy    1    /* Enables the S2_CopyFromBuff16 SANA-II
  389.                    buffer management option. */
  390.  
  391. /****************************************************************************/
  392.  
  393. /*
  394.  * Tags for use with the interface management API,
  395.  * specifically the ConfigureInterfaceTagList() call.
  396.  */
  397. #define IFC_BASE (TAG_USER+1800)
  398.  
  399. #define IFC_Address        (IFC_BASE+1)    /* The address to assign to
  400.                            the interface itself */
  401. #define IFC_NetMask        (IFC_BASE+2)    /* The interface's address
  402.                            net mask */
  403. #define IFC_DestinationAddress    (IFC_BASE+3)    /* The address of the other
  404.                            end of a point-to-point
  405.                            link */
  406. #define IFC_BroadcastAddress    (IFC_BASE+4)    /* The broadcast address to
  407.                            be used by the interface */
  408. #define IFC_Metric        (IFC_BASE+5)    /* The routing metric value */
  409.  
  410. #define IFC_AddAliasAddress    (IFC_BASE+6)    /* Add another alias address
  411.                            for this interface */
  412. #define IFC_DeleteAliasAddress    (IFC_BASE+7)    /* Remove an alias address
  413.                            for this interface */
  414. #define IFC_State        (IFC_BASE+8)    /* Mark an interface up, down,
  415.                            online or offline */
  416. #define IFC_GetPeerAddress    (IFC_BASE+9)    /* If available, obtain the
  417.                            interface's local address
  418.                            and the address of its
  419.                            point to point partner */
  420. #define IFC_GetDNS        (IFC_BASE+10)    /* If available, obtain the
  421.                            domain name servers known
  422.                            to this interface */
  423. #define IFC_AssociatedRoute    (IFC_BASE+12)    /* That interface is associated
  424.                            with a route. */
  425. #define IFC_AssociatedDNS    (IFC_BASE+13)    /* That interface is associated
  426.                            with a DNS. */
  427. #define IFC_ReleaseAddress    (IFC_BASE+14)    /* Release the address allocated
  428.                            for this interface (via the
  429.                            DHCP protocol). */
  430. #define IFC_SetDebugMode    (IFC_BASE+15)    /* Enable or disable debugging
  431.                            mode for this interface. */
  432. #define IFC_Complete        (IFC_BASE+16)    /* Indicate that the configuration
  433.                            for this interface is complete */
  434.  
  435. /****************************************************************************/
  436.  
  437. /*
  438.  * Tags for use with the interface management API,
  439.  * specifically the QueryInterfaceTagList() call.
  440.  */
  441. #define IFQ_BASE (TAG_USER+1900)
  442.  
  443. #define IFQ_DeviceName        (IFQ_BASE+1)    /* Query the associated
  444.                            SANA-II device name */
  445. #define IFQ_DeviceUnit        (IFQ_BASE+2)    /* Query the associated
  446.                            SANA-II unit number */
  447. #define IFQ_HardwareAddressSize    (IFQ_BASE+3)    /* Query the hardware address
  448.                            size (in bytes) */
  449. #define IFQ_HardwareAddress    (IFQ_BASE+4)    /* Query the hardware
  450.                            address */
  451. #define IFQ_MTU            (IFQ_BASE+5)    /* Query the maximum
  452.                            transmission unit */
  453. #define IFQ_BPS            (IFQ_BASE+6)    /* Query the transmission
  454.                            speed */
  455. #define IFQ_HardwareType    (IFQ_BASE+7)    /* Query the SANA-II hardware
  456.                            type */
  457. #define IFQ_PacketsReceived    (IFQ_BASE+8)    /* Query the number of
  458.                            packets received by this
  459.                            interface */
  460. #define IFQ_PacketsSent        (IFQ_BASE+9)    /* Query the number of
  461.                            packets sent by this
  462.                            interface */
  463. #define IFQ_BadData        (IFQ_BASE+10)    /* Query the number of bad
  464.                            packets dropped by this
  465.                            interface */
  466. #define IFQ_Overruns        (IFQ_BASE+11)    /* Query the number of buffer
  467.                            overruns */
  468. #define IFQ_UnknownTypes    (IFQ_BASE+12)    /* Query the number of unknown
  469.                            packet types dropped by this
  470.                            interface */
  471. #define IFQ_LastStart        (IFQ_BASE+13)    /* Query the last time the
  472.                            interface went online */
  473. #define IFQ_Address        (IFQ_BASE+14)    /* Query the IP address
  474.                            associated with this
  475.                            interface */
  476. #define IFQ_DestinationAddress    (IFQ_BASE+15)    /* Query the interface's
  477.                            destination address */
  478. #define IFQ_BroadcastAddress    (IFQ_BASE+16)    /* Query the interface's
  479.                            broadcast address */
  480. #define IFQ_NetMask        (IFQ_BASE+17)    /* Query the interface's
  481.                            subnet mask */
  482. #define IFQ_Metric        (IFQ_BASE+18)    /* Query the interface's
  483.                            metric value */
  484. #define IFQ_State        (IFQ_BASE+19)    /* Query the interface's
  485.                            status */
  486. #define IFQ_AddressBindType    (IFQ_BASE+20)    /* Query whether the address
  487.                            bound to this interface
  488.                            is statically, manually
  489.                            or dynamically bound. */
  490. #define IFQ_AddressLeaseExpires    (IFQ_BASE+21)    /* Find out whether and when
  491.                            the address bound to this
  492.                            interface expires. */
  493. #define IFQ_PrimaryDNSAddress    (IFQ_BASE+22)    /* Query the primary domain
  494.                            name server address known
  495.                            to this interface */
  496. #define IFQ_SecondaryDNSAddress    (IFQ_BASE+23)    /* Query the secondary domain
  497.                            name server address known
  498.                            to this interface */
  499. #define IFQ_NumReadRequests    (IFQ_BASE+24)    /* Number of read I/O requests
  500.                            allocated for this
  501.                            interface */
  502. #define IFQ_MaxReadRequests    (IFQ_BASE+25)    /* Maximum number of read I/O
  503.                            requests in use at a time
  504.                            on this interface */
  505. #define IFQ_NumWriteRequests    (IFQ_BASE+26)    /* Number of write I/O requests
  506.                            allocated for this
  507.                            interface */
  508. #define IFQ_MaxWriteRequests    (IFQ_BASE+27)    /* Maximum number of write I/O
  509.                            requests in use at a time
  510.                            on this interface */
  511. #define IFQ_GetBytesIn        (IFQ_BASE+28)    /* Query the number of bytes
  512.                            received */
  513. #define IFQ_GetBytesOut        (IFQ_BASE+29)    /* Query the number of bytes
  514.                            sent */
  515. #define IFQ_GetDebugMode    (IFQ_BASE+30)    /* Check if this interface has
  516.                            the debug mode enabled */
  517.  
  518. /****************************************************************************/
  519.  
  520. /* The different types of interface address binding. */
  521. #define IFABT_Unknown    0    /* The interface address has not been bound
  522.                    or is in transitional state; check later
  523.                    for more information. */
  524. #define IFABT_Static    1    /* The address was assigned manually, or
  525.                    by an automated configuration process
  526.                    and is not expected to change. */
  527. #define IFABT_Dynamic    2    /* The address was assigned by an automated
  528.                    configuration process and may change in the
  529.                    future. */
  530.  
  531. /****************************************************************************/
  532.  
  533. /*
  534.  * The 64 bit integer value used by the IFQ_GetBytesIn..IFQ_GetResetBytesOut
  535.  * query tags.
  536.  */
  537. typedef struct
  538. {
  539.     ULONG sbq_High;
  540.     ULONG sbq_Low;
  541. } SBQUAD_T;
  542.  
  543. /****************************************************************************/
  544.  
  545. /*
  546.  * Options available for use with the IFC_State and IFQ_State tags.
  547.  */
  548. #define SM_Offline    0    /* Interface is offline and not ready to
  549.                    receive and transmit data */
  550. #define SM_Online    1    /* Interface is online and ready to receive
  551.                    and transmit data */
  552. #define SM_Down        2    /* Interface is not ready to receive and
  553.                    transmit data, but might still be
  554.                    online. */
  555. #define SM_Up        3    /* Interface is ready to receive and transmit
  556.                    data, but not necessarily online. */
  557.  
  558. /****************************************************************************/
  559.  
  560. /*
  561.  * Types of monitoring hooks that can be installed.
  562.  */
  563. #define MHT_ICMP    0    /* ICMP message monitoring */
  564. #define MHT_UDP        1    /* UDP datagram monitoring */
  565. #define MHT_TCP_Connect    2    /* TCP connection monitoring */
  566. #define MHT_Connect    3    /* connect() call monitoring */
  567. #define MHT_Send    4    /* sendto() and sendmsg() monitoring */
  568. #define MHT_Packet    5    /* Low level packet monitoring */
  569. #define MHT_Bind    6    /* bind() call monitoring */
  570.  
  571. /****************************************************************************/
  572.  
  573. /*
  574.  * Parameters passed to the different monitoring hooks.
  575.  */
  576.  
  577. /* This type of message parameter is passed to 'MHT_Connect'
  578.  * type monitoring hooks.
  579.  */
  580. struct ConnectMonitorMsg
  581. {
  582.     LONG        cmm_Size;    /* Size of this data
  583.                        structure */
  584.     STRPTR        cmm_Caller;    /* The name of the calling
  585.                        program, if it chose to be
  586.                        identified */
  587.     LONG        cmm_Socket;    /* The socket to connect to
  588.                        the address */
  589.     struct sockaddr *
  590.             cmm_Name;    /* The address to connect
  591.                        to */
  592.     LONG        cmm_NameLen;    /* The size of the address */
  593. };
  594.  
  595. /* This type of message parameter is passed to 'MHT_Bind'
  596.  * type monitoring hooks.
  597.  */
  598. struct BindMonitorMsg
  599. {
  600.     LONG        bmm_Size;    /* Size of this data
  601.                        structure */
  602.     STRPTR        bmm_Caller;    /* The name of the calling
  603.                        program, if it chose to be
  604.                        identified */
  605.     LONG        bmm_Socket;    /* The socket to bind to the
  606.                        address */
  607.     struct sockaddr *
  608.             bmm_Name;    /* The address to bind */
  609.     LONG        bmm_NameLen;    /* The size of the address */
  610. };
  611.  
  612. /* This type of message is passed to 'MHT_Send' type monitoring hooks. */
  613. struct SendMonitorMessage
  614. {
  615.     LONG        smm_Size;    /* Size of this data structure */
  616.     STRPTR        smm_Caller;    /* The name of the calling
  617.                        program, if it chose to be
  618.                        identified */
  619.     LONG        smm_Socket;    /* The socket to connect to the
  620.                        address */
  621.     APTR        smm_Buffer;    /* Data to be sent */
  622.     LONG        smm_Len;    /* Amount of data to be sent */
  623.     LONG        smm_Flags;    /* Control flags, including
  624.                        MSG_OOB or MSG_DONTROUTE */
  625.     struct sockaddr *
  626.             smm_To;        /* The address to send the
  627.                        data to; this may be NULL */
  628.     LONG        smm_ToLen;    /* The size of the address to send
  629.                        this data to; this may be
  630.                        NULL */
  631.     struct msghdr *    smm_Msg;    /* The message to send; this may
  632.                        be NULL. */
  633. };
  634.  
  635. /* This type of message is passed to 'MHT_TCP_Connect' type
  636.  * monitoring hooks.
  637.  */
  638. struct TCPConnectMonitorMessage
  639. {
  640.     LONG        tcmm_Size;    /* Size of this data structure */
  641.     struct in_addr *
  642.             tcmm_Src;    /* Source internet address */
  643.     struct in_addr *
  644.             tcmm_Dst;    /* Destination internet address */
  645.     struct tcphdr *    tcmm_TCP;    /* TCP header */
  646. };
  647.  
  648. /* This type of message is passed to 'MHT_UDP' type monitoring hooks. */
  649. struct UDPMonitorMessage
  650. {
  651.     LONG        umm_Size;    /* Size of this data structure */
  652.     struct in_addr *
  653.             umm_Src;    /* Source internet address */
  654.     struct in_addr *
  655.             umm_Dst;    /* Destination internet address */
  656.     struct udphdr *    umm_UDP;    /* UDP header */
  657. };
  658.  
  659. /* This type of message is passed to 'MHT_ICMP' type monitoring hooks. */
  660. struct ICMPMonitorMessage
  661. {
  662.     LONG        imm_Size;    /* Size of this data structure */
  663.     struct in_addr *
  664.             imm_Src;    /* Source internet address */
  665.     struct in_addr *
  666.             imm_Dst;    /* Destination internet address */
  667.     struct icmp *    imm_ICMP;    /* ICMP header */
  668. };
  669.  
  670. /* This type of message is passed to 'MHT_Packet' type monitoring hooks. */
  671. struct PacketMonitorMessage
  672. {
  673.     LONG        pmm_Size;    /* Size of this data structure */
  674.     LONG        pmm_Direction;    /* Whether the packet was received
  675.                        or is about to be sent */
  676.     APTR        pmm_LinkLayerData;
  677.                     /* Points to the link layer part
  678.                        of the packet, typically an
  679.                        Ethernet header per RFC 894.
  680.                        This may be NULL. */
  681.     LONG        pmm_LinkLayerSize;
  682.                     /* Size of the link layer data part
  683.                        of the packet; this may be 0. */
  684.     APTR        pmm_PacketData;    /* Points to the packet 'payload'. */
  685.     LONG        pmm_PacketSize;    /* Size of the packet 'payload'. */
  686. };
  687.  
  688. /* Possible values for 'pmm_Direction'. */
  689. #define PMMD_Receive    0    /* Packet was received and is waiting to be
  690.                    processed */
  691. #define PMMD_Send    1    /* Packet is about to be sent */
  692.  
  693. /****************************************************************************/
  694.  
  695. /*
  696.  * Possible actions to be taken after a monitoring hook has
  697.  * examined the data it was passed. Any positive return value
  698.  * will cause the data to be dropped and the corresponding
  699.  * errno value to be set to the result.
  700.  */
  701. #define MA_Continue        0    /* Proceed as if no filtering had
  702.                        taken place */
  703. #define MA_Ignore        -1    /* Ignore the data and skip the
  704.                        normal route processing would
  705.                        take */
  706. #define MA_Drop            -2    /* Drop the data */
  707. #define MA_DropWithReset    -3    /* Drop the data and also reset the
  708.                        connection */
  709.  
  710. /****************************************************************************/
  711.  
  712. /*
  713.  * Parameters for use with the GetNetworkStatus() function.
  714.  */
  715.  
  716. /* What version of the statistics data should be returned; so far
  717.    there is only version #1. */
  718. #define NETWORKSTATUS_VERSION 1
  719.  
  720. /* What statistics should be provided */
  721.  
  722. #define NETSTATUS_icmp        0    /* Internet control message
  723.                        protocol statistics */
  724. #define NETSTATUS_igmp        1    /* Internet group management
  725.                        protocol statistics */
  726. #define NETSTATUS_ip        2    /* Internet protocol statistics */
  727. #define NETSTATUS_mb        3    /* Memory buffer statistics */
  728. #define NETSTATUS_mrt        4    /* Multicast routing statistics */
  729. #define NETSTATUS_rt        5    /* Routing statistics */
  730. #define NETSTATUS_tcp        6    /* Transmission control protocol
  731.                        statistics */
  732. #define NETSTATUS_udp        7    /* User datagram protocol
  733.                        statistics */
  734. #define NETSTATUS_tcp_sockets    9    /* TCP socket statistics */
  735. #define NETSTATUS_udp_sockets    10    /* UDP socket statistics */
  736.  
  737. /* Protocol connection data returned for each TCP/UDP socket. */
  738. struct protocol_connection_data
  739. {
  740.     struct in_addr
  741.         pcd_foreign_address;    /* Foreign host address */
  742.     UWORD    pcd_foreign_port;    /* Foreign port number */
  743.     struct in_addr
  744.         pcd_local_address;    /* Local host address */
  745.     UWORD    pcd_local_port;        /* Local port number */
  746.     ULONG    pcd_receive_queue_size;    /* Socket receive queue size */
  747.     ULONG    pcd_send_queue_size;    /* Socket send queue size */
  748.     LONG    pcd_tcp_state;        /* Socket TCP state */
  749. };
  750.  
  751. /****************************************************************************/
  752.  
  753. /*
  754.  * Interface address allocation (BOOTP and DHCP).
  755.  */
  756.  
  757. /* The message to send to the interface configuration process
  758.    to start looking for an IP address. */
  759. struct AddressAllocationMessage
  760. {
  761.     struct Message
  762.         aam_Message;
  763.     LONG    aam_Reserved;
  764.     LONG    aam_Result;        /* What kind of result this
  765.                        request produced. */
  766.     LONG    aam_Version;        /* Version number associated with
  767.                        this data structure. */
  768.     LONG    aam_Protocol;        /* What kind of configuration
  769.                        protocol should be used. */
  770.     char    aam_InterfaceName[16];    /* Name of interface an
  771.                        address is to be
  772.                        assigned to. */
  773.     LONG    aam_Timeout;        /* Number of seconds to
  774.                        wait before a result
  775.                        materializes. */
  776.     ULONG    aam_LeaseTime;        /* Requested lease time in
  777.                        seconds; 0 to accept the
  778.                        default. */
  779.     ULONG    aam_RequestedAddress;    /* Interface address that should
  780.                        be assigned, if possible; 0
  781.                        to accept the server's choice. */
  782.     STRPTR    aam_ClientIdentifier;    /* Unique identifier for this
  783.                        host */
  784.     ULONG    aam_Address;        /* Interface address
  785.                        returned upon
  786.                        success. */
  787.     ULONG    aam_ServerAddress;    /* Address of BOOTP server. */
  788.     ULONG    aam_SubnetMask;        /* Interface subnet
  789.                        mask; ignore if zero. */
  790.  
  791.     STRPTR    aam_NAKMessage;        /* In case of failure,
  792.                        put the explanation
  793.                        text here. */
  794.     LONG    aam_NAKMessageSize;    /* Maximum length of the
  795.                        negative ack message. */
  796.  
  797.     ULONG *    aam_RouterTable;    /* A list of router addresses
  798.                        will be put here. */
  799.     LONG    aam_RouterTableSize;    /* Maximum number of valid
  800.                        router addresses. */
  801.     
  802.     ULONG *    aam_DNSTable;        /* A list of domain name servers
  803.                        will be put here. */
  804.     LONG    aam_DNSTableSize;    /* Maximum number of valid
  805.                        domain name server
  806.                        addresses. */
  807.  
  808.     ULONG *    aam_StaticRouteTable;    /* A list of static routes
  809.                        will be put here. */
  810.     LONG    aam_StaticRouteTableSize;
  811.                     /* Maximum number of valid
  812.                        static routes. */
  813.  
  814.     STRPTR    aam_HostName;        /* If available, the name
  815.                        assigned to this host will
  816.                        be put here. */
  817.     LONG    aam_HostNameSize;    /* Maximum size of the host
  818.                        name. */
  819.  
  820.     STRPTR    aam_DomainName;        /* If available, the name
  821.                        of the domain assigned to
  822.                        this host will be put here. */
  823.     LONG    aam_DomainNameSize;    /* Maximum size of the domain
  824.                        name. */
  825.     UBYTE *    aam_BOOTPMessage;    /* Points to buffer to place
  826.                        the BOOTP message in. */
  827.     LONG    aam_BOOTPMessageSize;    /* Size of the buffer to place
  828.                        the BOOTP message in. */
  829.     struct DateStamp *
  830.         aam_LeaseExpires;    /* Points to buffer to place the
  831.                        lease expire date and time in.
  832.                        in. This will be 0 if no data
  833.                        is provided or if the lease
  834.                        never expires. */
  835. };
  836.  
  837. /* This data structure version. */
  838. #define AAM_VERSION 1
  839.  
  840. /* Available result codes. */
  841. #define AAMR_Success        0    /* Allocation has succeeded */
  842. #define AAMR_Aborted        1    /* The allocation was aborted */
  843. #define AAMR_InterfaceNotKnown    2    /* The interface name is not
  844.                        known */
  845. #define AAMR_InterfaceWrongType    3    /* The interface must support
  846.                        broadcast access. */
  847. #define AAMR_AddressKnown    4    /* The interface address is already
  848.                        known. */
  849. #define AAMR_VersionUnknown    5    /* The data structure version is
  850.                        not supported. */
  851. #define AAMR_NoMemory        6    /* Not enough memory to process
  852.                        the request. */
  853. #define AAMR_Timeout        7    /* The allocation request did not
  854.                        succeed in the requested time
  855.                        span. */
  856. #define AAMR_AddressInUse    8    /* The address to be allocated is
  857.                        already in use. */
  858. #define AAMR_AddrChangeFailed    9    /* The interface address could
  859.                        not be changed. */
  860. #define AAMR_MaskChangeFailed    10    /* The interface subnet mask could
  861.                        not be changed. */
  862. #define AAMR_Ignored        -1    /* The message type was not
  863.                        understood */
  864.  
  865. /* The minimum timeout value supported for an allocation to succeed. */
  866. #define AAM_TIMEOUT_MIN 10
  867.  
  868. /* The special DHCP lease times. */
  869. #define DHCP_DEFAULT_LEASE_TIME        0
  870. #define DHCP_INFINITE_LEASE_TIME    0xFFFFFFFF
  871.  
  872. /* The configuration protocols to use. */
  873. #define AAMP_BOOTP    0    /* Bootstrap Protocol (RFC 951) */
  874. #define AAMP_DHCP    1    /* Dynamic Host Configuration Protocol
  875.                    (RFC 2131) */
  876. #define AAMP_SLOWAUTO    2    /* Automatic address allocation; slower
  877.                    version for Ethernet networks with
  878.                    switches which use the IEEE Spanning
  879.                    Tree Protocol (802.1d) */
  880. #define AAMP_FASTAUTO    3    /* Automatic address allocation; faster
  881.                    version for wireless devices */
  882.  
  883. /* Tags for use with CreateAddressAllocationMessage(). */
  884. #define CAAMTA_BASE (TAG_USER+2000)
  885.  
  886. /* This corresponds to the 'aam_Timeout' member of the
  887.  * AddressAllocationMessage.
  888.  */
  889. #define CAAMTA_Timeout            (CAAMTA_BASE+1)
  890.  
  891. /* This corresponds to the 'aam_LeaseTime' member of the
  892.  * AddressAllocationMessage.
  893.  */
  894. #define CAAMTA_LeaseTime        (CAAMTA_BASE+2)
  895.  
  896. /* This corresponds to the 'aam_RequestedAddress' member of the
  897.  * AddressAllocationMessage.
  898.  */
  899. #define CAAMTA_RequestedAddress        (CAAMTA_BASE+3)
  900.  
  901. /* Pointer to the client identifier string to be used; this
  902.  * string must be at least 2 characters long. The string will
  903.  * be duplicated and stored in the 'aam_ClientIdentifier' member
  904.  * of the AddressAllocationMessage.
  905.  */
  906. #define CAAMTA_ClientIdentifier        (CAAMTA_BASE+4)
  907.  
  908. /* Size of the buffer to allocate for the NAK message, as
  909.  * stored in the 'aam_NAKMessage' member of the AddressAllocationMessage.
  910.  */
  911. #define CAAMTA_NAKMessageSize        (CAAMTA_BASE+5)
  912.  
  913. /* Size of the buffer to allocate for the router address table, as
  914.  * stored in the 'aam_RouterTable' member of the
  915.  * AddressAllocationMessage.
  916.  */
  917. #define CAAMTA_RouterTableSize        (CAAMTA_BASE+6)
  918.  
  919. /* Size of the buffer to allocate for the DNS address table, as
  920.  * stored in the 'aam_DNSTable' member of the AddressAllocationMessage.
  921.  */
  922. #define CAAMTA_DNSTableSize        (CAAMTA_BASE+7)
  923.  
  924. /* Size of the buffer to allocate for the static route address table, as
  925.  * stored in the 'aam_StaticRouteTable' member of the
  926.  * AddressAllocationMessage.
  927.  */
  928. #define CAAMTA_StaticRouteTableSize    (CAAMTA_BASE+8)
  929.  
  930. /* Size of the buffer to allocate for the host name, as stored in
  931.  * the 'aam_HostName' member of the AddressAllocationMessage.
  932.  */
  933. #define CAAMTA_HostNameSize        (CAAMTA_BASE+9)
  934.  
  935. /* Size of the buffer to allocate for the domain name, as stored in
  936.  * the 'aam_DomainName' member of the AddressAllocationMessage.
  937.  */
  938. #define CAAMTA_DomainNameSize        (CAAMTA_BASE+10)
  939.  
  940. /* Size of the buffer to allocate for the BOOTP message, as stored in
  941.  * the 'aam_BOOTPMessage' member of the AddressAllocationMessage.
  942.  */
  943. #define CAAMTA_BOOTPMessageSize        (CAAMTA_BASE+11)
  944.  
  945. /* Either FALSE or TRUE; if TRUE, will allocate a buffer for a
  946.  * DateStamp and put its address into the 'aam_LeaseExpires'
  947.  * member of the AddressAllocationMessage.
  948.  */
  949. #define CAAMTA_RecordLeaseExpiration    (CAAMTA_BASE+12)
  950.  
  951. /* The MsgPort to send the AddressAllocationMessage to after
  952.  * the configuration has finished.
  953.  */
  954. #define CAAMTA_ReplyPort        (CAAMTA_BASE+13)
  955.  
  956. /* Codes returned by CreateAddressAllocationMessage(). */
  957. #define CAAME_Success            0    /* It worked */
  958. #define CAAME_Invalid_result_ptr    1    /* No proper result pointer
  959.                            provided */
  960. #define CAAME_Not_enough_memory        2    /* No enough memory available */
  961. #define CAAME_Invalid_version        3    /* The version number is not
  962.                            in order */
  963. #define CAAME_Invalid_protocol        4    /* The protocol is neither BOOTP
  964.                            nor DHCP */
  965. #define CAAME_Invalid_interface_name    5    /* The interface name is
  966.                            not OK */
  967. #define CAAME_Interface_not_found    6    /* The name of the interface
  968.                            is not known */
  969. #define CAAME_Invalid_client_identifier    7    /* The client identifier is not
  970.                            OK */
  971. #define CAAME_Client_identifier_too_short 8    /* The client identifier is too
  972.                            short */
  973. #define CAAME_Client_identifier_too_long 9    /* The client identifier is too
  974.                            long */
  975.  
  976. /****************************************************************************/
  977.  
  978. /*
  979.  * The DNS management data structures.
  980.  */
  981.  
  982. /* These nodes are returned by the DNS API. */
  983. struct DomainNameServerNode
  984. {
  985.     struct MinNode
  986.         dnsn_MinNode;
  987.     LONG    dnsn_Size;    /* Size of this data structure */
  988.     STRPTR    dnsn_Address;    /* Points to NUL-terminated string
  989.                    which holds the IP address in
  990.                    dotted-decimal notation */
  991.     LONG    dnsn_UseCount;    /* Usage count of this address;
  992.                    negative values indicate
  993.                    statically-configured servers. */
  994. };
  995.  
  996. /****************************************************************************/
  997.  
  998. /*
  999.  * Filtering for incoming and outgoing IP packets.
  1000.  */
  1001.  
  1002. /* This identifies whether a packet was received or is about
  1003.  * to be sent. Check the IPFilterMsg->ifm_Direction field to
  1004.  * find out.
  1005.  */
  1006. #define IFMD_Incoming 0    /* Packet was received */
  1007. #define IFMD_Outgoing 1    /* Packet is about to be sent */
  1008.  
  1009. /* The packet filter hook is invoked with a message of
  1010.  * this type:
  1011.  */
  1012. struct IPFilterMsg
  1013. {
  1014.     LONG        ifm_Size;    /* Size of this data
  1015.                        structure */
  1016.     struct ip *    ifm_IP;        /* Points to IP packet header */
  1017.     LONG        ifm_IPLength;    /* Size of the IP packet header */
  1018.     struct ifnet *    ifm_Interface;    /* Interface this packet either
  1019.                        came in from or is to be
  1020.                        sent to */
  1021.     LONG        ifm_Direction;    /* Whether this packet came in
  1022.                        or is about to go out */
  1023.     struct mbuf *    ifm_Packet;    /* The entire packet, as stored
  1024.                        in a memory buffer */
  1025. };
  1026.  
  1027. /****************************************************************************/
  1028.  
  1029. #endif /* _LIBRARIES_BSDSOCKET_H */
  1030.