1 #ifndef _AMITCP_SOCKETBASETAGS_H_
    2 #define _AMITCP_SOCKETBASETAGS_H_
    3 /*
    4  *      TAG values for SocketBaseTagList()
    5  *
    6  *      Copyright © 1994-2000 AmiTCP/IP Group,
    7  *      Network Solutions Development, Inc.
    8  *      All rights reserved.
    9  *
   10  *      $Id: socketbasetags.h,v 1.4 2023/05/17 14:35:15 piru Exp $
   11  */
   12 
   13 #ifndef UTILITY_TAGITEM_H
   14 #include <utility/tagitem.h>
   15 #endif
   16 
   17 /*
   18  * utility/tagitem.h specifies that bits 16-30 in tags are reserved. So we 
   19  * don't use them for maximum compatability.
   20  */
   21 
   22 /*
   23  * Argument passing convention (bit 15)
   24  */
   25 #define SBTF_VAL 0x0000 /* by value */
   26 #define SBTF_REF 0x8000 /* by reference */
   27 
   28 /*
   29  * Code (bits 1-14)
   30  */
   31 #define SBTB_CODE 1
   32 #define SBTS_CODE 0x3FFF
   33 #define SBTM_CODE(tag) (((UWORD)(tag) >> SBTB_CODE) & SBTS_CODE)
   34 
   35 /* 
   36  * Direction (bit 0)
   37  */
   38 #define SBTF_GET 0x0
   39 #define SBTF_SET 0x1
   40 
   41 /*
   42  * Macros used with the SocketBaseTags() call. 'code' takes a STBC_
   43  * value and the argument goes in ti_Data.
   44  */
   45 #define SBTM_GETREF(code) \
   46   (TAG_USER | SBTF_REF | (((code) & SBTS_CODE) << SBTB_CODE))
   47 #define SBTM_GETVAL(code) \
   48   (TAG_USER | (((code) & SBTS_CODE) << SBTB_CODE))
   49 #define SBTM_SETREF(code) \
   50   (TAG_USER | SBTF_REF | (((code) & SBTS_CODE) << SBTB_CODE) | SBTF_SET)
   51 #define SBTM_SETVAL(code) \
   52   (TAG_USER | (((code) & SBTS_CODE) << SBTB_CODE) | SBTF_SET)
   53 
   54 /*
   55  * Tag code definitions. These codes are used with one of the above macros.
   56  *
   57  * All arguments are ULONG's or pointers (PTR suffix).
   58  */
   59 
   60 /* signal masks */
   61 #define SBTC_BREAKMASK    1
   62 #define SBTC_SIGIOMASK    2
   63 #define SBTC_SIGURGMASK   3
   64 #define SBTC_SIGEVENTMASK 4
   65 
   66 /* error code handling */
   67 #define SBTC_ERRNO  6
   68 #define SBTC_HERRNO 7
   69 
   70 /* socket descriptor table related tags */
   71 #define SBTC_DTABLESIZE 8
   72 
   73 /* link library fd allocation callback
   74  * 
   75  * Argument is a callback function with following prototype
   76  *
   77  * int fd = fdCallback(int fd, int action);
   78  *     D0                  D0      D1
   79  *
   80  * see net.lib sources for an example
   81  */
   82 #define SBTC_FDCALLBACK 9
   83 /*
   84  * "action" values:
   85  */
   86 #define FDCB_FREE  0
   87 #define FDCB_ALLOC 1
   88 #define FDCB_CHECK 2
   89 
   90 /* syslog variables (see netinclude:sys/syslog.h for values) */
   91 #define SBTC_LOGSTAT     10
   92 #define SBTC_LOGTAGPTR   11
   93 #define SBTC_LOGFACILITY 12
   94 #define SBTC_LOGMASK     13
   95 
   96 /*
   97  * The argument of following error string tags is a ULONG,
   98  * where the error number is stored. On return the string pointer is 
   99  * returned on this same ULONG. (GET ONLY)
  100  *
  101  * NOTE: error numbers defined in <exec/errors.h> are negative and must be
  102  * negated (turned to positive) before passing to the SocketBaseTagList().
  103  */
  104 #define SBTC_ERRNOSTRPTR    14 /* <sys/errno.h> */
  105 #define SBTC_HERRNOSTRPTR   15 /* <netdb.h> */
  106 #define SBTC_IOERRNOSTRPTR  16 /* <exec/errors.h> SEE NOTE ABOVE */
  107 #define SBTC_S2ERRNOSTRPTR  17 /* <devices/sana2.h> */
  108 #define SBTC_S2WERRNOSTRPTR	18 /* <devices/sana2.h> */
  109 
  110 
  111 /* links the errno pointer & size to the errno variable in your program */
  112 #define SBTC_ERRNOBYTEPTR 21
  113 #define SBTC_ERRNOWORDPTR 22
  114 #define SBTC_ERRNOLONGPTR 24
  115 /*
  116  * Macro for generating the errnoptr tag code from a (constant) size.
  117  * only 1, 2 & 4 are legal 'size' values. If the 'size' value is illegal,
  118  * the tag is set to 0, which causes SocketBaseTagList() to fail.
  119  */
  120 #define SBTC_ERRNOPTR(size)    ((size == sizeof(long)) ? SBTC_ERRNOLONGPTR   :\
  121 				((size == sizeof(short)) ? SBTC_ERRNOWORDPTR :\
  122 				 ((size == sizeof(char)) ? SBTC_ERRNOBYTEPTR :\
  123 				  0)))
  124 
  125 /* links the h_errno pointer to the h_errno variable in your program */
  126 #define SBTC_HERRNOLONGPTR 25
  127 
  128 /* protocol stack release information string pointer (read only!) */
  129 #define SBTC_RELEASESTRPTR 29
  130 
  131 /* Number of available Berkeley Packet Filter channels */
  132 #define SBTC_NUM_PACKET_FILTER_CHANNELS 40
  133 
  134 /*
  135  * Function pointer to get errno pointer. If specified this
  136  * function is called when setting / getting errno value. When set
  137  * SBTC_ERRNOBYTE/WORD/LONGPTR set pointer is not referenced.
  138  * Called as: int *ptr = func(void);
  139  *            D0
  140  * This pointer is also inherited to child processes that use the
  141  * implicit "autoopen" feature of NetStack (processes calling
  142  * bsdsocket.library without opening it).
  143  */
  144 #define SBTC_ERRNOFUNCPTR 80
  145 
  146 /*
  147  * Function pointer to get h_errno pointer. If specified this
  148  * function is called when setting / getting h_errno value. When set
  149  * SBTC_HERRNOLONGPTR set pointer is not referenced.
  150  * Called as: int *ptr = func(void);
  151  *            D0
  152  * This pointer is also inherited to child processes that use the
  153  * implicit "autoopen" feature of NetStack (processes calling
  154  * bsdsocket.library without opening it).
  155  */
  156 #define SBTC_HERRNOFUNCPTR 81
  157 
  158 #endif /* !_AMITCP_SOCKETBASETAGS_H_ */