Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2414 lines
72 KiB

  1. /*
  2. File: OpenTransportProviders.h
  3. Contains: This file contains provider-specific definitions for various built-in providers.
  4. Version: QuickTime 7.3
  5. Copyright: (c) 2007 (c) 1993-2001 by Apple Computer, Inc. and Mentat Inc., all rights reserved.
  6. Bugs?: For bug reports, consult the following page on
  7. the World Wide Web:
  8. http://developer.apple.com/bugreporter/
  9. */
  10. #ifndef __OPENTRANSPORTPROVIDERS__
  11. #define __OPENTRANSPORTPROVIDERS__
  12. #ifndef __OPENTRANSPORT__
  13. #include <OpenTransport.h>
  14. #endif
  15. #if PRAGMA_ONCE
  16. #pragma once
  17. #endif
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. #if PRAGMA_IMPORT
  22. #pragma import on
  23. #endif
  24. #if PRAGMA_STRUCT_ALIGN
  25. #pragma options align=mac68k
  26. #elif PRAGMA_STRUCT_PACKPUSH
  27. #pragma pack(push, 2)
  28. #elif PRAGMA_STRUCT_PACK
  29. #pragma pack(2)
  30. #endif
  31. #if defined(__MWERKS__) && TARGET_CPU_68K
  32. #pragma push
  33. #pragma pointers_in_D0
  34. #endif
  35. /* ***** TCP/IP ******/
  36. /* Basic types*/
  37. typedef UInt16 InetPort;
  38. typedef UInt32 InetHost;
  39. /* Enums used as address type designations.*/
  40. #define AF_INET 2
  41. enum {
  42. AF_DNS = 42
  43. };
  44. /*
  45. Enum which can be used to bind to all IP interfaces
  46. rather than a specific one.
  47. */
  48. enum {
  49. kOTAnyInetAddress = 0 /* Wildcard*/
  50. };
  51. /*
  52. Define the InetSvcRef type. This type needs special
  53. processing because in C++ it's a subclass of TProvider.
  54. See the definition of TEndpointRef in "OpenTransport.h"
  55. for the logic behind this definition.
  56. */
  57. #ifdef __cplusplus
  58. typedef class TInternetServices* InetSvcRef;
  59. #else
  60. typedef void* InetSvcRef;
  61. #endif
  62. #define kDefaultInternetServicesPath ((OTConfigurationRef)-3L)
  63. /* Shared library prefixes*/
  64. #define kInetVersion "3.1.1"
  65. #define kInetPrefix "ot:inet$"
  66. /* Module Names*/
  67. #define kDNRName "dnr"
  68. #define kTCPName "tcp"
  69. #define kUDPName "udp"
  70. #define kRawIPName "rawip"
  71. /* XTI Options*/
  72. /* Protocol levels*/
  73. enum {
  74. INET_IP = 0x00,
  75. INET_TCP = 0x06,
  76. INET_UDP = 0x11
  77. };
  78. /* TCP Level Options*/
  79. enum {
  80. TCP_NODELAY = 0x01,
  81. TCP_MAXSEG = 0x02,
  82. TCP_NOTIFY_THRESHOLD = 0x10, /** not a real XTI option */
  83. TCP_ABORT_THRESHOLD = 0x11, /** not a real XTI option */
  84. TCP_CONN_NOTIFY_THRESHOLD = 0x12, /** not a real XTI option */
  85. TCP_CONN_ABORT_THRESHOLD = 0x13, /** not a real XTI option */
  86. TCP_OOBINLINE = 0x14, /** not a real XTI option */
  87. TCP_URGENT_PTR_TYPE = 0x15, /** not a real XTI option */
  88. TCP_KEEPALIVE = 0x0008 /* keepalive defined in OpenTransport.h */
  89. };
  90. enum {
  91. T_GARBAGE = 2
  92. };
  93. /* UDP Level Options*/
  94. enum {
  95. UDP_CHECKSUM = 0x0600,
  96. UDP_RX_ICMP = 0x02
  97. };
  98. /* IP Level Options*/
  99. enum {
  100. kIP_OPTIONS = 0x01,
  101. kIP_TOS = 0x02,
  102. kIP_TTL = 0x03,
  103. kIP_REUSEADDR = 0x04,
  104. kIP_DONTROUTE = 0x10,
  105. kIP_BROADCAST = 0x20,
  106. kIP_REUSEPORT = 0x0200,
  107. kIP_HDRINCL = 0x1002,
  108. kIP_RCVOPTS = 0x1005,
  109. kIP_RCVDSTADDR = 0x1007,
  110. kIP_MULTICAST_IF = 0x1010, /* set/get IP multicast interface */
  111. kIP_MULTICAST_TTL = 0x1011, /* set/get IP multicast timetolive */
  112. kIP_MULTICAST_LOOP = 0x1012, /* set/get IP multicast loopback */
  113. kIP_ADD_MEMBERSHIP = 0x1013, /* add an IP group membership */
  114. kIP_DROP_MEMBERSHIP = 0x1014, /* drop an IP group membership */
  115. kIP_BROADCAST_IFNAME = 0x1015, /* Set interface for broadcasts */
  116. kIP_RCVIFADDR = 0x1016 /* Set interface for broadcasts */
  117. };
  118. enum {
  119. IP_OPTIONS = kIP_OPTIONS,
  120. IP_TOS = kIP_TOS,
  121. IP_TTL = kIP_TTL,
  122. IP_REUSEADDR = kIP_REUSEADDR,
  123. IP_DONTROUTE = kIP_DONTROUTE,
  124. IP_BROADCAST = kIP_BROADCAST,
  125. IP_REUSEPORT = kIP_REUSEPORT,
  126. IP_HDRINCL = kIP_HDRINCL,
  127. IP_RCVOPTS = kIP_RCVOPTS,
  128. IP_RCVDSTADDR = kIP_RCVDSTADDR,
  129. IP_MULTICAST_IF = kIP_MULTICAST_IF, /* set/get IP multicast interface */
  130. IP_MULTICAST_TTL = kIP_MULTICAST_TTL, /* set/get IP multicast timetolive */
  131. IP_MULTICAST_LOOP = kIP_MULTICAST_LOOP, /* set/get IP multicast loopback */
  132. IP_ADD_MEMBERSHIP = kIP_ADD_MEMBERSHIP, /* add an IP group membership */
  133. IP_DROP_MEMBERSHIP = kIP_DROP_MEMBERSHIP, /* drop an IP group membership */
  134. IP_BROADCAST_IFNAME = kIP_BROADCAST_IFNAME, /* Set interface for broadcasts */
  135. IP_RCVIFADDR = kIP_RCVIFADDR /* Set interface for broadcasts */
  136. };
  137. enum {
  138. DVMRP_INIT = 100, /* DVMRP-specific setsockopt commands, from ip_mroute.h*/
  139. DVMRP_DONE = 101,
  140. DVMRP_ADD_VIF = 102,
  141. DVMRP_DEL_VIF = 103,
  142. DVMRP_ADD_LGRP = 104,
  143. DVMRP_DEL_LGRP = 105,
  144. DVMRP_ADD_MRT = 106,
  145. DVMRP_DEL_MRT = 107
  146. };
  147. /* IP_TOS precdence levels*/
  148. enum {
  149. T_ROUTINE = 0,
  150. T_PRIORITY = 1,
  151. T_IMMEDIATE = 2,
  152. T_FLASH = 3,
  153. T_OVERRIDEFLASH = 4,
  154. T_CRITIC_ECP = 5,
  155. T_INETCONTROL = 6,
  156. T_NETCONTROL = 7
  157. };
  158. /* IP_TOS type of service*/
  159. enum {
  160. T_NOTOS = 0x00,
  161. T_LDELAY = (1 << 4),
  162. T_HITHRPT = (1 << 3),
  163. T_HIREL = (1 << 2)
  164. };
  165. #define SET_TOS(prec,tos) (((0x7 & (prec)) << 5) | (0x1c & (tos)))
  166. /* IP Multicast option structures*/
  167. struct TIPAddMulticast {
  168. InetHost multicastGroupAddress;
  169. InetHost interfaceAddress;
  170. };
  171. typedef struct TIPAddMulticast TIPAddMulticast;
  172. /* Protocol-specific events*/
  173. enum {
  174. T_DNRSTRINGTOADDRCOMPLETE = kPRIVATEEVENT + 1,
  175. T_DNRADDRTONAMECOMPLETE = kPRIVATEEVENT + 2,
  176. T_DNRSYSINFOCOMPLETE = kPRIVATEEVENT + 3,
  177. T_DNRMAILEXCHANGECOMPLETE = kPRIVATEEVENT + 4,
  178. T_DNRQUERYCOMPLETE = kPRIVATEEVENT + 5
  179. };
  180. /* InetAddress*/
  181. struct InetAddress {
  182. OTAddressType fAddressType; /* always AF_INET*/
  183. InetPort fPort; /* Port number */
  184. InetHost fHost; /* Host address in net byte order*/
  185. UInt8 fUnused[8]; /* Traditional unused bytes*/
  186. };
  187. typedef struct InetAddress InetAddress;
  188. /* Domain Name Resolver (DNR) */
  189. enum {
  190. kMaxHostAddrs = 10,
  191. kMaxSysStringLen = 32,
  192. kMaxHostNameLen = 255
  193. };
  194. typedef char InetDomainName[256];
  195. struct InetHostInfo {
  196. InetDomainName name;
  197. InetHost addrs[10];
  198. };
  199. typedef struct InetHostInfo InetHostInfo;
  200. struct InetSysInfo {
  201. char cpuType[32];
  202. char osType[32];
  203. };
  204. typedef struct InetSysInfo InetSysInfo;
  205. struct InetMailExchange {
  206. UInt16 preference;
  207. InetDomainName exchange;
  208. };
  209. typedef struct InetMailExchange InetMailExchange;
  210. struct DNSQueryInfo {
  211. UInt16 qType;
  212. UInt16 qClass;
  213. UInt32 ttl;
  214. InetDomainName name;
  215. UInt16 responseType; /* answer, authority, or additional*/
  216. UInt16 resourceLen; /* actual length of array which follows*/
  217. char resourceData[4]; /* size varies*/
  218. };
  219. typedef struct DNSQueryInfo DNSQueryInfo;
  220. /* DNSAddress*/
  221. /*
  222. The DNSAddress format is optional and may be used in connects,
  223. datagram sends, and resolve address calls. The name takes the
  224. format "somewhere.com" or "somewhere.com:portnumber" where
  225. the ":portnumber" is optional. The length of this structure
  226. is arbitrarily limited to the overall max length of a domain
  227. name (255 chars), although a longer one can be use successfully
  228. if you use this as a template for doing so. However, the domain name
  229. is still limited to 255 characters.
  230. */
  231. struct DNSAddress {
  232. OTAddressType fAddressType; /* always AF_DNS*/
  233. InetDomainName fName;
  234. };
  235. typedef struct DNSAddress DNSAddress;
  236. /* InetInterfaceInfo*/
  237. enum {
  238. kDefaultInetInterface = -1
  239. };
  240. enum {
  241. kInetInterfaceInfoVersion = 3
  242. };
  243. struct InetInterfaceInfo {
  244. InetHost fAddress;
  245. InetHost fNetmask;
  246. InetHost fBroadcastAddr;
  247. InetHost fDefaultGatewayAddr;
  248. InetHost fDNSAddr;
  249. UInt16 fVersion;
  250. UInt16 fHWAddrLen;
  251. UInt8 * fHWAddr;
  252. UInt32 fIfMTU;
  253. UInt8 * fReservedPtrs[2];
  254. InetDomainName fDomainName;
  255. UInt32 fIPSecondaryCount;
  256. UInt8 fReserved[252];
  257. };
  258. typedef struct InetInterfaceInfo InetInterfaceInfo;
  259. /* InetDHCPOption*/
  260. enum {
  261. kAllDHCPOptions = -1,
  262. kDHCPLongOption = 126,
  263. kDHCPLongOptionReq = 127
  264. };
  265. struct InetDHCPOption {
  266. UInt8 fOptionTag;
  267. UInt8 fOptionLen;
  268. UInt8 fOptionValue;
  269. };
  270. typedef struct InetDHCPOption InetDHCPOption;
  271. /* TCP/IP Utility Routines*/
  272. /*
  273. * OTInitInetAddress()
  274. *
  275. * Availability:
  276. * Non-Carbon CFM: not available
  277. * CarbonLib: in CarbonLib 1.0 and later
  278. * Mac OS X: in version 10.0 and later
  279. */
  280. EXTERN_API( void )
  281. OTInitInetAddress(
  282. InetAddress * addr,
  283. InetPort port,
  284. InetHost host);
  285. /*
  286. * OTInitDNSAddress()
  287. *
  288. * Availability:
  289. * Non-Carbon CFM: not available
  290. * CarbonLib: in CarbonLib 1.0 and later
  291. * Mac OS X: in version 10.0 and later
  292. */
  293. EXTERN_API( OTByteCount )
  294. OTInitDNSAddress(
  295. DNSAddress * addr,
  296. char * str);
  297. /*
  298. * OTInetStringToHost()
  299. *
  300. * Availability:
  301. * Non-Carbon CFM: not available
  302. * CarbonLib: in CarbonLib 1.0 and later
  303. * Mac OS X: in version 10.0 and later
  304. */
  305. EXTERN_API( OSStatus )
  306. OTInetStringToHost(
  307. const char * str,
  308. InetHost * host);
  309. /*
  310. * OTInetHostToString()
  311. *
  312. * Availability:
  313. * Non-Carbon CFM: not available
  314. * CarbonLib: in CarbonLib 1.0 and later
  315. * Mac OS X: in version 10.0 and later
  316. */
  317. EXTERN_API( void )
  318. OTInetHostToString(
  319. InetHost host,
  320. char * str);
  321. /*
  322. * OTInetGetInterfaceInfo()
  323. *
  324. * Availability:
  325. * Non-Carbon CFM: not available
  326. * CarbonLib: in CarbonLib 1.0 and later
  327. * Mac OS X: in version 10.0 and later
  328. */
  329. EXTERN_API( OSStatus )
  330. OTInetGetInterfaceInfo(
  331. InetInterfaceInfo * info,
  332. SInt32 val);
  333. /*
  334. * OTInetGetSecondaryAddresses()
  335. *
  336. * Availability:
  337. * Non-Carbon CFM: not available
  338. * CarbonLib: in CarbonLib 1.0 and later
  339. * Mac OS X: in version 10.0 and later
  340. */
  341. EXTERN_API( OSStatus )
  342. OTInetGetSecondaryAddresses(
  343. InetHost * addr,
  344. UInt32 * count,
  345. SInt32 val);
  346. #if CALL_NOT_IN_CARBON
  347. /*
  348. * OTInetGetDHCPConfigInfo()
  349. *
  350. * Availability:
  351. * Non-Carbon CFM: not available
  352. * CarbonLib: not available
  353. * Mac OS X: not available
  354. */
  355. EXTERN_API( OSStatus )
  356. OTInetGetDHCPConfigInfo(
  357. InetDHCPOption * buf,
  358. UInt32 bufSize,
  359. SInt32 index,
  360. SInt32 opt);
  361. /* InetServices & DNR Calls*/
  362. #endif /* CALL_NOT_IN_CARBON */
  363. #if !OTKERNEL
  364. /*
  365. Under Carbon, OTOpenInternetServices routines take a client context pointer. Applications may pass NULL
  366. after calling InitOpenTransport(kInitOTForApplicationMask, ...). Non-applications must always pass a
  367. valid client context.
  368. */
  369. /*
  370. * OTOpenInternetServicesInContext()
  371. *
  372. * Availability:
  373. * Non-Carbon CFM: not available
  374. * CarbonLib: in CarbonLib 1.0 and later
  375. * Mac OS X: in version 10.0 and later
  376. */
  377. EXTERN_API( InetSvcRef )
  378. OTOpenInternetServicesInContext(
  379. OTConfigurationRef cfig,
  380. OTOpenFlags oflag,
  381. OSStatus * err,
  382. OTClientContextPtr clientContext);
  383. /*
  384. * OTAsyncOpenInternetServicesInContext()
  385. *
  386. * Availability:
  387. * Non-Carbon CFM: not available
  388. * CarbonLib: in CarbonLib 1.0 and later
  389. * Mac OS X: in version 10.0 and later
  390. */
  391. EXTERN_API( OSStatus )
  392. OTAsyncOpenInternetServicesInContext(
  393. OTConfigurationRef cfig,
  394. OTOpenFlags oflag,
  395. OTNotifyUPP upp,
  396. void * contextPtr,
  397. OTClientContextPtr clientContext);
  398. #if CALL_NOT_IN_CARBON
  399. /*
  400. * OTOpenInternetServices()
  401. *
  402. * Availability:
  403. * Non-Carbon CFM: not available
  404. * CarbonLib: not available
  405. * Mac OS X: not available
  406. */
  407. EXTERN_API( InetSvcRef )
  408. OTOpenInternetServices(
  409. OTConfigurationRef cfig,
  410. OTOpenFlags oflag,
  411. OSStatus * err);
  412. /*
  413. * OTAsyncOpenInternetServices()
  414. *
  415. * Availability:
  416. * Non-Carbon CFM: not available
  417. * CarbonLib: not available
  418. * Mac OS X: not available
  419. */
  420. EXTERN_API( OSStatus )
  421. OTAsyncOpenInternetServices(
  422. OTConfigurationRef cfig,
  423. OTOpenFlags oflag,
  424. OTNotifyUPP proc,
  425. void * contextPtr);
  426. #endif /* CALL_NOT_IN_CARBON */
  427. #if OTCARBONAPPLICATION
  428. /* The following macro may be used by applications only.*/
  429. #define OTOpenInternetServices(cfig, oflags, err) OTOpenInternetServicesInContext(cfig, oflags, err, NULL)
  430. #define OTAsyncOpenInternetServices(cfig, oflags, proc, contextPtr) OTAsyncOpenInternetServicesInContext(cfig, oflags, proc, contextPtr, NULL)
  431. #endif /* OTCARBONAPPLICATION */
  432. /*
  433. * OTInetStringToAddress()
  434. *
  435. * Availability:
  436. * Non-Carbon CFM: not available
  437. * CarbonLib: in CarbonLib 1.0 and later
  438. * Mac OS X: in version 10.0 and later
  439. */
  440. EXTERN_API( OSStatus )
  441. OTInetStringToAddress(
  442. InetSvcRef ref,
  443. char * name,
  444. InetHostInfo * hinfo);
  445. /*
  446. * OTInetAddressToName()
  447. *
  448. * Availability:
  449. * Non-Carbon CFM: not available
  450. * CarbonLib: in CarbonLib 1.0 and later
  451. * Mac OS X: in version 10.0 and later
  452. */
  453. EXTERN_API( OSStatus )
  454. OTInetAddressToName(
  455. InetSvcRef ref,
  456. InetHost addr,
  457. InetDomainName name);
  458. /*
  459. * OTInetSysInfo()
  460. *
  461. * Availability:
  462. * Non-Carbon CFM: not available
  463. * CarbonLib: in CarbonLib 1.0 and later
  464. * Mac OS X: in version 10.0 and later
  465. */
  466. EXTERN_API( OSStatus )
  467. OTInetSysInfo(
  468. InetSvcRef ref,
  469. char * name,
  470. InetSysInfo * sysinfo);
  471. /*
  472. * OTInetMailExchange()
  473. *
  474. * Availability:
  475. * Non-Carbon CFM: not available
  476. * CarbonLib: in CarbonLib 1.0 and later
  477. * Mac OS X: in version 10.0 and later
  478. */
  479. EXTERN_API( OSStatus )
  480. OTInetMailExchange(
  481. InetSvcRef ref,
  482. char * name,
  483. UInt16 * num,
  484. InetMailExchange * mx);
  485. /*
  486. * OTInetQuery()
  487. *
  488. * Availability:
  489. * Non-Carbon CFM: not available
  490. * CarbonLib: in CarbonLib 1.0 and later
  491. * Mac OS X: in version 10.0 and later
  492. */
  493. EXTERN_API( OSStatus )
  494. OTInetQuery(
  495. InetSvcRef ref,
  496. char * name,
  497. UInt16 qClass,
  498. UInt16 qType,
  499. char * buf,
  500. OTByteCount buflen,
  501. void ** argv,
  502. OTByteCount argvlen,
  503. OTFlags flags);
  504. #ifdef __cplusplus
  505. } // Terminate C definitions
  506. class TInternetServices : public TProvider
  507. {
  508. public:
  509. OSStatus StringToAddress(char* name, InetHostInfo* hinfo)
  510. { return OTInetStringToAddress(this, name, hinfo); }
  511. OSStatus AddressToName(InetHost addr, InetDomainName name)
  512. { return OTInetAddressToName(this, addr, name); }
  513. OSStatus SysInfo(char* name, InetSysInfo* sysinfo )
  514. { return OTInetSysInfo(this, name, sysinfo); }
  515. OSStatus MailExchange(char* name, UInt16* num, InetMailExchange* mx)
  516. { return OTInetMailExchange(this, name, num, mx); }
  517. OSStatus Query(char* name, UInt16 qClass, UInt16 qType,
  518. char* buf, OTByteCount buflen,
  519. void** argv, OTByteCount argvlen,
  520. OTFlags flags)
  521. { return OTInetQuery(this, name, qClass, qType, buf, buflen, argv, argvlen, flags); }
  522. };
  523. extern "C" { /* resume C definitions */
  524. #endif
  525. #endif /* !OTKERNEL */
  526. /* ***** AppleTalk ******/
  527. /* Shared library prefixes*/
  528. #define kATalkVersion "1.1"
  529. #define kATalkPrefix "ot:atlk$"
  530. #define kATBinderID "ot:atbd$"
  531. /*******************************************************************************
  532. ** Module definitions
  533. ********************************************************************************/
  534. /* XTI Levels*/
  535. enum {
  536. ATK_DDP = FOUR_CHAR_CODE('DDP '),
  537. ATK_AARP = FOUR_CHAR_CODE('AARP'),
  538. ATK_ATP = FOUR_CHAR_CODE('ATP '),
  539. ATK_ADSP = FOUR_CHAR_CODE('ADSP'),
  540. ATK_ASP = FOUR_CHAR_CODE('ASP '),
  541. ATK_PAP = FOUR_CHAR_CODE('PAP '),
  542. ATK_NBP = FOUR_CHAR_CODE('NBP '),
  543. ATK_ZIP = FOUR_CHAR_CODE('ZIP ')
  544. };
  545. /* Module Names*/
  546. #define kDDPName "ddp"
  547. #define kATPName "atp"
  548. #define kADSPName "adsp"
  549. #define kASPName "asp"
  550. #define kPAPName "pap"
  551. #define kNBPName "nbp"
  552. #define kZIPName "zip"
  553. #define kLTalkName "ltlk"
  554. #define kLTalkAName "ltlkA"
  555. #define kLTalkBName "ltlkB"
  556. /*
  557. Protocol-specific Options
  558. NOTE:
  559. All Protocols support OPT_CHECKSUM (Value is (unsigned long)T_YES/T_NO)
  560. ATP supports OPT_RETRYCNT (# Retries, 0 = try once) and
  561. OPT_INTERVAL (# Milliseconds to wait)
  562. */
  563. enum {
  564. DDP_OPT_CHECKSUM = 0x0600,
  565. DDP_OPT_SRCADDR = 0x2101, /* DDP UnitDataReq Only - set src address, Value is DDPAddress */
  566. ATP_OPT_REPLYCNT = 0x2110, /* AppleTalk - ATP Resp Pkt Ct Type, Value is (unsigned long) pkt count */
  567. ATP_OPT_DATALEN = 0x2111, /* AppleTalk - ATP Pkt Data Len Type, Value is (unsigned long) length */
  568. ATP_OPT_RELTIMER = 0x2112, /* AppleTalk - ATP Release Timer Type, Value is (unsigned long) timer, (See Inside AppleTalk, second edition */
  569. ATP_OPT_TRANID = 0x2113, /* Value is (unsigned long) Boolean, Used to request Transaction ID, Returned with Transaction ID on requests */
  570. PAP_OPT_OPENRETRY = 0x2120 /* AppleTalk - PAP OpenConn Retry count, Value is (unsigned long) T_YES/T_NO */
  571. };
  572. /* Protocol-Specific Events*/
  573. /*
  574. If you send the IOCTL: OTIoctl(I_OTGetMiscellaneousEvents, 1),
  575. you will receive the T_ATALKxxx events on your endpoint.
  576. NOTE: The endpoint does not need to be bound.
  577. */
  578. enum {
  579. kAppleTalkEvent = kPROTOCOLEVENT | 0x00010000,
  580. T_GETMYZONECOMPLETE = kAppleTalkEvent + 1,
  581. T_GETLOCALZONESCOMPLETE = kAppleTalkEvent + 2,
  582. T_GETZONELISTCOMPLETE = kAppleTalkEvent + 3,
  583. T_GETATALKINFOCOMPLETE = kAppleTalkEvent + 4,
  584. T_ATALKROUTERDOWNEVENT = kAppleTalkEvent + 51, /* No routers have been seen for a while. If the cookie is NULL, all routers are gone. Otherwise, there is still an ARA router hanging around being used, and only the local cable has been timed out.*/
  585. T_ATALKROUTERUPEVENT = kAppleTalkEvent + 52, /* We didn't have a router, but now one has come up. Cookie is NULL for a normal router coming up, non-NULL for an ARA router coming on-line*/
  586. T_ATALKZONENAMECHANGEDEVENT = kAppleTalkEvent + 53, /* A Zone name change was issued from the router, so our AppleTalk Zone has changed.*/
  587. T_ATALKCONNECTIVITYCHANGEDEVENT = kAppleTalkEvent + 54, /* An ARA connection was established (cookie != NULL), or was disconnected (cookie == NULL)*/
  588. T_ATALKINTERNETAVAILABLEEVENT = kAppleTalkEvent + 55, /* A router has appeared, and our address is in the startup range. Cookie is hi/lo of new cable range.*/
  589. T_ATALKCABLERANGECHANGEDEVENT = kAppleTalkEvent + 56 /* A router has appeared, and it's incompatible with our current address. Cookie is hi/lo of new cable range.*/
  590. };
  591. enum {
  592. kAllATalkRoutersDown = 0, /* This indicates that all routers are offline*/
  593. kLocalATalkRoutersDown = -1L, /* This indicates that all local routers went offline, but an ARA router is still active*/
  594. kARARouterDisconnected = -2L /* This indicates that ARA was disconnected, do it's router went offline, and we have no local routers to fall back onto.*/
  595. };
  596. enum {
  597. kARARouterOnline = -1L, /* We had no local routers, but an ARA router is now online.*/
  598. kATalkRouterOnline = 0, /* We had no routers, but a local router is now online*/
  599. kLocalATalkRouterOnline = -2L /* We have an ARA router, but now we've seen a local router as well*/
  600. };
  601. #define IsAppleTalkEvent(x) ((x) & 0xffff0000) == kAppleTalkEvent)
  602. /* Protocol-specific IOCTLs*/
  603. enum {
  604. ATALK_IOC_FULLSELFSEND = ((MIOC_ATALK << 8) | 47), /* Turn on/off full self-send (it's automatic for non-backward-compatible links)*/
  605. ADSP_IOC_FORWARDRESET = ((MIOC_ATALK << 8) | 60) /* ADSP Forward Reset*/
  606. };
  607. /* Protocol-specific constants*/
  608. /* ECHO*/
  609. enum {
  610. kECHO_TSDU = 585 /* Max. # of data bytes.*/
  611. };
  612. /* NBP*/
  613. enum {
  614. kNBPMaxNameLength = 32,
  615. kNBPMaxTypeLength = 32,
  616. kNBPMaxZoneLength = 32,
  617. kNBPSlushLength = 9, /* Extra space for @, : and a few escape chars*/
  618. kNBPMaxEntityLength = (kNBPMaxNameLength + kNBPMaxTypeLength + kNBPMaxZoneLength + 3),
  619. kNBPEntityBufferSize = (kNBPMaxNameLength + kNBPMaxTypeLength + kNBPMaxZoneLength + kNBPSlushLength),
  620. kNBPWildCard = 0x3D, /* NBP name and type match anything '='*/
  621. kNBPImbeddedWildCard = 0xC5, /* NBP name and type match some '*'*/
  622. kNBPDefaultZone = 0x2A /* NBP default zone '*'*/
  623. };
  624. /* ZIP*/
  625. enum {
  626. kZIPMaxZoneLength = kNBPMaxZoneLength
  627. };
  628. enum {
  629. kDDPAddressLength = 8, /* value to use in netbuf.len field, Maximum length of AppleTalk address*/
  630. kNBPAddressLength = kNBPEntityBufferSize,
  631. kAppleTalkAddressLength = kDDPAddressLength + kNBPEntityBufferSize
  632. };
  633. #define OTCopyDDPAddress(addr, dest) \
  634. { \
  635. ((UInt32*)(dest))[0] = ((UInt32*)(addr))[0]; \
  636. ((UInt32*)(dest))[1] = ((UInt32*)(addr))[1]; \
  637. }
  638. /*******************************************************************************
  639. ** CLASS TAppleTalkServices
  640. ********************************************************************************/
  641. #if !OTKERNEL
  642. /*
  643. Define the ATSvcRef type. This type needs special
  644. processing because in C++ it's a subclass of TProvider.
  645. See the definition of TEndpointRef in "OpenTransport.h"
  646. for the logic behind this definition.
  647. */
  648. #ifdef __cplusplus
  649. typedef class TAppleTalkServices* ATSvcRef;
  650. #else
  651. typedef void* ATSvcRef;
  652. #endif
  653. #define kDefaultAppleTalkServicesPath ((OTConfigurationRef)-3L)
  654. /*
  655. Under Carbon, OpenAppleTalkServices routines take a client context pointer. Applications may pass NULL
  656. after calling InitOpenTransport(kInitOTForApplicationMask, ...). Non-applications must always pass a
  657. valid client context.
  658. */
  659. /*
  660. * OTAsyncOpenAppleTalkServicesInContext()
  661. *
  662. * Availability:
  663. * Non-Carbon CFM: not available
  664. * CarbonLib: in CarbonLib 1.0 and later
  665. * Mac OS X: in version 10.0 and later
  666. */
  667. EXTERN_API( OSStatus )
  668. OTAsyncOpenAppleTalkServicesInContext(
  669. OTConfigurationRef cfig,
  670. OTOpenFlags flags,
  671. OTNotifyUPP proc,
  672. void * contextPtr,
  673. OTClientContextPtr clientContext);
  674. /*
  675. * OTOpenAppleTalkServicesInContext()
  676. *
  677. * Availability:
  678. * Non-Carbon CFM: not available
  679. * CarbonLib: in CarbonLib 1.0 and later
  680. * Mac OS X: in version 10.0 and later
  681. */
  682. EXTERN_API( ATSvcRef )
  683. OTOpenAppleTalkServicesInContext(
  684. OTConfigurationRef cfig,
  685. OTOpenFlags flags,
  686. OSStatus * err,
  687. OTClientContextPtr clientContext);
  688. #if CALL_NOT_IN_CARBON
  689. /*
  690. * OTAsyncOpenAppleTalkServices()
  691. *
  692. * Availability:
  693. * Non-Carbon CFM: not available
  694. * CarbonLib: not available
  695. * Mac OS X: not available
  696. */
  697. EXTERN_API( OSStatus )
  698. OTAsyncOpenAppleTalkServices(
  699. OTConfigurationRef cfig,
  700. OTOpenFlags flags,
  701. OTNotifyUPP proc,
  702. void * contextPtr);
  703. /*
  704. * OTOpenAppleTalkServices()
  705. *
  706. * Availability:
  707. * Non-Carbon CFM: not available
  708. * CarbonLib: not available
  709. * Mac OS X: not available
  710. */
  711. EXTERN_API( ATSvcRef )
  712. OTOpenAppleTalkServices(
  713. OTConfigurationRef cfig,
  714. OTOpenFlags flags,
  715. OSStatus * err);
  716. #endif /* CALL_NOT_IN_CARBON */
  717. #if OTCARBONAPPLICATION
  718. /* The following macro may be used by applications only.*/
  719. #define OTOpenAppleTalkServices(cfig, oflags, err) OTOpenAppleTalkServicesInContext(cfig, oflags, err, NULL)
  720. #define OTAsyncOpenAppleTalkServices(cfig, oflags, proc, contextPtr) OTAsyncOpenAppleTalkServicesInContext(cfig, oflags, proc, contextPtr, NULL)
  721. #endif /* OTCARBONAPPLICATION */
  722. /* Get the zone associated with the ATSvcRef*/
  723. /*
  724. * OTATalkGetMyZone()
  725. *
  726. * Availability:
  727. * Non-Carbon CFM: not available
  728. * CarbonLib: in CarbonLib 1.0.2 and later
  729. * Mac OS X: in version 10.0 and later
  730. */
  731. EXTERN_API( OSStatus )
  732. OTATalkGetMyZone(
  733. ATSvcRef ref,
  734. TNetbuf * zone);
  735. /*
  736. Get the list of available zones associated with the local cable
  737. of the ATSvcRef
  738. */
  739. /*
  740. * OTATalkGetLocalZones()
  741. *
  742. * Availability:
  743. * Non-Carbon CFM: not available
  744. * CarbonLib: in CarbonLib 1.0.2 and later
  745. * Mac OS X: in version 10.0 and later
  746. */
  747. EXTERN_API( OSStatus )
  748. OTATalkGetLocalZones(
  749. ATSvcRef ref,
  750. TNetbuf * zones);
  751. /* Get the list of all zones on the internet specified by the ATSvcRef*/
  752. /*
  753. * OTATalkGetZoneList()
  754. *
  755. * Availability:
  756. * Non-Carbon CFM: not available
  757. * CarbonLib: in CarbonLib 1.0.2 and later
  758. * Mac OS X: in version 10.0 and later
  759. */
  760. EXTERN_API( OSStatus )
  761. OTATalkGetZoneList(
  762. ATSvcRef ref,
  763. TNetbuf * zones);
  764. /* Stores an AppleTalkInfo structure into the TNetbuf (see later in this file)*/
  765. /*
  766. * OTATalkGetInfo()
  767. *
  768. * Availability:
  769. * Non-Carbon CFM: not available
  770. * CarbonLib: in CarbonLib 1.0.2 and later
  771. * Mac OS X: in version 10.0 and later
  772. */
  773. EXTERN_API( OSStatus )
  774. OTATalkGetInfo(
  775. ATSvcRef ref,
  776. TNetbuf * info);
  777. #ifdef __cplusplus
  778. } // Terminate C definitions
  779. class TAppleTalkServices : public TProvider
  780. {
  781. public:
  782. OSStatus GetMyZone(TNetbuf* zone) { return OTATalkGetMyZone(this, zone); }
  783. OSStatus GetLocalZones(TNetbuf* zones) { return OTATalkGetLocalZones(this, zones); }
  784. OSStatus GetZoneList(TNetbuf* zones) { return OTATalkGetZoneList(this, zones); }
  785. OSStatus GetInfo(TNetbuf* info) { return OTATalkGetInfo(this, info); }
  786. };
  787. extern "C" { /* resume C definitions */
  788. #endif /* _cplus */
  789. #endif /* !OTKERNEL */
  790. /* AppleTalk Addressing*/
  791. /*
  792. The NBPEntity structure is used to manipulate NBP names without regard
  793. to issues of what kind of "special" characters are in the name.
  794. When stored as an address in an NBPAddress or DDPNBPAddress, they are
  795. stored as a character string, which is currently just ASCII, but in the
  796. future may be UniChar, or some other internationalizable scripting set.
  797. The string following an NBPAddress or DDPNBPAddress is intended to be
  798. suitable for showing to users, whereas NBPEntity is not.
  799. WARNING: NBPAddress and DDPNBPAddress structures do not "know" the length
  800. of the address. That must have been obtained as part of a Lookup or
  801. ResolveAddress call.
  802. */
  803. enum {
  804. AF_ATALK_FAMILY = 0x0100,
  805. AF_ATALK_DDP = 0x0100,
  806. AF_ATALK_DDPNBP = AF_ATALK_FAMILY + 1,
  807. AF_ATALK_NBP = AF_ATALK_FAMILY + 2,
  808. AF_ATALK_MNODE = AF_ATALK_FAMILY + 3
  809. };
  810. struct NBPEntity {
  811. UInt8 fEntity[99];
  812. };
  813. typedef struct NBPEntity NBPEntity;
  814. struct DDPAddress {
  815. OTAddressType fAddressType; /* One of the enums above*/
  816. UInt16 fNetwork;
  817. UInt8 fNodeID;
  818. UInt8 fSocket;
  819. UInt8 fDDPType;
  820. UInt8 fPad;
  821. #ifdef __cplusplus
  822. // C++ inline methods on this structure.
  823. void Init(const DDPAddress&);
  824. void Init(UInt16 net, UInt8 node, UInt8 socket);
  825. void Init(UInt16 net, UInt8 node, UInt8 socket, UInt8 type);
  826. void SetSocket(UInt8);
  827. void SetType(UInt8);
  828. void SetNode(UInt8);
  829. void SetNetwork(UInt16);
  830. OTByteCount GetAddressLength() const;
  831. OTAddressType GetAddressType() const;
  832. UInt8 GetSocket() const;
  833. UInt8 GetType() const;
  834. UInt8 GetNode() const;
  835. UInt16 GetNetwork() const;
  836. Boolean operator==(const DDPAddress&) const;
  837. Boolean operator!=(const DDPAddress&) const;
  838. void operator=(const DDPAddress&);
  839. #endif
  840. };
  841. typedef struct DDPAddress DDPAddress;
  842. struct NBPAddress {
  843. OTAddressType fAddressType; /* One of the enums above*/
  844. UInt8 fNBPNameBuffer[105];
  845. #ifdef __cplusplus
  846. // C++ inline methods on this structure.
  847. OTByteCount Init();
  848. OTByteCount Init(const NBPEntity&);
  849. OTByteCount Init(const char*);
  850. OTByteCount Init(const char*, OTByteCount len);
  851. Boolean ExtractEntity(NBPEntity&, OTByteCount len);
  852. OTAddressType GetAddressType() const;
  853. #endif
  854. };
  855. typedef struct NBPAddress NBPAddress;
  856. struct DDPNBPAddress {
  857. OTAddressType fAddressType; /* One of the enums above*/
  858. UInt16 fNetwork;
  859. UInt8 fNodeID;
  860. UInt8 fSocket;
  861. UInt8 fDDPType;
  862. UInt8 fPad;
  863. UInt8 fNBPNameBuffer[105];
  864. #ifdef __cplusplus
  865. // C++ inline methods on this structure.
  866. void Init(const DDPAddress&);
  867. void Init(UInt16 net, UInt8 node, UInt8 socket);
  868. void Init(UInt16 net, UInt8 node, UInt8 socket, UInt8 type);
  869. void SetSocket(UInt8);
  870. void SetType(UInt8);
  871. void SetNode(UInt8);
  872. void SetNetwork(UInt16);
  873. OTAddressType GetAddressType() const;
  874. UInt8 GetSocket() const;
  875. UInt8 GetType() const;
  876. UInt8 GetNode() const;
  877. UInt16 GetNetwork() const;
  878. Boolean ExtractEntity(NBPEntity&, OTByteCount len);
  879. OTByteCount SetNBPEntity(const NBPEntity&);
  880. OTByteCount SetNBPEntity(const char*);
  881. OTByteCount SetNBPEntity(const char*, OTByteCount len);
  882. Boolean operator==(const DDPAddress&) const;
  883. #endif
  884. };
  885. typedef struct DDPNBPAddress DDPNBPAddress;
  886. /* These are some utility routines for dealing with NBP and DDP addresses. */
  887. /* Functions to initialize the various AppleTalk Address types*/
  888. /*
  889. * OTInitDDPAddress()
  890. *
  891. * Availability:
  892. * Non-Carbon CFM: not available
  893. * CarbonLib: in CarbonLib 1.0 and later
  894. * Mac OS X: in version 10.0 and later
  895. */
  896. EXTERN_API( void )
  897. OTInitDDPAddress(
  898. DDPAddress * addr,
  899. UInt16 net,
  900. UInt8 node,
  901. UInt8 socket,
  902. UInt8 ddpType);
  903. /*
  904. * OTInitNBPAddress()
  905. *
  906. * Availability:
  907. * Non-Carbon CFM: not available
  908. * CarbonLib: in CarbonLib 1.0 and later
  909. * Mac OS X: in version 10.0 and later
  910. */
  911. EXTERN_API( OTByteCount )
  912. OTInitNBPAddress(
  913. NBPAddress * addr,
  914. const char * name);
  915. /*
  916. * OTInitDDPNBPAddress()
  917. *
  918. * Availability:
  919. * Non-Carbon CFM: not available
  920. * CarbonLib: in CarbonLib 1.0 and later
  921. * Mac OS X: in version 10.0 and later
  922. */
  923. EXTERN_API( OTByteCount )
  924. OTInitDDPNBPAddress(
  925. DDPNBPAddress * addr,
  926. const char * name,
  927. UInt16 net,
  928. UInt8 node,
  929. UInt8 socket,
  930. UInt8 ddpType);
  931. /* Compare 2 DDP addresses for equality*/
  932. /*
  933. * OTCompareDDPAddresses()
  934. *
  935. * Availability:
  936. * Non-Carbon CFM: not available
  937. * CarbonLib: in CarbonLib 1.0 and later
  938. * Mac OS X: in version 10.0 and later
  939. */
  940. EXTERN_API( Boolean )
  941. OTCompareDDPAddresses(
  942. const DDPAddress * addr1,
  943. const DDPAddress * addr2);
  944. /* Init an NBPEntity to a NULL name*/
  945. /*
  946. * OTInitNBPEntity()
  947. *
  948. * Availability:
  949. * Non-Carbon CFM: not available
  950. * CarbonLib: in CarbonLib 1.0 and later
  951. * Mac OS X: in version 10.0 and later
  952. */
  953. EXTERN_API( void )
  954. OTInitNBPEntity(NBPEntity * entity);
  955. /* Get the length an NBPEntity would have when stored as an address*/
  956. /*
  957. * OTGetNBPEntityLengthAsAddress()
  958. *
  959. * Availability:
  960. * Non-Carbon CFM: not available
  961. * CarbonLib: in CarbonLib 1.0 and later
  962. * Mac OS X: in version 10.0 and later
  963. */
  964. EXTERN_API( OTByteCount )
  965. OTGetNBPEntityLengthAsAddress(const NBPEntity * entity);
  966. /* Store an NBPEntity into an address buffer*/
  967. /*
  968. * OTSetAddressFromNBPEntity()
  969. *
  970. * Availability:
  971. * Non-Carbon CFM: not available
  972. * CarbonLib: in CarbonLib 1.0 and later
  973. * Mac OS X: in version 10.0 and later
  974. */
  975. EXTERN_API( OTByteCount )
  976. OTSetAddressFromNBPEntity(
  977. UInt8 * nameBuf,
  978. const NBPEntity * entity);
  979. /* Create an address buffer from a string (use -1 for len to use strlen)*/
  980. /*
  981. * OTSetAddressFromNBPString()
  982. *
  983. * Availability:
  984. * Non-Carbon CFM: not available
  985. * CarbonLib: in CarbonLib 1.0 and later
  986. * Mac OS X: in version 10.0 and later
  987. */
  988. EXTERN_API( OTByteCount )
  989. OTSetAddressFromNBPString(
  990. UInt8 * addrBuf,
  991. const char * name,
  992. SInt32 len);
  993. /*
  994. Create an NBPEntity from an address buffer. False is returned if
  995. the address was truncated.
  996. */
  997. /*
  998. * OTSetNBPEntityFromAddress()
  999. *
  1000. * Availability:
  1001. * Non-Carbon CFM: not available
  1002. * CarbonLib: in CarbonLib 1.0 and later
  1003. * Mac OS X: in version 10.0 and later
  1004. */
  1005. EXTERN_API( Boolean )
  1006. OTSetNBPEntityFromAddress(
  1007. NBPEntity * entity,
  1008. const UInt8 * addrBuf,
  1009. OTByteCount len);
  1010. /* Routines to set a piece of an NBP entity from a character string*/
  1011. /*
  1012. * OTSetNBPName()
  1013. *
  1014. * Availability:
  1015. * Non-Carbon CFM: not available
  1016. * CarbonLib: in CarbonLib 1.0 and later
  1017. * Mac OS X: in version 10.0 and later
  1018. */
  1019. EXTERN_API( Boolean )
  1020. OTSetNBPName(
  1021. NBPEntity * entity,
  1022. const char * name);
  1023. /*
  1024. * OTSetNBPType()
  1025. *
  1026. * Availability:
  1027. * Non-Carbon CFM: not available
  1028. * CarbonLib: in CarbonLib 1.0 and later
  1029. * Mac OS X: in version 10.0 and later
  1030. */
  1031. EXTERN_API( Boolean )
  1032. OTSetNBPType(
  1033. NBPEntity * entity,
  1034. const char * typeVal);
  1035. /*
  1036. * OTSetNBPZone()
  1037. *
  1038. * Availability:
  1039. * Non-Carbon CFM: not available
  1040. * CarbonLib: in CarbonLib 1.0 and later
  1041. * Mac OS X: in version 10.0 and later
  1042. */
  1043. EXTERN_API( Boolean )
  1044. OTSetNBPZone(
  1045. NBPEntity * entity,
  1046. const char * zone);
  1047. /* Routines to extract pieces of an NBP entity*/
  1048. /*
  1049. * OTExtractNBPName()
  1050. *
  1051. * Availability:
  1052. * Non-Carbon CFM: not available
  1053. * CarbonLib: in CarbonLib 1.0 and later
  1054. * Mac OS X: in version 10.0 and later
  1055. */
  1056. EXTERN_API( void )
  1057. OTExtractNBPName(
  1058. const NBPEntity * entity,
  1059. char * name);
  1060. /*
  1061. * OTExtractNBPType()
  1062. *
  1063. * Availability:
  1064. * Non-Carbon CFM: not available
  1065. * CarbonLib: in CarbonLib 1.0 and later
  1066. * Mac OS X: in version 10.0 and later
  1067. */
  1068. EXTERN_API( void )
  1069. OTExtractNBPType(
  1070. const NBPEntity * entity,
  1071. char * typeVal);
  1072. /*
  1073. * OTExtractNBPZone()
  1074. *
  1075. * Availability:
  1076. * Non-Carbon CFM: not available
  1077. * CarbonLib: in CarbonLib 1.0 and later
  1078. * Mac OS X: in version 10.0 and later
  1079. */
  1080. EXTERN_API( void )
  1081. OTExtractNBPZone(
  1082. const NBPEntity * entity,
  1083. char * zone);
  1084. #ifdef __cplusplus
  1085. // Inline methods for DDPAddress
  1086. inline void DDPAddress::operator=(const DDPAddress& addr)
  1087. {
  1088. *(UInt32*)&fAddressType = *(UInt32*)&addr.fAddressType;
  1089. *(UInt32*)&fNodeID = *(UInt32*)&addr.fNodeID;
  1090. }
  1091. inline Boolean DDPAddress::operator==(const DDPAddress& addr) const
  1092. {
  1093. return OTCompareDDPAddresses(&addr, this);
  1094. }
  1095. inline Boolean DDPAddress::operator!=(const DDPAddress& addr) const
  1096. {
  1097. return !OTCompareDDPAddresses(&addr, this);
  1098. }
  1099. inline void DDPAddress::SetSocket(UInt8 socket)
  1100. {
  1101. fSocket = socket;
  1102. }
  1103. inline void DDPAddress::SetNode(UInt8 node)
  1104. {
  1105. fNodeID = node;
  1106. }
  1107. inline void DDPAddress::SetType(UInt8 type)
  1108. {
  1109. fDDPType = type;
  1110. }
  1111. inline void DDPAddress::SetNetwork(UInt16 net)
  1112. {
  1113. fNetwork = net;
  1114. }
  1115. inline OTByteCount DDPAddress::GetAddressLength() const
  1116. {
  1117. return kDDPAddressLength;
  1118. }
  1119. inline OTAddressType DDPAddress::GetAddressType() const
  1120. {
  1121. return fAddressType;
  1122. }
  1123. inline UInt8 DDPAddress::GetSocket() const
  1124. {
  1125. return fSocket;
  1126. }
  1127. inline UInt8 DDPAddress::GetNode() const
  1128. {
  1129. return fNodeID;
  1130. }
  1131. inline UInt8 DDPAddress::GetType() const
  1132. {
  1133. return fDDPType;
  1134. }
  1135. inline UInt16 DDPAddress::GetNetwork() const
  1136. {
  1137. return fNetwork;
  1138. }
  1139. inline void DDPAddress::Init(UInt16 net, UInt8 node,
  1140. UInt8 socket)
  1141. {
  1142. fAddressType = AF_ATALK_DDP;
  1143. SetNetwork(net);
  1144. SetNode(node);
  1145. SetSocket(socket);
  1146. SetType(0);
  1147. }
  1148. inline void DDPAddress::Init(UInt16 net, UInt8 node,
  1149. UInt8 socket, UInt8 type)
  1150. {
  1151. fAddressType = AF_ATALK_DDP;
  1152. SetNetwork(net);
  1153. SetNode(node);
  1154. SetSocket(socket);
  1155. SetType(type);
  1156. }
  1157. inline void DDPAddress::Init(const DDPAddress& addr)
  1158. {
  1159. *(UInt32*)&fAddressType = *(UInt32*)&addr.fAddressType;
  1160. *(UInt32*)&fNodeID = *(UInt32*)&addr.fNodeID;
  1161. }
  1162. // Inline methods for NBPAddress
  1163. inline OTByteCount NBPAddress::Init()
  1164. {
  1165. fAddressType = AF_ATALK_NBP;
  1166. return sizeof(OTAddressType);
  1167. }
  1168. inline OTByteCount NBPAddress::Init(const NBPEntity& addr)
  1169. {
  1170. fAddressType = AF_ATALK_NBP;
  1171. return sizeof(OTAddressType) + OTSetAddressFromNBPEntity(fNBPNameBuffer, &addr);
  1172. }
  1173. inline OTByteCount NBPAddress::Init(const char* name)
  1174. {
  1175. fAddressType = AF_ATALK_NBP;
  1176. return sizeof(OTAddressType) + OTSetAddressFromNBPString(fNBPNameBuffer, name, -1);
  1177. }
  1178. inline OTByteCount NBPAddress::Init(const char* name, OTByteCount len)
  1179. {
  1180. fAddressType = AF_ATALK_NBP;
  1181. return sizeof(OTAddressType) + OTSetAddressFromNBPString(fNBPNameBuffer, name, (SInt32)len);
  1182. }
  1183. inline Boolean NBPAddress::ExtractEntity(NBPEntity& entity, OTByteCount len)
  1184. {
  1185. return OTSetNBPEntityFromAddress(&entity, fNBPNameBuffer, len);
  1186. }
  1187. inline OTAddressType NBPAddress::GetAddressType() const
  1188. {
  1189. return fAddressType;
  1190. }
  1191. // Inline methods for DDPNBPAddress
  1192. inline Boolean DDPNBPAddress::operator==(const DDPAddress& addr) const
  1193. {
  1194. return OTCompareDDPAddresses((const DDPAddress*)this, &addr);
  1195. }
  1196. inline void DDPNBPAddress::SetSocket(UInt8 socket)
  1197. {
  1198. fSocket = socket;
  1199. }
  1200. inline void DDPNBPAddress::SetNode(UInt8 node)
  1201. {
  1202. fNodeID = node;
  1203. }
  1204. inline void DDPNBPAddress::SetType(UInt8 type)
  1205. {
  1206. fDDPType = type;
  1207. }
  1208. inline void DDPNBPAddress::SetNetwork(UInt16 net)
  1209. {
  1210. fNetwork = net;
  1211. }
  1212. inline OTAddressType DDPNBPAddress::GetAddressType() const
  1213. {
  1214. return fAddressType;
  1215. }
  1216. inline UInt8 DDPNBPAddress::GetSocket() const
  1217. {
  1218. return fSocket;
  1219. }
  1220. inline UInt8 DDPNBPAddress::GetNode() const
  1221. {
  1222. return fNodeID;
  1223. }
  1224. inline UInt8 DDPNBPAddress::GetType() const
  1225. {
  1226. return fDDPType;
  1227. }
  1228. inline UInt16 DDPNBPAddress::GetNetwork() const
  1229. {
  1230. return fNetwork;
  1231. }
  1232. inline void DDPNBPAddress::Init(UInt16 net, UInt8 node,
  1233. UInt8 socket)
  1234. {
  1235. fAddressType = AF_ATALK_DDPNBP;
  1236. SetNetwork(net);
  1237. SetNode(node);
  1238. SetSocket(socket);
  1239. SetType(0);
  1240. }
  1241. inline void DDPNBPAddress::Init(UInt16 net, UInt8 node,
  1242. UInt8 socket, UInt8 type)
  1243. {
  1244. fAddressType = AF_ATALK_DDPNBP;
  1245. SetNetwork(net);
  1246. SetNode(node);
  1247. SetSocket(socket);
  1248. SetType(type);
  1249. }
  1250. inline void DDPNBPAddress::Init(const DDPAddress& addr)
  1251. {
  1252. fAddressType = AF_ATALK_DDPNBP;
  1253. SetNetwork(addr.GetNetwork());
  1254. SetNode(addr.GetNode());
  1255. SetSocket(addr.GetSocket());
  1256. SetType(addr.GetType());
  1257. fNBPNameBuffer[0] = 0;
  1258. }
  1259. inline OTByteCount DDPNBPAddress::SetNBPEntity(const NBPEntity& entity)
  1260. {
  1261. return OTSetAddressFromNBPEntity(fNBPNameBuffer, &entity) + kDDPAddressLength;
  1262. }
  1263. inline OTByteCount DDPNBPAddress::SetNBPEntity(const char* name)
  1264. {
  1265. return OTSetAddressFromNBPString(fNBPNameBuffer, name, -1) + kDDPAddressLength;
  1266. }
  1267. inline OTByteCount DDPNBPAddress::SetNBPEntity(const char* name, OTByteCount len)
  1268. {
  1269. return OTSetAddressFromNBPString(fNBPNameBuffer, name, (SInt32)len) + kDDPAddressLength;
  1270. }
  1271. inline Boolean DDPNBPAddress::ExtractEntity(NBPEntity& entity, OTByteCount len)
  1272. {
  1273. return OTSetNBPEntityFromAddress(&entity, fNBPNameBuffer, len);
  1274. }
  1275. #endif /* __cplusplus */
  1276. /* AppleTalkInfo as used by the OTGetATalkInfo function*/
  1277. struct AppleTalkInfo {
  1278. DDPAddress fOurAddress; /* Our DDP address (network # & node)*/
  1279. DDPAddress fRouterAddress; /* The address of a router on our cable*/
  1280. UInt16 fCableRange[2]; /* The current cable range*/
  1281. UInt16 fFlags; /* See below*/
  1282. };
  1283. typedef struct AppleTalkInfo AppleTalkInfo;
  1284. /* For the fFlags field in AppleTalkInfo*/
  1285. enum {
  1286. kATalkInfoIsExtended = 0x0001, /* This is an extended (phase 2) network*/
  1287. kATalkInfoHasRouter = 0x0002, /* This cable has a router*/
  1288. kATalkInfoOneZone = 0x0004 /* This cable has only one zone*/
  1289. };
  1290. /* ***** Ethernet ******/
  1291. /* Interface option flags*/
  1292. /* Ethernet framing options*/
  1293. enum {
  1294. kOTFramingEthernet = 0x01,
  1295. kOTFramingEthernetIPX = 0x02,
  1296. kOTFraming8023 = 0x04,
  1297. kOTFraming8022 = 0x08
  1298. };
  1299. /*
  1300. These are obsolete and will be going away in OT 1.5.
  1301. Hmmm, OT 1.5 got cancelled. The status of these options
  1302. is uncertain.
  1303. */
  1304. /* RawMode options*/
  1305. enum {
  1306. kOTRawRcvOn = 0,
  1307. kOTRawRcvOff = 1,
  1308. kOTRawRcvOnWithTimeStamp = 2
  1309. };
  1310. enum {
  1311. DL_PROMISC_OFF = 0 /* OPT_SETPROMISCUOUS value*/
  1312. };
  1313. /* Module definitions*/
  1314. /* Module IDs*/
  1315. enum {
  1316. kT8022ModuleID = 7100,
  1317. kEnetModuleID = 7101,
  1318. kTokenRingModuleID = 7102,
  1319. kFDDIModuleID = 7103
  1320. };
  1321. /* Module Names*/
  1322. #define kEnet8022Name "enet8022x"
  1323. #define kEnetName "enet"
  1324. #define kFastEnetName "fenet"
  1325. #define kTokenRingName "tokn"
  1326. #define kFDDIName "fddi"
  1327. #define kIRTalkName "irtlk"
  1328. #define kSMDSName "smds"
  1329. #define kATMName "atm"
  1330. #define kT8022Name "tpi8022x"
  1331. #define kATMSNAPName "atmsnap"
  1332. #define kFireWireName "firewire"
  1333. #define kFibreChannelName "fibre"
  1334. /* Address Family*/
  1335. enum {
  1336. AF_8022 = 8200 /* Our 802.2 generic address family*/
  1337. };
  1338. /* XTI Levels*/
  1339. enum {
  1340. LNK_ENET = FOUR_CHAR_CODE('ENET'),
  1341. LNK_TOKN = FOUR_CHAR_CODE('TOKN'),
  1342. LNK_FDDI = FOUR_CHAR_CODE('FDDI'),
  1343. LNK_TPI = FOUR_CHAR_CODE('LTPI')
  1344. };
  1345. /* Options*/
  1346. enum {
  1347. OPT_ADDMCAST = 0x1000,
  1348. OPT_DELMCAST = 0x1001,
  1349. OPT_RCVPACKETTYPE = 0x1002,
  1350. OPT_RCVDESTADDR = 0x1003,
  1351. OPT_SETRAWMODE = 0x1004,
  1352. OPT_SETPROMISCUOUS = 0x1005
  1353. };
  1354. typedef UInt32 OTPacketType;
  1355. enum {
  1356. kETypeStandard = 0,
  1357. kETypeMulticast = 1,
  1358. kETypeBroadcast = 2,
  1359. kETRawPacketBit = (unsigned long)0x80000000,
  1360. kETTimeStampBit = 0x40000000
  1361. };
  1362. /* Link related constants*/
  1363. enum {
  1364. kMulticastLength = 6, /* length of an ENET hardware addressaddress*/
  1365. k48BitAddrLength = 6,
  1366. k8022DLSAPLength = 2, /* The protocol type is our DLSAP*/
  1367. k8022SNAPLength = 5,
  1368. kEnetAddressLength = k48BitAddrLength + k8022DLSAPLength, /* length of an address field used by the ENET enpoint*/
  1369. /* = k48BitAddrLength + sizeof(protocol type)*/
  1370. kSNAPSAP = 0x00AA, /* Special DLSAPS for ENET*/
  1371. kIPXSAP = 0x00FF,
  1372. kMax8022SAP = 0x00FE,
  1373. k8022GlobalSAP = 0x00FF,
  1374. kMinDIXSAP = 1501,
  1375. kMaxDIXSAP = 0xFFFF
  1376. };
  1377. /* Generic Address Structure*/
  1378. struct T8022Address {
  1379. OTAddressType fAddrFamily;
  1380. UInt8 fHWAddr[6];
  1381. UInt16 fSAP;
  1382. UInt8 fSNAP[5];
  1383. };
  1384. typedef struct T8022Address T8022Address;
  1385. enum {
  1386. k8022BasicAddressLength = sizeof(OTAddressType) + k48BitAddrLength + sizeof(UInt16),
  1387. k8022SNAPAddressLength = sizeof(OTAddressType) + k48BitAddrLength + sizeof(UInt16) + k8022SNAPLength
  1388. };
  1389. /* Some helpful stuff for dealing with 48 bit addresses*/
  1390. #define OTCompare48BitAddresses(p1, p2) \
  1391. (*(const UInt32*)((const UInt8*)(p1)) == *(const UInt32*)((const UInt8*)(p2)) && \
  1392. *(const UInt16*)(((const UInt8*)(p1))+4) == *(const UInt16*)(((const UInt8*)(p2))+4) )
  1393. #define OTCopy48BitAddress(p1, p2) \
  1394. (*(UInt32*)((UInt8*)(p2)) = *(const UInt32*)((const UInt8*)(p1)), \
  1395. *(UInt16*)(((UInt8*)(p2))+4) = *(const UInt16*)(((const UInt8*)(p1))+4) )
  1396. #define OTClear48BitAddress(p1) \
  1397. (*(UInt32*)((UInt8*)(p1)) = 0, \
  1398. *(UInt16*)(((UInt8*)(p1))+4) = 0 )
  1399. #define OTCompare8022SNAP(p1, p2) \
  1400. (*(const UInt32*)((const UInt8*)(p1)) == *(const UInt32*)((const UInt8*)(p2)) && \
  1401. *(((const UInt8*)(p1))+4) == *(((const UInt8*)(p2))+4) )
  1402. #define OTCopy8022SNAP(p1, p2) \
  1403. (*(UInt32*)((UInt8*)(p2)) = *(const UInt32*)((const UInt8*)(p1)), \
  1404. *(((UInt8*)(p2))+4) = *(((const UInt8*)(p1))+4) )
  1405. #define OTIs48BitBroadcastAddress(p1) \
  1406. (*(UInt32*)((UInt8*)(p1)) == 0xffffffff && \
  1407. *(UInt16*)(((UInt8*)(p1))+4) == 0xffff )
  1408. #define OTSet48BitBroadcastAddress(p1) \
  1409. (*(UInt32*)((UInt8*)(p1)) = 0xffffffff, \
  1410. *(UInt16*)(((UInt8*)(p1))+4) = 0xffff )
  1411. #define OTIs48BitZeroAddress(p1) \
  1412. (*(UInt32*)((UInt8*)(p1)) == 0 && \
  1413. *(UInt16*)(((UInt8*)(p1))+4) == 0 )
  1414. /* Link related constants*/
  1415. enum {
  1416. kEnetPacketHeaderLength = (2 * k48BitAddrLength) + k8022DLSAPLength,
  1417. kEnetTSDU = 1514, /* The TSDU for ethernet.*/
  1418. kTokenRingTSDU = 4458, /* The TSDU for TokenRing.*/
  1419. kFDDITSDU = 4458, /* The TSDU for FDDI. */
  1420. k8022SAPLength = 1,
  1421. k8022BasicHeaderLength = 3, /* define the length of the header portion of an 802.2 packet.*/
  1422. /* = SSAP+DSAP+ControlByte*/
  1423. k8022SNAPHeaderLength = k8022SNAPLength + k8022BasicHeaderLength
  1424. };
  1425. /*******************************************************************************
  1426. ** Address Types recognized by the Enet DLPI
  1427. ********************************************************************************/
  1428. typedef UInt32 EAddrType;
  1429. enum {
  1430. keaStandardAddress = 0,
  1431. keaMulticast = 1,
  1432. keaBroadcast = 2,
  1433. keaBadAddress = 3,
  1434. keaRawPacketBit = (unsigned long)0x80000000,
  1435. keaTimeStampBit = 0x40000000
  1436. };
  1437. /* Packet Header Structures*/
  1438. struct EnetPacketHeader {
  1439. UInt8 fDestAddr[6];
  1440. UInt8 fSourceAddr[6];
  1441. UInt16 fProto;
  1442. };
  1443. typedef struct EnetPacketHeader EnetPacketHeader;
  1444. struct T8022Header {
  1445. UInt8 fDSAP;
  1446. UInt8 fSSAP;
  1447. UInt8 fCtrl;
  1448. };
  1449. typedef struct T8022Header T8022Header;
  1450. struct T8022SNAPHeader {
  1451. UInt8 fDSAP;
  1452. UInt8 fSSAP;
  1453. UInt8 fCtrl;
  1454. UInt8 fSNAP[5];
  1455. };
  1456. typedef struct T8022SNAPHeader T8022SNAPHeader;
  1457. struct T8022FullPacketHeader {
  1458. EnetPacketHeader fEnetPart;
  1459. T8022SNAPHeader f8022Part;
  1460. };
  1461. typedef struct T8022FullPacketHeader T8022FullPacketHeader;
  1462. /* Define the lengths of the structures above*/
  1463. enum {
  1464. kT8022HeaderLength = 3,
  1465. kT8022SNAPHeaderLength = 3 + k8022SNAPLength,
  1466. kT8022FullPacketHeaderLength = kEnetPacketHeaderLength + kT8022SNAPHeaderLength
  1467. };
  1468. /* ***** Serial ******/
  1469. /* Module Definitions*/
  1470. /* XTI Level*/
  1471. enum {
  1472. COM_SERIAL = FOUR_CHAR_CODE('SERL')
  1473. };
  1474. /* Version Number*/
  1475. #define kSerialABVersion "1.1.1"
  1476. /* Module Names*/
  1477. #define kSerialABName "serialAB"
  1478. #define kSerialName "serial"
  1479. #define kSerialPortAName "serialA"
  1480. #define kSerialPortBName "serialB"
  1481. enum {
  1482. kSerialABModuleID = 7200
  1483. };
  1484. enum {
  1485. kOTSerialFramingAsync = 0x01, /* Support Async serial mode */
  1486. kOTSerialFramingHDLC = 0x02, /* Support HDLC synchronous serial mode */
  1487. kOTSerialFramingSDLC = 0x04, /* Support SDLC synchronous serial mode */
  1488. kOTSerialFramingAsyncPackets = 0x08, /* Support Async "packet" serial mode */
  1489. kOTSerialFramingPPP = 0x10 /* Port does its own PPP framing - wants unframed packets from PPP */
  1490. };
  1491. /* IOCTL Calls for Serial Drivers*/
  1492. enum {
  1493. I_SetSerialDTR = ((MIOC_SRL << 8) | 0), /* Set DTR (0 = off, 1 = on)*/
  1494. kOTSerialSetDTROff = 0,
  1495. kOTSerialSetDTROn = 1,
  1496. I_SetSerialBreak = ((MIOC_SRL << 8) | 1), /* Send a break on the line - kOTSerialSetBreakOff = off, kOTSerialSetBreakOn = on,*/
  1497. /* Any other number is the number of milliseconds to leave break on, then*/
  1498. /* auto shutoff*/
  1499. kOTSerialSetBreakOn = (unsigned long)0xFFFFFFFF,
  1500. kOTSerialSetBreakOff = 0,
  1501. I_SetSerialXOffState = ((MIOC_SRL << 8) | 2), /* Force XOFF state - 0 = Unconditionally clear XOFF state, 1 = unconditionally set it*/
  1502. kOTSerialForceXOffTrue = 1,
  1503. kOTSerialForceXOffFalse = 0,
  1504. I_SetSerialXOn = ((MIOC_SRL << 8) | 3), /* Send an XON character, 0 = send only if in XOFF state, 1 = send always*/
  1505. kOTSerialSendXOnAlways = 1,
  1506. kOTSerialSendXOnIfXOffTrue = 0,
  1507. I_SetSerialXOff = ((MIOC_SRL << 8) | 4), /* Send an XOFF character, 0 = send only if in XON state, 1 = send always*/
  1508. kOTSerialSendXOffAlways = 1,
  1509. kOTSerialSendXOffIfXOnTrue = 0
  1510. };
  1511. /* Option Management for Serial Drivers*/
  1512. /*
  1513. These options are all 4-byte values.
  1514. BaudRate is the baud rate.
  1515. DataBits is the number of data bits.
  1516. StopBits is the number of stop bits times 10.
  1517. Parity is an enum
  1518. */
  1519. enum {
  1520. SERIAL_OPT_BAUDRATE = 0x0100, /* UInt32 */
  1521. SERIAL_OPT_DATABITS = 0x0101, /* UInt32 */
  1522. SERIAL_OPT_STOPBITS = 0x0102, /* UInt32 10, 15 or 20 for 1, 1.5 or 2 */
  1523. SERIAL_OPT_PARITY = 0x0103, /* UInt32 */
  1524. SERIAL_OPT_STATUS = 0x0104, /* UInt32 */
  1525. /* The "Status" option is a 4-byte value option that is ReadOnly*/
  1526. /* It returns a bitmap of the current serial status*/
  1527. SERIAL_OPT_HANDSHAKE = 0x0105, /* UInt32 */
  1528. /* The "Handshake" option defines what kind of handshaking the serial port*/
  1529. /* will do for line flow control. The value is a 32-bit value defined by*/
  1530. /* the function or macro SerialHandshakeData below.*/
  1531. /* For no handshake, or CTS handshake, the onChar and offChar parameters*/
  1532. /* are ignored.*/
  1533. SERIAL_OPT_RCVTIMEOUT = 0x0106, /* The "RcvTimeout" option defines how long the receiver should wait before delivering*/
  1534. /* less than the RcvLoWat number of characters. If RcvLoWat is 0, then the RcvTimeout*/
  1535. /* is how long a gap to wait for before delivering characters. This parameter is advisory,*/
  1536. /* and serial drivers are free to deliver data whenever they deem it convenient. For instance,*/
  1537. /* many serial drivers will deliver data whenever 64 bytes have been received, since 64 bytes*/
  1538. /* is the smallest STREAMS buffer size. Keep in mind that timeouts are quantized, so be sure to*/
  1539. /* look at the return value of the option to determine what it was negotiated to.*/
  1540. SERIAL_OPT_ERRORCHARACTER = 0x0107, /* This option defines how characters with parity errors are handled.*/
  1541. /* A 0 value will disable all replacement. A single character value in the low*/
  1542. /* byte designates the replacement character. When characters are received with a */
  1543. /* parity error, they are replaced by this specified character. If a valid incoming*/
  1544. /* character matches the replacement character, then the received character's msb is*/
  1545. /* cleared. For this situation, the alternate character is used, if specified in bits*/
  1546. /* 8 through 15 of the option long, with 0xff being place in bits 16 through 23.*/
  1547. /* Whenever a valid character is received that matches the first replacement character,*/
  1548. /* it is replaced with this alternate character.*/
  1549. SERIAL_OPT_EXTCLOCK = 0x0108, /* The "ExtClock" requests an external clock. A 0-value turns off external clocking.*/
  1550. /* Any other value is a requested divisor for the external clock. Be aware that*/
  1551. /* not all serial implementations support an external clock, and that not all*/
  1552. /* requested divisors will be supported if it does support an external clock.*/
  1553. SERIAL_OPT_BURSTMODE = 0x0109, /* The "BurstMode" option informs the serial driver that it should continue looping,*/
  1554. /* reading incoming characters, rather than waiting for an interrupt for each character.*/
  1555. /* This option may not be supported by all Serial driver*/
  1556. SERIAL_OPT_DUMMY = 0x010A /* placeholder*/
  1557. };
  1558. typedef UInt32 ParityOptionValues;
  1559. enum {
  1560. kOTSerialNoParity = 0,
  1561. kOTSerialOddParity = 1,
  1562. kOTSerialEvenParity = 2
  1563. };
  1564. enum {
  1565. kOTSerialSwOverRunErr = 0x01,
  1566. kOTSerialBreakOn = 0x08,
  1567. kOTSerialParityErr = 0x10,
  1568. kOTSerialOverrunErr = 0x20,
  1569. kOTSerialFramingErr = 0x40,
  1570. kOTSerialXOffSent = 0x00010000,
  1571. kOTSerialDTRNegated = 0x00020000,
  1572. kOTSerialCTLHold = 0x00040000,
  1573. kOTSerialXOffHold = 0x00080000,
  1574. kOTSerialOutputBreakOn = 0x01000000
  1575. };
  1576. enum {
  1577. kOTSerialXOnOffInputHandshake = 1, /* Want XOn/XOff handshake for incoming characters */
  1578. kOTSerialXOnOffOutputHandshake = 2, /* Want XOn/XOff handshake for outgoing characters */
  1579. kOTSerialCTSInputHandshake = 4, /* Want CTS handshake for incoming characters */
  1580. kOTSerialDTROutputHandshake = 8 /* Want DTR handshake for outoing characters */
  1581. };
  1582. #ifdef __cplusplus
  1583. inline UInt32 OTSerialHandshakeData(UInt16 type, UInt8 onChar, UInt8 offChar)
  1584. {
  1585. return (((UInt32)type) << 16) | (((UInt32)onChar) << 8) | offChar;
  1586. }
  1587. #else
  1588. #define OTSerialHandshakeData(type, onChar, offChar) \
  1589. ((((UInt32)type) << 16) | (((UInt32)onChar) << 8) | offChar)
  1590. #endif
  1591. #ifdef __cplusplus
  1592. inline UInt32 OTSerialSetErrorCharacter(UInt8 rep)
  1593. {
  1594. return (UInt32)rep & 0x000000ff;
  1595. }
  1596. inline UInt32 OTSerialSetErrorCharacterWithAlternate(UInt8 rep, UInt8 alternate)
  1597. {
  1598. return (((rep & 0xff) | ((alternate & 0xff) << 8)) | 0x80000000L);
  1599. }
  1600. #else
  1601. #define OTSerialSetErrorCharacter(rep) \
  1602. ((rep) & 0xff)
  1603. #define OTSerialSetErrorCharacterWithAlternate(rep, alternate) \
  1604. ((((rep) & 0xff) | (((alternate) & 0xff) << 8)) | 0x80000000L)
  1605. #endif
  1606. /* Default attributes for the serial ports*/
  1607. enum {
  1608. kOTSerialDefaultBaudRate = 19200,
  1609. kOTSerialDefaultDataBits = 8,
  1610. kOTSerialDefaultStopBits = 10,
  1611. kOTSerialDefaultParity = kOTSerialNoParity,
  1612. kOTSerialDefaultHandshake = 0,
  1613. kOTSerialDefaultOnChar = ('Q' & 0xFFFFFFBF),
  1614. kOTSerialDefaultOffChar = ('S' & 0xFFFFFFBF),
  1615. kOTSerialDefaultSndBufSize = 1024,
  1616. kOTSerialDefaultRcvBufSize = 1024,
  1617. kOTSerialDefaultSndLoWat = 96,
  1618. kOTSerialDefaultRcvLoWat = 1,
  1619. kOTSerialDefaultRcvTimeout = 10
  1620. };
  1621. /* ***** ISDN ******/
  1622. /* Module Definitions*/
  1623. /* XTI Level*/
  1624. enum {
  1625. COM_ISDN = FOUR_CHAR_CODE('ISDN')
  1626. };
  1627. /* Module Names*/
  1628. #define kISDNName "isdn"
  1629. enum {
  1630. kISDNModuleID = 7300
  1631. };
  1632. /* ISDN framing methods, set using the I_OTSetFramingType IOCTL*/
  1633. enum {
  1634. kOTISDNFramingTransparentSupported = 0x0010, /* Support Transparent mode */
  1635. kOTISDNFramingHDLCSupported = 0x0020, /* Support HDLC Synchronous mode */
  1636. kOTISDNFramingV110Supported = 0x0040, /* Support V.110 Asynchronous mode */
  1637. kOTISDNFramingV14ESupported = 0x0080 /* Support V.14 Asynchronous mode */
  1638. };
  1639. /* Miscellaneous equates*/
  1640. /* Disconnect reason codes (from Q.931)*/
  1641. enum {
  1642. kOTISDNUnallocatedNumber = 1,
  1643. kOTISDNNoRouteToSpecifiedTransitNetwork = 2,
  1644. kOTISDNNoRouteToDestination = 3,
  1645. kOTISDNChannelUnacceptable = 6,
  1646. kOTISDNNormal = 16,
  1647. kOTISDNUserBusy = 17,
  1648. kOTISDNNoUserResponding = 18,
  1649. kOTISDNNoAnswerFromUser = 19,
  1650. kOTISDNCallRejected = 21,
  1651. kOTISDNNumberChanged = 22,
  1652. kOTISDNNonSelectedUserClearing = 26,
  1653. kOTISDNDestinationOutOfOrder = 27,
  1654. kOTISDNInvalidNumberFormat = 28,
  1655. kOTISDNFacilityRejected = 29,
  1656. kOTISDNNormalUnspecified = 31,
  1657. kOTISDNNoCircuitChannelAvailable = 34,
  1658. kOTISDNNetworkOutOfOrder = 41,
  1659. kOTISDNSwitchingEquipmentCongestion = 42,
  1660. kOTISDNAccessInformationDiscarded = 43,
  1661. kOTISDNRequestedCircuitChannelNotAvailable = 44,
  1662. kOTISDNResourceUnavailableUnspecified = 45,
  1663. kOTISDNQualityOfServiceUnvailable = 49,
  1664. kOTISDNRequestedFacilityNotSubscribed = 50,
  1665. kOTISDNBearerCapabilityNotAuthorized = 57,
  1666. kOTISDNBearerCapabilityNotPresentlyAvailable = 58,
  1667. kOTISDNCallRestricted = 59,
  1668. kOTISDNServiceOrOptionNotAvilableUnspecified = 63,
  1669. kOTISDNBearerCapabilityNotImplemented = 65,
  1670. kOTISDNRequestedFacilityNotImplemented = 69,
  1671. kOTISDNOnlyRestrictedDigitalBearer = 70,
  1672. kOTISDNServiceOrOptionNotImplementedUnspecified = 79,
  1673. kOTISDNCallIdentityNotUsed = 83,
  1674. kOTISDNCallIdentityInUse = 84,
  1675. kOTISDNNoCallSuspended = 85,
  1676. kOTISDNCallIdentityCleared = 86,
  1677. kOTISDNIncompatibleDestination = 88,
  1678. kOTISDNInvalidTransitNetworkSelection = 91,
  1679. kOTISDNInvalidMessageUnspecified = 95,
  1680. kOTISDNMandatoryInformationElementIsMissing = 96,
  1681. kOTISDNMessageTypeNonExistentOrNotImplemented = 97,
  1682. kOTISDNInterworkingUnspecified = 127
  1683. };
  1684. /* OTISDNAddress*/
  1685. /*
  1686. The OTISDNAddress has the following format:
  1687. "xxxxxx*yy"
  1688. where 'x' is the phone number and 'y' is the sub address (if available
  1689. in the network. The characters are coded in ASCII (IA5), and valid
  1690. characters are: '0'-'9','#','*'.
  1691. The max length of the each phone number is 21 characters (?) and the max
  1692. subaddress length is network dependent.
  1693. When using bonded channels the phone numbers are separated by '&'.
  1694. The X.25 user data is preceded by '@'.
  1695. */
  1696. enum {
  1697. kAF_ISDN = 0x2000
  1698. };
  1699. enum {
  1700. AF_ISDN = kAF_ISDN
  1701. };
  1702. enum {
  1703. kOTISDNMaxPhoneSize = 32,
  1704. kOTISDNMaxSubSize = 4
  1705. };
  1706. struct OTISDNAddress {
  1707. OTAddressType fAddressType;
  1708. UInt16 fPhoneLength;
  1709. char fPhoneNumber[37];
  1710. };
  1711. typedef struct OTISDNAddress OTISDNAddress;
  1712. /* IOCTL Calls for ISDN*/
  1713. /* ISDN shares the same ioctl space as serial.*/
  1714. enum {
  1715. MIOC_ISDN = 'U' /* ISDN ioctl() cmds */
  1716. };
  1717. enum {
  1718. I_OTISDNAlerting = ((MIOC_ISDN << 8) | 100), /* Send or receive an ALERTING message*/
  1719. I_OTISDNSuspend = ((MIOC_ISDN << 8) | 101), /* Send a SUSPEND message*/
  1720. /* The parameter is the Call Identity (Maximum 8 octets)*/
  1721. I_OTISDNSuspendAcknowledge = ((MIOC_ISDN << 8) | 102), /* Receive a SUSPEND ACKNOWLEDGE message*/
  1722. I_OTISDNSuspendReject = ((MIOC_ISDN << 8) | 103), /* Receive a SUSPEND REJECT message*/
  1723. I_OTISDNResume = ((MIOC_ISDN << 8) | 104), /* Send a RESUME message*/
  1724. /* The parameter is the Call Identity (Maximum 8 octets)*/
  1725. I_OTISDNResumeAcknowledge = ((MIOC_ISDN << 8) | 105), /* Receive a RESUME ACKNOWLEDGE message*/
  1726. I_OTISDNResumeReject = ((MIOC_ISDN << 8) | 106), /* Receive a RESUME REJECT message*/
  1727. I_OTISDNFaciltity = ((MIOC_ISDN << 8) | 107) /* Send or receive a FACILITY message*/
  1728. };
  1729. /* Connect user data size*/
  1730. enum {
  1731. kOTISDNMaxUserDataSize = 32
  1732. };
  1733. /* Option management calls for ISDN*/
  1734. enum {
  1735. ISDN_OPT_COMMTYPE = 0x0200,
  1736. ISDN_OPT_FRAMINGTYPE = 0x0201,
  1737. ISDN_OPT_56KADAPTATION = 0x0202
  1738. };
  1739. /* For ISDN_OPT_COMMTYPE...*/
  1740. enum {
  1741. kOTISDNTelephoneALaw = 1, /* G.711 A-law */
  1742. kOTISDNTelephoneMuLaw = 26, /* G.711 .-law */
  1743. kOTISDNDigital64k = 13, /* unrestricted digital (default) */
  1744. kOTISDNDigital56k = 37, /* user rate 56Kb/s */
  1745. kOTISDNVideo64k = 41, /* video terminal at 64Kb/s */
  1746. kOTISDNVideo56k = 42 /* video terminal at 56Kb/s */
  1747. };
  1748. /* For ISDN_OPT_FRAMINGTYPE...*/
  1749. enum {
  1750. kOTISDNFramingTransparent = 0x0010, /* Transparent mode */
  1751. kOTISDNFramingHDLC = 0x0020, /* HDLC synchronous mode (default) */
  1752. kOTISDNFramingV110 = 0x0040, /* V.110 asynchronous mode */
  1753. kOTISDNFramingV14E = 0x0080 /* V.14E asynchronous mode */
  1754. };
  1755. /* For ISDN_OPT_56KADAPTATION...*/
  1756. enum {
  1757. kOTISDNNot56KAdaptation = false, /* not 56K Adaptation (default) */
  1758. kOTISDN56KAdaptation = true /* 56K Adaptation */
  1759. };
  1760. /* Default options, you do not need to set these*/
  1761. enum {
  1762. kOTISDNDefaultCommType = kOTISDNDigital64k,
  1763. kOTISDNDefaultFramingType = kOTISDNFramingHDLC,
  1764. kOTISDNDefault56KAdaptation = kOTISDNNot56KAdaptation
  1765. };
  1766. /*******************************************************************************
  1767. * Constants for Open Transport-based Remote Access/PPP API
  1768. ********************************************************************************/
  1769. /* OTCreateConfiguration name for PPP control endpoint*/
  1770. #define kPPPControlName "ppp"
  1771. /* XTI Level*/
  1772. enum {
  1773. COM_PPP = FOUR_CHAR_CODE('PPPC')
  1774. };
  1775. /* Options limits*/
  1776. enum {
  1777. kPPPMaxIDLength = 255,
  1778. kPPPMaxPasswordLength = 255,
  1779. kPPPMaxDTEAddressLength = 127,
  1780. kPPPMaxCallInfoLength = 255
  1781. };
  1782. /* Various XTI option value constants*/
  1783. enum {
  1784. kPPPStateInitial = 1,
  1785. kPPPStateClosed = 2,
  1786. kPPPStateClosing = 3,
  1787. kPPPStateOpening = 4,
  1788. kPPPStateOpened = 5
  1789. };
  1790. enum {
  1791. kPPPConnectionStatusIdle = 1,
  1792. kPPPConnectionStatusConnecting = 2,
  1793. kPPPConnectionStatusConnected = 3,
  1794. kPPPConnectionStatusDisconnecting = 4
  1795. };
  1796. enum {
  1797. kPPPMinMRU = 0,
  1798. kPPPMaxMRU = 4500
  1799. };
  1800. enum {
  1801. kIPCPTCPHdrCompressionDisabled = 0,
  1802. kIPCPTCPHdrCompressionEnabled = 1
  1803. };
  1804. enum {
  1805. kPPPCompressionDisabled = 0x00000000,
  1806. kPPPProtoCompression = 0x00000001,
  1807. kPPPAddrCompression = 0x00000002
  1808. };
  1809. enum {
  1810. kPPPNoOutAuthentication = 0,
  1811. kPPPCHAPOrPAPOutAuthentication = 1
  1812. };
  1813. enum {
  1814. kCCReminderTimerDisabled = 0,
  1815. kCCIPIdleTimerDisabled = 0
  1816. };
  1817. enum {
  1818. kPPPScriptTypeModem = 1,
  1819. kPPPScriptTypeConnect = 2,
  1820. kPPPMaxScriptSize = 32000
  1821. };
  1822. enum {
  1823. kE164Address = 1,
  1824. kPhoneAddress = 1,
  1825. kCompoundPhoneAddress = 2,
  1826. kX121Address = 3
  1827. };
  1828. enum {
  1829. kPPPConnectionStatusDialogsFlag = 0x00000001,
  1830. kPPPConnectionRemindersFlag = 0x00000002,
  1831. kPPPConnectionFlashingIconFlag = 0x00000004,
  1832. kPPPOutPasswordDialogsFlag = 0x00000008,
  1833. kPPPAllAlertsDisabledFlag = 0x00000000,
  1834. kPPPAllAlertsEnabledFlag = 0x0000000F
  1835. };
  1836. enum {
  1837. kPPPAsyncMapCharsNone = 0x00000000,
  1838. kPPPAsyncMapCharsXOnXOff = 0x000A0000,
  1839. kPPPAsyncMapCharsAll = (unsigned long)0xFFFFFFFF
  1840. };
  1841. /* Option names*/
  1842. enum {
  1843. IPCP_OPT_GETREMOTEPROTOADDR = 0x00007000,
  1844. IPCP_OPT_GETLOCALPROTOADDR = 0x00007001,
  1845. IPCP_OPT_TCPHDRCOMPRESSION = 0x00007002,
  1846. LCP_OPT_PPPCOMPRESSION = 0x00007003,
  1847. LCP_OPT_MRU = 0x00007004,
  1848. LCP_OPT_RCACCMAP = 0x00007005,
  1849. LCP_OPT_TXACCMAP = 0x00007006,
  1850. SEC_OPT_OUTAUTHENTICATION = 0x00007007,
  1851. SEC_OPT_ID = 0x00007008,
  1852. SEC_OPT_PASSWORD = 0x00007009,
  1853. CC_OPT_REMINDERTIMER = 0x00007010,
  1854. CC_OPT_IPIDLETIMER = 0x00007011,
  1855. CC_OPT_DTEADDRESSTYPE = 0x00007012,
  1856. CC_OPT_DTEADDRESS = 0x00007013,
  1857. CC_OPT_CALLINFO = 0x00007014,
  1858. CC_OPT_GETMISCINFO = 0x00007015,
  1859. PPP_OPT_GETCURRENTSTATE = 0x00007016,
  1860. LCP_OPT_ECHO = 0x00007017, /* Available on Mac OS X only */
  1861. CC_OPT_SERIALPORTNAME = 0x00007200
  1862. };
  1863. /* Endpoint events*/
  1864. enum {
  1865. kPPPEvent = kPROTOCOLEVENT | 0x000F0000,
  1866. kPPPConnectCompleteEvent = kPPPEvent + 1,
  1867. kPPPSetScriptCompleteEvent = kPPPEvent + 2,
  1868. kPPPDisconnectCompleteEvent = kPPPEvent + 3,
  1869. kPPPDisconnectEvent = kPPPEvent + 4,
  1870. kPPPIPCPUpEvent = kPPPEvent + 5,
  1871. kPPPIPCPDownEvent = kPPPEvent + 6,
  1872. kPPPLCPUpEvent = kPPPEvent + 7,
  1873. kPPPLCPDownEvent = kPPPEvent + 8,
  1874. kPPPLowerLayerUpEvent = kPPPEvent + 9,
  1875. kPPPLowerLayerDownEvent = kPPPEvent + 10,
  1876. kPPPAuthenticationStartedEvent = kPPPEvent + 11,
  1877. kPPPAuthenticationFinishedEvent = kPPPEvent + 12,
  1878. kPPPDCEInitStartedEvent = kPPPEvent + 13,
  1879. kPPPDCEInitFinishedEvent = kPPPEvent + 14,
  1880. kPPPDCECallStartedEvent = kPPPEvent + 15,
  1881. kPPPDCECallFinishedEvent = kPPPEvent + 16
  1882. };
  1883. #if CALL_NOT_IN_CARBON
  1884. /* Support for modem script endpoints: */
  1885. /* The Configuration name for the Opentransport Modem/Script engine. */
  1886. #define kScriptName "Script"
  1887. /* To check if the Modem/Script engine is installed you should interrogate
  1888. the proper Gestalt Selectors for Open Transport-based Modem libraries. */
  1889. #define gestaltOpenTptModem 'otmo'
  1890. #define gestaltOpenTptModemPresent 0
  1891. #define gestaltOpenTptModemVersion 'otmv'
  1892. #define kGestaltOpenTptModemVersion 0x01000080
  1893. /* These are the Modem/Script Configurator error codes. Other codes may be
  1894. returned from Open Transport and operating system routines. */
  1895. #define kModemNoError 0
  1896. #define kModemOutOfMemory -14000
  1897. #define kModemPreferencesMissing -14001
  1898. #define kModemScriptMissing -14002
  1899. /* The Modem Configuration pref resource file constants. */
  1900. #define kModemConfigFileCreator 'modm'
  1901. #define kModemConfigFileType 'mdpf'
  1902. #define kModemConfigVersion 0x00010000
  1903. #define kModemConfigExportType 'mdex'
  1904. #define kModemScriptType 'mlts' /* Same as ARA 1.0/2.0 */
  1905. #define kModemScriptCreator 'slnk' /* Same as ARA 1.0/2.0 */
  1906. /* Configuration resource constants. */
  1907. #define kModemConfigTypeModem 'ccl ' /* Type for Modem config resource */
  1908. #define kModemSelectedConfigID 1 /* ID of resource containing.. */
  1909. #define kModemSelectedConfigType 'ccfg' /* the ID of current selected CCL */
  1910. #define kModemConfigNameType 'cnam' /* type of config name rez */
  1911. #define kModemConfigTypeLocks 'lkmd' /* Types for lock rez */
  1912. #define kModemConfigFirstID 128 /* lowest id for configuration rez */
  1913. /* Maximum script file name size. Same as "name" field of FSSpec. */
  1914. #define kMaxScriptNameSize 64
  1915. /* File name to use only if the internationalized one can't be read
  1916. from the resource fork. */
  1917. #define kDefaultModemPrefsFileName "\pModem Preferences"
  1918. /* Dial tone modes */
  1919. enum
  1920. {
  1921. kDialToneNormal = 0,
  1922. kDialToneIgnore = 1,
  1923. kDialToneManual = 2
  1924. };
  1925. /* Modem Configuration Resource format for Modem configuration info. */
  1926. typedef struct
  1927. {
  1928. UInt32 version;
  1929. Boolean useModemScript;
  1930. FSSpec modemScript;
  1931. Boolean modemSpeakerOn;
  1932. Boolean modemPulseDial;
  1933. UInt32 modemDialToneMode;
  1934. SInt8 lowerLayerName[kMaxProviderNameSize];
  1935. } RAConfigModem;
  1936. #endif /* CALL_NOT_IN_CARBON */
  1937. /*******************************************************************************
  1938. * IOCTL constants for I_OTConnect, I_OTDisconnect and I_OTScript
  1939. * are defined in OpenTransport.h
  1940. ********************************************************************************/
  1941. /*******************************************************************************
  1942. * PPPMRULimits
  1943. ********************************************************************************/
  1944. struct PPPMRULimits {
  1945. UInt32 mruSize; /* proposed or actual*/
  1946. UInt32 upperMRULimit;
  1947. UInt32 lowerMRULimit;
  1948. };
  1949. typedef struct PPPMRULimits PPPMRULimits;
  1950. /*******************************************************************************
  1951. * CCMiscInfo
  1952. ********************************************************************************/
  1953. struct CCMiscInfo {
  1954. UInt32 connectionStatus;
  1955. UInt32 connectionTimeElapsed;
  1956. UInt32 connectionTimeRemaining;
  1957. UInt32 bytesTransmitted;
  1958. UInt32 bytesReceived;
  1959. UInt32 reserved;
  1960. };
  1961. typedef struct CCMiscInfo CCMiscInfo;
  1962. /*******************************************************************************
  1963. * LCPEcho
  1964. ********************************************************************************/
  1965. /* Set both fields to zero to disable sending of LCP echo requests*/
  1966. struct LCPEcho {
  1967. UInt32 retryCount;
  1968. UInt32 retryPeriod; /* in milliseconds*/
  1969. };
  1970. typedef struct LCPEcho LCPEcho;
  1971. /*******************************************************************************
  1972. * Bits used to tell kind of product
  1973. ********************************************************************************/
  1974. enum {
  1975. kRAProductClientOnly = 2,
  1976. kRAProductOnePortServer = 3,
  1977. kRAProductManyPortServer = 4
  1978. };
  1979. #if defined(__MWERKS__) && TARGET_CPU_68K
  1980. #pragma pop
  1981. #endif
  1982. #if PRAGMA_STRUCT_ALIGN
  1983. #pragma options align=reset
  1984. #elif PRAGMA_STRUCT_PACKPUSH
  1985. #pragma pack(pop)
  1986. #elif PRAGMA_STRUCT_PACK
  1987. #pragma pack()
  1988. #endif
  1989. #ifdef PRAGMA_IMPORT_OFF
  1990. #pragma import off
  1991. #elif PRAGMA_IMPORT
  1992. #pragma import reset
  1993. #endif
  1994. #ifdef __cplusplus
  1995. }
  1996. #endif
  1997. #endif /* __OPENTRANSPORTPROVIDERS__ */