home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / darwin / darwinx86.iso / usr / include / netat / aurp.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-09-30  |  9.7 KB  |  290 lines

  1. /*
  2.  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
  3.  *
  4.  * @APPLE_LICENSE_HEADER_START@
  5.  * 
  6.  * The contents of this file constitute Original Code as defined in and
  7.  * are subject to the Apple Public Source License Version 1.1 (the
  8.  * "License").  You may not use this file except in compliance with the
  9.  * License.  Please obtain a copy of the License at
  10.  * http://www.apple.com/publicsource and read it before using this file.
  11.  * 
  12.  * This Original Code and all software distributed under the License are
  13.  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  14.  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  15.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
  16.  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
  17.  * License for the specific language governing rights and limitations
  18.  * under the License.
  19.  * 
  20.  * @APPLE_LICENSE_HEADER_END@
  21.  */
  22. /*
  23.  *    Copyright (c) 1996 Apple Computer, Inc. 
  24.  *
  25.  *        Created April 23, 1996, by Justin C. Walker
  26.  *
  27.  *    File: aurp.h
  28.  */
  29.  
  30. #ifndef _NETAT_AURP_H_
  31. #define    _NETAT_AURP_H_
  32.  
  33. /*
  34.  * AURP device ioctl (I_STR) 'subcommands'
  35.  */
  36. #define AUC_CFGTNL    0    /* Configure Tunnels */
  37. #define AUC_SHTDOWN    1    /* Shutdown AURP */
  38. #define AUC_EXPNET    2    /* Configure exported networks */
  39. #define AUC_HIDENET    3    /* Configure hidden netowrks */
  40. #define AUC_UDPPORT    4    /* UPD Port number */
  41. #define AUC_NETLIST    5    /* List of remote endpoints */
  42. #define AUC_TIMER    6    /* Configured update interval timer */
  43. #define AUC_ADDNET      7       /* Add remote endpoints */
  44. #define AUC_ACCEPTALL   8       /* Accept all nets */
  45. #define AUC_MAX         9       /* Maximun numbers of access nets */
  46.  
  47. /* Default AURP-over-UDP port */
  48. #define AURP_SOCKNUM      387
  49. #define AURP_MAXNETACCESS 64
  50.  
  51. #ifdef KERNEL
  52.  
  53. #define AURPCODE_REG                   0
  54. #define AURPCODE_RTMPPKT               1
  55. #define AURPCODE_DATAPKT               2
  56. #define AURPCODE_AURPPROTO             3
  57. #define AURPCODE_DEBUGINFO             10
  58. #ifdef NOT_USED
  59. #define AURPCODE_RTINFO 11 /* was used to set up pointers to the
  60.                   routing table, the zone table, and 
  61.                   several functions */
  62. #endif
  63. #define AURPCODE_RTUPDATE              12
  64.  
  65. #define AURPSTATE_Unconnected          0
  66. #define AURPSTATE_Connected            1
  67. #define AURPSTATE_WaitingForOpenRsp    2
  68. #define AURPSTATE_WaitingForRIRsp      3
  69. #define AURPSTATE_WaitingForTickleAck  4
  70. #define AURPSTATE_WaitingForRIAck1     5
  71. #define AURPSTATE_WaitingForRIAck2     6
  72. #define AURPSTATE_WaitingForRIAck3     7
  73.  
  74. #define AURPCMD_RIReq                  1
  75. #define AURPCMD_RIRsp                  2
  76. #define AURPCMD_RIAck                  3
  77. #define AURPCMD_RIUpd                  4
  78. #define AURPCMD_RDReq                  5
  79. #define AURPCMD_ZReq                   6
  80. #define AURPCMD_ZRsp                   7
  81. #define AURPCMD_OpenReq                8
  82. #define AURPCMD_OpenRsp                9
  83. #define AURPCMD_Tickle                 14
  84. #define AURPCMD_TickleAck              15
  85.  
  86. #define AURPSUBCODE_ZoneInfo1          1
  87. #define AURPSUBCODE_ZoneInfo2          2
  88. #define AURPSUBCODE_GetZoneNets        3
  89. #define AURPSUBCODE_GetDomainZoneList  4
  90.  
  91. #define AURPEV_Null                    0
  92. #define AURPEV_NetAdded                1
  93. #define AURPEV_NetDeleted              2
  94. #define AURPEV_NetRouteChange          3
  95. #define AURPEV_NetDistChange           4
  96. #define AURPEV_NetZoneChange           5
  97.  
  98. #define AURP_Version                   1
  99. #define AURP_ProbeRetryInterval        300
  100. #define AURP_MaxTickleRetry            4
  101. #define AURP_TickleRetryInterval       30
  102. #define AURP_MaxRetry                  10
  103. #define AURP_RetryInterval             3
  104. #define AURP_UpdateRate                1
  105. #define AURP_UDType                    0
  106. #define AURP_UDNode                    1
  107. #define AURP_UDSize                    2
  108. #define AURP_FirstSeqNum               1
  109. #define AURP_LastSeqNum                65535
  110. #define AURP_MaxPktSize                1400
  111. #define AURP_MaxNetAccess              64
  112. #define AURP_NetHiden                  0x01
  113.  
  114. #define AURPERR_NormalConnectionClose  -1
  115. #define AURPERR_RoutingLoopDetected    -2
  116. #define AURPERR_ConnectionOutOfSync    -3
  117. #define AURPERR_OptionNegotiationError -4
  118. #define AURPERR_InvalidVersionNumber   -5
  119. #define AURPERR_InsufficientResources  -6
  120. #define AURPERR_AuthenticationError    -7
  121.  
  122. #define AURPFLG_NA    0x4000
  123. #define AURPFLG_ND    0x2000
  124. #define AURPFLG_NDC   0x1000
  125. #define AURPFLG_ZC    0x0800
  126. #define AURPFLG_RMA   0x4000
  127. #define AURPFLG_HCRA  0x2000
  128. #define AURPFLG_SZI   0x4000
  129. #define AURPFLG_LAST  0x8000
  130.  
  131. /*
  132.  * AURP state block
  133.  */
  134. typedef struct {
  135.     unsigned char  get_zi;          /* get zone info flag */
  136.     unsigned char  rem_node;        /* node id of a tunnel peer */
  137.     unsigned char  tickle_retry;    /* tickle retry count */
  138.     unsigned char  rcv_retry;       /* data receiver retry count */
  139.     unsigned char  snd_state;       /* data sender state */
  140.     unsigned char  rcv_state;       /* data receiver state */
  141.     unsigned char  filler[2];
  142.     unsigned short rcv_update_rate;
  143.     unsigned short snd_next_entry;  /* next entry in RT */
  144.     unsigned short rcv_env;
  145.     unsigned short snd_sui;
  146.     unsigned short rcv_connection_id;   /* data receiver connection id */
  147.     unsigned short snd_connection_id;   /* data sender connection id */
  148.     unsigned short rcv_sequence_number; /* data receiver sequence number */
  149.     unsigned short snd_sequence_number; /* data sender sequence number */
  150.     int   rcv_tmo;
  151.     int   snd_tmo;
  152.     gbuf_t *rsp_m;
  153.     gbuf_t *upd_m;
  154. } aurp_state_t;
  155.  
  156. /*
  157.  * AURP protocol header
  158.  */
  159. typedef struct {
  160.     unsigned short connection_id;
  161.     unsigned short sequence_number;
  162.     unsigned short command_code;
  163.     unsigned short flags;
  164. } aurp_hdr_t;
  165.  
  166. #ifdef KERNEL
  167.  
  168. #ifdef AURP_SUPPORT
  169.  
  170. extern atlock_t aurpgen_lock;
  171. extern gref_t *aurp_gref;
  172. extern unsigned char dst_addr_cnt;
  173. extern unsigned char net_access_cnt;
  174. extern unsigned char net_export;
  175. extern unsigned short rcv_connection_id;
  176. extern int net_port;
  177. extern int update_tmo;
  178. extern aurp_state_t aurp_state[];
  179. extern unsigned short net_access[];
  180. #endif
  181.  
  182. struct myq
  183. {    struct mbuf *q_head;
  184.     struct mbuf *q_tail;
  185.     int q_cnt;
  186. };
  187.  
  188. #define LOCK_DECL(x)    atlock_t x
  189.  
  190. /*
  191.  * Quandry: if we use a single socket, we have to rebind on each call.
  192.  * If we use separate sockets per tunnel endpoint, we have to examine
  193.  *  each one on wakeup.  What to do; what to do?
  194.  */
  195. struct aurp_global_t
  196. {    int src_addr;        /* What's our IP address? */
  197.     int udp_port;        /* Local UDP port */
  198.     unsigned short net_access[AURP_MAXNETACCESS];
  199.     long dst_addr[256];    /* Tunnel 'other ends', passed in from user */
  200.     int pid;        /* Who are we? */
  201.     struct socket *tunnel;    /* IP socket for all IP endpoints */
  202.     int event;        /* Sleep queue anchor */
  203.     int event_anchor;    /* Sleep queue anchor */
  204.     atlock_t glock;        /* aurp_global lock */
  205.     struct uio auio;    /* Dummy uio struct for soreceive() */
  206.     /* Statistics */
  207.     unsigned int toosmall;    /* size less than domain header, from UDP */
  208.     unsigned int no_mbufs;    /* gbuf_to_mbuf failed */
  209.     unsigned int no_gbufs;    /* mbuf_to_gbuf failed */
  210.     unsigned int shutdown;    /* shutdown flag */
  211.     unsigned int running;    /* running flag */
  212. };
  213.  
  214. #define AE_ATALK    0x01    /* A/talk input event */
  215. #define AE_UDPIP    0x02    /* UDP/IP input event */
  216. #define AE_SHUTDOWN    0x04    /* Shutdown AURP process */
  217.  
  218. void aurp_wakeup __P((struct socket *, caddr_t, int));
  219. struct mbuf *at_gbuf_to_mbuf __P((gbuf_t *));
  220. gbuf_t *at_mbuf_to_gbuf __P((struct mbuf *, int));
  221. int at_insert __P((gbuf_t *m, unsigned int type, unsigned int node));
  222. int ddp_AURPfuncx __P((int code, void *param, unsigned char node));
  223. int AURPinit __P((void));
  224. int aurpd_start __P((void));
  225. void atalk_to_ip __P((gbuf_t *m));
  226. void AURPaccess __P((void));
  227. void AURPshutdown __P((void));
  228. void AURPiocack __P((gref_t *gref, gbuf_t *m));
  229. void AURPiocnak __P((gref_t *gref, gbuf_t *m, int error));
  230. void AURPsndZReq __P((aurp_state_t *state));
  231. void AURPsndZRsp __P((aurp_state_t *state, gbuf_t *dat_m, int flag));
  232. void AURPsndRIUpd __P((aurp_state_t *state));
  233. void AURPsndRIReq __P((aurp_state_t *state));
  234. void AURPsndRIAck __P((aurp_state_t *state, gbuf_t *m, unsigned short flags));
  235. void AURPsndOpenReq __P((aurp_state_t *state));
  236. void AURPsndRDReq __P((aurp_state_t *state));
  237. void AURPrcvZReq __P((aurp_state_t *state, gbuf_t *m));
  238. void AURPrcvZRsp __P((aurp_state_t *state, gbuf_t *m));
  239. void AURPrcvRIUpd __P((aurp_state_t *state, gbuf_t *m));
  240. void AURPrcvRIReq __P((aurp_state_t *state, gbuf_t *m));
  241. void AURPrcvRIAck __P((aurp_state_t *state, gbuf_t *m));
  242. void AURPrcvRIRsp __P((aurp_state_t *state, gbuf_t *m));
  243. void AURPrcvOpenReq __P((aurp_state_t *state, gbuf_t *m));
  244. void AURPrcvOpenRsp __P((aurp_state_t *state, gbuf_t *m));
  245. void AURPrcvTickle __P((aurp_state_t *state, gbuf_t *m));
  246. void AURPrcvTickleAck __P((aurp_state_t *state, gbuf_t *m));
  247. void AURPrcvRDReq __P((aurp_state_t *state, gbuf_t *m));
  248. void AURPfreemsg __P((gbuf_t *m));
  249. void AURPrtupdate __P((RT_entry *entry, unsigned char ev));
  250. void AURPsend __P((gbuf_t *mdata, int type, int node));
  251. void AURPcleanup __P((aurp_state_t *state));
  252. void AURPpurgeri __P((unsigned char node));
  253. int AURPgetri __P((short next_entry, unsigned char *buf, short *len));
  254. int AURPsetri __P((unsigned char node, gbuf_t *m));
  255. int AURPupdateri __P((unsigned char node, gbuf_t *m));
  256.  
  257. #endif    /* KERNEL */
  258.  
  259. /* AURP header for IP tunneling */
  260. typedef struct aurp_domain
  261. {    char  dst_length;
  262.     char  dst_authority;
  263.     short dst_distinguisher;
  264.     long  dst_address;
  265.     char  src_length;
  266.     char  src_authority;
  267.     short src_distinguisher;
  268.     long  src_address;
  269.     short version;
  270.     short reserved;
  271.     short type;
  272. } aurp_domain_t;
  273.  
  274. /* AURP/domain header constants */
  275. #define AUD_Version    0x1
  276. #define AUD_Atalk    0x2
  277. #define AUD_AURP    0x3
  278.  
  279. /* IP domain identifier constants */
  280. #define IP_LENGTH        7
  281. #define IP_AUTHORITY        1
  282. #define IP_DISTINGUISHER    0
  283. /* Need this because the )(*&^%$#@ compiler rounds up the size */
  284. #define IP_DOMAINSIZE        22
  285.  
  286. /****### LD 9/26/97*/
  287. extern struct aurp_global_t aurp_global;
  288. #endif /* KERNEL */
  289. #endif /* _NETAT_AURP_H_ */
  290.