so32dll.pas 60 KB

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