UnixTypes.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright notice, this
  9. * list of conditions and the following disclaimer.
  10. *
  11. * 2. Redistributions in binary form must reproduce the above copyright notice,
  12. * this list of conditions and the following disclaimer in the documentation
  13. * and/or other materials provided with the distribution.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  16. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  19. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  20. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  21. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  22. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  23. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  24. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. */
  26. #pragma once
  27. #include <AK/DistinctNumeric.h>
  28. #include <AK/Types.h>
  29. #define O_RDONLY (1 << 0)
  30. #define O_WRONLY (1 << 1)
  31. #define O_RDWR (O_RDONLY | O_WRONLY)
  32. #define O_ACCMODE (O_RDONLY | O_WRONLY)
  33. #define O_EXEC (1 << 2)
  34. #define O_CREAT (1 << 3)
  35. #define O_EXCL (1 << 4)
  36. #define O_NOCTTY (1 << 5)
  37. #define O_TRUNC (1 << 6)
  38. #define O_APPEND (1 << 7)
  39. #define O_NONBLOCK (1 << 8)
  40. #define O_DIRECTORY (1 << 9)
  41. #define O_NOFOLLOW (1 << 10)
  42. #define O_CLOEXEC (1 << 11)
  43. #define O_DIRECT (1 << 12)
  44. // Kernel internal options.
  45. #define O_NOFOLLOW_NOERROR (1 << 29)
  46. #define O_UNLINK_INTERNAL (1 << 30)
  47. #define MS_NODEV (1 << 0)
  48. #define MS_NOEXEC (1 << 1)
  49. #define MS_NOSUID (1 << 2)
  50. #define MS_BIND (1 << 3)
  51. #define MS_RDONLY (1 << 4)
  52. #define MS_REMOUNT (1 << 5)
  53. enum {
  54. _SC_NPROCESSORS_CONF,
  55. _SC_NPROCESSORS_ONLN,
  56. _SC_OPEN_MAX,
  57. _SC_TTY_NAME_MAX,
  58. _SC_PAGESIZE,
  59. _SC_GETPW_R_SIZE_MAX,
  60. _SC_CLK_TCK,
  61. };
  62. #define PERF_EVENT_SAMPLE 0
  63. #define PERF_EVENT_MALLOC 1
  64. #define PERF_EVENT_FREE 2
  65. #define WNOHANG 1
  66. #define WUNTRACED 2
  67. #define WSTOPPED WUNTRACED
  68. #define WEXITED 4
  69. #define WCONTINUED 8
  70. #define WNOWAIT 0x1000000
  71. #define R_OK 4
  72. #define W_OK 2
  73. #define X_OK 1
  74. #define F_OK 0
  75. #define SIG_DFL ((void*)0)
  76. #define SIG_ERR ((void*)-1)
  77. #define SIG_IGN ((void*)1)
  78. #define SEEK_SET 0
  79. #define SEEK_CUR 1
  80. #define SEEK_END 2
  81. #define MAP_SHARED 0x01
  82. #define MAP_PRIVATE 0x02
  83. #define MAP_FIXED 0x10
  84. #define MAP_ANONYMOUS 0x20
  85. #define MAP_ANON MAP_ANONYMOUS
  86. #define MAP_STACK 0x40
  87. #define MAP_NORESERVE 0x80
  88. #define MAP_RANDOMIZED 0x100
  89. #define PROT_READ 0x1
  90. #define PROT_WRITE 0x2
  91. #define PROT_EXEC 0x4
  92. #define PROT_NONE 0x0
  93. #define MADV_SET_VOLATILE 0x100
  94. #define MADV_SET_NONVOLATILE 0x200
  95. #define MADV_GET_VOLATILE 0x400
  96. #define F_DUPFD 0
  97. #define F_GETFD 1
  98. #define F_SETFD 2
  99. #define F_GETFL 3
  100. #define F_SETFL 4
  101. #define F_ISTTY 5
  102. #define FD_CLOEXEC 1
  103. #define _FUTEX_OP_SHIFT_OP 28
  104. #define _FUTEX_OP_MASK_OP 0xf
  105. #define _FUTEX_OP_SHIFT_CMP 24
  106. #define _FUTEX_OP_MASK_CMP 0xf
  107. #define _FUTEX_OP_SHIFT_OP_ARG 12
  108. #define _FUTEX_OP_MASK_OP_ARG 0xfff
  109. #define _FUTEX_OP_SHIFT_CMP_ARG 0
  110. #define _FUTEX_OP_MASK_CMP_ARG 0xfff
  111. #define _FUTEX_OP(val3) (((val3) >> _FUTEX_OP_SHIFT_OP) & _FUTEX_OP_MASK_OP)
  112. #define _FUTEX_CMP(val3) (((val3) >> _FUTEX_OP_SHIFT_CMP) & _FUTEX_OP_MASK_CMP)
  113. #define _FUTEX_OP_ARG(val3) (((val3) >> _FUTEX_OP_SHIFT_OP_ARG) & _FUTEX_OP_MASK_OP_ARG)
  114. #define _FUTEX_CMP_ARG(val3) (((val3) >> _FUTEX_OP_SHIFT_CMP_ARG) & _FUTEX_OP_MASK_CMP_ARG)
  115. #define FUTEX_OP_SET 0
  116. #define FUTEX_OP_ADD 1
  117. #define FUTEX_OP_OR 2
  118. #define FUTEX_OP_ANDN 3
  119. #define FUTEX_OP_XOR 4
  120. #define FUTEX_OP_ARG_SHIFT 8
  121. #define FUTEX_OP_CMP_EQ 0
  122. #define FUTEX_OP_CMP_NE 1
  123. #define FUTEX_OP_CMP_LT 2
  124. #define FUTEX_OP_CMP_LE 3
  125. #define FUTEX_OP_CMP_GT 4
  126. #define FUTEX_OP_CMP_GE 5
  127. #define FUTEX_WAIT 1
  128. #define FUTEX_WAKE 2
  129. #define FUTEX_REQUEUE 3
  130. #define FUTEX_CMP_REQUEUE 4
  131. #define FUTEX_WAKE_OP 5
  132. #define FUTEX_WAIT_BITSET 9
  133. #define FUTEX_WAKE_BITSET 10
  134. #define FUTEX_PRIVATE_FLAG (1 << 7)
  135. #define FUTEX_CLOCK_REALTIME (1 << 8)
  136. #define FUTEX_CMD_MASK ~(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME)
  137. #define FUTEX_BITSET_MATCH_ANY 0xffffffff
  138. #define S_IFMT 0170000
  139. #define S_IFDIR 0040000
  140. #define S_IFCHR 0020000
  141. #define S_IFBLK 0060000
  142. #define S_IFREG 0100000
  143. #define S_IFIFO 0010000
  144. #define S_IFLNK 0120000
  145. #define S_IFSOCK 0140000
  146. #define S_ISUID 04000
  147. #define S_ISGID 02000
  148. #define S_ISVTX 01000
  149. #define S_IRUSR 0400
  150. #define S_IWUSR 0200
  151. #define S_IXUSR 0100
  152. #define S_IRGRP 0040
  153. #define S_IWGRP 0020
  154. #define S_IXGRP 0010
  155. #define S_IROTH 0004
  156. #define S_IWOTH 0002
  157. #define S_IXOTH 0001
  158. /* c_cc characters */
  159. #define VINTR 0
  160. #define VQUIT 1
  161. #define VERASE 2
  162. #define VKILL 3
  163. #define VEOF 4
  164. #define VTIME 5
  165. #define VMIN 6
  166. #define VSWTC 7
  167. #define VSTART 8
  168. #define VSTOP 9
  169. #define VSUSP 10
  170. #define VEOL 11
  171. #define VREPRINT 12
  172. #define VDISCARD 13
  173. #define VWERASE 14
  174. #define VLNEXT 15
  175. #define VEOL2 16
  176. #define VINFO 17
  177. /* c_iflag bits */
  178. #define IGNBRK 0000001
  179. #define BRKINT 0000002
  180. #define IGNPAR 0000004
  181. #define PARMRK 0000010
  182. #define INPCK 0000020
  183. #define ISTRIP 0000040
  184. #define INLCR 0000100
  185. #define IGNCR 0000200
  186. #define ICRNL 0000400
  187. #define IUCLC 0001000
  188. #define IXON 0002000
  189. #define IXANY 0004000
  190. #define IXOFF 0010000
  191. #define IMAXBEL 0020000
  192. #define IUTF8 0040000
  193. /* c_oflag bits */
  194. #define OPOST 0000001
  195. #define OLCUC 0000002
  196. #define ONLCR 0000004
  197. #define OCRNL 0000010
  198. #define ONOCR 0000020
  199. #define ONLRET 0000040
  200. #define OFILL 0000100
  201. #define OFDEL 0000200
  202. #if defined __USE_MISC || defined __USE_XOPEN
  203. # define NLDLY 0000400
  204. # define NL0 0000000
  205. # define NL1 0000400
  206. # define CRDLY 0003000
  207. # define CR0 0000000
  208. # define CR1 0001000
  209. # define CR2 0002000
  210. # define CR3 0003000
  211. # define TABDLY 0014000
  212. # define TAB0 0000000
  213. # define TAB1 0004000
  214. # define TAB2 0010000
  215. # define TAB3 0014000
  216. # define BSDLY 0020000
  217. # define BS0 0000000
  218. # define BS1 0020000
  219. # define FFDLY 0100000
  220. # define FF0 0000000
  221. # define FF1 0100000
  222. #endif
  223. #define VTDLY 0040000
  224. #define VT0 0000000
  225. #define VT1 0040000
  226. #ifdef __USE_MISC
  227. # define XTABS 0014000
  228. #endif
  229. /* c_cflag bit meaning */
  230. #ifdef __USE_MISC
  231. # define CBAUD 0010017
  232. #endif
  233. #define B0 0000000 /* hang up */
  234. #define B50 0000001
  235. #define B75 0000002
  236. #define B110 0000003
  237. #define B134 0000004
  238. #define B150 0000005
  239. #define B200 0000006
  240. #define B300 0000007
  241. #define B600 0000010
  242. #define B1200 0000011
  243. #define B1800 0000012
  244. #define B2400 0000013
  245. #define B4800 0000014
  246. #define B9600 0000015
  247. #define B19200 0000016
  248. #define B38400 0000017
  249. #ifdef __USE_MISC
  250. # define EXTA B19200
  251. # define EXTB B38400
  252. #endif
  253. #define CSIZE 0000060
  254. #define CS5 0000000
  255. #define CS6 0000020
  256. #define CS7 0000040
  257. #define CS8 0000060
  258. #define CSTOPB 0000100
  259. #define CREAD 0000200
  260. #define PARENB 0000400
  261. #define PARODD 0001000
  262. #define HUPCL 0002000
  263. #define CLOCAL 0004000
  264. #ifdef __USE_MISC
  265. # define CBAUDEX 0010000
  266. #endif
  267. #define B57600 0010001
  268. #define B115200 0010002
  269. #define B230400 0010003
  270. #define B460800 0010004
  271. #define B500000 0010005
  272. #define B576000 0010006
  273. #define B921600 0010007
  274. #define B1000000 0010010
  275. #define B1152000 0010011
  276. #define B1500000 0010012
  277. #define B2000000 0010013
  278. #define B2500000 0010014
  279. #define B3000000 0010015
  280. #define B3500000 0010016
  281. #define B4000000 0010017
  282. #define __MAX_BAUD B4000000
  283. #ifdef __USE_MISC
  284. # define CIBAUD 002003600000 /* input baud rate (not used) */
  285. # define CMSPAR 010000000000 /* mark or space (stick) parity */
  286. # define CRTSCTS 020000000000 /* flow control */
  287. #endif
  288. /* c_lflag bits */
  289. #define ISIG 0000001
  290. #define ICANON 0000002
  291. #if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
  292. # define XCASE 0000004
  293. #endif
  294. #define ECHO 0000010
  295. #define ECHOE 0000020
  296. #define ECHOK 0000040
  297. #define ECHONL 0000100
  298. #define NOFLSH 0000200
  299. #define TOSTOP 0000400
  300. #ifdef __USE_MISC
  301. # define ECHOCTL 0001000
  302. # define ECHOPRT 0002000
  303. # define ECHOKE 0004000
  304. # define FLUSHO 0010000
  305. # define PENDIN 0040000
  306. #endif
  307. #define IEXTEN 0100000
  308. #ifdef __USE_MISC
  309. # define EXTPROC 0200000
  310. #endif
  311. /* tcflow() and TCXONC use these */
  312. #define TCOOFF 0
  313. #define TCOON 1
  314. #define TCIOFF 2
  315. #define TCION 3
  316. /* tcflush() and TCFLSH use these */
  317. #define TCIFLUSH 0
  318. #define TCOFLUSH 1
  319. #define TCIOFLUSH 2
  320. /* tcsetattr uses these */
  321. #define TCSANOW 0
  322. #define TCSADRAIN 1
  323. #define TCSAFLUSH 2
  324. typedef u32 dev_t;
  325. typedef u32 ino_t;
  326. typedef u16 mode_t;
  327. typedef u32 nlink_t;
  328. typedef u32 uid_t;
  329. typedef u32 gid_t;
  330. typedef u32 clock_t;
  331. typedef u32 socklen_t;
  332. typedef int pid_t;
  333. // Avoid interference with AK/Types.h and LibC/sys/types.h by defining *separate* names:
  334. TYPEDEF_DISTINCT_ORDERED_ID(pid_t, ProcessID);
  335. TYPEDEF_DISTINCT_ORDERED_ID(pid_t, ThreadID);
  336. TYPEDEF_DISTINCT_ORDERED_ID(pid_t, SessionID);
  337. TYPEDEF_DISTINCT_ORDERED_ID(pid_t, ProcessGroupID);
  338. struct tms {
  339. clock_t tms_utime;
  340. clock_t tms_stime;
  341. clock_t tms_cutime;
  342. clock_t tms_cstime;
  343. };
  344. typedef void (*__sighandler_t)(int);
  345. typedef __sighandler_t sighandler_t;
  346. typedef u32 sigset_t;
  347. union sigval {
  348. int sival_int;
  349. void* sival_ptr;
  350. };
  351. typedef struct siginfo {
  352. int si_signo;
  353. int si_code;
  354. pid_t si_pid;
  355. uid_t si_uid;
  356. void* si_addr;
  357. int si_status;
  358. union sigval si_value;
  359. } siginfo_t;
  360. struct sigaction {
  361. union {
  362. void (*sa_handler)(int);
  363. void (*sa_sigaction)(int, siginfo_t*, void*);
  364. };
  365. sigset_t sa_mask;
  366. int sa_flags;
  367. };
  368. #define SA_NOCLDSTOP 1
  369. #define SA_NOCLDWAIT 2
  370. #define SA_SIGINFO 4
  371. #define SA_NODEFER 0x40000000
  372. #define SIG_BLOCK 0
  373. #define SIG_UNBLOCK 1
  374. #define SIG_SETMASK 2
  375. #define CLD_EXITED 0
  376. #define CLD_KILLED 1
  377. #define CLD_DUMPED 2
  378. #define CLD_TRAPPED 3
  379. #define CLD_STOPPED 4
  380. #define CLD_CONTINUED 5
  381. #define OFF_T_MAX 2147483647
  382. typedef ssize_t off_t;
  383. typedef i64 time_t;
  384. struct utimbuf {
  385. time_t actime;
  386. time_t modtime;
  387. };
  388. typedef u32 blksize_t;
  389. typedef u32 blkcnt_t;
  390. #define NCCS 32
  391. typedef uint32_t tcflag_t;
  392. typedef uint8_t cc_t;
  393. typedef uint32_t speed_t;
  394. struct termios {
  395. tcflag_t c_iflag;
  396. tcflag_t c_oflag;
  397. tcflag_t c_cflag;
  398. tcflag_t c_lflag;
  399. cc_t c_cc[NCCS];
  400. speed_t c_ispeed;
  401. speed_t c_ospeed;
  402. };
  403. struct stat {
  404. dev_t st_dev; /* ID of device containing file */
  405. ino_t st_ino; /* inode number */
  406. mode_t st_mode; /* protection */
  407. nlink_t st_nlink; /* number of hard links */
  408. uid_t st_uid; /* user ID of owner */
  409. gid_t st_gid; /* group ID of owner */
  410. dev_t st_rdev; /* device ID (if special file) */
  411. off_t st_size; /* total size, in bytes */
  412. blksize_t st_blksize; /* blocksize for file system I/O */
  413. blkcnt_t st_blocks; /* number of 512B blocks allocated */
  414. time_t st_atime; /* time of last access */
  415. time_t st_mtime; /* time of last modification */
  416. time_t st_ctime; /* time of last status change */
  417. };
  418. #define POLLIN (1u << 0)
  419. #define POLLPRI (1u << 1)
  420. #define POLLOUT (1u << 2)
  421. #define POLLERR (1u << 3)
  422. #define POLLHUP (1u << 4)
  423. #define POLLNVAL (1u << 5)
  424. #define POLLRDHUP (1u << 13)
  425. struct pollfd {
  426. int fd;
  427. short events;
  428. short revents;
  429. };
  430. #define AF_MASK 0xff
  431. #define AF_UNSPEC 0
  432. #define AF_LOCAL 1
  433. #define AF_INET 2
  434. #define AF_MAX 3
  435. #define PF_LOCAL AF_LOCAL
  436. #define PF_INET AF_INET
  437. #define SOCK_TYPE_MASK 0xff
  438. #define SOCK_STREAM 1
  439. #define SOCK_RAW 3
  440. #define SOCK_DGRAM 2
  441. #define SOCK_NONBLOCK 04000
  442. #define SOCK_CLOEXEC 02000000
  443. #define SHUT_RD 1
  444. #define SHUT_WR 2
  445. #define SHUT_RDWR 3
  446. #define MSG_TRUNC 0x1
  447. #define MSG_CTRUNC 0x2
  448. #define MSG_DONTWAIT 0x40
  449. #define SOL_SOCKET 1
  450. enum {
  451. SO_RCVTIMEO,
  452. SO_SNDTIMEO,
  453. SO_TYPE,
  454. SO_ERROR,
  455. SO_PEERCRED,
  456. SO_RCVBUF,
  457. SO_SNDBUF,
  458. SO_REUSEADDR,
  459. SO_BINDTODEVICE,
  460. SO_KEEPALIVE,
  461. SO_TIMESTAMP,
  462. };
  463. enum {
  464. SCM_TIMESTAMP,
  465. };
  466. #define IPPROTO_IP 0
  467. #define IPPROTO_ICMP 1
  468. #define IPPROTO_TCP 6
  469. #define IPPROTO_UDP 17
  470. #define IP_TTL 2
  471. struct ucred {
  472. pid_t pid;
  473. uid_t uid;
  474. gid_t gid;
  475. };
  476. struct sockaddr {
  477. u16 sa_family;
  478. char sa_data[14];
  479. };
  480. #define S_IFSOCK 0140000
  481. #define UNIX_PATH_MAX 108
  482. struct sockaddr_un {
  483. u16 sun_family;
  484. char sun_path[UNIX_PATH_MAX];
  485. };
  486. struct in_addr {
  487. uint32_t s_addr;
  488. };
  489. struct sockaddr_in {
  490. int16_t sin_family;
  491. uint16_t sin_port;
  492. struct in_addr sin_addr;
  493. char sin_zero[8];
  494. };
  495. typedef u32 __u32;
  496. typedef u16 __u16;
  497. typedef u8 __u8;
  498. typedef int __s32;
  499. typedef short __s16;
  500. typedef u32 useconds_t;
  501. typedef i32 suseconds_t;
  502. struct timeval {
  503. time_t tv_sec;
  504. suseconds_t tv_usec;
  505. };
  506. struct timespec {
  507. time_t tv_sec;
  508. long tv_nsec;
  509. };
  510. typedef enum {
  511. P_ALL = 1,
  512. P_PID,
  513. P_PGID
  514. } idtype_t;
  515. typedef int clockid_t;
  516. #define CLOCK_REALTIME 0
  517. #define CLOCK_MONOTONIC 1
  518. #define CLOCK_MONOTONIC_RAW 4
  519. #define CLOCK_REALTIME_COARSE 5
  520. #define CLOCK_MONOTONIC_COARSE 6
  521. #define TIMER_ABSTIME 99
  522. #define UTSNAME_ENTRY_LEN 65
  523. struct utsname {
  524. char sysname[UTSNAME_ENTRY_LEN];
  525. char nodename[UTSNAME_ENTRY_LEN];
  526. char release[UTSNAME_ENTRY_LEN];
  527. char version[UTSNAME_ENTRY_LEN];
  528. char machine[UTSNAME_ENTRY_LEN];
  529. };
  530. struct iovec {
  531. void* iov_base;
  532. size_t iov_len;
  533. };
  534. struct cmsghdr {
  535. socklen_t cmsg_len;
  536. int cmsg_level;
  537. int cmsg_type;
  538. };
  539. struct msghdr {
  540. void* msg_name;
  541. socklen_t msg_namelen;
  542. struct iovec* msg_iov;
  543. int msg_iovlen;
  544. void* msg_control;
  545. socklen_t msg_controllen;
  546. int msg_flags;
  547. };
  548. struct sched_param {
  549. int sched_priority;
  550. };
  551. struct ifreq {
  552. #define IFNAMSIZ 16
  553. char ifr_name[IFNAMSIZ];
  554. union {
  555. struct sockaddr ifru_addr;
  556. struct sockaddr ifru_dstaddr;
  557. struct sockaddr ifru_broadaddr;
  558. struct sockaddr ifru_netmask;
  559. struct sockaddr ifru_hwaddr;
  560. short ifru_flags;
  561. int ifru_metric;
  562. int64_t ifru_vnetid;
  563. uint64_t ifru_media;
  564. void* ifru_data;
  565. unsigned int ifru_index;
  566. } ifr_ifru;
  567. #define ifr_addr ifr_ifru.ifru_addr // address
  568. #define ifr_dstaddr ifr_ifru.ifru_dstaddr // other end of p-to-p link
  569. #define ifr_broadaddr ifr_ifru.ifru_broadaddr // broadcast address
  570. #define ifr_netmask ifr_ifru.ifru_netmask // network mask
  571. #define ifr_flags ifr_ifru.ifru_flags // flags
  572. #define ifr_metric ifr_ifru.ifru_metric // metric
  573. #define ifr_mtu ifr_ifru.ifru_metric // mtu (overload)
  574. #define ifr_hardmtu ifr_ifru.ifru_metric // hardmtu (overload)
  575. #define ifr_media ifr_ifru.ifru_media // media options
  576. #define ifr_rdomainid ifr_ifru.ifru_metric // VRF instance (overload)
  577. #define ifr_vnetid ifr_ifru.ifru_vnetid // Virtual Net Id
  578. #define ifr_ttl ifr_ifru.ifru_metric // tunnel TTL (overload)
  579. #define ifr_data ifr_ifru.ifru_data // for use by interface
  580. #define ifr_index ifr_ifru.ifru_index // interface index
  581. #define ifr_llprio ifr_ifru.ifru_metric // link layer priority
  582. #define ifr_hwaddr ifr_ifru.ifru_hwaddr // MAC address
  583. };
  584. struct rtentry {
  585. struct sockaddr rt_gateway; /* the gateway address */
  586. struct sockaddr rt_genmask; /* the target network mask */
  587. unsigned short int rt_flags;
  588. char* rt_dev;
  589. /* FIXME: complete the struct */
  590. };
  591. #define RTF_UP 0x1 /* do not delete the route */
  592. #define RTF_GATEWAY 0x2 /* the route is a gateway and not an end host */
  593. #define AT_FDCWD -100
  594. #define PURGE_ALL_VOLATILE 0x1
  595. #define PURGE_ALL_CLEAN_INODE 0x2
  596. #define PT_TRACE_ME 1
  597. #define PT_ATTACH 2
  598. #define PT_CONTINUE 3
  599. #define PT_SYSCALL 4
  600. #define PT_GETREGS 5
  601. #define PT_DETACH 6
  602. #define PT_PEEK 7
  603. #define PT_POKE 8
  604. #define PT_SETREGS 9
  605. // Used in struct dirent
  606. enum {
  607. DT_UNKNOWN = 0,
  608. #define DT_UNKNOWN DT_UNKNOWN
  609. DT_FIFO = 1,
  610. #define DT_FIFO DT_FIFO
  611. DT_CHR = 2,
  612. #define DT_CHR DT_CHR
  613. DT_DIR = 4,
  614. #define DT_DIR DT_DIR
  615. DT_BLK = 6,
  616. #define DT_BLK DT_BLK
  617. DT_REG = 8,
  618. #define DT_REG DT_REG
  619. DT_LNK = 10,
  620. #define DT_LNK DT_LNK
  621. DT_SOCK = 12,
  622. #define DT_SOCK DT_SOCK
  623. DT_WHT = 14
  624. #define DT_WHT DT_WHT
  625. };