so32dll.pas 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2000, 2001 by madded2 ([email protected]).
  4. Copyright (c) 2002, 2004 Yuri Prokushev ([email protected]).
  5. Copyright (c) 2005 Soren Ager
  6. Interface to OS/2 32-bit sockets library
  7. **********************************************************************
  8. Inet & Sockets Unit v1.04.
  9. /c/ 2000, 2001 by madded2 ([email protected]).
  10. based on units from SIBYL & infos from Toolkit 4.0.
  11. for help use tcppr.inf and C samples from toolkit.
  12. without res_* and dh_* funcs, and have very
  13. bad support for select() and ioctl() funcs
  14. new in ver 1.04 : little ioctl() & iptrace support + errors SOCE* constants
  15. new in ver 1.03 : used inet_lib.lib file for fixing VP linker bug
  16. new in ver 1.02 : $saves sections, need for correct registers operations
  17. new in ver 1.01 : ip header struct
  18. }
  19. {
  20. @abstract(a unit to handle sockets)
  21. @author(Yuri Prokushev ([email protected]))
  22. @author(madded2 ([email protected]))
  23. @created(3 Sep 2002)
  24. @lastmod(23 Sep 2002)
  25. @todo(sys/ioctl.h, sys/ioctlos2.h, sys/itypes.h)
  26. This is functions from SO32DLL.DLL. These functions allows to use
  27. protocol-independed sockets. Equal to SYS\SOCKET.H, NERRNO.H, SYS\SYSCTL.H.
  28. }
  29. unit SO32Dll;
  30. interface
  31. {$MODE ObjFPC}
  32. {$ASMMODE Intel}
  33. {$PACKRECORDS 1}
  34. (***************************************************************************)
  35. (* *)
  36. (* Types *)
  37. (* *)
  38. (***************************************************************************)
  39. const
  40. // stream socket
  41. SOCK_STREAM = 1;
  42. // datagram socket
  43. SOCK_DGRAM = 2;
  44. // raw-protocol interface
  45. SOCK_RAW = 3;
  46. // reliably-delivered message
  47. SOCK_RDM = 4;
  48. // sequenced packet stream
  49. SOCK_SEQPACKET = 5;
  50. (***************************************************************************)
  51. (* *)
  52. (* Option flags per-socket *)
  53. (* *)
  54. (***************************************************************************)
  55. const
  56. // turn on debugging info recording
  57. SO_DEBUG = $0001;
  58. // socket has had listen()
  59. SO_ACCEPTCONN = $0002;
  60. // allow local address reuse
  61. SO_REUSEADDR = $0004;
  62. // keep connections alive
  63. SO_KEEPALIVE = $0008;
  64. // just use interface addresses
  65. SO_DONTROUTE = $0010;
  66. // permit sending of broadcast msgs
  67. SO_BROADCAST = $0020;
  68. // bypass hardware when possible
  69. SO_USELOOPBACK = $0040;
  70. // linger on close if data present
  71. SO_LINGER = $0080;
  72. // leave received OOB data in line
  73. SO_OOBINLINE = $0100;
  74. // limited broadcast sent on all IFs
  75. SO_L_BROADCAST = $0200;
  76. // set if shut down called for rcv
  77. SO_RCV_SHUTDOWN = $0400;
  78. // set if shutdown called for send
  79. SO_SND_SHUTDOWN = $0800;
  80. // allow local address & port reuse
  81. SO_REUSEPORT = $1000;
  82. // allow t/tcp on socket
  83. SO_TTCP = $2000;
  84. (***************************************************************************)
  85. (* *)
  86. (* Additional options, not kept in so_options *)
  87. (* *)
  88. (***************************************************************************)
  89. const
  90. // send buffer size
  91. SO_SNDBUF = $1001;
  92. // receive buffer size
  93. SO_RCVBUF = $1002;
  94. // send low-water mark
  95. SO_SNDLOWAT = $1003;
  96. // receive low-water mark
  97. SO_RCVLOWAT = $1004;
  98. // send timeout
  99. SO_SNDTIMEO = $1005;
  100. // receive timeout
  101. SO_RCVTIMEO = $1006;
  102. // get error status and clear
  103. SO_ERROR = $1007;
  104. // get socket type
  105. SO_TYPE = $1008;
  106. // get socket options
  107. SO_OPTIONS = $1010;
  108. (***************************************************************************)
  109. (* *)
  110. (* Structure used for manipulating linger option *)
  111. (* *)
  112. (***************************************************************************)
  113. type
  114. //Structure used for manipulating linger option
  115. linger = record
  116. l_onoff : Longint; // option on/off
  117. l_linger : Longint; // linger time
  118. end;
  119. (***************************************************************************)
  120. (* *)
  121. (* Level number for (get/set)sockopt() to apply to socket itself *)
  122. (* *)
  123. (***************************************************************************)
  124. const
  125. // options for socket level
  126. SOL_SOCKET = $ffff;
  127. (***************************************************************************)
  128. (* *)
  129. (* Address families *)
  130. (* *)
  131. (***************************************************************************)
  132. const
  133. // unspecified
  134. AF_UNSPEC = 0;
  135. // local to host (pipes, portals)
  136. AF_LOCAL = 1;
  137. // backward compatibility
  138. AF_UNIX = AF_LOCAL;
  139. AF_OS2 = AF_UNIX;
  140. // internetwork: UDP, TCP, etc.
  141. AF_INET = 2;
  142. // arpanet imp addresses
  143. AF_IMPLINK = 3;
  144. // pup protocols: e.g. BSP
  145. AF_PUP = 4;
  146. // mit CHAOS protocols
  147. AF_CHAOS = 5;
  148. // XEROX NS protocols
  149. AF_NS = 6;
  150. // ISO protocols
  151. AF_ISO = 7;
  152. // ISO protocols
  153. AF_OSI = AF_ISO;
  154. // european computer manufacturers
  155. AF_ECMA = 8;
  156. // datakit protocols
  157. AF_DATAKIT = 9;
  158. // CCITT protocols, X.25 etc
  159. AF_CCITT = 10;
  160. // IBM SNA
  161. AF_SNA = 11;
  162. // DECnet
  163. AF_DECnet = 12;
  164. // DEC Direct data link interface
  165. AF_DLI = 13;
  166. // LAT
  167. AF_LAT = 14;
  168. // NSC Hyperchannel
  169. AF_HYLINK = 15;
  170. // Apple Talk
  171. AF_APPLETALK = 16;
  172. // Netbios
  173. AF_NB = 17;
  174. // Netbios
  175. AF_NETBIOS = AF_NB;
  176. // Link layer interface
  177. AF_LINK = 18;
  178. // eXpress Transfer Protocol (no AF)
  179. pseudo_AF_XTP = 19;
  180. // connection-oriented IP, aka ST II
  181. AF_COIP = 20;
  182. // Computer Network Technology
  183. AF_CNT = 21;
  184. // Help Identify RTIP packets
  185. pseudo_AF_RTIP = 22;
  186. // Novell Internet Protocol
  187. AF_IPX = 23;
  188. // Simple Internet Protocol
  189. AF_SIP = 24;
  190. AF_INET6 = 24;
  191. // Help Identify PIP packets
  192. pseudo_AF_PIP = 25;
  193. // Internal Routing Protocol
  194. AF_ROUTE = 39;
  195. // firewall support
  196. AF_FWIP = 40;
  197. // IPSEC and encryption techniques
  198. AF_IPSEC = 41;
  199. // DES
  200. AF_DES = 42;
  201. AF_MD5 = 43;
  202. AF_CDMF = 44;
  203. AF_MAX = 45;
  204. (***************************************************************************)
  205. (* *)
  206. (* Structure used by kernel to store most addresses *)
  207. (* *)
  208. (***************************************************************************)
  209. type
  210. // Structure used by kernel to store most addresses
  211. sockaddr = record
  212. sa_len: Byte; // total length
  213. sa_family: Byte; // address family
  214. sa_data: array [0..13] of Byte; // up to 14 bytes of direct address
  215. end;
  216. psockaddr = ^sockaddr;
  217. (***************************************************************************)
  218. (* *)
  219. (* Structure used by kernel to pass protocol information in raw sockets *)
  220. (* *)
  221. (***************************************************************************)
  222. type
  223. // Structure used by kernel to pass protocol information in raw sockets
  224. sockproto = record
  225. sp_family: Word; // address family
  226. sp_protocol: Word; // protocol
  227. end;
  228. (***************************************************************************)
  229. (* *)
  230. (* Protocol families, same as address families for now *)
  231. (* *)
  232. (***************************************************************************)
  233. const
  234. PF_UNSPEC = AF_UNSPEC;
  235. PF_LOCAL = AF_LOCAL;
  236. PF_UNIX = AF_UNIX;
  237. PF_OS2 = AF_OS2;
  238. PF_INET = AF_INET;
  239. PF_IMPLINK = AF_IMPLINK;
  240. PF_PUP = AF_PUP;
  241. PF_CHAOS = AF_CHAOS;
  242. PF_NS = AF_NS;
  243. PF_ISO = AF_ISO;
  244. PF_OSI = AF_OSI;
  245. PF_ECMA = AF_ECMA;
  246. PF_DATAKIT = AF_DATAKIT;
  247. PF_CCITT = AF_CCITT;
  248. PF_SNA = AF_SNA;
  249. PF_DECnet = AF_DECnet;
  250. PF_DLI = AF_DLI;
  251. PF_LAT = AF_LAT;
  252. PF_HYLINK = AF_HYLINK;
  253. PF_APPLETALK = AF_APPLETALK;
  254. PF_NETBIOS = AF_NB;
  255. PF_NB = AF_NB;
  256. PF_ROUTE = AF_ROUTE;
  257. PF_LINK = AF_LINK;
  258. // really just proto family, no AF
  259. PF_XTP = pseudo_AF_XTP;
  260. PF_COIP = AF_COIP;
  261. PF_CNT = AF_CNT;
  262. PF_SIP = AF_SIP;
  263. PF_INET6 = AF_INET6;
  264. // same format as AF_NS
  265. PF_IPX = AF_IPX;
  266. // same format as AF_INET
  267. PF_RTIP = pseudo_AF_RTIP;
  268. PF_PIP = pseudo_AF_PIP;
  269. PF_MAX = AF_MAX;
  270. (***************************************************************************)
  271. (* *)
  272. (* Definitions for sysctl call. The sysctl call uses a hierarchical name *)
  273. (* for objects that can be examined or modified. The name is expressed as *)
  274. (* a sequence of integers. Like a file path name, the meaning of each *)
  275. (* component depends on its place in the hierarchy. The top-level and kern *)
  276. (* identifiers are defined here, and other identifiers are defined in the *)
  277. (* respective subsystem header files. *)
  278. (* *)
  279. (***************************************************************************)
  280. const
  281. // largest number of components supported
  282. CTL_MAXNAME = 12;
  283. (***************************************************************************)
  284. (* *)
  285. (* Each subsystem defined by sysctl defines a list of variables *)
  286. (* for that subsystem. Each name is either a node with further *)
  287. (* levels defined below it, or it is a leaf of some particular *)
  288. (* type given below. Each sysctl level defines a set of name/type *)
  289. (* pairs to be used by sysctl(1) in manipulating the subsystem. *)
  290. (* *)
  291. (***************************************************************************)
  292. type
  293. ctlname=record
  294. ctl_name: PChar; // subsystem name
  295. ctl_type: Longint; // type of name
  296. end;
  297. const
  298. // name is a node
  299. CTLTYPE_NODE =1;
  300. // name describes an integer
  301. CTLTYPE_INT =2;
  302. // name describes a string
  303. CTLTYPE_STRING =3;
  304. // name describes a 64-bit number
  305. CTLTYPE_QUAD =4;
  306. // name describes a structure
  307. CTLTYPE_STRUCT =5;
  308. // inetcfg sysctl code
  309. CTLTYPE_INETCFG =6;
  310. // inetver sysctl code
  311. CTLTYPE_INEVER =7;
  312. (*
  313. * Top-level identifiers
  314. *)
  315. const
  316. // "high kernel": proc, limits
  317. CTL_KERN = 1;
  318. // network, see socket.h
  319. CTL_NET = 4;
  320. // OS/2 specific codes
  321. CTL_OS2 = 9;
  322. (*
  323. #define CTL_NAMES { \
  324. { 0, 0 }, \
  325. { "kern", CTLTYPE_NODE }, \
  326. { "net", CTLTYPE_NODE }, \
  327. { "os2", CTLTYPE_NODE }, \
  328. }
  329. /*
  330. * CTL_KERN identifiers
  331. */
  332. #define KERN_MAXFILES 7 /* int: max open files */
  333. #define KERN_HOSTNAME 10 /* string: hostname */
  334. #define KERN_HOSTID 11 /* int: host identifier */
  335. #define CTL_KERN_NAMES { \
  336. { 0, 0 }, \
  337. { "ostype", CTLTYPE_STRING }, \
  338. { "osrelease", CTLTYPE_STRING }, \
  339. { "osrevision", CTLTYPE_INT }, \
  340. { "version", CTLTYPE_STRING }, \
  341. { "maxvnodes", CTLTYPE_INT }, \
  342. { "maxproc", CTLTYPE_INT }, \
  343. { "maxfiles", CTLTYPE_INT }, \
  344. { "argmax", CTLTYPE_INT }, \
  345. { "securelevel", CTLTYPE_INT }, \
  346. { "hostname", CTLTYPE_STRING }, \
  347. { "hostid", CTLTYPE_INT }, \
  348. { "clockrate", CTLTYPE_STRUCT }, \
  349. { "vnode", CTLTYPE_STRUCT }, \
  350. { "proc", CTLTYPE_STRUCT }, \
  351. { "file", CTLTYPE_STRUCT }, \
  352. { "profiling", CTLTYPE_NODE }, \
  353. { "posix1version", CTLTYPE_INT }, \
  354. { "ngroups", CTLTYPE_INT }, \
  355. { "job_control", CTLTYPE_INT }, \
  356. { "saved_ids", CTLTYPE_INT }, \
  357. { "boottime", CTLTYPE_STRUCT }, \
  358. }
  359. /*
  360. * KERN_SYSCTL objects
  361. */
  362. #define KERNCTL_INETVER 70 /* Sysctl code for sockets Inetversion */
  363. #define OS2_MEMMAPIO 1 /* memory map io */
  364. #define OS2_QUERY_MEMMAPIO 2 /* Query if mapped memory usable */
  365. /* Generic Structure for Inetcfg calls */
  366. struct inetcfg_ctl{
  367. unsigned long var_name;
  368. unsigned long var_cur_val;
  369. unsigned long var_max_val;
  370. unsigned long var_def_val;
  371. unsigned long var_min_val;
  372. };
  373. /* Inetversion */
  374. struct inetvers_ctl {
  375. float version;
  376. char versionstr[10]; /* Less than 10 chars in version string */
  377. };
  378. #include <sys/cdefs.h>
  379. #ifndef KERNEL
  380. __BEGIN_DECLS
  381. int _System sysctl __TCPPROTO((int *, u_int, void *, size_t *, void *, size_t));
  382. __END_DECLS
  383. #endif
  384. *)
  385. (* !!TODO!! Not finished yet!!
  386. /*
  387. * Definitions for network related sysctl, CTL_NET.
  388. *
  389. * Second level is protocol family.
  390. * Third level is protocol number.
  391. *
  392. * Further levels are defined by the individual families below.
  393. */
  394. const
  395. NET_MAXID = AF_MAX;
  396. #define CTL_NET_NAMES { \
  397. { 0, 0 }, \
  398. { "local", CTLTYPE_NODE }, \
  399. { "inet", CTLTYPE_NODE }, \
  400. { "implink", CTLTYPE_NODE }, \
  401. { "pup", CTLTYPE_NODE }, \
  402. { "chaos", CTLTYPE_NODE }, \
  403. { "xerox_ns", CTLTYPE_NODE }, \
  404. { "iso", CTLTYPE_NODE }, \
  405. { "emca", CTLTYPE_NODE }, \
  406. { "datakit", CTLTYPE_NODE }, \
  407. { "ccitt", CTLTYPE_NODE }, \
  408. { "ibm_sna", CTLTYPE_NODE }, \
  409. { "decnet", CTLTYPE_NODE }, \
  410. { "dec_dli", CTLTYPE_NODE }, \
  411. { "lat", CTLTYPE_NODE }, \
  412. { "hylink", CTLTYPE_NODE }, \
  413. { "appletalk", CTLTYPE_NODE }, \
  414. { "netbios", CTLTYPE_NODE }, \
  415. { "route", CTLTYPE_NODE }, \
  416. { "link_layer", CTLTYPE_NODE }, \
  417. { "xtp", CTLTYPE_NODE }, \
  418. { "coip", CTLTYPE_NODE }, \
  419. { "cnt", CTLTYPE_NODE }, \
  420. { "rtip", CTLTYPE_NODE }, \
  421. { "ipx", CTLTYPE_NODE }, \
  422. { "sip", CTLTYPE_NODE }, \
  423. { "pip", CTLTYPE_NODE }, \
  424. }
  425. /*
  426. * PF_ROUTE - Routing table
  427. *
  428. * Three additional levels are defined:
  429. * Fourth: address family, 0 is wildcard
  430. * Fifth: type of info, defined below
  431. * Sixth: flag(s) to mask with for NET_RT_FLAGS
  432. */
  433. const
  434. // dump; may limit to a.f.
  435. NET_RT_DUMP = 1;
  436. // by flags, e.g. RESOLVING
  437. NET_RT_FLAGS = 2;
  438. // survey interface list
  439. NET_RT_IFLIST = 3;
  440. NET_RT_MAXID = 4;
  441. #define CTL_NET_RT_NAMES { \
  442. { 0, 0 }, \
  443. { "dump", CTLTYPE_STRUCT }, \
  444. { "flags", CTLTYPE_STRUCT }, \
  445. { "iflist", CTLTYPE_STRUCT }, \
  446. }
  447. *)
  448. (***************************************************************************)
  449. (* *)
  450. (* Maximum queue length specifiable by listen *)
  451. (* *)
  452. (***************************************************************************)
  453. const
  454. // Maximum queue length specifiable by listen
  455. SOMAXCONN = 1024;
  456. (***************************************************************************)
  457. (* *)
  458. (* Message header for recvmsg and sendmsg calls *)
  459. (* Used value-result for recvmsg, value only for sendmsg *)
  460. (* *)
  461. (***************************************************************************)
  462. type
  463. iovec = record
  464. iov_base : Pointer;
  465. iov_len : Longint;
  466. end;
  467. // Message header for recvmsg and sendmsg calls
  468. msghdr = record
  469. msg_name: pChar; // optional address
  470. msg_namelen: Longint; // size of address
  471. msg_iov: ^iovec; // scatter/gather array
  472. msg_iovlen: Longint; // # elements in msg_iov (max 1024)
  473. msg_control: pChar; // ancillary data, see below
  474. msg_controllen: Longint; // ancillary data buffer len
  475. msg_flags: Longint; // flags on received message
  476. end;
  477. const
  478. // process out-of-band data
  479. MSG_OOB = $1;
  480. // peek at incoming message
  481. MSG_PEEK = $2;
  482. // send without using routing tables
  483. MSG_DONTROUTE = $4;
  484. // send without using routing tables
  485. MSG_FULLREAD = $8;
  486. // data completes record
  487. MSG_EOR = $10;
  488. // data discarded before delivery
  489. MSG_TRUNC = $20;
  490. // control data lost before delivery
  491. MSG_CTRUNC = $40;
  492. // wait for full request or error
  493. MSG_WAITALL = $80;
  494. // this message should be nonblocking
  495. MSG_DONTWAIT = $100;
  496. MSG_EOF = $200;
  497. // mem mapped io
  498. MSG_MAPIO = $400;
  499. (***************************************************************************)
  500. (* *)
  501. (* Header for ancillary data objects in msg_control buffer *)
  502. (* Used for additional information with/about a datagram *)
  503. (* not expressible by flags. The format is a sequence *)
  504. (* of message elements headed by cmsghdr structures *)
  505. (* *)
  506. (***************************************************************************)
  507. type
  508. // Header for ancillary data objects in msg_control buffer
  509. cmsghdr = record
  510. cmsg_len: Longint; // data byte count, including hdr
  511. cmsg_level: Longint; // originating protocol
  512. cmsg_type: Longint; // protocol-specific type
  513. end;
  514. cmsg = record
  515. cmsg_hdr: cmsghdr;
  516. cmsg_data: array [0..0] of Byte;
  517. end;
  518. (***************************************************************************)
  519. (* *)
  520. (* "Socket"-level control message types *)
  521. (* *)
  522. (***************************************************************************)
  523. const
  524. // access rights (array of int)
  525. SCM_RIGHTS = $01;
  526. (***************************************************************************)
  527. (* *)
  528. (* 4.3 compat sockaddr, move to compat file later *)
  529. (* *)
  530. (***************************************************************************)
  531. type
  532. // 4.3 compat sockaddr
  533. osockaddr = record
  534. sa_family: Word; // address family
  535. sa_data: array [0..13] of Byte; // up to 14 bytes of direct address
  536. end;
  537. (***************************************************************************)
  538. (* *)
  539. (* 4.3-compat message header (move to compat file later) *)
  540. (* *)
  541. (***************************************************************************)
  542. type
  543. // 4.3-compat message header
  544. omsghdr = record
  545. msg_name: pChar; // optional address
  546. msg_namelen: Longint; // size of address
  547. msg_iov: ^iovec; // scatter/gather array
  548. msg_iovlen: Longint; // # elements in msg_iov
  549. msg_accrights: pChar; // access rights sent/received
  550. msg_accrightslen: Longint;
  551. end;
  552. (* !!TODO
  553. /*
  554. * send_file parameter structure
  555. */
  556. struct sf_parms {
  557. void *header_data; /* ptr to header data */
  558. size_t header_length; /* size of header data */
  559. int file_handle; /* file handle to send from */
  560. size_t file_size; /* size of file */
  561. int file_offset; /* byte offset in file to send from */
  562. size_t file_bytes; /* bytes of file to be sent */
  563. void *trailer_data; /* ptr to trailer data */
  564. size_t trailer_length; /* size of trailer data */
  565. size_t bytes_sent; /* bytes sent in this send_file call */
  566. };
  567. *)
  568. { !!TODO Check is all this functions defined
  569. __BEGIN_DECLS
  570. int _System accept_and_recv __TCPPROTO((long, long*, struct sockaddr *, long*, struct sockaddr*, long*, caddr_t, size_t));
  571. ssize_t _System recvfrom __TCPPROTO((int, void *, size_t, int, struct sockaddr *, int *));
  572. ssize_t _System recvmsg __TCPPROTO((int, struct msghdr *, int));
  573. ssize_t _System send __TCPPROTO((int, const void *, size_t, int));
  574. ssize_t _System sendto __TCPPROTO((int, const void *, size_t, int, const struct sockaddr *, int));
  575. ssize_t _System sendmsg __TCPPROTO((int, const struct msghdr *, int));
  576. ssize_t _System send_file __TCPPROTO((int *, struct sf_parms *, int ));
  577. int _System setsockopt __TCPPROTO((int, int, int, const void *, int));
  578. int _System shutdown __TCPPROTO((int, int));
  579. int _System socket __TCPPROTO((int, int, int));
  580. int _System socketpair __TCPPROTO((int, int, int, int *));
  581. /* OS/2 additions */
  582. int _System sock_init __TCPPROTO((void));
  583. int _System sock_errno __TCPPROTO((void));
  584. void _System psock_errno __TCPPROTO((const char *));
  585. char * _System sock_strerror __TCPPROTO((int));
  586. int _System soabort __TCPPROTO((int));
  587. int _System so_cancel __TCPPROTO((int));
  588. int _System getinetversion __TCPPROTO((char *));
  589. void _System addsockettolist __TCPPROTO((int));
  590. int _System removesocketfromlist __TCPPROTO((int));
  591. /*int _System removesocketfromlist __TCPPROTO((long *));*/ /*changed on 09-30-98 for corresponding change in sockets.c file*/
  592. /* SOCKS additions */
  593. int _System Raccept __TCPPROTO((int, struct sockaddr *, int *));
  594. int _System Rbind __TCPPROTO((int, struct sockaddr *, int, struct sockaddr *));
  595. int _System Rconnect __TCPPROTO((int, const struct sockaddr *, int));
  596. int _System Rgetsockname __TCPPROTO((int, struct sockaddr *, int *));
  597. int _System Rlisten __TCPPROTO((int, int));
  598. __END_DECLS
  599. /* more OS/2 stuff */
  600. const
  601. // should be on free list
  602. MT_FREE = 0;
  603. // dynamic (data) allocation
  604. MT_DATA = 1;
  605. // packet header
  606. MT_HEADER = 2;
  607. // socket structure
  608. MT_SOCKET = 3;
  609. // protocol control block
  610. MT_PCB = 4;
  611. // routing tables
  612. MT_RTABLE = 5;
  613. // IMP host tables
  614. MT_HTABLE = 6;
  615. // address resolution tables
  616. MT_ATABLE = 7;
  617. // socket name
  618. MT_SONAME = 8;
  619. // zombie proc status
  620. MT_ZOMBIE = 9;
  621. // socket options
  622. MT_SOOPTS = 10;
  623. // fragment reassembly header
  624. MT_FTABLE = 11;
  625. // access rights
  626. MT_RIGHTS = 12;
  627. // interface address
  628. MT_IFADDR = 13;
  629. Type
  630. sostats=record
  631. count: integer;
  632. socketdata: array[0..13*MAXSOCKETS-1] of integer;
  633. end;
  634. }
  635. (***************************************************************************)
  636. (* *)
  637. (* SOCE* constants - socket errors from NERRNO.H *)
  638. (* All OS/2 SOCKET API error constants are biased by SOCBASEERR from the *)
  639. (* "normal" *)
  640. (* *)
  641. (***************************************************************************)
  642. const
  643. SOCBASEERR = 10000;
  644. // Not owner
  645. SOCEPERM = (SOCBASEERR+1);
  646. // No such file or directory
  647. SOCENOENT = (SOCBASEERR+2);
  648. // No such process
  649. SOCESRCH = (SOCBASEERR+3);
  650. // Interrupted system call
  651. SOCEINTR = (SOCBASEERR+4);
  652. // Input/output error
  653. SOCEIO = (SOCBASEERR+5);
  654. SOCENXIO = (SOCBASEERR+6); // No such device or address
  655. SOCE2BIG = (SOCBASEERR+7); // Argument list too long
  656. SOCENOEXEC = (SOCBASEERR+8); // Exec format error
  657. SOCEBADF = (SOCBASEERR+9); // Bad file number
  658. SOCECHILD = (SOCBASEERR+10); // No child processes
  659. SOCEDEADLK = (SOCBASEERR+11); // Resource deadlock avoided
  660. SOCENOMEM = (SOCBASEERR+12); // Cannot allocate memory
  661. SOCEACCES = (SOCBASEERR+13); // Permission denied
  662. SOCEFAULT = (SOCBASEERR+14); // Bad address
  663. SOCENOTBLK = (SOCBASEERR+15); // Block device required
  664. SOCEBUSY = (SOCBASEERR+16); // Device busy
  665. SOCEEXIST = (SOCBASEERR+17); // File exists
  666. SOCEXDEV = (SOCBASEERR+18); // Cross-device link
  667. SOCENODEV = (SOCBASEERR+19); // Operation not supported by device
  668. SOCENOTDIR = (SOCBASEERR+20); // Not a directory
  669. SOCEISDIR = (SOCBASEERR+21); // Is a directory
  670. SOCEINVAL = (SOCBASEERR+22); // Invalid argument
  671. SOCENFILE = (SOCBASEERR+23); // Too many open files in system
  672. SOCEMFILE = (SOCBASEERR+24); // Too many open files
  673. SOCENOTTY = (SOCBASEERR+25); // Inappropriate ioctl for device
  674. SOCETXTBSY = (SOCBASEERR+26); // Text file busy
  675. SOCEFBIG = (SOCBASEERR+27); // File too large
  676. SOCENOSPC = (SOCBASEERR+28); // No space left on device
  677. SOCESPIPE = (SOCBASEERR+29); // Illegal seek
  678. SOCEROFS = (SOCBASEERR+30); // Read-only file system
  679. SOCEMLINK = (SOCBASEERR+31); // Too many links
  680. SOCEPIPE = (SOCBASEERR+32); // Broken pipe
  681. // math software
  682. SOCEDOM = (SOCBASEERR+33); // Numerical argument out of domain
  683. SOCERANGE = (SOCBASEERR+34); // Result too large
  684. // non-blocking and interrupt i/o
  685. SOCEAGAIN = (SOCBASEERR+35); // Resource temporarily unavailable
  686. SOCEWOULDBLOCK = SOCEAGAIN; // Operation would block
  687. SOCEINPROGRESS = (SOCBASEERR+36); // Operation now in progress
  688. SOCEALREADY = (SOCBASEERR+37); // Operation already in progress
  689. // ipc/network software -- argument errors
  690. SOCENOTSOCK = (SOCBASEERR+38); // Socket operation on non-socket
  691. SOCEDESTADDRREQ = (SOCBASEERR+39); // Destination address required
  692. SOCEMSGSIZE = (SOCBASEERR+40); // Message too long
  693. SOCEPROTOTYPE = (SOCBASEERR+41); // Protocol wrong type for socket
  694. SOCENOPROTOOPT = (SOCBASEERR+42); // Protocol not available
  695. SOCEPROTONOSUPPORT = (SOCBASEERR+43); // Protocol not supported
  696. SOCESOCKTNOSUPPORT = (SOCBASEERR+44); // Socket type not supported
  697. SOCEOPNOTSUPP = (SOCBASEERR+45); // Operation not supported
  698. SOCEPFNOSUPPORT = (SOCBASEERR+46); // Protocol family not supported
  699. SOCEAFNOSUPPORT = (SOCBASEERR+47); // Address family not supported by protocol family
  700. SOCEADDRINUSE = (SOCBASEERR+48); // Address already in use
  701. SOCEADDRNOTAVAIL = (SOCBASEERR+49); // Can't assign requested address
  702. // ipc/network software -- operational errors
  703. SOCENETDOWN = (SOCBASEERR+50); // Network is down
  704. SOCENETUNREACH = (SOCBASEERR+51); // Network is unreachable
  705. SOCENETRESET = (SOCBASEERR+52); // Network dropped connection on reset
  706. SOCECONNABORTED = (SOCBASEERR+53); // Software caused connection abort
  707. SOCECONNRESET = (SOCBASEERR+54); // Connection reset by peer
  708. SOCENOBUFS = (SOCBASEERR+55); // No buffer space available
  709. SOCEISCONN = (SOCBASEERR+56); // Socket is already connected
  710. SOCENOTCONN = (SOCBASEERR+57); // Socket is not connected
  711. SOCESHUTDOWN = (SOCBASEERR+58); // Can't send after socket shutdown
  712. SOCETOOMANYREFS = (SOCBASEERR+59); // Too many references: can't splice
  713. SOCETIMEDOUT = (SOCBASEERR+60); // Operation timed out
  714. SOCECONNREFUSED = (SOCBASEERR+61); // Connection refused
  715. SOCELOOP = (SOCBASEERR+62); // Too many levels of symbolic links
  716. SOCENAMETOOLONG = (SOCBASEERR+63); // File name too long
  717. // should be rearranged
  718. SOCEHOSTDOWN = (SOCBASEERR+64); // Host is down
  719. SOCEHOSTUNREACH = (SOCBASEERR+65); // No route to host
  720. SOCENOTEMPTY = (SOCBASEERR+66); // Directory not empty
  721. // quotas & mush
  722. SOCEPROCLIM = (SOCBASEERR+67); // Too many processes
  723. SOCEUSERS = (SOCBASEERR+68); // Too many users
  724. SOCEDQUOT = (SOCBASEERR+69); // Disc quota exceeded
  725. // Network File System
  726. SOCESTALE = (SOCBASEERR+70); // Stale NFS file handle
  727. SOCEREMOTE = (SOCBASEERR+71); // Too many levels of remote in path
  728. SOCEBADRPC = (SOCBASEERR+72); // RPC struct is bad
  729. SOCERPCMISMATCH = (SOCBASEERR+73); // RPC version wrong
  730. SOCEPROGUNAVAIL = (SOCBASEERR+74); // RPC prog. not avail
  731. SOCEPROGMISMATCH = (SOCBASEERR+75); // Program version wrong
  732. SOCEPROCUNAVAIL = (SOCBASEERR+76); // Bad procedure for program
  733. SOCENOLCK = (SOCBASEERR+77); // No locks available
  734. SOCENOSYS = (SOCBASEERR+78); // Function not implemented
  735. SOCEFTYPE = (SOCBASEERR+79); // Inappropriate file type or format
  736. SOCEAUTH = (SOCBASEERR+80); // Authentication error
  737. SOCENEEDAUTH = (SOCBASEERR+81); // Need authenticator
  738. SOCEOS2ERR = (SOCBASEERR+100); // OS/2 Error
  739. SOCELAST = (SOCBASEERR+100); // Must be equal largest errno
  740. (* !!TODO Add this consts
  741. /*
  742. * OS/2 SOCKET API errors redefined as regular BSD error constants
  743. */
  744. #ifndef ENOENT
  745. #define ENOENT SOCENOENT
  746. #endif
  747. #ifndef EFAULT
  748. #define EFAULT SOCEFAULT
  749. #endif
  750. #ifndef EBUSY
  751. #define EBUSY SOCEBUSY
  752. #endif
  753. #ifndef ENXIO
  754. #define ENXIO SOCENXIO
  755. #endif
  756. #ifndef EACCES
  757. #define EACCES SOCEACCES
  758. #endif
  759. #ifndef ENOMEM
  760. #define ENOMEM SOCENOMEM
  761. #endif
  762. #ifndef ENOTDIR
  763. #define ENOTDIR SOCENOTDIR
  764. #endif
  765. #ifndef EPERM
  766. #define EPERM SOCEPERM
  767. #endif
  768. #ifndef ESRCH
  769. #define ESRCH SOCESRCH
  770. #endif
  771. #ifndef EDQUOT
  772. #define EDQUOT SOCEDQUOT
  773. #endif
  774. #ifndef EEXIST
  775. #define EEXIST SOCEEXIST
  776. #endif
  777. #ifndef EBUSY
  778. #define EBUSY SOCEBUSY
  779. #endif
  780. #ifndef EWOULDBLOCK
  781. #define EWOULDBLOCK SOCEWOULDBLOCK
  782. #endif
  783. #ifndef EINPROGRESS
  784. #define EINPROGRESS SOCEINPROGRESS
  785. #endif
  786. #ifndef EALREADY
  787. #define EALREADY SOCEALREADY
  788. #endif
  789. #ifndef ENOTSOCK
  790. #define ENOTSOCK SOCENOTSOCK
  791. #endif
  792. #ifndef EDESTADDRREQ
  793. #define EDESTADDRREQ SOCEDESTADDRREQ
  794. #endif
  795. #ifndef EMSGSIZE
  796. #define EMSGSIZE SOCEMSGSIZE
  797. #endif
  798. #ifndef EPROTOTYPE
  799. #define EPROTOTYPE SOCEPROTOTYPE
  800. #endif
  801. #ifndef ENOPROTOOPT
  802. #define ENOPROTOOPT SOCENOPROTOOPT
  803. #endif
  804. #ifndef EPROTONOSUPPORT
  805. #define EPROTONOSUPPORT SOCEPROTONOSUPPORT
  806. #endif
  807. #ifndef ESOCKTNOSUPPORT
  808. #define ESOCKTNOSUPPORT SOCESOCKTNOSUPPORT
  809. #endif
  810. #ifndef EOPNOTSUPP
  811. #define EOPNOTSUPP SOCEOPNOTSUPP
  812. #endif
  813. #ifndef EPFNOSUPPORT
  814. #define EPFNOSUPPORT SOCEPFNOSUPPORT
  815. #endif
  816. #ifndef EAFNOSUPPORT
  817. #define EAFNOSUPPORT SOCEAFNOSUPPORT
  818. #endif
  819. #ifndef EADDRINUSE
  820. #define EADDRINUSE SOCEADDRINUSE
  821. #endif
  822. #ifndef EADDRNOTAVAIL
  823. #define EADDRNOTAVAIL SOCEADDRNOTAVAIL
  824. #endif
  825. #ifndef ENETDOWN
  826. #define ENETDOWN SOCENETDOWN
  827. #endif
  828. #ifndef ENETUNREACH
  829. #define ENETUNREACH SOCENETUNREACH
  830. #endif
  831. #ifndef ENETRESET
  832. #define ENETRESET SOCENETRESET
  833. #endif
  834. #ifndef ECONNABORTED
  835. #define ECONNABORTED SOCECONNABORTED
  836. #endif
  837. #ifndef ECONNRESET
  838. #define ECONNRESET SOCECONNRESET
  839. #endif
  840. #ifndef ENOBUFS
  841. #define ENOBUFS SOCENOBUFS
  842. #endif
  843. #ifndef EISCONN
  844. #define EISCONN SOCEISCONN
  845. #endif
  846. #ifndef ENOTCONN
  847. #define ENOTCONN SOCENOTCONN
  848. #endif
  849. #ifndef ESHUTDOWN
  850. #define ESHUTDOWN SOCESHUTDOWN
  851. #endif
  852. #ifndef ETOOMANYREFS
  853. #define ETOOMANYREFS SOCETOOMANYREFS
  854. #endif
  855. #ifndef ETIMEDOUT
  856. #define ETIMEDOUT SOCETIMEDOUT
  857. #endif
  858. #ifndef ECONNREFUSED
  859. #define ECONNREFUSED SOCECONNREFUSED
  860. #endif
  861. #ifndef ELOOP
  862. #define ELOOP SOCELOOP
  863. #endif
  864. #ifndef ENAMETOOLONG /* Borland and Watcom define this */
  865. #define ENAMETOOLONG SOCENAMETOOLONG
  866. #endif
  867. #ifndef EHOSTDOWN
  868. #define EHOSTDOWN SOCEHOSTDOWN
  869. #endif
  870. #ifndef EHOSTUNREACH
  871. #define EHOSTUNREACH SOCEHOSTUNREACH
  872. #endif
  873. #ifndef ENOTEMPTY /* Watcom defines this */
  874. #define ENOTEMPTY SOCENOTEMPTY
  875. #endif
  876. #ifndef EINVAL
  877. #define EINVAL SOCEINVAL
  878. #endif
  879. #ifndef EINTR
  880. #define EINTR SOCEINTR
  881. #endif
  882. #ifndef EMFILE
  883. #define EMFILE SOCEMFILE
  884. #endif
  885. #ifndef EPIPE
  886. #define EPIPE SOCEPIPE
  887. #endif
  888. *)
  889. // * bsd select definitions
  890. const
  891. {
  892. * Select uses bit masks of file descriptors in longs. These macros
  893. * manipulate such bit fields (the filesystem macros use chars).
  894. * FD_SETSIZE may be defined by the user, but the default here should
  895. * be enough for most uses.
  896. }
  897. FD_SETSIZE = 64;
  898. type
  899. fd_set = record
  900. fd_count : Word; // how many are SET?
  901. fd_array : array[0..FD_SETSIZE-1] of Longint; // an array of SOCKETs
  902. end;
  903. timeval = record
  904. tv_sec : Longint; // Number of seconds
  905. tv_usec : Longint; // Number of microseconds
  906. end;
  907. {
  908. * ioctl & ip trace support
  909. }
  910. const
  911. FIONREAD = (Ord('f') SHL 8) OR 127;
  912. FIONBIO = (Ord('f') SHL 8) OR 126;
  913. FIOASYNC = (Ord('f') SHL 8) OR 125;
  914. FIOTCPCKSUM = (Ord('f') SHL 8) OR 128;
  915. FIONSTATUS = (Ord('f') SHL 8) OR 120;
  916. FIONURG = (Ord('f') SHL 8) OR 121;
  917. SIOCSHIWAT = (Ord('s') SHL 8) OR 0;
  918. SIOCGHIWAT = (Ord('s') SHL 8) OR 1;
  919. SIOCSLOWAT = (Ord('s') SHL 8) OR 2;
  920. SIOCGLOWAT = (Ord('s') SHL 8) OR 3;
  921. SIOCATMARK = (Ord('s') SHL 8) OR 7;
  922. SIOCSPGRP = (Ord('s') SHL 8) OR 8;
  923. SIOCGPGRP = (Ord('s') SHL 8) OR 9;
  924. SIOCSHOSTID = (Ord('s') SHL 8) OR 10;
  925. SIOCADDRT = (Ord('r') SHL 8) OR 10;
  926. SIOCDELRT = (Ord('r') SHL 8) OR 11;
  927. SIOMETRIC1RT = (Ord('r') SHL 8) OR 12;
  928. SIOMETRIC2RT = (Ord('r') SHL 8) OR 13;
  929. SIOMETRIC3RT = (Ord('r') SHL 8) OR 14;
  930. SIOMETRIC4RT = (Ord('r') SHL 8) OR 15;
  931. SIOCREGADDNET = (Ord('r') SHL 8) OR 12;
  932. SIOCREGDELNET = (Ord('r') SHL 8) OR 13;
  933. SIOCREGROUTES = (Ord('r') SHL 8) OR 14;
  934. SIOCFLUSHROUTES=(Ord('r') SHL 8) OR 15;
  935. SIOCSIFADDR = (Ord('i') SHL 8) OR 12;
  936. SIOCGIFADDR = (Ord('i') SHL 8) OR 13;
  937. SIOCSIFDSTADDR= (Ord('i') SHL 8) OR 14;
  938. SIOCGIFDSTADDR= (Ord('i') SHL 8) OR 15;
  939. SIOCSIFFLAGS = (Ord('i') SHL 8) OR 16;
  940. SIOCGIFFLAGS = (Ord('i') SHL 8) OR 17;
  941. SIOCGIFBRDADDR= (Ord('i') SHL 8) OR 18;
  942. SIOCSIFBRDADDR= (Ord('i') SHL 8) OR 19;
  943. SIOCGIFCONF = (Ord('i') SHL 8) OR 20;
  944. SIOCGIFNETMASK= (Ord('i') SHL 8) OR 21;
  945. SIOCSIFNETMASK= (Ord('i') SHL 8) OR 22;
  946. SIOCGIFMETRIC = (Ord('i') SHL 8) OR 23;
  947. SIOCSIFMETRIC = (Ord('i') SHL 8) OR 24;
  948. SIOCSIFSETSIG = (Ord('i') SHL 8) OR 25;
  949. SIOCSIFCLRSIG = (Ord('i') SHL 8) OR 26;
  950. SIOCSIFBRD = (Ord('i') SHL 8) OR 27; { SINGLE-rt bcst. using old # for bkw cmpt }
  951. SIOCSIFALLRTB = (Ord('i') SHL 8) OR 63; { added to configure all-route broadcst }
  952. SIOCGIFLOAD =(Ord('i') SHL 8) OR 27;
  953. SIOCSIFFILTERSRC=(Ord('i') SHL 8) OR 28;
  954. SIOCGIFFILTERSRC=(Ord('i') SHL 8) OR 29;
  955. SIOCSARP = (Ord('i') SHL 8) OR 30;
  956. SIOCGARP = (Ord('i') SHL 8) OR 31;
  957. SIOCDARP = (Ord('i') SHL 8) OR 32;
  958. SIOCSIFSNMPSIG= (Ord('i') SHL 8) OR 33;
  959. SIOCSIFSNMPCLR= (Ord('i') SHL 8) OR 34;
  960. SIOCSIFSNMPCRC= (Ord('i') SHL 8) OR 35;
  961. SIOCSIFPRIORITY=(Ord('i') SHL 8) OR 36;
  962. SIOCGIFPRIORITY=(Ord('i') SHL 8) OR 37;
  963. SIOCSIFFILTERDST=(Ord('i') SHL 8) OR 38;
  964. SIOCGIFFILTERDST=(Ord('i') SHL 8) OR 39;
  965. SIOCSIF802_3 = (Ord('i') SHL 8) OR 40;
  966. SIOCSIFNO802_3= (Ord('i') SHL 8) OR 41;
  967. SIOCSIFNOREDIR= (Ord('i') SHL 8) OR 42;
  968. SIOCSIFYESREDIR= (Ord('i') SHL 8) OR 43;
  969. SIOCSIFMTU = (Ord('i') SHL 8) OR 45;
  970. SIOCSIFFDDI = (Ord('i') SHL 8) OR 46;
  971. SIOCSIFNOFDDI = (Ord('i') SHL 8) OR 47;
  972. SIOCSRDBRD = (Ord('i') SHL 8) OR 48;
  973. SIOCSARP_TR = (Ord('i') SHL 8) OR 49;
  974. SIOCGARP_TR = (Ord('i') SHL 8) OR 50;
  975. { multicast ioctls }
  976. SIOCADDMULTI = (Ord('i') SHL 8) OR 51; { add m'cast addr }
  977. SIOCDELMULTI = (Ord('i') SHL 8) OR 52; { del m'cast addr }
  978. SIOCMULTISBC = (Ord('i') SHL 8) OR 61; { use broadcast to send IP multicast }
  979. SIOCMULTISFA = (Ord('i') SHL 8) OR 62; { use functional addr to send IP multicast }
  980. {$IFDEF SLBOOTP}
  981. SIOCGUNIT = (Ord('i') SHL 8) OR 70; { Used to retreive unit number on }
  982. { serial interface }
  983. {$ENDIF}
  984. SIOCSIFSPIPE = (Ord('i') SHL 8) OR 71; { used to set pipe size on interface }
  985. { this is used as tcp send buffer size }
  986. SIOCSIFRPIPE = (Ord('i') SHL 8) OR 72; { used to set pipe size on interface }
  987. { this is used as tcp recv buffer size }
  988. SIOCSIFTCPSEG = (Ord('i') SHL 8) OR 73; { set the TCP segment size on interface }
  989. SIOCSIFUSE576 = (Ord('i') SHL 8) OR 74; { enable/disable the automatic change of mss to 576 }
  990. { if going through a router }
  991. SIOCGIFVALID = (Ord('i') SHL 8) OR 75; { to check if the interface is Valid or not }
  992. { sk June 14 1995 }
  993. SIOCGIFBOUND = (Ord('i') SHL 8) OR 76; { ioctl to return bound/shld bind ifs }
  994. { Interface Tracing Support }
  995. SIOCGIFEFLAGS = (Ord('i') SHL 8) OR 150;
  996. SIOCSIFEFLAGS = (Ord('i') SHL 8) OR 151;
  997. SIOCGIFTRACE = (Ord('i') SHL 8) OR 152;
  998. SIOCSIFTRACE = (Ord('i') SHL 8) OR 153;
  999. {$IFDEF SLSTATS}
  1000. SIOCSSTAT = (Ord('i') SHL 8) OR 154;
  1001. SIOCGSTAT = (Ord('i') SHL 8) OR 155;
  1002. {$ENDIF}
  1003. { NETSTAT stuff }
  1004. SIOSTATMBUF = (Ord('n') SHL 8) OR 40;
  1005. SIOSTATTCP = (Ord('n') SHL 8) OR 41;
  1006. SIOSTATUDP = (Ord('n') SHL 8) OR 42;
  1007. SIOSTATIP = (Ord('n') SHL 8) OR 43;
  1008. SIOSTATSO = (Ord('n') SHL 8) OR 44;
  1009. SIOSTATRT = (Ord('n') SHL 8) OR 45;
  1010. SIOFLUSHRT = (Ord('n') SHL 8) OR 46;
  1011. SIOSTATICMP = (Ord('n') SHL 8) OR 47;
  1012. SIOSTATIF = (Ord('n') SHL 8) OR 48;
  1013. SIOSTATAT = (Ord('n') SHL 8) OR 49;
  1014. SIOSTATARP = (Ord('n') SHL 8) OR 50;
  1015. SIOSTATIF42 = (Ord('n') SHL 8) OR 51;
  1016. (* From fpc 2.0.0
  1017. SIOCGIFFLAGS = $6900 + 17; // get interface flags
  1018. { Interface Tracing Support }
  1019. SIOCGIFEFLAGS = $6900 + 150; // get interface enhanced flags
  1020. SIOCSIFEFLAGS = $6900 + 151; // set interface enhanced flags
  1021. SIOCGIFTRACE = $6900 + 152; // get interface trace data
  1022. SIOCSIFTRACE = $6900 + 153; // set interface trace data
  1023. { sorry, i skip other ioctl commands, see SYS\ioctl.h from toolkit for it.. }
  1024. *)
  1025. (* !!TODO Check all macros from sys/itypes.h
  1026. function LSwap(a:Longint):Longint;
  1027. function WSwap(a:Word):Word;
  1028. { host -> network for long (4 bytes) }
  1029. function htonl(a:Longint):Longint;
  1030. { network -> host for long (4 bytes) }
  1031. function ntohl(a:Longint):Longint;
  1032. { host -> network for small (2 bytes) }
  1033. function htons(a:Word):Word;
  1034. { network -> host for small (2 bytes) }
  1035. function ntohs(a:Word):Word;
  1036. *)
  1037. { * init / misc funcs }
  1038. { init sockets system }
  1039. function sock_init:Longint; cdecl;
  1040. { get inet version. version - buffer of ?? size for returned string. }
  1041. function getinetversion(var version):Longint; cdecl;
  1042. { * sockets errors reporting funcs }
  1043. { last err code for this thread }
  1044. function sock_errno:Longint; cdecl;
  1045. { print last err string + str if not NIL }
  1046. procedure psock_errno(var str:PChar); cdecl;
  1047. { * sockets creation / close funcs }
  1048. { create new socket }
  1049. function socket(domain,stype,protocol:Longint):Longint; cdecl;
  1050. { close socket }
  1051. function soclose(sock:Longint):Longint; cdecl;
  1052. { cancel socket }
  1053. function so_cancel(sock:Longint):Longint; cdecl;
  1054. { shutdown socket. howto: 0/1/2 }
  1055. function shutdown(sock,howto:Longint):Longint; cdecl;
  1056. { abort socket. no docs found about it :( }
  1057. function soabort(sock:Longint):Longint; cdecl;
  1058. (***************************************************************************)
  1059. (* *)
  1060. (* sockets connection funcs *)
  1061. (* *)
  1062. (***************************************************************************)
  1063. { accept a connection from remote host. returns s_addr & s_addr_len if not nil }
  1064. function accept(sock:Longint; var s_addr:sockaddr; s_addr_len:Longint):Longint; cdecl;
  1065. { bind a local name to the socket }
  1066. function bind(sock:Longint; var s_addr: sockaddr; s_addr_len:Longint):Longint; cdecl;
  1067. { connect socket to remote host }
  1068. function connect(sock:Longint; var s_addr:sockaddr; s_addr_len:Longint):Longint; cdecl;
  1069. { listen on socket. max_conn - queue size of listen. }
  1070. function listen(sock,max_conn:Longint):Longint; cdecl;
  1071. (***************************************************************************)
  1072. (* *)
  1073. (* sockets read/write funcs *)
  1074. (* *)
  1075. (***************************************************************************)
  1076. { read data from socket. ! return N of readed bytes, or 0 (closed) or -1 }
  1077. function recv(sock:Longint; var buf; buf_len,flags:Longint):Longint; cdecl;
  1078. { send data to socket. ! return N of sent bytes. -1 - err }
  1079. function send(sock:Longint; var buf; buf_len,flags:Longint):Longint; cdecl;
  1080. { read data from socket. ! return N of readed bytes, or 0 (closed) or -1 }
  1081. function recvfrom(sock:Longint; var buf; buf_len,flags:Longint; var s_addr:sockaddr; var s_addr_len:Longint):Longint; cdecl;
  1082. { send data to socket. ! return N of sent bytes. -1 - err }
  1083. function sendto(sock:Longint; var buf; buf_len,flags:Longint; var s_addr:sockaddr; s_addr_len:Longint):Longint; cdecl;
  1084. { read data into iov_count number of buffers iov.
  1085. ! return N of readed bytes, or 0 (closed) or -1 }
  1086. function readv(sock:Longint; var iov:iovec; iov_count:Longint):LONGINT; cdecl;
  1087. { write data from iov_count number of buffers iov.
  1088. ! return N of writed bytes, or -1 }
  1089. function writev(sock:Longint; var iov:iovec; iov_count:Longint):LONGINT; cdecl;
  1090. { read data + control info from socket
  1091. ! return N of readed bytes, or 0 (closed) or -1 }
  1092. function recvmsg(sock:Longint; var msgbuf:msghdr; flags:Longint):Longint; cdecl;
  1093. { send data + control info to socket
  1094. ! return N of sended bytes, or -1 }
  1095. function sendmsg(sock:Longint; var msgbuf:msghdr; flags:Longint):Longint; cdecl;
  1096. (***************************************************************************)
  1097. (* *)
  1098. (* select funcs *)
  1099. (* *)
  1100. (***************************************************************************)
  1101. { OS/2 select. 0 - timeout. -1 - err. XX - N of sockets worked. }
  1102. function os2_select(var sockets; N_reads, N_writes, N_exepts, timeout:Longint):Longint; cdecl;
  1103. { bsd select here. heavy voodoo.. }
  1104. function select(nfds:Longint; var readfds,writefds,exceptfds:fd_set; var timeout:timeval):Longint; cdecl;
  1105. (***************************************************************************)
  1106. (* *)
  1107. (* misc info *)
  1108. (* *)
  1109. (***************************************************************************)
  1110. { get host ip addr - addr of primary interface }
  1111. function gethostid:Longint; cdecl;
  1112. { get connected to socket hostname }
  1113. function getpeername(sock:Longint; var s_addr:sockaddr; var s_addr_len:Longint):Longint; cdecl;
  1114. { get local socket name }
  1115. function getsockname(sock:Longint; var s_addr:sockaddr; var s_addr_len:Longint):Longint; cdecl;
  1116. (***************************************************************************)
  1117. (* *)
  1118. (* options & ioctls *)
  1119. (* *)
  1120. (***************************************************************************)
  1121. { get socket options }
  1122. function getsockopt(sock,level,optname:Longint; var buf; var buf_len:Longint):Longint; cdecl;
  1123. { set socket options }
  1124. function setsockopt(sock,level,optname:Longint; var buf; buf_len:Longint):Longint; cdecl;
  1125. { f@$king ioctl. use sys/ioctl.h }
  1126. function os2_ioctl(sock,cmd:Longint; var data; data_len:Longint):Longint; cdecl;
  1127. (***************************************************************************)
  1128. (* *)
  1129. (* functions only for 4.1+ ip stacks (but also found in 4.02w ;)) *)
  1130. (* *)
  1131. (***************************************************************************)
  1132. function addsockettolist(sock:Longint):Longint; cdecl;
  1133. function removesocketfromlist(sock:Longint):Longint; cdecl;
  1134. implementation
  1135. function LSwap(a:Longint):Longint; assembler;
  1136. asm
  1137. mov eax,a
  1138. xchg ah,al
  1139. ror eax,16
  1140. xchg ah,al
  1141. end;
  1142. function WSwap(a:Word):Word; assembler;
  1143. asm
  1144. mov ax,a
  1145. xchg ah,al
  1146. end;
  1147. function accept(sock:Longint; var s_addr: sockaddr; s_addr_len:Longint):Longint; cdecl; external 'SO32DLL' index 1;
  1148. function bind(sock:Longint; var s_addr: sockaddr; s_addr_len:Longint):Longint; cdecl; external 'SO32DLL' index 2;
  1149. function connect(sock:Longint; var s_addr:sockaddr; s_addr_len:Longint):Longint; cdecl; external 'SO32DLL' index 3;
  1150. function gethostid: Longint; cdecl; external 'SO32DLL' index 4;
  1151. function getpeername(sock:Longint; var s_addr:sockaddr; var s_addr_len:Longint):Longint; cdecl; external 'SO32DLL' index 5;
  1152. function getsockname(sock:Longint; var s_addr:sockaddr; var s_addr_len:Longint):Longint; cdecl; external 'SO32DLL' index 6;
  1153. function getsockopt(sock,level,optname:Longint; var buf; var buf_len:Longint):Longint; cdecl; external 'SO32DLL' index 7;
  1154. function os2_ioctl(sock,cmd:Longint; var data; data_len:Longint):Longint; cdecl; external 'SO32DLL' index 8;
  1155. function listen(sock,max_conn:Longint):Longint; cdecl; external 'SO32DLL' index 9;
  1156. function recv(sock:Longint; var buf; buf_len,flags:Longint):Longint; cdecl; external 'SO32DLL' index 10;
  1157. function recvfrom(sock:Longint; var buf; buf_len,flags:Longint;var s_addr:sockaddr; var s_addr_len:Longint):Longint; cdecl; external 'SO32DLL' index 11;
  1158. function os2_select(var sockets; N_reads, N_writes, N_exepts, timeout:Longint):Longint; cdecl; external 'SO32DLL' index 12;
  1159. function send(sock:Longint; var buf; buf_len,flags:Longint):Longint; cdecl; external 'SO32DLL' index 13;
  1160. function sendto(sock:Longint; var buf; buf_len,flags:Longint;var s_addr:sockaddr; s_addr_len:Longint):Longint; cdecl; external 'SO32DLL' index 14;
  1161. function setsockopt(sock,level,optname:Longint; var buf; buf_len:Longint):Longint; cdecl; external 'SO32DLL' index 15;
  1162. function socket(domain,stype,protocol:Longint):Longint; cdecl; external 'SO32DLL' index 16;
  1163. function soclose(sock:Longint):Longint; cdecl; external 'SO32DLL' index 17;
  1164. function so_cancel(sock:Longint):Longint; cdecl; external 'SO32DLL' index 18;
  1165. function soabort(sock:Longint):Longint; cdecl; external 'SO32DLL' index 19;
  1166. function sock_errno:Longint; cdecl; external 'SO32DLL' index 20;
  1167. function recvmsg(sock:Longint; var msgbuf:msghdr; flags:Longint):Longint; cdecl; external 'SO32DLL' index 21;
  1168. function sendmsg(sock:Longint; var msgbuf:msghdr; flags:Longint):Longint; cdecl; external 'SO32DLL' index 22;
  1169. function readv(sock:Longint; var iov:iovec; iov_count:Longint):LONGINT; cdecl; external 'SO32DLL' index 23;
  1170. function writev(sock:Longint; var iov:iovec; iov_count:Longint):LONGINT; cdecl; external 'SO32DLL' index 24;
  1171. function shutdown(sock,howto:Longint):Longint; cdecl; external 'SO32DLL' index 25;
  1172. function sock_init:Longint; cdecl; external 'SO32DLL' index 26;
  1173. function addsockettolist(sock:Longint):Longint; cdecl; external 'SO32DLL' index 27;
  1174. function removesocketfromlist(sock:Longint):Longint; cdecl; external 'SO32DLL' index 28;
  1175. { entry 29 not used }
  1176. procedure psock_errno(var str:PChar); cdecl; external 'SO32DLL' index 30;
  1177. function getinetversion(var version):Longint; cdecl; external 'SO32DLL' index 31;
  1178. function select(nfds:Longint;
  1179. var readfds,writefds,exceptfds:fd_set;
  1180. var timeout:timeval):Longint; cdecl; external 'SO32DLL' index 32;
  1181. function htonl(a:Longint):Longint;
  1182. begin htonl:=LSwap(a); end;
  1183. { host -> network for long (4 bytes) }
  1184. function ntohl(a:Longint):Longint;
  1185. begin ntohl:=LSwap(a); end;
  1186. { network -> host for long (4 bytes) }
  1187. function htons(a:Word):Word;
  1188. begin htons:=WSwap(a); end;
  1189. { host -> network for small (2 bytes) }
  1190. function ntohs(a:Word):Word;
  1191. begin ntohs:=WSwap(a); end;
  1192. { network -> host for small (2 bytes) }
  1193. end.
  1194. (* !!TODO Following code not revised as yet
  1195. {*
  1196. * User-settable options (used with setsockopt).
  1197. *}
  1198. TCP_NODELAY = $01; // don't delay send to coalesce packets
  1199. TCP_MAXSEG = $02; // set maximum segment size
  1200. TCP_MSL = $03; // MSL HACK
  1201. TCP_TIMESTMP = $04; // RFC 1323 (RTTM TimeStamp)
  1202. TCP_WINSCALE = $05; // RFC 1323 (Window Scale)
  1203. TCP_CC = $06; // RFC 1644 (Connection Count)
  1204. {
  1205. * Structures returned by network data base library. All addresses are
  1206. * supplied in host order, and returned in network order (suitable for
  1207. * use in system calls).
  1208. }
  1209. type
  1210. PLongint = ^Longint;
  1211. { struct for gethostbyname() and gethostbyaddr() }
  1212. hostent = record
  1213. h_name : PChar; // official name of host
  1214. h_aliases : ^PChar; // alias list
  1215. h_addrtype : Longint; // host address type
  1216. h_length : Longint; // length of address
  1217. h_addr_list : ^PLongint; // list of addresses from name server
  1218. end;
  1219. phostent = ^hostent;
  1220. {
  1221. * Error return codes from gethostbyname(), gethostbyaddr() and res_* funcs
  1222. * (left in extern int h_errno).
  1223. }
  1224. const
  1225. NETDB_INTERNAL = -1; // see errno
  1226. NETDB_SUCCESS = 0; // no problem
  1227. HOST_NOT_FOUND = 1; // Authoritative Answer Host not found
  1228. TRY_AGAIN = 2; // Non-Authoritive Host not found, or SERVERFAIL
  1229. NO_RECOVERY = 3; // Non recoverable errors, FORMERR, REFUSED, NOTIMP
  1230. NO_DATA = 4; // Valid name, no data record of requested type
  1231. NO_ADDRESS = NO_DATA; // no address, look for MX record
  1232. type
  1233. { struct for getprotobyname() and getprotobynumber() }
  1234. protoent = record
  1235. p_name : PChar; // official protocol name
  1236. p_aliases : ^PChar; // alias list
  1237. p_proto : Longint; // protocol #
  1238. end;
  1239. pprotoent = ^protoent;
  1240. type
  1241. { struct for getservbyname() and getservbyport() }
  1242. servent = record
  1243. s_name : PChar; // official service name
  1244. s_aliases : ^PChar; // alias list
  1245. s_port : Longint; // port # (need ntohl() !!)
  1246. s_proto : PChar; // protocol to use
  1247. end;
  1248. pservent = ^servent;
  1249. const
  1250. IFF_UP = $1; // interface is up
  1251. IFF_BROADCAST = $2; // broadcast address valid
  1252. IFF_DEBUG = $4; // turn on debugging
  1253. IFF_LOOPBACK = $8; // is a loopback net
  1254. IFF_POINTOPOINT = $10; // interface is point-to-point link
  1255. IFF_LINK2 = $20; // was trailers, not used
  1256. IFF_NOTRAILERS = IFF_LINK2;
  1257. IFF_RUNNING = $40; // resources allocated
  1258. IFF_NOARP = $80; // no address resolution protocol
  1259. IFF_PROMISC = $100; // receive all packets
  1260. IFF_ALLMULTI = $200; // receive all multicast packets
  1261. IFF_BRIDGE = $1000; // support token ring routine field
  1262. IFF_SNAP = $2000; // support extended SAP header
  1263. IFF_DEFMTU = $400; // default mtu of 1500
  1264. IFF_RFC1469_BC = 1; // using broadcast
  1265. IFF_RFC1469_FA = 2; // using functional
  1266. IFF_RFC1469_MA = 3; // using multicast
  1267. IFF_ETHER = $4000; // Ethernet interface
  1268. IFF_LOOPBRD = $8000; // loop back broadcasts
  1269. IFF_MULTICAST = $800; // supports multicast
  1270. IFF_SIMPLEX = $10000; // can't hear own transmissions
  1271. IFF_OACTIVE = $20000; // transmission in progress
  1272. IFF_802_3 = $40000;
  1273. IFF_CANONICAL = $80000;
  1274. IFF_RUNNINGBLK = $100000; // threads waited for intf running
  1275. { Interface enhanced flags }
  1276. IFFE_PKTTRACE = $00000001; // trace datalink where possible
  1277. IFFE_IPTRACE = $00000002; // trace ONLY IP packets
  1278. type
  1279. { trace buffer struct }
  1280. pkt_trace_hdr = record
  1281. pt_htype : Word; // header type
  1282. pt_len : Word; // in: pt_buf len, out: packet len
  1283. pt_data : Pointer; // packet
  1284. pt_tstamp : Longint; // time stamp in milliseconds
  1285. end;
  1286. const
  1287. { physical protocols IDs }
  1288. HT_IP = $01; // IP
  1289. HT_ETHER = $06; // Ethernet
  1290. HT_ISO88023 = $07; // CSMA CD
  1291. HT_ISO88025 = $09; // Token Ring
  1292. HT_SLIP = $1c; // Serial Line IP
  1293. HT_PPP = $18; // PPP IP
  1294. const
  1295. IFNAMSIZ = 16; // interface name length
  1296. type
  1297. {
  1298. * Interface request structure used for socket
  1299. * ioctl's. All interface ioctl's must have parameter
  1300. * definitions which begin with ifr_name. The
  1301. * remainder may be interface specific.
  1302. }
  1303. ifreq = record
  1304. ifr_name : array[0..IFNAMSIZ-1] of Char;
  1305. case Byte of
  1306. 0: (ifr_addr : sockaddr); // address
  1307. 1: (ifr_dstaddr : sockaddr); // other end of p-to-p link
  1308. 2: (ifr_broadaddr : sockaddr); // broadcast address
  1309. 3: (ifr_flags : Word); // flags
  1310. 4: (ifr_metric : Longint); // metric
  1311. 5: (ifr_data : Pointer); // for use by interface
  1312. 6: (ifr_eflags : Longint); // eflags
  1313. end;
  1314. {
  1315. * Structure of an internet header, naked of options.
  1316. }
  1317. type
  1318. ip = record
  1319. hlen_ver : Byte; { lo 4 bits = header len/4
  1320. hi 4 bits = ip ver (4) }
  1321. ip_tos : Byte; { type of service }
  1322. ip_len : Word; { total packet length }
  1323. ip_id : Word; { identification }
  1324. ip_off : Word; { fragment offset field }
  1325. ip_ttl : Byte; { time to live }
  1326. ip_p : Byte; { protocol (see IPPROTO_* ) }
  1327. ip_sum : Word; { header checksum }
  1328. ip_src, ip_dst : Longint; { ip from / to addr }
  1329. end;
  1330. { in.h / inet.h const & func }
  1331. {
  1332. * Protocols
  1333. }
  1334. const
  1335. IPPROTO_IP = 0; { dummy for IP }
  1336. IPPROTO_ICMP = 1; { control message protocol }
  1337. IPPROTO_GGP = 3; { gateway^2 (deprecated) }
  1338. IPPROTO_TCP = 6; { tcp }
  1339. IPPROTO_EGP = 8; { exterior gateway protocol }
  1340. IPPROTO_PUP = 12; { pup }
  1341. IPPROTO_UDP = 17; { user datagram protocol }
  1342. IPPROTO_IDP = 22; { xns idp }
  1343. IPPROTO_RAW = 255; { raw IP packet }
  1344. IPPROTO_MAX = 256;
  1345. {
  1346. * Ports < IPPORT_RESERVED are reserved for
  1347. * privileged processes (e.g. root).
  1348. * Ports > IPPORT_USERRESERVED are reserved
  1349. * for servers, not necessarily privileged.
  1350. }
  1351. const
  1352. IPPORT_RESERVED = 1024;
  1353. IPPORT_USERRESERVED = 5000;
  1354. {
  1355. * Link numbers
  1356. }
  1357. const
  1358. IMPLINK_IP = 155;
  1359. IMPLINK_LOWEXPER = 156;
  1360. IMPLINK_HIGHEXPER = 158;
  1361. {
  1362. * Definitions of bits in internet address integers.
  1363. * On subnets, the decomposition of addresses to host and net parts
  1364. * is done according to subnet mask, not the masks here.
  1365. }
  1366. const
  1367. IN_CLASSA_NET = $ff000000;
  1368. IN_CLASSA_NSHIFT = 24;
  1369. IN_CLASSA_HOST = $00ffffff;
  1370. IN_CLASSA_MAX = 128;
  1371. IN_CLASSB_NET = $ffff0000;
  1372. IN_CLASSB_NSHIFT = 16;
  1373. IN_CLASSB_HOST = $0000ffff;
  1374. IN_CLASSB_MAX = 65536;
  1375. IN_CLASSC_NET = $ffffff00;
  1376. IN_CLASSC_NSHIFT = 8;
  1377. IN_CLASSC_HOST = $000000ff;
  1378. INADDR_ANY = $00000000;
  1379. INADDR_BROADCAST = $ffffffff; { must be masked }
  1380. INADDR_NONE = $ffffffff; { -1 return }
  1381. IN_LOOPBACKNET = 127; { official! }
  1382. {
  1383. * Socket address, internet style.
  1384. }
  1385. type
  1386. sockaddr_in = record
  1387. sin_family : Word;
  1388. sin_port : Word; { htons first!! }
  1389. sin_addr : Longint; {in_addr; hist reasons :)) }
  1390. sin_zero : array[0..7] of Byte; {must be zero}
  1391. end;
  1392. { * Internet address (a structure for historical reasons) }
  1393. type
  1394. in_addr = record
  1395. s_addr : Longint;
  1396. end;
  1397. {*
  1398. * Options for use with [gs]etsockopt at the IP level.
  1399. * }
  1400. const
  1401. IP_OPTIONS = 1; // buf/ip_opts; set/get IP options
  1402. IP_MULTICAST_IF = 2; // u_char; set/get IP multicast i/f
  1403. IP_MULTICAST_TTL = 3; // u_char; set/get IP multicast ttl
  1404. IP_MULTICAST_LOOP = 4; // u_char; set/get IP multicast loopback
  1405. IP_ADD_MEMBERSHIP = 5; // ip_mreq; add an IP group membership
  1406. IP_DROP_MEMBERSHIP = 6; // ip_mreq; drop an IP group membership
  1407. IP_HDRINCL = 7; // int; header is included with data
  1408. IP_TOS = 8; // int; IP type of service and preced.
  1409. IP_TTL = 9; // int; IP time to live
  1410. IP_RECVOPTS = 10; // bool; receive all IP opts w/dgram
  1411. IP_RECVRETOPTS = 11; // bool; receive IP opts for response
  1412. IP_RECVDSTADDR = 12; // bool; receive IP dst addr w/dgram
  1413. IP_RETOPTS = 13; // ip_opts; set/get IP options
  1414. IP_RECVTRRI = 14; // bool; receive token ring routing inf
  1415. {*
  1416. * Defaults and limits for options
  1417. * }
  1418. IP_DEFAULT_MULTICAST_TTL = 1; // normally limit m'casts to 1 hop
  1419. IP_DEFAULT_MULTICAST_LOOP = 1; // normally hear sends if a member
  1420. IP_MAX_MEMBERSHIPS = 20; // per socket; must fit in one mbuf
  1421. MAX_IN_MULTI = 16*IP_MAX_MEMBERSHIPS; // 320 max per os2
  1422. *)
  1423. (* List of not checked functions from SO32DLL.DLL
  1424. ³ 00011 ³ RECVFROM
  1425. ³ 00012 ³ SELECT
  1426. ³ 00013 ³ SEND
  1427. ³ 00014 ³ SENDTO
  1428. ³ 00015 ³ SETSOCKOPT
  1429. ³ 00016 ³ SOCKET
  1430. ³ 00017 ³ SOCLOSE
  1431. ³ 00018 ³ SO_CANCEL
  1432. ³ 00019 ³ SOABORT
  1433. ³ 00020 ³ SOCK_ERRNO
  1434. ³ 00021 ³ RECVMSG
  1435. ³ 00022 ³ SENDMSG
  1436. ³ 00023 ³ READV
  1437. ³ 00024 ³ WRITEV
  1438. ³ 00025 ³ SHUTDOWN
  1439. ³ 00026 ³ SOCK_INIT
  1440. ³ 00027 ³ ADDSOCKETTOLIST
  1441. ³ 00028 ³ REMOVESOCKETFROMLIST
  1442. ³ 00030 ³ PSOCK_ERRNO
  1443. ³ 00031 ³ GETINETVERSION
  1444. ³ 00032 ³ BSDSELECT
  1445. ³ 00035 ³ SET_ERRNO
  1446. ³ 00038 ³ WINSOCKCLEANUPSOCKETS
  1447. ³ 00039 ³ GETSOCKETFROMLIST
  1448. À´Done
  1449. *)