Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / workbench / network / stacks / AROSTCP / netinclude / libraries / bsdsocket.h
blob270fa9b019f3419d4c763963de41ad221fb65507
1 #ifndef _LIBRARIES_BSDSOCKET_H
2 #define _LIBRARIES_BSDSOCKET_H
4 /*
5 * $Id$
7 * :ts=8
9 * Copyright © 2006 by Pavel Fedin
11 * Taken from 'Roadshow' -- Amiga TCP/IP stack
12 * Copyright © 2001-2004 by Olaf Barthel.
13 * All Rights Reserved.
15 * Amiga specific TCP/IP 'C' header files;
16 * Freely Distributable
19 /****************************************************************************/
21 #ifndef EXEC_PORTS_H
22 #include <exec/ports.h>
23 #endif /* EXEC_PORTS_H */
25 #ifndef UTILITY_TAGITEM_H
26 #include <utility/tagitem.h>
27 #endif /* UTILITY_TAGITEM_H */
29 #ifndef DOS_H
30 #include <dos/dos.h>
31 #endif /* DOS_H */
33 #include <bsdsocket/socketbasetags.h>
35 /****************************************************************************/
37 #ifndef _SYS_SOCKET_H_
38 #include <sys/socket.h>
39 #endif /* _SYS_SOCKET_H_ */
41 #ifndef _NETINET_IN_H_
42 #include <netinet/in.h>
43 #endif /* _NETINET_IN_H_ */
45 #ifndef _NET_IF_H_
46 #include <net/if.h>
47 #endif /* _NET_IF_H_ */
49 #ifndef _SYS_MBUF_H_
50 #include <sys/mbuf.h>
51 #endif /* _SYS_MBUF_H_ */
53 /****************************************************************************/
55 #ifdef __cplusplus
56 extern "C" {
57 #endif /* __cplusplus */
59 /****************************************************************************/
61 #ifdef __GNUC__
62 #ifdef __PPC__
63 #pragma pack(2)
64 #endif
65 #elif defined(__VBCC__)
66 #pragma amiga-align
67 #endif
69 /****************************************************************************/
72 * Additional parameters for SocketBaseTagList().
73 * Standard bsdsocket.library v4 tags are placed in amitcp/socketbasetags.h
76 /* Number of Berkeley packet filter channels available. */
77 #define SBTC_NUM_PACKET_FILTER_CHANNELS 40
79 /* Whether or not the routing API is supported. */
80 #define SBTC_HAVE_ROUTING_API 41
82 /* Enable/Disable UDP checksums? */
83 #define SBTC_UDP_CHECKSUM 42
85 /* Enable/Disable IP packet forwarding? */
86 #define SBTC_IP_FORWARDING 43
88 /* Get/set the default IP packet TTL value. */
89 #define SBTC_IP_DEFAULT_TTL 44
91 /* Respond to ICMP mask requests? */
92 #define SBTC_ICMP_MASK_REPLY 45
94 /* Enable/Disable sending of redirection messages? */
95 #define SBTC_ICMP_SEND_REDIRECTS 46
97 /* Whether or not the interface API is supported. */
98 #define SBTC_HAVE_INTERFACE_API 47
100 /* How ICMP echo messages should be processed. */
101 #define SBTC_ICMP_PROCESS_ECHO 48
103 /* How ICMP time stamp messages should be processed. */
104 #define SBTC_ICMP_PROCESS_TSTAMP 49
106 /* Whether or not the monitoring API is supported. */
107 #define SBTC_HAVE_MONITORING_API 50
109 /* Whether or not library bases can be shared by different
110 callers. */
111 #define SBTC_CAN_SHARE_LIBRARY_BASES 51
113 /* Set the name of the log output file or get a pointer
114 to the current file name. */
115 #define SBTC_LOG_FILE_NAME 52
117 /* Whether or not the status API is supported. */
118 #define SBTC_HAVE_STATUS_API 53
120 /* Whether or not the DNS API is supported. */
121 #define SBTC_HAVE_DNS_API 54
123 /* Set or get a pointer to the currently installed log hook. */
124 #define SBTC_LOG_HOOK 55
126 /* Get the system status, with regard to whether the TCP/IP stack
127 has access to network interfaces and name resolution servers. */
128 #define SBTC_SYSTEM_STATUS 56
130 /* Get or set the signal mask used to send a notification when
131 the address of an interface has changed. */
132 #define SBTC_SIG_ADDRESS_CHANGE_MASK 57
134 /* If the IP filter API is supported, which version of that API
135 would it be? */
136 #define SBTC_IPF_API_VERSION 58
138 /* Whether or not the local database access API is supported. */
139 #define SBTC_HAVE_LOCAL_DATABASE_API 59
141 /* Whether or not the address conversion API is supported. */
142 #define SBTC_HAVE_ADDRESS_CONVERSION_API 60
144 /* Whether or not the kernel memory API is supported. */
145 #define SBTC_HAVE_KERNEL_MEMORY_API 61
147 /* Get or set the IP filter hook which is invoked whenever a
148 datagram has arrived or is about to be sent. */
149 #define SBTC_IP_FILTER_HOOK 62
151 /* Whether or not the server API is supported. */
152 #define SBTC_HAVE_SERVER_API 63
154 /* Query the number of bytes received so far. */
155 #define SBTC_GET_BYTES_RECEIVED 64
157 /* Query the number of bytes sent so far. */
158 #define SBTC_GET_BYTES_SENT 65
160 /****************************************************************************/
163 * Flags returned by a SocketBaseTagList() 'SBTC_SYSTEM_STATUS' query.
166 #define SBSYSSTAT_Interfaces (1L<<0) /* Interfaces are available,
167 configured and
168 operational. */
169 #define SBSYSSTAT_PTP_Interfaces (1L<<1) /* Point-to-point interfaces
170 are available, configured
171 and operational. */
172 #define SBSYSSTAT_BCast_Interfaces (1L<<2) /* Broadcast interfaces are
173 available, configured and
174 operational. */
175 #define SBSYSSTAT_Resolver (1L<<3) /* Domain name servers are
176 known and available */
177 #define SBSYSSTAT_Routes (1L<<4) /* Routing information is
178 configured */
179 #define SBSYSSTAT_DefaultRoute (1L<<5) /* A default route is
180 configured */
182 /****************************************************************************/
185 * Data structures for use with the log hook.
188 struct LogHookMessage
190 LONG lhm_Size; /* Size of this data structure in bytes. */
191 LONG lhm_Priority; /* Log entry priority (LOG_EMERG..LOG_DEBUG) */
192 struct DateStamp
193 lhm_Date; /* Time and date when this log entry was
194 added. */
195 STRPTR lhm_Tag; /* Name of the facility which added this entry;
196 this can be NULL. */
197 ULONG lhm_ID; /* ID of the facility which added this entry;
198 this can be zero. */
199 STRPTR lhm_Message; /* NUL-terminated string which contains the
200 log message to be displayed. */
203 /****************************************************************************/
206 * Options for configuring how ICMP echo and time stamp
207 * requests should be processed.
209 #define IR_Process 0 /* Process the request and respond to it */
210 #define IR_Ignore 1 /* Ignore the request, but feed it into the
211 raw IP packet processing framework */
212 #define IR_Drop 2 /* Ignore the request and treat it as if
213 it had a checksum error */
215 /****************************************************************************/
218 * For use with ReleaseSocket() and ReleaseCopyOfSocket().
221 #define UNIQUE_ID (-1)
223 /****************************************************************************/
226 * Tags for use with the routing API.
229 #define RTA_BASE (TAG_USER+1600)
231 #define RTA_Destination (RTA_BASE+1) /* Route destination
232 address */
233 #define RTA_Gateway (RTA_BASE+2) /* Gateway address */
234 #define RTA_DefaultGateway (RTA_BASE+3) /* Default gateway address */
235 #define RTA_DestinationHost (RTA_BASE+4) /* Route destination
236 address; destination is
237 assumed to be a host and
238 not a network */
239 #define RTA_DestinationNet (RTA_BASE+5) /* Route destination
240 address; destination is
241 assumed to be a network
242 and not a host */
244 /****************************************************************************/
247 * Tags for use with the interface management API,
248 * specifically the AddInterfaceTagList() call.
250 #define IFA_BASE (TAG_USER+1700)
252 #define IFA_IPType (IFA_BASE+1) /* IP packet type */
253 #define IFA_ARPType (IFA_BASE+2) /* ARP packet type */
254 #define IFA_NumReadRequests (IFA_BASE+3) /* Number of read requests
255 to queue */
256 #define IFA_NumWriteRequests (IFA_BASE+4) /* Number of write requests
257 to queue */
258 #define IFA_NumARPRequests (IFA_BASE+5) /* Number of ARP requests
259 to queue */
260 #define IFA_PacketFilterMode (IFA_BASE+6) /* Operating mode of the
261 Berkeley packet filter */
262 #define IFA_PointToPoint (IFA_BASE+7) /* Whether or not this
263 interface is of the
264 point-to-point type */
265 #define IFA_Reserved0 (IFA_BASE+8) /* This tag is reserved for
266 future use */
267 #define IFA_Multicast (IFA_BASE+9) /* Whether or not this
268 interface is allowed to
269 send multicast packets */
270 #define IFA_DownGoesOffline (IFA_BASE+10) /* Whether or not this
271 interface will go offline
272 when it is taken down */
273 #define IFA_ReportOffline (IFA_BASE+11) /* Whether or not this
274 interface will cause a
275 notification message to
276 be logged when it goes
277 offline */
278 #define IFA_RequiresInitDelay (IFA_BASE+12) /* Whether or not this
279 interface requires a short
280 delay to precede the
281 device initialization */
282 #define IFA_CopyMode (IFA_BASE+13) /* Special data copy options
283 for this interface */
284 #define IFA_HardwareAddress (IFA_BASE+14) /* Set the interface hardware
285 address to a certain
286 value. */
287 #define IFA_SetDebugMode (IFA_BASE+15) /* Enable or disable debugging
288 mode for this interface. */
290 /****************************************************************************/
292 /* This is used with the 'IFA_HardwareAddress' tag above. */
293 struct InterfaceHardwareAddress
295 LONG iha_Length; /* Number of bits in address */
296 UBYTE * iha_Address; /* Points to first address byte */
299 /****************************************************************************/
302 * Options available for use with the IFA_PacketFilterMode tag.
304 #define PFM_Nothing 0 /* Filter is disabled for this interface. */
305 #define PFM_Local 1 /* Filter is enabled; only packets intended
306 for this interface are filtered */
307 #define PFM_IPandARP 2 /* Filter is enabled; all IP and ARP packets
308 are filtered, even if they are not intended
309 for this interface */
310 #define PFM_Everything 3 /* Filter is enabled; all packets are filtered
311 that pass by, regardless of their type and
312 contents */
314 /****************************************************************************/
317 * Options available for use with the IFA_CopyMode tag.
319 #define CM_SlowWordCopy 0 /* Disables the S2_CopyFromBuff16 SANA-II
320 buffer management option (default). */
321 #define CM_FastWordCopy 1 /* Enables the S2_CopyFromBuff16 SANA-II
322 buffer management option. */
324 /****************************************************************************/
327 * Tags for use with the interface management API,
328 * specifically the ConfigureInterfaceTagList() call.
330 #define IFC_BASE (TAG_USER+1800)
332 #define IFC_Address (IFC_BASE+1) /* The address to assign to
333 the interface itself */
334 #define IFC_NetMask (IFC_BASE+2) /* The interface's address
335 net mask */
336 #define IFC_DestinationAddress (IFC_BASE+3) /* The address of the other
337 end of a point-to-point
338 link */
339 #define IFC_BroadcastAddress (IFC_BASE+4) /* The broadcast address to
340 be used by the interface */
341 #define IFC_Metric (IFC_BASE+5) /* The routing metric value */
343 #define IFC_AddAliasAddress (IFC_BASE+6) /* Add another alias address
344 for this interface */
345 #define IFC_DeleteAliasAddress (IFC_BASE+7) /* Remove an alias address
346 for this interface */
347 #define IFC_State (IFC_BASE+8) /* Mark an interface up, down,
348 online or offline */
349 #define IFC_GetPeerAddress (IFC_BASE+9) /* If available, obtain the
350 interface's local address
351 and the address of its
352 point to point partner */
353 #define IFC_GetDNS (IFC_BASE+10) /* If available, obtain the
354 domain name servers known
355 to this interface */
356 #define IFC_AssociatedRoute (IFC_BASE+12) /* That interface is associated
357 with a route. */
358 #define IFC_AssociatedDNS (IFC_BASE+13) /* That interface is associated
359 with a DNS. */
360 #define IFC_ReleaseAddress (IFC_BASE+14) /* Release the address allocated
361 for this interface (via the
362 DHCP protocol). */
363 #define IFC_SetDebugMode (IFC_BASE+15) /* Enable or disable debugging
364 mode for this interface. */
365 #define IFC_Complete (IFC_BASE+16) /* Indicate that the configuration
366 for this interface is complete */
368 /****************************************************************************/
371 * Tags for use with the interface management API,
372 * specifically the QueryInterfaceTagList() call.
374 #define IFQ_BASE (TAG_USER+1900)
376 #define IFQ_DeviceName (IFQ_BASE+1) /* Query the associated
377 SANA-II device name */
378 #define IFQ_DeviceUnit (IFQ_BASE+2) /* Query the associated
379 SANA-II unit number */
380 #define IFQ_HardwareAddressSize (IFQ_BASE+3) /* Query the hardware address
381 size (in bytes) */
382 #define IFQ_HardwareAddress (IFQ_BASE+4) /* Query the hardware
383 address */
384 #define IFQ_MTU (IFQ_BASE+5) /* Query the maximum
385 transmission unit */
386 #define IFQ_BPS (IFQ_BASE+6) /* Query the transmission
387 speed */
388 #define IFQ_HardwareType (IFQ_BASE+7) /* Query the SANA-II hardware
389 type */
390 #define IFQ_PacketsReceived (IFQ_BASE+8) /* Query the number of
391 packets received by this
392 interface */
393 #define IFQ_PacketsSent (IFQ_BASE+9) /* Query the number of
394 packets sent by this
395 interface */
396 #define IFQ_BadData (IFQ_BASE+10) /* Query the number of bad
397 packets dropped by this
398 interface */
399 #define IFQ_Overruns (IFQ_BASE+11) /* Query the number of buffer
400 overruns */
401 #define IFQ_UnknownTypes (IFQ_BASE+12) /* Query the number of unknown
402 packet types dropped by this
403 interface */
404 #define IFQ_LastStart (IFQ_BASE+13) /* Query the last time the
405 interface went online */
406 #define IFQ_Address (IFQ_BASE+14) /* Query the IP address
407 associated with this
408 interface */
409 #define IFQ_DestinationAddress (IFQ_BASE+15) /* Query the interface's
410 destination address */
411 #define IFQ_BroadcastAddress (IFQ_BASE+16) /* Query the interface's
412 broadcast address */
413 #define IFQ_NetMask (IFQ_BASE+17) /* Query the interface's
414 subnet mask */
415 #define IFQ_Metric (IFQ_BASE+18) /* Query the interface's
416 metric value */
417 #define IFQ_State (IFQ_BASE+19) /* Query the interface's
418 status */
419 #define IFQ_AddressBindType (IFQ_BASE+20) /* Query whether the address
420 bound to this interface
421 is statically, manually
422 or dynamically bound. */
423 #define IFQ_AddressLeaseExpires (IFQ_BASE+21) /* Find out whether and when
424 the address bound to this
425 interface expires. */
426 #define IFQ_PrimaryDNSAddress (IFQ_BASE+22) /* Query the primary domain
427 name server address known
428 to this interface */
429 #define IFQ_SecondaryDNSAddress (IFQ_BASE+23) /* Query the secondary domain
430 name server address known
431 to this interface */
432 #define IFQ_NumReadRequests (IFQ_BASE+24) /* Number of read I/O requests
433 allocated for this
434 interface */
435 #define IFQ_MaxReadRequests (IFQ_BASE+25) /* Maximum number of read I/O
436 requests in use at a time
437 on this interface */
438 #define IFQ_NumWriteRequests (IFQ_BASE+26) /* Number of write I/O requests
439 allocated for this
440 interface */
441 #define IFQ_MaxWriteRequests (IFQ_BASE+27) /* Maximum number of write I/O
442 requests in use at a time
443 on this interface */
444 #define IFQ_GetBytesIn (IFQ_BASE+28) /* Query the number of bytes
445 received */
446 #define IFQ_GetBytesOut (IFQ_BASE+29) /* Query the number of bytes
447 sent */
448 #define IFQ_GetDebugMode (IFQ_BASE+30) /* Check if this interface has
449 the debug mode enabled */
450 #define IFQ_GetSANA2CopyStats (IFQ_BASE+31) /* Obtain the SANA-II data
451 copy statistics */
452 #define IFQ_NumReadRequestsPending (IFQ_BASE+32)
453 /* Number of read I/O requests
454 still pending to be
455 satisfied on this
456 interface */
457 #define IFQ_NumWriteRequestsPending (IFQ_BASE+33)
458 /* Number of write I/O requests
459 still pending to be
460 satisfied on this
461 interface */
463 /****************************************************************************/
465 /* This is used with the 'IFQ_GetSANA2CopyStats' tag above. */
466 struct SANA2CopyStats
468 ULONG s2cs_DMAIn; /* How many times data was received via the
469 DMA transfer function */
470 ULONG s2cs_DMAOut; /* How many times data was sent via the
471 DMA transfer function */
473 ULONG s2cs_ByteIn; /* How many times data was received via the
474 byte wide copy function */
475 ULONG s2cs_ByteOut; /* How many times data was sent via the
476 byte wide copy function */
478 ULONG s2cs_WordOut; /* How many times data was sent via the
479 word wide copy function */
482 /****************************************************************************/
484 /* The different types of interface address binding. */
485 #define IFABT_Unknown 0 /* The interface address has not been bound
486 or is in transitional state; check later
487 for more information. */
488 #define IFABT_Static 1 /* The address was assigned manually, or
489 by an automated configuration process
490 and is not expected to change. */
491 #define IFABT_Dynamic 2 /* The address was assigned by an automated
492 configuration process and may change in the
493 future. */
495 /****************************************************************************/
498 * The 64 bit integer value used by the IFQ_GetBytesIn..IFQ_GetResetBytesOut
499 * query tags.
501 typedef struct
503 ULONG sbq_High;
504 ULONG sbq_Low;
505 } SBQUAD_T;
507 /****************************************************************************/
510 * Options available for use with the IFC_State and IFQ_State tags.
512 #define SM_Offline 0 /* Interface is offline and not ready to
513 receive and transmit data */
514 #define SM_Online 1 /* Interface is online and ready to receive
515 and transmit data */
516 #define SM_Down 2 /* Interface is not ready to receive and
517 transmit data, but might still be
518 online. */
519 #define SM_Up 3 /* Interface is ready to receive and transmit
520 data, but not necessarily online. */
522 /****************************************************************************/
525 * Types of monitoring hooks that can be installed.
527 #define MHT_ICMP 0 /* ICMP message monitoring */
528 #define MHT_UDP 1 /* UDP datagram monitoring */
529 #define MHT_TCP_Connect 2 /* TCP connection monitoring */
530 #define MHT_Connect 3 /* connect() call monitoring */
531 #define MHT_Send 4 /* sendto() and sendmsg() monitoring */
532 #define MHT_Packet 5 /* Low level packet monitoring */
533 #define MHT_Bind 6 /* bind() call monitoring */
535 /****************************************************************************/
538 * Parameters passed to the different monitoring hooks.
541 /* This type of message parameter is passed to 'MHT_Connect'
542 * type monitoring hooks.
544 struct ConnectMonitorMsg
546 LONG cmm_Size; /* Size of this data
547 structure */
548 STRPTR cmm_Caller; /* The name of the calling
549 program, if it chose to be
550 identified */
551 LONG cmm_Socket; /* The socket to connect to
552 the address */
553 struct sockaddr *
554 cmm_Name; /* The address to connect
555 to */
556 LONG cmm_NameLen; /* The size of the address */
559 /* This type of message parameter is passed to 'MHT_Bind'
560 * type monitoring hooks.
562 struct BindMonitorMsg
564 LONG bmm_Size; /* Size of this data
565 structure */
566 STRPTR bmm_Caller; /* The name of the calling
567 program, if it chose to be
568 identified */
569 LONG bmm_Socket; /* The socket to bind to the
570 address */
571 struct sockaddr *
572 bmm_Name; /* The address to bind */
573 LONG bmm_NameLen; /* The size of the address */
576 /* This type of message is passed to 'MHT_Send' type monitoring hooks. */
577 struct SendMonitorMessage
579 LONG smm_Size; /* Size of this data structure */
580 STRPTR smm_Caller; /* The name of the calling
581 program, if it chose to be
582 identified */
583 LONG smm_Socket; /* The socket to connect to the
584 address */
585 APTR smm_Buffer; /* Data to be sent */
586 LONG smm_Len; /* Amount of data to be sent */
587 LONG smm_Flags; /* Control flags, including
588 MSG_OOB or MSG_DONTROUTE */
589 struct sockaddr *
590 smm_To; /* The address to send the
591 data to; this may be NULL */
592 LONG smm_ToLen; /* The size of the address to send
593 this data to; this may be
594 NULL */
595 struct msghdr * smm_Msg; /* The message to send; this may
596 be NULL. */
599 /* This type of message is passed to 'MHT_TCP_Connect' type
600 * monitoring hooks.
602 struct TCPConnectMonitorMessage
604 LONG tcmm_Size; /* Size of this data structure */
605 struct in_addr *
606 tcmm_Src; /* Source internet address */
607 struct in_addr *
608 tcmm_Dst; /* Destination internet address */
609 struct tcphdr * tcmm_TCP; /* TCP header */
612 /* This type of message is passed to 'MHT_UDP' type monitoring hooks. */
613 struct UDPMonitorMessage
615 LONG umm_Size; /* Size of this data structure */
616 struct in_addr *
617 umm_Src; /* Source internet address */
618 struct in_addr *
619 umm_Dst; /* Destination internet address */
620 struct udphdr * umm_UDP; /* UDP header */
623 /* This type of message is passed to 'MHT_ICMP' type monitoring hooks. */
624 struct ICMPMonitorMessage
626 LONG imm_Size; /* Size of this data structure */
627 struct in_addr *
628 imm_Src; /* Source internet address */
629 struct in_addr *
630 imm_Dst; /* Destination internet address */
631 struct icmp * imm_ICMP; /* ICMP header */
634 /* This type of message is passed to 'MHT_Packet' type monitoring hooks. */
635 struct PacketMonitorMessage
637 LONG pmm_Size; /* Size of this data structure */
638 LONG pmm_Direction; /* Whether the packet was received
639 or is about to be sent */
640 APTR pmm_LinkLayerData;
641 /* Points to the link layer part
642 of the packet, typically an
643 Ethernet header per RFC 894.
644 This may be NULL. */
645 LONG pmm_LinkLayerSize;
646 /* Size of the link layer data part
647 of the packet; this may be 0. */
648 APTR pmm_PacketData; /* Points to the packet 'payload'. */
649 LONG pmm_PacketSize; /* Size of the packet 'payload'. */
652 /* Possible values for 'pmm_Direction'. */
653 #define PMMD_Receive 0 /* Packet was received and is waiting to be
654 processed */
655 #define PMMD_Send 1 /* Packet is about to be sent */
657 /****************************************************************************/
660 * Possible actions to be taken after a monitoring hook has
661 * examined the data it was passed. Any positive return value
662 * will cause the data to be dropped and the corresponding
663 * errno value to be set to the result.
665 #define MA_Continue 0 /* Proceed as if no filtering had
666 taken place */
667 #define MA_Ignore -1 /* Ignore the data and skip the
668 normal route processing would
669 take */
670 #define MA_Drop -2 /* Drop the data */
671 #define MA_DropWithReset -3 /* Drop the data and also reset the
672 connection */
674 /****************************************************************************/
677 * Parameters for use with the GetNetworkStatus() function.
680 /* What version of the statistics data should be returned; so far
681 there is only version #1. */
682 #define NETWORKSTATUS_VERSION 1
684 /* What statistics should be provided */
686 #define NETSTATUS_icmp 0 /* Internet control message
687 protocol statistics */
688 #define NETSTATUS_igmp 1 /* Internet group management
689 protocol statistics */
690 #define NETSTATUS_ip 2 /* Internet protocol statistics */
691 #define NETSTATUS_mb 3 /* Memory buffer statistics */
692 #define NETSTATUS_mrt 4 /* Multicast routing statistics */
693 #define NETSTATUS_rt 5 /* Routing statistics */
694 #define NETSTATUS_tcp 6 /* Transmission control protocol
695 statistics */
696 #define NETSTATUS_udp 7 /* User datagram protocol
697 statistics */
698 #define NETSTATUS_tcp_sockets 9 /* TCP socket statistics */
699 #define NETSTATUS_udp_sockets 10 /* UDP socket statistics */
701 /* Protocol connection data returned for each TCP/UDP socket. */
702 struct protocol_connection_data
704 struct in_addr
705 pcd_foreign_address; /* Foreign host address */
706 UWORD pcd_foreign_port; /* Foreign port number */
707 struct in_addr
708 pcd_local_address; /* Local host address */
709 UWORD pcd_local_port; /* Local port number */
710 ULONG pcd_receive_queue_size; /* Socket receive queue size */
711 ULONG pcd_send_queue_size; /* Socket send queue size */
712 LONG pcd_tcp_state; /* Socket TCP state */
715 /****************************************************************************/
718 * Interface address allocation (BOOTP and DHCP).
721 /* The message to send to the interface configuration process
722 to start looking for an IP address. */
723 struct AddressAllocationMessage
725 struct Message
726 aam_Message;
727 LONG aam_Reserved;
728 LONG aam_Result; /* What kind of result this
729 request produced. */
730 LONG aam_Version; /* Version number associated with
731 this data structure. */
732 LONG aam_Protocol; /* What kind of configuration
733 protocol should be used. */
734 char aam_InterfaceName[16]; /* Name of interface an
735 address is to be
736 assigned to. */
737 LONG aam_Timeout; /* Number of seconds to
738 wait before a result
739 materializes. */
740 ULONG aam_LeaseTime; /* Requested lease time in
741 seconds; 0 to accept the
742 default. */
743 ULONG aam_RequestedAddress; /* Interface address that should
744 be assigned, if possible; 0
745 to accept the server's choice. */
746 STRPTR aam_ClientIdentifier; /* Unique identifier for this
747 host */
748 ULONG aam_Address; /* Interface address
749 returned upon
750 success. */
751 ULONG aam_ServerAddress; /* Address of BOOTP server. */
752 ULONG aam_SubnetMask; /* Interface subnet
753 mask; ignore if zero. */
755 STRPTR aam_NAKMessage; /* In case of failure,
756 put the explanation
757 text here. */
758 LONG aam_NAKMessageSize; /* Maximum length of the
759 negative ack message. */
761 ULONG * aam_RouterTable; /* A list of router addresses
762 will be put here. */
763 LONG aam_RouterTableSize; /* Maximum number of valid
764 router addresses. */
766 ULONG * aam_DNSTable; /* A list of domain name servers
767 will be put here. */
768 LONG aam_DNSTableSize; /* Maximum number of valid
769 domain name server
770 addresses. */
772 ULONG * aam_StaticRouteTable; /* A list of static routes
773 will be put here. */
774 LONG aam_StaticRouteTableSize;
775 /* Maximum number of valid
776 static routes. */
778 STRPTR aam_HostName; /* If available, the name
779 assigned to this host will
780 be put here. */
781 LONG aam_HostNameSize; /* Maximum size of the host
782 name. */
784 STRPTR aam_DomainName; /* If available, the name
785 of the domain assigned to
786 this host will be put here. */
787 LONG aam_DomainNameSize; /* Maximum size of the domain
788 name. */
789 UBYTE * aam_BOOTPMessage; /* Points to buffer to place
790 the BOOTP message in. */
791 LONG aam_BOOTPMessageSize; /* Size of the buffer to place
792 the BOOTP message in. */
793 struct DateStamp *
794 aam_LeaseExpires; /* Points to buffer to place the
795 lease expire date and time in.
796 in. This will be 0 if no data
797 is provided or if the lease
798 never expires. */
801 /* This data structure version. */
802 #define AAM_VERSION 1
804 /* Available result codes. */
805 #define AAMR_Success 0 /* Allocation has succeeded */
806 #define AAMR_Aborted 1 /* The allocation was aborted */
807 #define AAMR_InterfaceNotKnown 2 /* The interface name is not
808 known */
809 #define AAMR_InterfaceWrongType 3 /* The interface must support
810 broadcast access. */
811 #define AAMR_AddressKnown 4 /* The interface address is already
812 known. */
813 #define AAMR_VersionUnknown 5 /* The data structure version is
814 not supported. */
815 #define AAMR_NoMemory 6 /* Not enough memory to process
816 the request. */
817 #define AAMR_Timeout 7 /* The allocation request did not
818 succeed in the requested time
819 span. */
820 #define AAMR_AddressInUse 8 /* The address to be allocated is
821 already in use. */
822 #define AAMR_AddrChangeFailed 9 /* The interface address could
823 not be changed. */
824 #define AAMR_MaskChangeFailed 10 /* The interface subnet mask could
825 not be changed. */
826 #define AAMR_Ignored -1 /* The message type was not
827 understood */
829 /* The minimum timeout value supported for an allocation to succeed. */
830 #define AAM_TIMEOUT_MIN 10
832 /* The special DHCP lease times. */
833 #define DHCP_DEFAULT_LEASE_TIME 0
834 #define DHCP_INFINITE_LEASE_TIME 0xFFFFFFFF
836 /* The configuration protocols to use. */
837 #define AAMP_BOOTP 0 /* Bootstrap Protocol (RFC 951) */
838 #define AAMP_DHCP 1 /* Dynamic Host Configuration Protocol
839 (RFC 2131) */
840 #define AAMP_SLOWAUTO 2 /* Automatic address allocation; slower
841 version for Ethernet networks with
842 switches which use the IEEE Spanning
843 Tree Protocol (802.1d) */
844 #define AAMP_FASTAUTO 3 /* Automatic address allocation; faster
845 version for wireless devices */
847 /* Tags for use with CreateAddressAllocationMessage(). */
848 #define CAAMTA_BASE (TAG_USER+2000)
850 /* This corresponds to the 'aam_Timeout' member of the
851 * AddressAllocationMessage.
853 #define CAAMTA_Timeout (CAAMTA_BASE+1)
855 /* This corresponds to the 'aam_LeaseTime' member of the
856 * AddressAllocationMessage.
858 #define CAAMTA_LeaseTime (CAAMTA_BASE+2)
860 /* This corresponds to the 'aam_RequestedAddress' member of the
861 * AddressAllocationMessage.
863 #define CAAMTA_RequestedAddress (CAAMTA_BASE+3)
865 /* Pointer to the client identifier string to be used; this
866 * string must be at least 2 characters long. The string will
867 * be duplicated and stored in the 'aam_ClientIdentifier' member
868 * of the AddressAllocationMessage.
870 #define CAAMTA_ClientIdentifier (CAAMTA_BASE+4)
872 /* Size of the buffer to allocate for the NAK message, as
873 * stored in the 'aam_NAKMessage' member of the AddressAllocationMessage.
875 #define CAAMTA_NAKMessageSize (CAAMTA_BASE+5)
877 /* Size of the buffer to allocate for the router address table, as
878 * stored in the 'aam_RouterTable' member of the
879 * AddressAllocationMessage.
881 #define CAAMTA_RouterTableSize (CAAMTA_BASE+6)
883 /* Size of the buffer to allocate for the DNS address table, as
884 * stored in the 'aam_DNSTable' member of the AddressAllocationMessage.
886 #define CAAMTA_DNSTableSize (CAAMTA_BASE+7)
888 /* Size of the buffer to allocate for the static route address table, as
889 * stored in the 'aam_StaticRouteTable' member of the
890 * AddressAllocationMessage.
892 #define CAAMTA_StaticRouteTableSize (CAAMTA_BASE+8)
894 /* Size of the buffer to allocate for the host name, as stored in
895 * the 'aam_HostName' member of the AddressAllocationMessage.
897 #define CAAMTA_HostNameSize (CAAMTA_BASE+9)
899 /* Size of the buffer to allocate for the domain name, as stored in
900 * the 'aam_DomainName' member of the AddressAllocationMessage.
902 #define CAAMTA_DomainNameSize (CAAMTA_BASE+10)
904 /* Size of the buffer to allocate for the BOOTP message, as stored in
905 * the 'aam_BOOTPMessage' member of the AddressAllocationMessage.
907 #define CAAMTA_BOOTPMessageSize (CAAMTA_BASE+11)
909 /* Either FALSE or TRUE; if TRUE, will allocate a buffer for a
910 * DateStamp and put its address into the 'aam_LeaseExpires'
911 * member of the AddressAllocationMessage.
913 #define CAAMTA_RecordLeaseExpiration (CAAMTA_BASE+12)
915 /* The MsgPort to send the AddressAllocationMessage to after
916 * the configuration has finished.
918 #define CAAMTA_ReplyPort (CAAMTA_BASE+13)
920 /* Codes returned by CreateAddressAllocationMessage(). */
921 #define CAAME_Success 0 /* It worked */
922 #define CAAME_Invalid_result_ptr 1 /* No proper result pointer
923 provided */
924 #define CAAME_Not_enough_memory 2 /* No enough memory available */
925 #define CAAME_Invalid_version 3 /* The version number is not
926 in order */
927 #define CAAME_Invalid_protocol 4 /* The protocol is neither BOOTP
928 nor DHCP */
929 #define CAAME_Invalid_interface_name 5 /* The interface name is
930 not OK */
931 #define CAAME_Interface_not_found 6 /* The name of the interface
932 is not known */
933 #define CAAME_Invalid_client_identifier 7 /* The client identifier is not
934 OK */
935 #define CAAME_Client_identifier_too_short 8 /* The client identifier is too
936 short */
937 #define CAAME_Client_identifier_too_long 9 /* The client identifier is too
938 long */
940 /****************************************************************************/
943 * The DNS management data structures.
946 /* These nodes are returned by the DNS API. */
947 struct DomainNameServerNode
949 struct MinNode
950 dnsn_MinNode;
951 LONG dnsn_Size; /* Size of this data structure */
952 STRPTR dnsn_Address; /* Points to NUL-terminated string
953 which holds the IP address in
954 dotted-decimal notation */
955 LONG dnsn_UseCount; /* Usage count of this address;
956 negative values indicate
957 statically-configured servers. */
960 /****************************************************************************/
963 * Filtering for incoming and outgoing IP packets.
966 /* This identifies whether a packet was received or is about
967 * to be sent. Check the IPFilterMsg->ifm_Direction field to
968 * find out.
970 #define IFMD_Incoming 0 /* Packet was received */
971 #define IFMD_Outgoing 1 /* Packet is about to be sent */
973 /* The packet filter hook is invoked with a message of
974 * this type:
976 struct IPFilterMsg
978 LONG ifm_Size; /* Size of this data structure */
979 struct ip * ifm_IP; /* Points to IP packet header */
980 LONG ifm_IPLength; /* Size of the IP packet header */
981 struct ifnet * ifm_Interface; /* Interface this packet either
982 came in from or is to be
983 sent to */
984 LONG ifm_Direction; /* Whether this packet came in
985 or is about to go out */
986 struct mbuf * ifm_Packet; /* The entire packet, as stored
987 in a memory buffer */
990 /****************************************************************************/
993 * Network shutdown
996 /* To shut down the network, send a message of the following form to the
997 * network controller message port.
999 struct NetShutdownMessage
1001 struct Message nsm_Message; /* Standard Message header */
1003 ULONG nsm_Command; /* The action to be performed */
1005 APTR nsm_Data; /* Payload */
1006 ULONG nsm_Length; /* Payload size */
1008 LONG nsm_Error; /* Whether or not the command
1009 suceeded */
1010 ULONG nsm_Actual; /* How much data was transferred */
1013 /* The command to be sent to the network controller message port must
1014 * be one of the following:
1017 #define NSMC_Shutdown 1 /* Shut down the network; a pointer to an
1018 ULONG may be placed in nsm_Data (if the
1019 shutdown does not succeed, this is where
1020 the number of active clients will be
1021 placed). */
1023 #define NSMC_Cancel 2 /* Cancel a shutdown request; this recalls
1024 a shutdown message, to which a pointer must
1025 be placed in nsm_Data. */
1027 /* Error codes that may be set when a message returns: */
1029 #define NSME_Success 0 /* Command was processed successfully */
1031 #define NSME_Aborted 1 /* Command was aborted */
1033 #define NSME_InUse 2 /* Network is still running, since clients are
1034 still using it */
1036 #define NSME_Ignored 3 /* Command was ignored (network may be shutting
1037 down right now) */
1039 #define NSME_NotFound 4 /* Shutdown command to be cancelled could not
1040 be recalled */
1042 /* The name of the public network controller message port: */
1043 #define NETWORK_CONTROLLER_PORT_NAME "TCP/IP Control"
1045 /* The network controller message port data structure; check the magic
1046 * cookie before you post a message to it!
1048 struct NetControlPort
1050 struct MsgPort ncp_Port;
1051 ULONG ncp_Magic;
1054 /* The magic cookie stored in ncp_Magic: */
1055 #define NCPM_Cookie 0x20040306
1057 /****************************************************************************/
1059 #ifdef __GNUC__
1060 #ifdef __PPC__
1061 #pragma pack()
1062 #endif
1063 #elif defined(__VBCC__)
1064 #pragma default-align
1065 #endif
1067 /****************************************************************************/
1069 #ifdef __cplusplus
1071 #endif /* __cplusplus */
1073 /****************************************************************************/
1075 #endif /* _LIBRARIES_BSDSOCKET_H */