UnixTypes.h 16 KB

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