PageRenderTime 24ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/jni/libnl/netlink-types.h

https://gitlab.com/obay/batphone_adhoc
C Header | 758 lines | 560 code | 114 blank | 84 comment | 0 complexity | 8777bcef317657c875b07666d2ab20b0 MD5 | raw file
  1. /*
  2. * netlink-types.h Netlink Types (Private)
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation version 2.1
  7. * of the License.
  8. *
  9. * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
  10. */
  11. #ifndef NETLINK_LOCAL_TYPES_H_
  12. #define NETLINK_LOCAL_TYPES_H_
  13. #include <netlink/list.h>
  14. #include <netlink/route/link.h>
  15. #include <netlink/route/qdisc.h>
  16. #include <netlink/route/rtnl.h>
  17. #include <netlink/route/route.h>
  18. #define NL_SOCK_BUFSIZE_SET (1<<0)
  19. #define NL_SOCK_PASSCRED (1<<1)
  20. #define NL_OWN_PORT (1<<2)
  21. #define NL_MSG_PEEK (1<<3)
  22. #define NL_MSG_CRED_PRESENT 1
  23. struct nl_cache_ops;
  24. struct nl_handle;
  25. struct nl_object;
  26. struct nl_cb
  27. {
  28. nl_recvmsg_msg_cb_t cb_set[NL_CB_TYPE_MAX+1];
  29. void * cb_args[NL_CB_TYPE_MAX+1];
  30. nl_recvmsg_err_cb_t cb_err;
  31. void * cb_err_arg;
  32. /** May be used to replace nl_recvmsgs with your own implementation
  33. * in all internal calls to nl_recvmsgs. */
  34. int (*cb_recvmsgs_ow)(struct nl_handle *,
  35. struct nl_cb *);
  36. /** Overwrite internal calls to nl_recv, must return the number of
  37. * octets read and allocate a buffer for the received data. */
  38. int (*cb_recv_ow)(struct nl_handle *,
  39. struct sockaddr_nl *,
  40. unsigned char **,
  41. struct ucred **);
  42. /** Overwrites internal calls to nl_send, must send the netlink
  43. * message. */
  44. int (*cb_send_ow)(struct nl_handle *,
  45. struct nl_msg *);
  46. int cb_refcnt;
  47. };
  48. struct nl_handle
  49. {
  50. struct sockaddr_nl h_local;
  51. struct sockaddr_nl h_peer;
  52. int h_fd;
  53. int h_proto;
  54. unsigned int h_seq_next;
  55. unsigned int h_seq_expect;
  56. int h_flags;
  57. struct nl_cb * h_cb;
  58. };
  59. struct nl_cache
  60. {
  61. struct nl_list_head c_items;
  62. int c_nitems;
  63. int c_iarg1;
  64. int c_iarg2;
  65. struct nl_cache_ops * c_ops;
  66. };
  67. struct nl_cache_assoc
  68. {
  69. struct nl_cache * ca_cache;
  70. change_func_t ca_change;
  71. };
  72. struct nl_cache_mngr
  73. {
  74. int cm_protocol;
  75. int cm_flags;
  76. int cm_nassocs;
  77. struct nl_handle * cm_handle;
  78. struct nl_cache_assoc * cm_assocs;
  79. };
  80. struct nl_parser_param;
  81. struct genl_info
  82. {
  83. struct sockaddr_nl * who;
  84. struct nlmsghdr * nlh;
  85. struct genlmsghdr * genlhdr;
  86. void * userhdr;
  87. struct nlattr ** attrs;
  88. };
  89. #define LOOSE_FLAG_COMPARISON 1
  90. #define NL_OBJ_MARK 1
  91. struct nl_object
  92. {
  93. NLHDR_COMMON
  94. };
  95. struct nl_data
  96. {
  97. size_t d_size;
  98. void * d_data;
  99. };
  100. struct nl_addr
  101. {
  102. int a_family;
  103. unsigned int a_maxsize;
  104. unsigned int a_len;
  105. int a_prefixlen;
  106. int a_refcnt;
  107. char a_addr[0];
  108. };
  109. struct nl_msg
  110. {
  111. int nm_protocol;
  112. int nm_flags;
  113. struct sockaddr_nl nm_src;
  114. struct sockaddr_nl nm_dst;
  115. struct ucred nm_creds;
  116. struct nlmsghdr * nm_nlh;
  117. size_t nm_size;
  118. };
  119. struct rtnl_link_map
  120. {
  121. uint64_t lm_mem_start;
  122. uint64_t lm_mem_end;
  123. uint64_t lm_base_addr;
  124. uint16_t lm_irq;
  125. uint8_t lm_dma;
  126. uint8_t lm_port;
  127. };
  128. #define IFQDISCSIZ 32
  129. struct rtnl_link
  130. {
  131. NLHDR_COMMON
  132. char l_name[IFNAMSIZ];
  133. uint32_t l_family;
  134. uint32_t l_arptype;
  135. uint32_t l_index;
  136. uint32_t l_flags;
  137. uint32_t l_change;
  138. uint32_t l_mtu;
  139. uint32_t l_link;
  140. uint32_t l_txqlen;
  141. uint32_t l_weight;
  142. uint32_t l_master;
  143. struct nl_addr *l_addr;
  144. struct nl_addr *l_bcast;
  145. char l_qdisc[IFQDISCSIZ];
  146. struct rtnl_link_map l_map;
  147. uint64_t l_stats[RTNL_LINK_STATS_MAX+1];
  148. uint32_t l_flag_mask;
  149. uint8_t l_operstate;
  150. uint8_t l_linkmode;
  151. /* 2 byte hole */
  152. struct rtnl_link_info_ops *l_info_ops;
  153. void * l_info;
  154. };
  155. struct rtnl_ncacheinfo
  156. {
  157. uint32_t nci_confirmed; /**< Time since neighbour validty was last confirmed */
  158. uint32_t nci_used; /**< Time since neighbour entry was last ued */
  159. uint32_t nci_updated; /**< Time since last update */
  160. uint32_t nci_refcnt; /**< Reference counter */
  161. };
  162. struct rtnl_neigh
  163. {
  164. NLHDR_COMMON
  165. uint32_t n_family;
  166. uint32_t n_ifindex;
  167. uint16_t n_state;
  168. uint8_t n_flags;
  169. uint8_t n_type;
  170. struct nl_addr *n_lladdr;
  171. struct nl_addr *n_dst;
  172. uint32_t n_probes;
  173. struct rtnl_ncacheinfo n_cacheinfo;
  174. uint32_t n_state_mask;
  175. uint32_t n_flag_mask;
  176. };
  177. struct rtnl_addr_cacheinfo
  178. {
  179. /* Preferred lifetime in seconds */
  180. uint32_t aci_prefered;
  181. /* Valid lifetime in seconds */
  182. uint32_t aci_valid;
  183. /* Timestamp of creation in 1/100s seince boottime */
  184. uint32_t aci_cstamp;
  185. /* Timestamp of last update in 1/100s since boottime */
  186. uint32_t aci_tstamp;
  187. };
  188. struct rtnl_addr
  189. {
  190. NLHDR_COMMON
  191. uint8_t a_family;
  192. uint8_t a_prefixlen;
  193. uint8_t a_flags;
  194. uint8_t a_scope;
  195. uint32_t a_ifindex;
  196. struct nl_addr *a_peer;
  197. struct nl_addr *a_local;
  198. struct nl_addr *a_bcast;
  199. struct nl_addr *a_anycast;
  200. struct nl_addr *a_multicast;
  201. struct rtnl_addr_cacheinfo a_cacheinfo;
  202. char a_label[IFNAMSIZ];
  203. uint32_t a_flag_mask;
  204. };
  205. #define NEXTHOP_HAS_FLAGS 0x000001
  206. #define NEXTHOP_HAS_WEIGHT 0x000002
  207. #define NEXTHOP_HAS_IFINDEX 0x000004
  208. #define NEXTHOP_HAS_GATEWAY 0x000008
  209. struct rtnl_nexthop
  210. {
  211. uint8_t rtnh_flags;
  212. uint8_t rtnh_flag_mask;
  213. uint8_t rtnh_weight;
  214. /* 1 byte spare */
  215. uint32_t rtnh_ifindex;
  216. struct nl_addr * rtnh_gateway;
  217. uint32_t rtnh_mask;
  218. struct nl_list_head rtnh_list;
  219. };
  220. struct rtnl_route
  221. {
  222. NLHDR_COMMON
  223. uint8_t rt_family;
  224. uint8_t rt_dst_len;
  225. uint8_t rt_src_len;
  226. uint8_t rt_tos;
  227. uint8_t rt_table;
  228. uint8_t rt_protocol;
  229. uint8_t rt_scope;
  230. uint8_t rt_type;
  231. uint32_t rt_flags;
  232. struct nl_addr * rt_dst;
  233. struct nl_addr * rt_src;
  234. char rt_iif[IFNAMSIZ];
  235. uint32_t rt_oif;
  236. struct nl_addr * rt_gateway;
  237. uint32_t rt_prio;
  238. uint32_t rt_metrics[RTAX_MAX];
  239. uint32_t rt_metrics_mask;
  240. struct nl_addr * rt_pref_src;
  241. struct nl_list_head rt_nexthops;
  242. realm_t rt_realms;
  243. struct rtnl_rtcacheinfo rt_cacheinfo;
  244. uint32_t rt_mp_algo;
  245. uint32_t rt_flag_mask;
  246. };
  247. struct rtnl_rule
  248. {
  249. NLHDR_COMMON
  250. uint64_t r_mark;
  251. uint32_t r_prio;
  252. uint32_t r_realms;
  253. uint32_t r_table;
  254. uint8_t r_dsfield;
  255. uint8_t r_type;
  256. uint8_t r_family;
  257. uint8_t r_src_len;
  258. uint8_t r_dst_len;
  259. char r_iif[IFNAMSIZ];
  260. struct nl_addr *r_src;
  261. struct nl_addr *r_dst;
  262. struct nl_addr *r_srcmap;
  263. };
  264. struct rtnl_neightbl_parms
  265. {
  266. /**
  267. * Interface index of the device this parameter set is assigned
  268. * to or 0 for the default set.
  269. */
  270. uint32_t ntp_ifindex;
  271. /**
  272. * Number of references to this parameter set.
  273. */
  274. uint32_t ntp_refcnt;
  275. /**
  276. * Queue length for pending arp requests, i.e. the number of
  277. * packets which are accepted from other layers while the
  278. * neighbour address is still being resolved
  279. */
  280. uint32_t ntp_queue_len;
  281. /**
  282. * Number of requests to send to the user level ARP daemon.
  283. * Specify 0 to disable.
  284. */
  285. uint32_t ntp_app_probes;
  286. /**
  287. * Maximum number of retries for unicast solicitation.
  288. */
  289. uint32_t ntp_ucast_probes;
  290. /**
  291. * Maximum number of retries for multicast solicitation.
  292. */
  293. uint32_t ntp_mcast_probes;
  294. /**
  295. * Base value in milliseconds to ompute reachable time, see RFC2461.
  296. */
  297. uint64_t ntp_base_reachable_time;
  298. /**
  299. * Actual reachable time (read-only)
  300. */
  301. uint64_t ntp_reachable_time; /* secs */
  302. /**
  303. * The time in milliseconds between retransmitted Neighbor
  304. * Solicitation messages.
  305. */
  306. uint64_t ntp_retrans_time;
  307. /**
  308. * Interval in milliseconds to check for stale neighbour
  309. * entries.
  310. */
  311. uint64_t ntp_gc_stale_time; /* secs */
  312. /**
  313. * Delay in milliseconds for the first time probe if
  314. * the neighbour is reachable.
  315. */
  316. uint64_t ntp_probe_delay; /* secs */
  317. /**
  318. * Maximum delay in milliseconds of an answer to a neighbour
  319. * solicitation message.
  320. */
  321. uint64_t ntp_anycast_delay;
  322. /**
  323. * Minimum age in milliseconds before a neighbour entry
  324. * may be replaced.
  325. */
  326. uint64_t ntp_locktime;
  327. /**
  328. * Delay in milliseconds before answering to an ARP request
  329. * for which a proxy ARP entry exists.
  330. */
  331. uint64_t ntp_proxy_delay;
  332. /**
  333. * Queue length for the delayed proxy arp requests.
  334. */
  335. uint32_t ntp_proxy_qlen;
  336. /**
  337. * Mask of available parameter attributes
  338. */
  339. uint32_t ntp_mask;
  340. };
  341. #define NTBLNAMSIZ 32
  342. /**
  343. * Neighbour table
  344. * @ingroup neightbl
  345. */
  346. struct rtnl_neightbl
  347. {
  348. NLHDR_COMMON
  349. char nt_name[NTBLNAMSIZ];
  350. uint32_t nt_family;
  351. uint32_t nt_gc_thresh1;
  352. uint32_t nt_gc_thresh2;
  353. uint32_t nt_gc_thresh3;
  354. uint64_t nt_gc_interval;
  355. struct ndt_config nt_config;
  356. struct rtnl_neightbl_parms nt_parms;
  357. struct ndt_stats nt_stats;
  358. };
  359. struct rtnl_ratespec
  360. {
  361. uint8_t rs_cell_log;
  362. uint16_t rs_feature;
  363. uint16_t rs_addend;
  364. uint16_t rs_mpu;
  365. uint32_t rs_rate;
  366. };
  367. struct rtnl_tstats
  368. {
  369. struct {
  370. uint64_t bytes;
  371. uint64_t packets;
  372. } tcs_basic;
  373. struct {
  374. uint32_t bps;
  375. uint32_t pps;
  376. } tcs_rate_est;
  377. struct {
  378. uint32_t qlen;
  379. uint32_t backlog;
  380. uint32_t drops;
  381. uint32_t requeues;
  382. uint32_t overlimits;
  383. } tcs_queue;
  384. };
  385. #define TCKINDSIZ 32
  386. #define NL_TCA_GENERIC(pre) \
  387. NLHDR_COMMON \
  388. uint32_t pre ##_family; \
  389. uint32_t pre ##_ifindex; \
  390. uint32_t pre ##_handle; \
  391. uint32_t pre ##_parent; \
  392. uint32_t pre ##_info; \
  393. char pre ##_kind[TCKINDSIZ]; \
  394. struct nl_data * pre ##_opts; \
  395. uint64_t pre ##_stats[RTNL_TC_STATS_MAX+1]; \
  396. struct nl_data * pre ##_xstats; \
  397. void * pre ##_subdata; \
  398. struct rtnl_tca
  399. {
  400. NL_TCA_GENERIC(tc);
  401. };
  402. struct rtnl_qdisc
  403. {
  404. NL_TCA_GENERIC(q);
  405. struct rtnl_qdisc_ops *q_ops;
  406. };
  407. struct rtnl_class
  408. {
  409. NL_TCA_GENERIC(c);
  410. struct rtnl_class_ops *c_ops;
  411. };
  412. struct rtnl_cls
  413. {
  414. NL_TCA_GENERIC(c);
  415. uint32_t c_prio;
  416. uint32_t c_protocol;
  417. struct rtnl_cls_ops *c_ops;
  418. };
  419. struct rtnl_u32
  420. {
  421. uint32_t cu_divisor;
  422. uint32_t cu_hash;
  423. uint32_t cu_classid;
  424. uint32_t cu_link;
  425. struct nl_data * cu_pcnt;
  426. struct nl_data * cu_selector;
  427. struct nl_data * cu_act;
  428. struct nl_data * cu_police;
  429. char cu_indev[IFNAMSIZ];
  430. int cu_mask;
  431. };
  432. struct rtnl_fw
  433. {
  434. uint32_t cf_classid;
  435. struct nl_data * cf_act;
  436. struct nl_data * cf_police;
  437. char cf_indev[IFNAMSIZ];
  438. int cf_mask;
  439. };
  440. struct rtnl_dsmark_qdisc
  441. {
  442. uint16_t qdm_indices;
  443. uint16_t qdm_default_index;
  444. uint32_t qdm_set_tc_index;
  445. uint32_t qdm_mask;
  446. };
  447. struct rtnl_dsmark_class
  448. {
  449. uint8_t cdm_bmask;
  450. uint8_t cdm_value;
  451. uint32_t cdm_mask;
  452. };
  453. struct rtnl_fifo
  454. {
  455. uint32_t qf_limit;
  456. uint32_t qf_mask;
  457. };
  458. struct rtnl_prio
  459. {
  460. uint32_t qp_bands;
  461. uint8_t qp_priomap[TC_PRIO_MAX+1];
  462. uint32_t qp_mask;
  463. };
  464. struct rtnl_tbf
  465. {
  466. uint32_t qt_limit;
  467. uint32_t qt_mpu;
  468. struct rtnl_ratespec qt_rate;
  469. uint32_t qt_rate_bucket;
  470. uint32_t qt_rate_txtime;
  471. struct rtnl_ratespec qt_peakrate;
  472. uint32_t qt_peakrate_bucket;
  473. uint32_t qt_peakrate_txtime;
  474. uint32_t qt_mask;
  475. };
  476. struct rtnl_sfq
  477. {
  478. uint32_t qs_quantum;
  479. uint32_t qs_perturb;
  480. uint32_t qs_limit;
  481. uint32_t qs_divisor;
  482. uint32_t qs_flows;
  483. uint32_t qs_mask;
  484. };
  485. struct rtnl_netem_corr
  486. {
  487. uint32_t nmc_delay;
  488. uint32_t nmc_loss;
  489. uint32_t nmc_duplicate;
  490. };
  491. struct rtnl_netem_reo
  492. {
  493. uint32_t nmro_probability;
  494. uint32_t nmro_correlation;
  495. };
  496. struct rtnl_netem
  497. {
  498. uint32_t qnm_latency;
  499. uint32_t qnm_limit;
  500. uint32_t qnm_loss;
  501. uint32_t qnm_gap;
  502. uint32_t qnm_duplicate;
  503. uint32_t qnm_jitter;
  504. uint32_t qnm_mask;
  505. struct rtnl_netem_corr qnm_corr;
  506. struct rtnl_netem_reo qnm_ro;
  507. };
  508. struct rtnl_htb_qdisc
  509. {
  510. uint32_t qh_rate2quantum;
  511. uint32_t qh_defcls;
  512. uint32_t qh_mask;
  513. };
  514. struct rtnl_htb_class
  515. {
  516. uint32_t ch_prio;
  517. uint32_t ch_mtu;
  518. struct rtnl_ratespec ch_rate;
  519. struct rtnl_ratespec ch_ceil;
  520. uint32_t ch_rbuffer;
  521. uint32_t ch_cbuffer;
  522. uint32_t ch_quantum;
  523. uint8_t ch_overhead;
  524. uint8_t ch_mpu;
  525. uint32_t ch_mask;
  526. };
  527. struct rtnl_cbq
  528. {
  529. struct tc_cbq_lssopt cbq_lss;
  530. struct tc_ratespec cbq_rate;
  531. struct tc_cbq_wrropt cbq_wrr;
  532. struct tc_cbq_ovl cbq_ovl;
  533. struct tc_cbq_fopt cbq_fopt;
  534. struct tc_cbq_police cbq_police;
  535. };
  536. struct rtnl_red
  537. {
  538. uint32_t qr_limit;
  539. uint32_t qr_qth_min;
  540. uint32_t qr_qth_max;
  541. uint8_t qr_flags;
  542. uint8_t qr_wlog;
  543. uint8_t qr_plog;
  544. uint8_t qr_scell_log;
  545. uint32_t qr_mask;
  546. };
  547. struct flnl_request
  548. {
  549. NLHDR_COMMON
  550. struct nl_addr * lr_addr;
  551. uint32_t lr_fwmark;
  552. uint8_t lr_tos;
  553. uint8_t lr_scope;
  554. uint8_t lr_table;
  555. };
  556. struct flnl_result
  557. {
  558. NLHDR_COMMON
  559. struct flnl_request * fr_req;
  560. uint8_t fr_table_id;
  561. uint8_t fr_prefixlen;
  562. uint8_t fr_nh_sel;
  563. uint8_t fr_type;
  564. uint8_t fr_scope;
  565. uint32_t fr_error;
  566. };
  567. #define GENL_OP_HAS_POLICY 1
  568. #define GENL_OP_HAS_DOIT 2
  569. #define GENL_OP_HAS_DUMPIT 4
  570. struct genl_family_op
  571. {
  572. uint32_t o_id;
  573. uint32_t o_flags;
  574. struct nl_list_head o_list;
  575. };
  576. struct genl_family
  577. {
  578. NLHDR_COMMON
  579. uint16_t gf_id;
  580. char gf_name[GENL_NAMSIZ];
  581. uint32_t gf_version;
  582. uint32_t gf_hdrsize;
  583. uint32_t gf_maxattr;
  584. struct nl_list_head gf_ops;
  585. };
  586. union nfnl_ct_proto
  587. {
  588. struct {
  589. uint16_t src;
  590. uint16_t dst;
  591. } port;
  592. struct {
  593. uint16_t id;
  594. uint8_t type;
  595. uint8_t code;
  596. } icmp;
  597. };
  598. struct nfnl_ct_dir {
  599. struct nl_addr * src;
  600. struct nl_addr * dst;
  601. union nfnl_ct_proto proto;
  602. uint64_t packets;
  603. uint64_t bytes;
  604. };
  605. union nfnl_ct_protoinfo {
  606. struct {
  607. uint8_t state;
  608. } tcp;
  609. };
  610. struct nfnl_ct {
  611. NLHDR_COMMON
  612. uint8_t ct_family;
  613. uint8_t ct_proto;
  614. union nfnl_ct_protoinfo ct_protoinfo;
  615. uint32_t ct_status;
  616. uint32_t ct_status_mask;
  617. uint32_t ct_timeout;
  618. uint32_t ct_mark;
  619. uint32_t ct_use;
  620. uint32_t ct_id;
  621. struct nfnl_ct_dir ct_orig;
  622. struct nfnl_ct_dir ct_repl;
  623. };
  624. struct nfnl_log {
  625. NLHDR_COMMON
  626. uint8_t log_family;
  627. uint8_t log_hook;
  628. uint16_t log_hwproto;
  629. uint32_t log_mark;
  630. struct timeval log_timestamp;
  631. uint32_t log_indev;
  632. uint32_t log_outdev;
  633. uint32_t log_physindev;
  634. uint32_t log_physoutdev;
  635. uint8_t log_hwaddr[8];
  636. int log_hwaddr_len;
  637. void * log_payload;
  638. int log_payload_len;
  639. char * log_prefix;
  640. uint32_t log_uid;
  641. uint32_t log_seq;
  642. uint32_t log_seq_global;
  643. };
  644. #endif