kerneldefs.pp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794
  1. {$mode objfpc}
  2. {$h+}
  3. {$if not defined(linux) or not defined(cpui386)}
  4. {$error The KernelDefs unit is a legacy Kylix-compatibility unit that is only supported on Linux/i386. It is known not to work in various ways on other OSes and architectures (including Linux/x86_64). }
  5. {$endif}
  6. unit kerneldefs;
  7. interface
  8. // Translated from asm/types.h (i386)
  9. const
  10. HZ = 100;
  11. EXEC_PAGESIZE = 4096;
  12. NGROUPS = 32;
  13. NOGROUP = -(1);
  14. MAXHOSTNAMELEN = 64;
  15. CLOCKS_PER_SEC = 100;
  16. type
  17. Pumode_t = ^umode_t;
  18. umode_t = word;
  19. P__s8 = ^__s8;
  20. __s8 = shortint;
  21. P__u8 = ^__u8;
  22. __u8 = byte;
  23. P__s16 = ^__s16;
  24. __s16 = smallint;
  25. P__u16 = ^__u16;
  26. __u16 = word;
  27. P__s32 = ^__s32;
  28. __s32 = longint;
  29. P__u32 = ^__u32;
  30. __u32 = dword;
  31. P__s64 = ^__s64;
  32. __s64 = int64;
  33. P__u64 = ^__u64;
  34. __u64 = qword;
  35. type
  36. Ps8 = ^s8;
  37. s8 = char;
  38. Pu8 = ^u8;
  39. u8 = byte;
  40. Ps16 = ^s16;
  41. s16 = smallint;
  42. Pu16 = ^u16;
  43. u16 = word;
  44. Ps32 = ^s32;
  45. s32 = longint;
  46. Pu32 = ^u32;
  47. u32 = dword;
  48. Ps64 = ^s64;
  49. s64 = int64;
  50. Pu64 = ^u64;
  51. u64 = qword;
  52. const
  53. BITS_PER_LONG = 32;
  54. // Translated from include/linux/if_ether.h
  55. const
  56. ETH_ALEN = 6;
  57. ETH_HLEN = 14;
  58. ETH_ZLEN = 60;
  59. ETH_DATA_LEN = 1500;
  60. ETH_FRAME_LEN = 1514;
  61. ETH_P_LOOP = $0060;
  62. ETH_P_PUP = $0200;
  63. ETH_P_PUPAT = $0201;
  64. ETH_P_IP = $0800;
  65. ETH_P_X25 = $0805;
  66. ETH_P_ARP = $0806;
  67. ETH_P_BPQ = $08FF;
  68. ETH_P_IEEEPUP = $0a00;
  69. ETH_P_IEEEPUPAT = $0a01;
  70. ETH_P_DEC = $6000;
  71. ETH_P_DNA_DL = $6001;
  72. ETH_P_DNA_RC = $6002;
  73. ETH_P_DNA_RT = $6003;
  74. ETH_P_LAT = $6004;
  75. ETH_P_DIAG = $6005;
  76. ETH_P_CUST = $6006;
  77. ETH_P_SCA = $6007;
  78. ETH_P_RARP = $8035;
  79. ETH_P_ATALK = $809B;
  80. ETH_P_AARP = $80F3;
  81. ETH_P_8021Q = $8100;
  82. ETH_P_IPX = $8137;
  83. ETH_P_IPV6 = $86DD;
  84. ETH_P_PPP_DISC = $8863;
  85. ETH_P_PPP_SES = $8864;
  86. ETH_P_ATMMPOA = $884c;
  87. ETH_P_ATMFATE = $8884;
  88. ETH_P_802_3 = $0001;
  89. ETH_P_AX25 = $0002;
  90. ETH_P_ALL = $0003;
  91. ETH_P_802_2 = $0004;
  92. ETH_P_SNAP = $0005;
  93. ETH_P_DDCMP = $0006;
  94. ETH_P_WAN_PPP = $0007;
  95. ETH_P_PPP_MP = $0008;
  96. ETH_P_LOCALTALK = $0009;
  97. ETH_P_PPPTALK = $0010;
  98. ETH_P_TR_802_2 = $0011;
  99. ETH_P_MOBITEX = $0015;
  100. ETH_P_CONTROL = $0016;
  101. ETH_P_IRDA = $0017;
  102. ETH_P_ECONET = $0018;
  103. type
  104. Pethhdr = ^ethhdr;
  105. ethhdr = record
  106. h_dest : array[0..(ETH_ALEN)-1] of byte;
  107. h_source : array[0..(ETH_ALEN)-1] of byte;
  108. h_proto : word;
  109. end;
  110. // Translated from include/linux/if_fddi.h
  111. const
  112. FDDI_K_ALEN = 6;
  113. FDDI_K_8022_HLEN = 16;
  114. FDDI_K_SNAP_HLEN = 21;
  115. FDDI_K_8022_ZLEN = 16;
  116. FDDI_K_SNAP_ZLEN = 21;
  117. FDDI_K_8022_DLEN = 4475;
  118. FDDI_K_SNAP_DLEN = 4470;
  119. FDDI_K_LLC_ZLEN = 13;
  120. FDDI_K_LLC_LEN = 4491;
  121. FDDI_FC_K_VOID = $00;
  122. FDDI_FC_K_NON_RESTRICTED_TOKEN = $80;
  123. FDDI_FC_K_RESTRICTED_TOKEN = $C0;
  124. FDDI_FC_K_SMT_MIN = $41;
  125. FDDI_FC_K_SMT_MAX = $4F;
  126. FDDI_FC_K_MAC_MIN = $C1;
  127. FDDI_FC_K_MAC_MAX = $CF;
  128. FDDI_FC_K_ASYNC_LLC_MIN = $50;
  129. FDDI_FC_K_ASYNC_LLC_DEF = $54;
  130. FDDI_FC_K_ASYNC_LLC_MAX = $5F;
  131. FDDI_FC_K_SYNC_LLC_MIN = $D0;
  132. FDDI_FC_K_SYNC_LLC_MAX = $D7;
  133. FDDI_FC_K_IMPLEMENTOR_MIN = $60;
  134. FDDI_FC_K_IMPLEMENTOR_MAX = $6F;
  135. FDDI_FC_K_RESERVED_MIN = $70;
  136. FDDI_FC_K_RESERVED_MAX = $7F;
  137. FDDI_EXTENDED_SAP = $AA;
  138. FDDI_UI_CMD = $03;
  139. type
  140. Pfddi_8022_1_hdr = ^fddi_8022_1_hdr;
  141. fddi_8022_1_hdr = record
  142. dsap : __u8;
  143. ssap : __u8;
  144. ctrl : __u8;
  145. end;
  146. Pfddi_8022_2_hdr = ^fddi_8022_2_hdr;
  147. fddi_8022_2_hdr = record
  148. dsap : __u8;
  149. ssap : __u8;
  150. ctrl_1 : __u8;
  151. ctrl_2 : __u8;
  152. end;
  153. const
  154. FDDI_K_OUI_LEN = 3;
  155. type
  156. Pfddi_snap_hdr = ^fddi_snap_hdr;
  157. fddi_snap_hdr = record
  158. dsap : __u8;
  159. ssap : __u8;
  160. ctrl : __u8;
  161. oui : array[0..(FDDI_K_OUI_LEN)-1] of __u8;
  162. ethertype : __u16;
  163. end;
  164. Pfddihdr = ^fddihdr;
  165. fddihdr = record
  166. fc : __u8;
  167. daddr : array[0..(FDDI_K_ALEN)-1] of __u8;
  168. saddr : array[0..(FDDI_K_ALEN)-1] of __u8;
  169. hdr : record
  170. case longint of
  171. 0 : ( llc_8022_1 : fddi_8022_1_hdr );
  172. 1 : ( llc_8022_2 : fddi_8022_2_hdr );
  173. 2 : ( llc_snap : fddi_snap_hdr );
  174. end;
  175. end;
  176. Pfddi_statistics = ^fddi_statistics;
  177. fddi_statistics = record
  178. rx_packets : __u32;
  179. tx_packets : __u32;
  180. rx_bytes : __u32;
  181. tx_bytes : __u32;
  182. rx_errors : __u32;
  183. tx_errors : __u32;
  184. rx_dropped : __u32;
  185. tx_dropped : __u32;
  186. multicast : __u32;
  187. transmit_collision : __u32;
  188. rx_length_errors : __u32;
  189. rx_over_errors : __u32;
  190. rx_crc_errors : __u32;
  191. rx_frame_errors : __u32;
  192. rx_fifo_errors : __u32;
  193. rx_missed_errors : __u32;
  194. tx_aborted_errors : __u32;
  195. tx_carrier_errors : __u32;
  196. tx_fifo_errors : __u32;
  197. tx_heartbeat_errors : __u32;
  198. tx_window_errors : __u32;
  199. rx_compressed : __u32;
  200. tx_compressed : __u32;
  201. smt_station_id : array[0..7] of __u8;
  202. smt_op_version_id : __u32;
  203. smt_hi_version_id : __u32;
  204. smt_lo_version_id : __u32;
  205. smt_user_data : array[0..31] of __u8;
  206. smt_mib_version_id : __u32;
  207. smt_mac_cts : __u32;
  208. smt_non_master_cts : __u32;
  209. smt_master_cts : __u32;
  210. smt_available_paths : __u32;
  211. smt_config_capabilities : __u32;
  212. smt_config_policy : __u32;
  213. smt_connection_policy : __u32;
  214. smt_t_notify : __u32;
  215. smt_stat_rpt_policy : __u32;
  216. smt_trace_max_expiration : __u32;
  217. smt_bypass_present : __u32;
  218. smt_ecm_state : __u32;
  219. smt_cf_state : __u32;
  220. smt_remote_disconnect_flag : __u32;
  221. smt_station_status : __u32;
  222. smt_peer_wrap_flag : __u32;
  223. smt_time_stamp : __u32;
  224. smt_transition_time_stamp : __u32;
  225. mac_frame_status_Functions : __u32;
  226. mac_t_max_capability : __u32;
  227. mac_tvx_capability : __u32;
  228. mac_available_paths : __u32;
  229. mac_current_path : __u32;
  230. mac_upstream_nbr : array[0..(FDDI_K_ALEN)-1] of __u8;
  231. mac_downstream_nbr : array[0..(FDDI_K_ALEN)-1] of __u8;
  232. mac_old_upstream_nbr : array[0..(FDDI_K_ALEN)-1] of __u8;
  233. mac_old_downstream_nbr : array[0..(FDDI_K_ALEN)-1] of __u8;
  234. mac_dup_address_test : __u32;
  235. mac_requested_paths : __u32;
  236. mac_downstream_port_type : __u32;
  237. mac_smt_address : array[0..(FDDI_K_ALEN)-1] of __u8;
  238. mac_t_req : __u32;
  239. mac_t_neg : __u32;
  240. mac_t_max : __u32;
  241. mac_tvx_value : __u32;
  242. mac_frame_cts : __u32;
  243. mac_copied_cts : __u32;
  244. mac_transmit_cts : __u32;
  245. mac_error_cts : __u32;
  246. mac_lost_cts : __u32;
  247. mac_frame_error_threshold : __u32;
  248. mac_frame_error_ratio : __u32;
  249. mac_rmt_state : __u32;
  250. mac_da_flag : __u32;
  251. mac_una_da_flag : __u32;
  252. mac_frame_error_flag : __u32;
  253. mac_ma_unitdata_available : __u32;
  254. mac_hardware_present : __u32;
  255. mac_ma_unitdata_enable : __u32;
  256. path_tvx_lower_bound : __u32;
  257. path_t_max_lower_bound : __u32;
  258. path_max_t_req : __u32;
  259. path_configuration : array[0..7] of __u32;
  260. port_my_type : array[0..1] of __u32;
  261. port_neighbor_type : array[0..1] of __u32;
  262. port_connection_policies : array[0..1] of __u32;
  263. port_mac_indicated : array[0..1] of __u32;
  264. port_current_path : array[0..1] of __u32;
  265. port_requested_paths : array[0..(3 * 2)-1] of __u8;
  266. port_mac_placement : array[0..1] of __u32;
  267. port_available_paths : array[0..1] of __u32;
  268. port_pmd_class : array[0..1] of __u32;
  269. port_connection_capabilities : array[0..1] of __u32;
  270. port_bs_flag : array[0..1] of __u32;
  271. port_lct_fail_cts : array[0..1] of __u32;
  272. port_ler_estimate : array[0..1] of __u32;
  273. port_lem_reject_cts : array[0..1] of __u32;
  274. port_lem_cts : array[0..1] of __u32;
  275. port_ler_cutoff : array[0..1] of __u32;
  276. port_ler_alarm : array[0..1] of __u32;
  277. port_connect_state : array[0..1] of __u32;
  278. port_pcm_state : array[0..1] of __u32;
  279. port_pc_withhold : array[0..1] of __u32;
  280. port_ler_flag : array[0..1] of __u32;
  281. port_hardware_present : array[0..1] of __u32;
  282. end;
  283. // Translated from /linux/if_slip.h
  284. const
  285. SL_MODE_SLIP = 0;
  286. SL_MODE_CSLIP = 1;
  287. SL_MODE_KISS = 4;
  288. SL_OPT_SIXBIT = 2;
  289. SL_OPT_ADAPTIVE = 8;
  290. SIOCDEVPRIVATE = $89F0;
  291. SIOCPROTOPRIVATE = $89E0;
  292. SIOCSKEEPALIVE = SIOCDEVPRIVATE;
  293. SIOCGKEEPALIVE = SIOCDEVPRIVATE + 1;
  294. SIOCSOUTFILL = SIOCDEVPRIVATE + 2;
  295. SIOCGOUTFILL = SIOCDEVPRIVATE + 3;
  296. SIOCSLEASE = SIOCDEVPRIVATE + 4;
  297. SIOCGLEASE = SIOCDEVPRIVATE + 5;
  298. // Translated from /linux/if_tr.h
  299. const
  300. TR_ALEN = 6;
  301. AC = $10;
  302. LLC_FRAME = $40;
  303. EXTENDED_SAP = $AA;
  304. UI_CMD = $03;
  305. type
  306. Ptrh_hdr = ^trh_hdr;
  307. trh_hdr = record
  308. ac : __u8;
  309. fc : __u8;
  310. daddr : array[0..(TR_ALEN)-1] of __u8;
  311. saddr : array[0..(TR_ALEN)-1] of __u8;
  312. rcf : __u16;
  313. rseg : array[0..7] of __u16;
  314. end;
  315. Ptrllc = ^trllc;
  316. trllc = record
  317. dsap : __u8;
  318. ssap : __u8;
  319. llc : __u8;
  320. protid : array[0..2] of __u8;
  321. ethertype : __u16;
  322. end;
  323. Ptr_statistics = ^tr_statistics;
  324. tr_statistics = record
  325. rx_packets : dword;
  326. tx_packets : dword;
  327. rx_bytes : dword;
  328. tx_bytes : dword;
  329. rx_errors : dword;
  330. tx_errors : dword;
  331. rx_dropped : dword;
  332. tx_dropped : dword;
  333. multicast : dword;
  334. transmit_collision : dword;
  335. line_errors : dword;
  336. internal_errors : dword;
  337. burst_errors : dword;
  338. A_C_errors : dword;
  339. abort_delimiters : dword;
  340. lost_frames : dword;
  341. recv_congest_count : dword;
  342. frame_copied_errors : dword;
  343. frequency_errors : dword;
  344. token_errors : dword;
  345. dummy1 : dword;
  346. end;
  347. const
  348. TR_RII = $80;
  349. TR_RCF_DIR_BIT = $80;
  350. TR_RCF_LEN_MASK = $1f00;
  351. TR_RCF_BROADCAST = $8000;
  352. TR_RCF_LIMITED_BROADCAST = $C000;
  353. TR_RCF_FRAME2K = $20;
  354. TR_RCF_BROADCAST_MASK = $C000;
  355. TR_MAXRIFLEN = 18;
  356. const
  357. TR_HLEN = (SizeOf(trh_hdr) + SizeOf(trllc));
  358. // Translated from linux/ppp_defs.h
  359. const
  360. PPP_HDRLEN = 4;
  361. PPP_FCSLEN = 2;
  362. PPP_MRU = 1500;
  363. Function PPP_ADDRESS(const p): __u8;
  364. Function PPP_CONTROL(const p): __u8;
  365. Function PPP_PROTOCOL(const p): __u16;
  366. Const
  367. PPP_ALLSTATIONS = $ff;
  368. PPP_UI = $03;
  369. PPP_FLAG = $7e;
  370. PPP_ESCAPE = $7d;
  371. PPP_TRANS = $20;
  372. PPP_IP = $21;
  373. PPP_AT = $29;
  374. PPP_IPX = $2b;
  375. PPP_VJC_COMP = $2d;
  376. PPP_VJC_UNCOMP = $2f;
  377. PPP_MP = $3d;
  378. PPP_IPV6 = $57;
  379. PPP_COMPFRAG = $fb;
  380. PPP_COMP = $fd;
  381. PPP_IPCP = $8021;
  382. PPP_ATCP = $8029;
  383. PPP_IPXCP = $802b;
  384. PPP_IPV6CP = $8057;
  385. PPP_CCPFRAG = $80fb;
  386. PPP_CCP = $80fd;
  387. PPP_LCP = $c021;
  388. PPP_PAP = $c023;
  389. PPP_LQR = $c025;
  390. PPP_CHAP = $c223;
  391. PPP_CBCP = $c029;
  392. PPP_INITFCS = $ffff;
  393. PPP_GOODFCS = $f0b8;
  394. type
  395. Pext_accm = ^ext_accm;
  396. ext_accm = packed array[0..8-1] of __u32;
  397. NPmode = Longint;
  398. Const
  399. NPMODE_PASS = 0;
  400. NPMODE_DROP = 1;
  401. NPMODE_ERROR = 2;
  402. NPMODE_QUEUE = 3;
  403. type
  404. Ppppstat = ^pppstat;
  405. pppstat = record
  406. ppp_discards : __u32;
  407. ppp_ibytes : __u32;
  408. ppp_ioctects : __u32;
  409. ppp_ipackets : __u32;
  410. ppp_ierrors : __u32;
  411. ppp_ilqrs : __u32;
  412. ppp_obytes : __u32;
  413. ppp_ooctects : __u32;
  414. ppp_opackets : __u32;
  415. ppp_oerrors : __u32;
  416. ppp_olqrs : __u32;
  417. end;
  418. Pvjstat = ^vjstat;
  419. vjstat = record
  420. vjs_packets : __u32;
  421. vjs_compressed : __u32;
  422. vjs_searches : __u32;
  423. vjs_misses : __u32;
  424. vjs_uncompressedin : __u32;
  425. vjs_compressedin : __u32;
  426. vjs_errorin : __u32;
  427. vjs_tossed : __u32;
  428. end;
  429. Pcompstat = ^compstat;
  430. compstat = record
  431. unc_bytes : __u32;
  432. unc_packets : __u32;
  433. comp_bytes : __u32;
  434. comp_packets : __u32;
  435. inc_bytes : __u32;
  436. inc_packets : __u32;
  437. in_count : __u32;
  438. bytes_out : __u32;
  439. ratio : double;
  440. end;
  441. Pppp_stats = ^ppp_stats;
  442. ppp_stats = record
  443. p : pppstat;
  444. vj : vjstat;
  445. end;
  446. Pppp_comp_stats = ^ppp_comp_stats;
  447. ppp_comp_stats = record
  448. c : compstat;
  449. d : compstat;
  450. end;
  451. __kernel_time_t = Longint;
  452. ppp_idle = record
  453. xmit_idle: __kernel_time_t;
  454. recv_idle: __kernel_time_t;
  455. end;
  456. Pppp_idle = ^ppp_idle;
  457. // Translated from linux/ppp-comp.h
  458. const
  459. DO_BSD_COMPRESS = 1;
  460. DO_DEFLATE = 1;
  461. DO_PREDICTOR_1 = 0;
  462. DO_PREDICTOR_2 = 0;
  463. type
  464. Pcompressor = ^compressor;
  465. compressor = record
  466. compress_proto : longint;
  467. comp_alloc : Function (options:Pbyte; opt_len:longint):pointer;cdecl;
  468. comp_free : procedure (state:pointer);
  469. comp_init : Function (state:pointer; options:Pbyte; opt_len:longint; _unit:longint; opthdr:longint;
  470. debug:longint):longint;
  471. comp_reset : procedure (state:pointer);
  472. compress : Function (state:pointer; rptr:Pbyte; obuf:Pbyte; isize:longint; osize:longint):longint;
  473. comp_stat : procedure (state:pointer; stats:Pcompstat);
  474. decomp_alloc : Function (options:Pbyte; opt_len:longint):pointer;
  475. decomp_free : procedure (state:pointer);
  476. decomp_init : Function (state:pointer; options:Pbyte; opt_len:longint; _unit:longint; opthdr:longint;
  477. mru:longint; debug:longint):longint;
  478. decomp_reset : procedure (state:pointer);
  479. decompress : Function (state:pointer; ibuf:Pbyte; isize:longint; obuf:Pbyte; osize:longint):longint;
  480. incomp : procedure (state:pointer; ibuf:Pbyte; icnt:longint);
  481. decomp_stat : procedure (state:pointer; stats:Pcompstat);
  482. end;
  483. const
  484. DECOMP_ERROR = -(1);
  485. DECOMP_FATALERROR = -(2);
  486. CCP_CONFREQ = 1;
  487. CCP_CONFACK = 2;
  488. CCP_TERMREQ = 5;
  489. CCP_TERMACK = 6;
  490. CCP_RESETREQ = 14;
  491. CCP_RESETACK = 15;
  492. CCP_MAX_OPTION_LENGTH = 32;
  493. Function CCP_CODE(dp: Pointer): Byte;
  494. Function CCP_ID(dp: Pointer): Byte;
  495. Function CCP_LENGTH(dp: Pointer): Word;
  496. Function CCP_OPT_CODE(dp: Pointer): Byte;
  497. Function CCP_OPT_LENGTH(dp: Pointer): Byte;
  498. const
  499. CCP_HDRLEN = 4;
  500. CCP_OPT_MINLEN = 2;
  501. CI_BSD_COMPRESS = 21;
  502. CILEN_BSD_COMPRESS = 3;
  503. BSD_CURRENT_VERSION = 1;
  504. Function BSD_NBITS(x: longint): longint;
  505. Function BSD_VERSION(x: longint): longint;
  506. Function BSD_MAKE_OPT(v, n: longint): longint;
  507. const
  508. BSD_MIN_BITS = 9;
  509. BSD_MAX_BITS = 15;
  510. CI_DEFLATE = 26;
  511. CI_DEFLATE_DRAFT = 24;
  512. CILEN_DEFLATE = 4;
  513. DEFLATE_MIN_SIZE = 8;
  514. DEFLATE_MAX_SIZE = 15;
  515. DEFLATE_METHOD_VAL = 8;
  516. Function DEFLATE_SIZE(x: longint): longint;
  517. Function DEFLATE_METHOD(x: longint): longint;
  518. Function DEFLATE_MAKE_OPT(w: longint): longint;
  519. const
  520. DEFLATE_CHK_SEQUENCE = 0;
  521. CI_PREDICTOR_1 = 1;
  522. CILEN_PREDICTOR_1 = 2;
  523. CI_PREDICTOR_2 = 2;
  524. CILEN_PREDICTOR_2 = 2;
  525. // Translated from linux/atalk.h
  526. const
  527. ATPORT_FIRST = 1;
  528. ATPORT_RESERVED = 128;
  529. ATPORT_LAST = 254;
  530. ATADDR_ANYNET = __u16(0);
  531. ATADDR_ANYNODE = __u8(0);
  532. ATADDR_ANYPORT = __u8(0);
  533. ATADDR_BCAST = __u8(255);
  534. const
  535. DDP_MAXSZ = 587;
  536. DDP_MAXHOPS = 15;
  537. SIOCATALKDIFADDR = SIOCPROTOPRIVATE + 0;
  538. type
  539. Pat_addr = ^at_addr;
  540. at_addr = record
  541. s_net : __u16;
  542. s_node : __u8;
  543. end;
  544. sa_family_t = Word; // From libc.
  545. Psockaddr_at = ^sockaddr_at;
  546. sockaddr_at = record
  547. sat_family : sa_family_t;
  548. sat_port : __u8;
  549. sat_addr : at_addr;
  550. sat_zero : array[0..7] of char;
  551. end;
  552. Pnetrange = ^netrange;
  553. netrange = record
  554. nr_phase : __u8;
  555. nr_firstnet : __u16;
  556. nr_lastnet : __u16;
  557. end;
  558. Patalk_route = ^atalk_route;
  559. atalk_route = record
  560. dev : Pointer; // pnet_device ??
  561. target : at_addr;
  562. gateway : at_addr;
  563. flags : longint;
  564. next : Patalk_route;
  565. end;
  566. Const
  567. ATIF_PROBE = 1; { Probing for an address }
  568. ATIF_PROBE_FAIL = 2; { Probe collided }
  569. Type
  570. PATalkIFace = ^TATalkIFace;
  571. atalk_iface = record
  572. dev: Pointer;
  573. address: at_addr;
  574. status: longint;
  575. nets: netrange;
  576. next: PATalkIFace;
  577. end;
  578. TATalkIFace = atalk_iface;
  579. Patalk_sock = ^atalk_sock;
  580. atalk_sock = record
  581. dest_net : word;
  582. src_net : word;
  583. dest_node : byte;
  584. src_node : byte;
  585. dest_port : byte;
  586. src_port : byte;
  587. end;
  588. // Translated from linux/igmp.h
  589. type
  590. Pigmphdr = ^igmphdr;
  591. igmphdr = record
  592. __type : __u8;
  593. code : __u8;
  594. csum : __u16;
  595. group : __u32;
  596. end;
  597. const
  598. IGMP_HOST_MEMBERSHIP_QUERY = $11;
  599. IGMP_HOST_MEMBERSHIP_REPORT = $12;
  600. IGMP_DVMRP = $13;
  601. IGMP_PIM = $14;
  602. IGMP_TRACE = $15;
  603. IGMP_HOST_NEW_MEMBERSHIP_REPORT = $16;
  604. IGMP_HOST_LEAVE_MESSAGE = $17;
  605. IGMP_MTRACE_RESP = $1e;
  606. IGMP_MTRACE = $1f;
  607. IGMP_DELAYING_MEMBER = $01;
  608. IGMP_IDLE_MEMBER = $02;
  609. IGMP_LAZY_MEMBER = $03;
  610. IGMP_SLEEPING_MEMBER = $04;
  611. IGMP_AWAKENING_MEMBER = $05;
  612. IGMP_MINLEN = 8;
  613. IGMP_MAX_HOST_REPORT_DELAY = 10;
  614. IGMP_TIMER_SCALE = 10;
  615. IGMP_AGE_THRESHOLD = 400;
  616. { ---------------------------------------------------------------------
  617. Borland compatibility types
  618. ---------------------------------------------------------------------}
  619. Type
  620. TATalkRoute = atalk_route;
  621. Implementation
  622. Function PPP_ADDRESS(const p): __u8;
  623. begin
  624. Result:=P__u8(@p)^;
  625. end;
  626. Function PPP_CONTROL(const p): __u8;
  627. begin
  628. Result:=P__u8(Cardinal(@p) + SizeOf(__u8))^;
  629. end;
  630. Function PPP_PROTOCOL(const p): __u16;
  631. begin
  632. Result:=P__u8(Cardinal(@p) + SizeOf(__u8)*2)^ shl 8;
  633. Result:=Result + P__u8(Cardinal(@p) + SizeOf(__u8)*3)^
  634. end;
  635. Function CCP_CODE(dp: Pointer): Byte;
  636. begin
  637. Result:=PByte(dp)^;
  638. end;
  639. Function CCP_ID(dp: Pointer): Byte;
  640. begin
  641. Inc(PByte(dp));
  642. Result:=PByte(dp)^;
  643. end;
  644. Function CCP_LENGTH(dp: Pointer): Word;
  645. begin
  646. Inc(PByte(dp), 2);
  647. Result:=(PByte(dp)^ shl 8);
  648. Inc(PByte(dp), 1);
  649. Result:=Result + PByte(dp)^;
  650. end;
  651. Function CCP_OPT_CODE(dp: Pointer): Byte;
  652. begin
  653. Result:=PByte(dp)^;
  654. end;
  655. Function CCP_OPT_LENGTH(dp: Pointer): Byte;
  656. begin
  657. Inc(PByte(dp));
  658. Result:=PByte(dp)^;
  659. end;
  660. Function DEFLATE_SIZE(x: longint): longint;
  661. begin
  662. Result:=(Cardinal(x) shr 4) + DEFLATE_MIN_SIZE;
  663. end;
  664. Function DEFLATE_METHOD(x: longint): longint;
  665. begin
  666. Result:=x and $0F;
  667. end;
  668. Function DEFLATE_MAKE_OPT(w: longint): longint;
  669. begin
  670. Result:=((w - DEFLATE_MIN_SIZE) shl 4) + DEFLATE_METHOD_VAL;
  671. end;
  672. Function BSD_NBITS(x: longint): longint;
  673. begin
  674. Result:=(x and $1F);
  675. end;
  676. Function BSD_VERSION(x: longint): longint;
  677. begin
  678. Result:=Cardinal(x) shr 5;
  679. end;
  680. Function BSD_MAKE_OPT(v, n: longint): longint;
  681. begin
  682. Result:= longint((Cardinal(v) shl 5) or Cardinal(n));
  683. end;
  684. end.