UnixTypes.h 16 KB

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