so32dll.pas 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702
  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. TFDSet = FD_Set;
  904. PFDSet = ^TFDSet;
  905. timeval = record
  906. tv_sec : Longint; // Number of seconds
  907. tv_usec : Longint; // Number of microseconds
  908. end;
  909. TTimeVal = TimeVal;
  910. PTimeVal = ^TTimeVal;
  911. {
  912. * ioctl & ip trace support
  913. }
  914. const
  915. FIONREAD = (Ord('f') SHL 8) OR 127;
  916. FIONBIO = (Ord('f') SHL 8) OR 126;
  917. FIOASYNC = (Ord('f') SHL 8) OR 125;
  918. FIOTCPCKSUM = (Ord('f') SHL 8) OR 128;
  919. FIONSTATUS = (Ord('f') SHL 8) OR 120;
  920. FIONURG = (Ord('f') SHL 8) OR 121;
  921. SIOCSHIWAT = (Ord('s') SHL 8) OR 0;
  922. SIOCGHIWAT = (Ord('s') SHL 8) OR 1;
  923. SIOCSLOWAT = (Ord('s') SHL 8) OR 2;
  924. SIOCGLOWAT = (Ord('s') SHL 8) OR 3;
  925. SIOCATMARK = (Ord('s') SHL 8) OR 7;
  926. SIOCSPGRP = (Ord('s') SHL 8) OR 8;
  927. SIOCGPGRP = (Ord('s') SHL 8) OR 9;
  928. SIOCSHOSTID = (Ord('s') SHL 8) OR 10;
  929. SIOCADDRT = (Ord('r') SHL 8) OR 10;
  930. SIOCDELRT = (Ord('r') SHL 8) OR 11;
  931. SIOMETRIC1RT = (Ord('r') SHL 8) OR 12;
  932. SIOMETRIC2RT = (Ord('r') SHL 8) OR 13;
  933. SIOMETRIC3RT = (Ord('r') SHL 8) OR 14;
  934. SIOMETRIC4RT = (Ord('r') SHL 8) OR 15;
  935. SIOCREGADDNET = (Ord('r') SHL 8) OR 12;
  936. SIOCREGDELNET = (Ord('r') SHL 8) OR 13;
  937. SIOCREGROUTES = (Ord('r') SHL 8) OR 14;
  938. SIOCFLUSHROUTES=(Ord('r') SHL 8) OR 15;
  939. SIOCSIFADDR = (Ord('i') SHL 8) OR 12;
  940. SIOCGIFADDR = (Ord('i') SHL 8) OR 13;
  941. SIOCSIFDSTADDR= (Ord('i') SHL 8) OR 14;
  942. SIOCGIFDSTADDR= (Ord('i') SHL 8) OR 15;
  943. SIOCSIFFLAGS = (Ord('i') SHL 8) OR 16;
  944. SIOCGIFFLAGS = (Ord('i') SHL 8) OR 17;
  945. SIOCGIFBRDADDR= (Ord('i') SHL 8) OR 18;
  946. SIOCSIFBRDADDR= (Ord('i') SHL 8) OR 19;
  947. SIOCGIFCONF = (Ord('i') SHL 8) OR 20;
  948. SIOCGIFNETMASK= (Ord('i') SHL 8) OR 21;
  949. SIOCSIFNETMASK= (Ord('i') SHL 8) OR 22;
  950. SIOCGIFMETRIC = (Ord('i') SHL 8) OR 23;
  951. SIOCSIFMETRIC = (Ord('i') SHL 8) OR 24;
  952. SIOCSIFSETSIG = (Ord('i') SHL 8) OR 25;
  953. SIOCSIFCLRSIG = (Ord('i') SHL 8) OR 26;
  954. SIOCSIFBRD = (Ord('i') SHL 8) OR 27; { SINGLE-rt bcst. using old # for bkw cmpt }
  955. SIOCSIFALLRTB = (Ord('i') SHL 8) OR 63; { added to configure all-route broadcst }
  956. SIOCGIFLOAD =(Ord('i') SHL 8) OR 27;
  957. SIOCSIFFILTERSRC=(Ord('i') SHL 8) OR 28;
  958. SIOCGIFFILTERSRC=(Ord('i') SHL 8) OR 29;
  959. SIOCSARP = (Ord('i') SHL 8) OR 30;
  960. SIOCGARP = (Ord('i') SHL 8) OR 31;
  961. SIOCDARP = (Ord('i') SHL 8) OR 32;
  962. SIOCSIFSNMPSIG= (Ord('i') SHL 8) OR 33;
  963. SIOCSIFSNMPCLR= (Ord('i') SHL 8) OR 34;
  964. SIOCSIFSNMPCRC= (Ord('i') SHL 8) OR 35;
  965. SIOCSIFPRIORITY=(Ord('i') SHL 8) OR 36;
  966. SIOCGIFPRIORITY=(Ord('i') SHL 8) OR 37;
  967. SIOCSIFFILTERDST=(Ord('i') SHL 8) OR 38;
  968. SIOCGIFFILTERDST=(Ord('i') SHL 8) OR 39;
  969. SIOCSIF802_3 = (Ord('i') SHL 8) OR 40;
  970. SIOCSIFNO802_3= (Ord('i') SHL 8) OR 41;
  971. SIOCSIFNOREDIR= (Ord('i') SHL 8) OR 42;
  972. SIOCSIFYESREDIR= (Ord('i') SHL 8) OR 43;
  973. SIOCSIFMTU = (Ord('i') SHL 8) OR 45;
  974. SIOCSIFFDDI = (Ord('i') SHL 8) OR 46;
  975. SIOCSIFNOFDDI = (Ord('i') SHL 8) OR 47;
  976. SIOCSRDBRD = (Ord('i') SHL 8) OR 48;
  977. SIOCSARP_TR = (Ord('i') SHL 8) OR 49;
  978. SIOCGARP_TR = (Ord('i') SHL 8) OR 50;
  979. { multicast ioctls }
  980. SIOCADDMULTI = (Ord('i') SHL 8) OR 51; { add m'cast addr }
  981. SIOCDELMULTI = (Ord('i') SHL 8) OR 52; { del m'cast addr }
  982. SIOCMULTISBC = (Ord('i') SHL 8) OR 61; { use broadcast to send IP multicast }
  983. SIOCMULTISFA = (Ord('i') SHL 8) OR 62; { use functional addr to send IP multicast }
  984. {$IFDEF SLBOOTP}
  985. SIOCGUNIT = (Ord('i') SHL 8) OR 70; { Used to retreive unit number on }
  986. { serial interface }
  987. {$ENDIF}
  988. SIOCSIFSPIPE = (Ord('i') SHL 8) OR 71; { used to set pipe size on interface }
  989. { this is used as tcp send buffer size }
  990. SIOCSIFRPIPE = (Ord('i') SHL 8) OR 72; { used to set pipe size on interface }
  991. { this is used as tcp recv buffer size }
  992. SIOCSIFTCPSEG = (Ord('i') SHL 8) OR 73; { set the TCP segment size on interface }
  993. SIOCSIFUSE576 = (Ord('i') SHL 8) OR 74; { enable/disable the automatic change of mss to 576 }
  994. { if going through a router }
  995. SIOCGIFVALID = (Ord('i') SHL 8) OR 75; { to check if the interface is Valid or not }
  996. { sk June 14 1995 }
  997. SIOCGIFBOUND = (Ord('i') SHL 8) OR 76; { ioctl to return bound/shld bind ifs }
  998. { Interface Tracing Support }
  999. SIOCGIFEFLAGS = (Ord('i') SHL 8) OR 150;
  1000. SIOCSIFEFLAGS = (Ord('i') SHL 8) OR 151;
  1001. SIOCGIFTRACE = (Ord('i') SHL 8) OR 152;
  1002. SIOCSIFTRACE = (Ord('i') SHL 8) OR 153;
  1003. {$IFDEF SLSTATS}
  1004. SIOCSSTAT = (Ord('i') SHL 8) OR 154;
  1005. SIOCGSTAT = (Ord('i') SHL 8) OR 155;
  1006. {$ENDIF}
  1007. { NETSTAT stuff }
  1008. SIOSTATMBUF = (Ord('n') SHL 8) OR 40;
  1009. SIOSTATTCP = (Ord('n') SHL 8) OR 41;
  1010. SIOSTATUDP = (Ord('n') SHL 8) OR 42;
  1011. SIOSTATIP = (Ord('n') SHL 8) OR 43;
  1012. SIOSTATSO = (Ord('n') SHL 8) OR 44;
  1013. SIOSTATRT = (Ord('n') SHL 8) OR 45;
  1014. SIOFLUSHRT = (Ord('n') SHL 8) OR 46;
  1015. SIOSTATICMP = (Ord('n') SHL 8) OR 47;
  1016. SIOSTATIF = (Ord('n') SHL 8) OR 48;
  1017. SIOSTATAT = (Ord('n') SHL 8) OR 49;
  1018. SIOSTATARP = (Ord('n') SHL 8) OR 50;
  1019. SIOSTATIF42 = (Ord('n') SHL 8) OR 51;
  1020. (* From fpc 2.0.0
  1021. SIOCGIFFLAGS = $6900 + 17; // get interface flags
  1022. { Interface Tracing Support }
  1023. SIOCGIFEFLAGS = $6900 + 150; // get interface enhanced flags
  1024. SIOCSIFEFLAGS = $6900 + 151; // set interface enhanced flags
  1025. SIOCGIFTRACE = $6900 + 152; // get interface trace data
  1026. SIOCSIFTRACE = $6900 + 153; // set interface trace data
  1027. { sorry, i skip other ioctl commands, see SYS\ioctl.h from toolkit for it.. }
  1028. *)
  1029. (* !!TODO Check all macros from sys/itypes.h
  1030. function LSwap(a:Longint):Longint;
  1031. function WSwap(a:Word):Word;
  1032. { host -> network for long (4 bytes) }
  1033. function htonl(a:Longint):Longint;
  1034. { network -> host for long (4 bytes) }
  1035. function ntohl(a:Longint):Longint;
  1036. { host -> network for small (2 bytes) }
  1037. function htons(a:Word):Word;
  1038. { network -> host for small (2 bytes) }
  1039. function ntohs(a:Word):Word;
  1040. *)
  1041. { * init / misc funcs }
  1042. { init sockets system }
  1043. function sock_init:Longint; cdecl;
  1044. { get inet version. version - buffer of ?? size for returned string. }
  1045. function getinetversion(var version):Longint; cdecl;
  1046. { * sockets errors reporting funcs }
  1047. { last err code for this thread }
  1048. function sock_errno:Longint; cdecl;
  1049. { print last err string + str if not NIL }
  1050. procedure psock_errno(var str:PChar); cdecl;
  1051. { * sockets creation / close funcs }
  1052. { create new socket }
  1053. function socket(domain,stype,protocol:Longint):Longint; cdecl;
  1054. { close socket }
  1055. function soclose(sock:Longint):Longint; cdecl;
  1056. { cancel socket }
  1057. function so_cancel(sock:Longint):Longint; cdecl;
  1058. { shutdown socket. howto: 0/1/2 }
  1059. function shutdown(sock,howto:Longint):Longint; cdecl;
  1060. { abort socket. no docs found about it :( }
  1061. function soabort(sock:Longint):Longint; cdecl;
  1062. (***************************************************************************)
  1063. (* *)
  1064. (* sockets connection funcs *)
  1065. (* *)
  1066. (***************************************************************************)
  1067. { accept a connection from remote host. returns s_addr & s_addr_len if not nil }
  1068. function accept(sock:Longint; var s_addr:sockaddr; s_addr_len:Longint):Longint; cdecl;
  1069. { bind a local name to the socket }
  1070. function bind(sock:Longint; var s_addr: sockaddr; s_addr_len:Longint):Longint; cdecl;
  1071. { connect socket to remote host }
  1072. function connect(sock:Longint; var s_addr:sockaddr; s_addr_len:Longint):Longint; cdecl;
  1073. { listen on socket. max_conn - queue size of listen. }
  1074. function listen(sock,max_conn:Longint):Longint; cdecl;
  1075. (***************************************************************************)
  1076. (* *)
  1077. (* sockets read/write funcs *)
  1078. (* *)
  1079. (***************************************************************************)
  1080. { read data from socket. ! return N of readed bytes, or 0 (closed) or -1 }
  1081. function recv(sock:Longint; var buf; buf_len,flags:Longint):Longint; cdecl;
  1082. { send data to socket. ! return N of sent bytes. -1 - err }
  1083. function send(sock:Longint; var buf; buf_len,flags:Longint):Longint; cdecl;
  1084. { read data from socket. ! return N of readed bytes, or 0 (closed) or -1 }
  1085. function recvfrom(sock:Longint; var buf; buf_len,flags:Longint; var s_addr:sockaddr; var s_addr_len:Longint):Longint; cdecl;
  1086. { send data to socket. ! return N of sent bytes. -1 - err }
  1087. function sendto(sock:Longint; var buf; buf_len,flags:Longint; var s_addr:sockaddr; s_addr_len:Longint):Longint; cdecl;
  1088. { read data into iov_count number of buffers iov.
  1089. ! return N of readed bytes, or 0 (closed) or -1 }
  1090. function readv(sock:Longint; var iov:iovec; iov_count:Longint):LONGINT; cdecl;
  1091. { write data from iov_count number of buffers iov.
  1092. ! return N of writed bytes, or -1 }
  1093. function writev(sock:Longint; var iov:iovec; iov_count:Longint):LONGINT; cdecl;
  1094. { read data + control info from socket
  1095. ! return N of readed bytes, or 0 (closed) or -1 }
  1096. function recvmsg(sock:Longint; var msgbuf:msghdr; flags:Longint):Longint; cdecl;
  1097. { send data + control info to socket
  1098. ! return N of sended bytes, or -1 }
  1099. function sendmsg(sock:Longint; var msgbuf:msghdr; flags:Longint):Longint; cdecl;
  1100. (***************************************************************************)
  1101. (* *)
  1102. (* select funcs *)
  1103. (* *)
  1104. (***************************************************************************)
  1105. { OS/2 select. 0 - timeout. -1 - err. XX - N of sockets worked. }
  1106. function os2_select(var sockets; N_reads, N_writes, N_exepts, timeout:Longint):Longint; cdecl;
  1107. { bsd select here. heavy voodoo.. }
  1108. function select(nfds:Longint; var readfds,writefds,exceptfds:fd_set; var timeout:timeval):Longint; cdecl;
  1109. (***************************************************************************)
  1110. (* *)
  1111. (* misc info *)
  1112. (* *)
  1113. (***************************************************************************)
  1114. { get host ip addr - addr of primary interface }
  1115. function gethostid:Longint; cdecl;
  1116. { get connected to socket hostname }
  1117. function getpeername(sock:Longint; var s_addr:sockaddr; var s_addr_len:Longint):Longint; cdecl;
  1118. { get local socket name }
  1119. function getsockname(sock:Longint; var s_addr:sockaddr; var s_addr_len:Longint):Longint; cdecl;
  1120. (***************************************************************************)
  1121. (* *)
  1122. (* options & ioctls *)
  1123. (* *)
  1124. (***************************************************************************)
  1125. { get socket options }
  1126. function getsockopt(sock,level,optname:Longint; var buf; var buf_len:Longint):Longint; cdecl;
  1127. { set socket options }
  1128. function setsockopt(sock,level,optname:Longint; var buf; buf_len:Longint):Longint; cdecl;
  1129. { f@$king ioctl. use sys/ioctl.h }
  1130. function os2_ioctl(sock,cmd:Longint; var data; data_len:Longint):Longint; cdecl;
  1131. (***************************************************************************)
  1132. (* *)
  1133. (* functions only for 4.1+ ip stacks (but also found in 4.02w ;)) *)
  1134. (* *)
  1135. (***************************************************************************)
  1136. function addsockettolist(sock:Longint):Longint; cdecl;
  1137. function removesocketfromlist(sock:Longint):Longint; cdecl;
  1138. implementation
  1139. function LSwap(a:Longint):Longint; assembler;
  1140. asm
  1141. mov eax,a
  1142. xchg ah,al
  1143. ror eax,16
  1144. xchg ah,al
  1145. end;
  1146. function WSwap(a:Word):Word; assembler;
  1147. asm
  1148. mov ax,a
  1149. xchg ah,al
  1150. end;
  1151. function accept(sock:Longint; var s_addr: sockaddr; s_addr_len:Longint):Longint; cdecl; external 'SO32DLL' index 1;
  1152. function bind(sock:Longint; var s_addr: sockaddr; s_addr_len:Longint):Longint; cdecl; external 'SO32DLL' index 2;
  1153. function connect(sock:Longint; var s_addr:sockaddr; s_addr_len:Longint):Longint; cdecl; external 'SO32DLL' index 3;
  1154. function gethostid: Longint; cdecl; external 'SO32DLL' index 4;
  1155. function getpeername(sock:Longint; var s_addr:sockaddr; var s_addr_len:Longint):Longint; cdecl; external 'SO32DLL' index 5;
  1156. function getsockname(sock:Longint; var s_addr:sockaddr; var s_addr_len:Longint):Longint; cdecl; external 'SO32DLL' index 6;
  1157. function getsockopt(sock,level,optname:Longint; var buf; var buf_len:Longint):Longint; cdecl; external 'SO32DLL' index 7;
  1158. function os2_ioctl(sock,cmd:Longint; var data; data_len:Longint):Longint; cdecl; external 'SO32DLL' index 8;
  1159. function listen(sock,max_conn:Longint):Longint; cdecl; external 'SO32DLL' index 9;
  1160. function recv(sock:Longint; var buf; buf_len,flags:Longint):Longint; cdecl; external 'SO32DLL' index 10;
  1161. 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;
  1162. function os2_select(var sockets; N_reads, N_writes, N_exepts, timeout:Longint):Longint; cdecl; external 'SO32DLL' index 12;
  1163. function send(sock:Longint; var buf; buf_len,flags:Longint):Longint; cdecl; external 'SO32DLL' index 13;
  1164. function sendto(sock:Longint; var buf; buf_len,flags:Longint;var s_addr:sockaddr; s_addr_len:Longint):Longint; cdecl; external 'SO32DLL' index 14;
  1165. function setsockopt(sock,level,optname:Longint; var buf; buf_len:Longint):Longint; cdecl; external 'SO32DLL' index 15;
  1166. function socket(domain,stype,protocol:Longint):Longint; cdecl; external 'SO32DLL' index 16;
  1167. function soclose(sock:Longint):Longint; cdecl; external 'SO32DLL' index 17;
  1168. function so_cancel(sock:Longint):Longint; cdecl; external 'SO32DLL' index 18;
  1169. function soabort(sock:Longint):Longint; cdecl; external 'SO32DLL' index 19;
  1170. function sock_errno:Longint; cdecl; external 'SO32DLL' index 20;
  1171. function recvmsg(sock:Longint; var msgbuf:msghdr; flags:Longint):Longint; cdecl; external 'SO32DLL' index 21;
  1172. function sendmsg(sock:Longint; var msgbuf:msghdr; flags:Longint):Longint; cdecl; external 'SO32DLL' index 22;
  1173. function readv(sock:Longint; var iov:iovec; iov_count:Longint):LONGINT; cdecl; external 'SO32DLL' index 23;
  1174. function writev(sock:Longint; var iov:iovec; iov_count:Longint):LONGINT; cdecl; external 'SO32DLL' index 24;
  1175. function shutdown(sock,howto:Longint):Longint; cdecl; external 'SO32DLL' index 25;
  1176. function sock_init:Longint; cdecl; external 'SO32DLL' index 26;
  1177. function addsockettolist(sock:Longint):Longint; cdecl; external 'SO32DLL' index 27;
  1178. function removesocketfromlist(sock:Longint):Longint; cdecl; external 'SO32DLL' index 28;
  1179. { entry 29 not used }
  1180. procedure psock_errno(var str:PChar); cdecl; external 'SO32DLL' index 30;
  1181. function getinetversion(var version):Longint; cdecl; external 'SO32DLL' index 31;
  1182. function select(nfds:Longint;
  1183. var readfds,writefds,exceptfds:fd_set;
  1184. var timeout:timeval):Longint; cdecl; external 'SO32DLL' index 32;
  1185. function htonl(a:Longint):Longint;
  1186. begin htonl:=LSwap(a); end;
  1187. { host -> network for long (4 bytes) }
  1188. function ntohl(a:Longint):Longint;
  1189. begin ntohl:=LSwap(a); end;
  1190. { network -> host for long (4 bytes) }
  1191. function htons(a:Word):Word;
  1192. begin htons:=WSwap(a); end;
  1193. { host -> network for small (2 bytes) }
  1194. function ntohs(a:Word):Word;
  1195. begin ntohs:=WSwap(a); end;
  1196. { network -> host for small (2 bytes) }
  1197. end.
  1198. (* !!TODO Following code not revised as yet
  1199. {*
  1200. * User-settable options (used with setsockopt).
  1201. *}
  1202. TCP_NODELAY = $01; // don't delay send to coalesce packets
  1203. TCP_MAXSEG = $02; // set maximum segment size
  1204. TCP_MSL = $03; // MSL HACK
  1205. TCP_TIMESTMP = $04; // RFC 1323 (RTTM TimeStamp)
  1206. TCP_WINSCALE = $05; // RFC 1323 (Window Scale)
  1207. TCP_CC = $06; // RFC 1644 (Connection Count)
  1208. {
  1209. * Structures returned by network data base library. All addresses are
  1210. * supplied in host order, and returned in network order (suitable for
  1211. * use in system calls).
  1212. }
  1213. type
  1214. PLongint = ^Longint;
  1215. { struct for gethostbyname() and gethostbyaddr() }
  1216. hostent = record
  1217. h_name : PChar; // official name of host
  1218. h_aliases : ^PChar; // alias list
  1219. h_addrtype : Longint; // host address type
  1220. h_length : Longint; // length of address
  1221. h_addr_list : ^PLongint; // list of addresses from name server
  1222. end;
  1223. phostent = ^hostent;
  1224. {
  1225. * Error return codes from gethostbyname(), gethostbyaddr() and res_* funcs
  1226. * (left in extern int h_errno).
  1227. }
  1228. const
  1229. NETDB_INTERNAL = -1; // see errno
  1230. NETDB_SUCCESS = 0; // no problem
  1231. HOST_NOT_FOUND = 1; // Authoritative Answer Host not found
  1232. TRY_AGAIN = 2; // Non-Authoritive Host not found, or SERVERFAIL
  1233. NO_RECOVERY = 3; // Non recoverable errors, FORMERR, REFUSED, NOTIMP
  1234. NO_DATA = 4; // Valid name, no data record of requested type
  1235. NO_ADDRESS = NO_DATA; // no address, look for MX record
  1236. type
  1237. { struct for getprotobyname() and getprotobynumber() }
  1238. protoent = record
  1239. p_name : PChar; // official protocol name
  1240. p_aliases : ^PChar; // alias list
  1241. p_proto : Longint; // protocol #
  1242. end;
  1243. pprotoent = ^protoent;
  1244. type
  1245. { struct for getservbyname() and getservbyport() }
  1246. servent = record
  1247. s_name : PChar; // official service name
  1248. s_aliases : ^PChar; // alias list
  1249. s_port : Longint; // port # (need ntohl() !!)
  1250. s_proto : PChar; // protocol to use
  1251. end;
  1252. pservent = ^servent;
  1253. const
  1254. IFF_UP = $1; // interface is up
  1255. IFF_BROADCAST = $2; // broadcast address valid
  1256. IFF_DEBUG = $4; // turn on debugging
  1257. IFF_LOOPBACK = $8; // is a loopback net
  1258. IFF_POINTOPOINT = $10; // interface is point-to-point link
  1259. IFF_LINK2 = $20; // was trailers, not used
  1260. IFF_NOTRAILERS = IFF_LINK2;
  1261. IFF_RUNNING = $40; // resources allocated
  1262. IFF_NOARP = $80; // no address resolution protocol
  1263. IFF_PROMISC = $100; // receive all packets
  1264. IFF_ALLMULTI = $200; // receive all multicast packets
  1265. IFF_BRIDGE = $1000; // support token ring routine field
  1266. IFF_SNAP = $2000; // support extended SAP header
  1267. IFF_DEFMTU = $400; // default mtu of 1500
  1268. IFF_RFC1469_BC = 1; // using broadcast
  1269. IFF_RFC1469_FA = 2; // using functional
  1270. IFF_RFC1469_MA = 3; // using multicast
  1271. IFF_ETHER = $4000; // Ethernet interface
  1272. IFF_LOOPBRD = $8000; // loop back broadcasts
  1273. IFF_MULTICAST = $800; // supports multicast
  1274. IFF_SIMPLEX = $10000; // can't hear own transmissions
  1275. IFF_OACTIVE = $20000; // transmission in progress
  1276. IFF_802_3 = $40000;
  1277. IFF_CANONICAL = $80000;
  1278. IFF_RUNNINGBLK = $100000; // threads waited for intf running
  1279. { Interface enhanced flags }
  1280. IFFE_PKTTRACE = $00000001; // trace datalink where possible
  1281. IFFE_IPTRACE = $00000002; // trace ONLY IP packets
  1282. type
  1283. { trace buffer struct }
  1284. pkt_trace_hdr = record
  1285. pt_htype : Word; // header type
  1286. pt_len : Word; // in: pt_buf len, out: packet len
  1287. pt_data : Pointer; // packet
  1288. pt_tstamp : Longint; // time stamp in milliseconds
  1289. end;
  1290. const
  1291. { physical protocols IDs }
  1292. HT_IP = $01; // IP
  1293. HT_ETHER = $06; // Ethernet
  1294. HT_ISO88023 = $07; // CSMA CD
  1295. HT_ISO88025 = $09; // Token Ring
  1296. HT_SLIP = $1c; // Serial Line IP
  1297. HT_PPP = $18; // PPP IP
  1298. const
  1299. IFNAMSIZ = 16; // interface name length
  1300. type
  1301. {
  1302. * Interface request structure used for socket
  1303. * ioctl's. All interface ioctl's must have parameter
  1304. * definitions which begin with ifr_name. The
  1305. * remainder may be interface specific.
  1306. }
  1307. ifreq = record
  1308. ifr_name : array[0..IFNAMSIZ-1] of Char;
  1309. case Byte of
  1310. 0: (ifr_addr : sockaddr); // address
  1311. 1: (ifr_dstaddr : sockaddr); // other end of p-to-p link
  1312. 2: (ifr_broadaddr : sockaddr); // broadcast address
  1313. 3: (ifr_flags : Word); // flags
  1314. 4: (ifr_metric : Longint); // metric
  1315. 5: (ifr_data : Pointer); // for use by interface
  1316. 6: (ifr_eflags : Longint); // eflags
  1317. end;
  1318. {
  1319. * Structure of an internet header, naked of options.
  1320. }
  1321. type
  1322. ip = record
  1323. hlen_ver : Byte; { lo 4 bits = header len/4
  1324. hi 4 bits = ip ver (4) }
  1325. ip_tos : Byte; { type of service }
  1326. ip_len : Word; { total packet length }
  1327. ip_id : Word; { identification }
  1328. ip_off : Word; { fragment offset field }
  1329. ip_ttl : Byte; { time to live }
  1330. ip_p : Byte; { protocol (see IPPROTO_* ) }
  1331. ip_sum : Word; { header checksum }
  1332. ip_src, ip_dst : Longint; { ip from / to addr }
  1333. end;
  1334. { in.h / inet.h const & func }
  1335. {
  1336. * Protocols
  1337. }
  1338. const
  1339. IPPROTO_IP = 0; { dummy for IP }
  1340. IPPROTO_ICMP = 1; { control message protocol }
  1341. IPPROTO_GGP = 3; { gateway^2 (deprecated) }
  1342. IPPROTO_TCP = 6; { tcp }
  1343. IPPROTO_EGP = 8; { exterior gateway protocol }
  1344. IPPROTO_PUP = 12; { pup }
  1345. IPPROTO_UDP = 17; { user datagram protocol }
  1346. IPPROTO_IDP = 22; { xns idp }
  1347. IPPROTO_RAW = 255; { raw IP packet }
  1348. IPPROTO_MAX = 256;
  1349. {
  1350. * Ports < IPPORT_RESERVED are reserved for
  1351. * privileged processes (e.g. root).
  1352. * Ports > IPPORT_USERRESERVED are reserved
  1353. * for servers, not necessarily privileged.
  1354. }
  1355. const
  1356. IPPORT_RESERVED = 1024;
  1357. IPPORT_USERRESERVED = 5000;
  1358. {
  1359. * Link numbers
  1360. }
  1361. const
  1362. IMPLINK_IP = 155;
  1363. IMPLINK_LOWEXPER = 156;
  1364. IMPLINK_HIGHEXPER = 158;
  1365. {
  1366. * Definitions of bits in internet address integers.
  1367. * On subnets, the decomposition of addresses to host and net parts
  1368. * is done according to subnet mask, not the masks here.
  1369. }
  1370. const
  1371. IN_CLASSA_NET = $ff000000;
  1372. IN_CLASSA_NSHIFT = 24;
  1373. IN_CLASSA_HOST = $00ffffff;
  1374. IN_CLASSA_MAX = 128;
  1375. IN_CLASSB_NET = $ffff0000;
  1376. IN_CLASSB_NSHIFT = 16;
  1377. IN_CLASSB_HOST = $0000ffff;
  1378. IN_CLASSB_MAX = 65536;
  1379. IN_CLASSC_NET = $ffffff00;
  1380. IN_CLASSC_NSHIFT = 8;
  1381. IN_CLASSC_HOST = $000000ff;
  1382. INADDR_ANY = $00000000;
  1383. INADDR_BROADCAST = $ffffffff; { must be masked }
  1384. INADDR_NONE = $ffffffff; { -1 return }
  1385. IN_LOOPBACKNET = 127; { official! }
  1386. {
  1387. * Socket address, internet style.
  1388. }
  1389. type
  1390. sockaddr_in = record
  1391. sin_family : Word;
  1392. sin_port : Word; { htons first!! }
  1393. sin_addr : Longint; {in_addr; hist reasons :)) }
  1394. sin_zero : array[0..7] of Byte; {must be zero}
  1395. end;
  1396. { * Internet address (a structure for historical reasons) }
  1397. type
  1398. in_addr = record
  1399. s_addr : Longint;
  1400. end;
  1401. {*
  1402. * Options for use with [gs]etsockopt at the IP level.
  1403. * }
  1404. const
  1405. IP_OPTIONS = 1; // buf/ip_opts; set/get IP options
  1406. IP_MULTICAST_IF = 2; // u_char; set/get IP multicast i/f
  1407. IP_MULTICAST_TTL = 3; // u_char; set/get IP multicast ttl
  1408. IP_MULTICAST_LOOP = 4; // u_char; set/get IP multicast loopback
  1409. IP_ADD_MEMBERSHIP = 5; // ip_mreq; add an IP group membership
  1410. IP_DROP_MEMBERSHIP = 6; // ip_mreq; drop an IP group membership
  1411. IP_HDRINCL = 7; // int; header is included with data
  1412. IP_TOS = 8; // int; IP type of service and preced.
  1413. IP_TTL = 9; // int; IP time to live
  1414. IP_RECVOPTS = 10; // bool; receive all IP opts w/dgram
  1415. IP_RECVRETOPTS = 11; // bool; receive IP opts for response
  1416. IP_RECVDSTADDR = 12; // bool; receive IP dst addr w/dgram
  1417. IP_RETOPTS = 13; // ip_opts; set/get IP options
  1418. IP_RECVTRRI = 14; // bool; receive token ring routing inf
  1419. {*
  1420. * Defaults and limits for options
  1421. * }
  1422. IP_DEFAULT_MULTICAST_TTL = 1; // normally limit m'casts to 1 hop
  1423. IP_DEFAULT_MULTICAST_LOOP = 1; // normally hear sends if a member
  1424. IP_MAX_MEMBERSHIPS = 20; // per socket; must fit in one mbuf
  1425. MAX_IN_MULTI = 16*IP_MAX_MEMBERSHIPS; // 320 max per os2
  1426. *)
  1427. (* List of not checked functions from SO32DLL.DLL
  1428. ³ 00011 ³ RECVFROM
  1429. ³ 00012 ³ SELECT
  1430. ³ 00013 ³ SEND
  1431. ³ 00014 ³ SENDTO
  1432. ³ 00015 ³ SETSOCKOPT
  1433. ³ 00016 ³ SOCKET
  1434. ³ 00017 ³ SOCLOSE
  1435. ³ 00018 ³ SO_CANCEL
  1436. ³ 00019 ³ SOABORT
  1437. ³ 00020 ³ SOCK_ERRNO
  1438. ³ 00021 ³ RECVMSG
  1439. ³ 00022 ³ SENDMSG
  1440. ³ 00023 ³ READV
  1441. ³ 00024 ³ WRITEV
  1442. ³ 00025 ³ SHUTDOWN
  1443. ³ 00026 ³ SOCK_INIT
  1444. ³ 00027 ³ ADDSOCKETTOLIST
  1445. ³ 00028 ³ REMOVESOCKETFROMLIST
  1446. ³ 00030 ³ PSOCK_ERRNO
  1447. ³ 00031 ³ GETINETVERSION
  1448. ³ 00032 ³ BSDSELECT
  1449. ³ 00035 ³ SET_ERRNO
  1450. ³ 00038 ³ WINSOCKCLEANUPSOCKETS
  1451. ³ 00039 ³ GETSOCKETFROMLIST
  1452. À´Done
  1453. *)