netlink-types.h revision ef858fb492dfe98e3ae194264fbc73649cf8493a
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-2008 Thomas Graf <tgraf@suug.ch> 10 */ 11 12#ifndef NETLINK_LOCAL_TYPES_H_ 13#define NETLINK_LOCAL_TYPES_H_ 14 15#include <netlink/list.h> 16#include <netlink/route/link.h> 17#include <netlink/route/qdisc.h> 18#include <netlink/route/rtnl.h> 19#include <netlink/route/route.h> 20 21#define NL_SOCK_BUFSIZE_SET (1<<0) 22#define NL_SOCK_PASSCRED (1<<1) 23#define NL_OWN_PORT (1<<2) 24#define NL_MSG_PEEK (1<<3) 25#define NL_NO_AUTO_ACK (1<<4) 26 27#define NL_MSG_CRED_PRESENT 1 28 29struct nl_cache_ops; 30struct nl_sock; 31struct nl_object; 32 33struct nl_cb 34{ 35 nl_recvmsg_msg_cb_t cb_set[NL_CB_TYPE_MAX+1]; 36 void * cb_args[NL_CB_TYPE_MAX+1]; 37 38 nl_recvmsg_err_cb_t cb_err; 39 void * cb_err_arg; 40 41 /** May be used to replace nl_recvmsgs with your own implementation 42 * in all internal calls to nl_recvmsgs. */ 43 int (*cb_recvmsgs_ow)(struct nl_sock *, 44 struct nl_cb *); 45 46 /** Overwrite internal calls to nl_recv, must return the number of 47 * octets read and allocate a buffer for the received data. */ 48 int (*cb_recv_ow)(struct nl_sock *, 49 struct sockaddr_nl *, 50 unsigned char **, 51 struct ucred **); 52 53 /** Overwrites internal calls to nl_send, must send the netlink 54 * message. */ 55 int (*cb_send_ow)(struct nl_sock *, 56 struct nl_msg *); 57 58 int cb_refcnt; 59}; 60 61struct nl_sock 62{ 63 struct sockaddr_nl s_local; 64 struct sockaddr_nl s_peer; 65 int s_fd; 66 int s_proto; 67 unsigned int s_seq_next; 68 unsigned int s_seq_expect; 69 int s_flags; 70 struct nl_cb * s_cb; 71}; 72 73struct nl_cache 74{ 75 struct nl_list_head c_items; 76 int c_nitems; 77 int c_iarg1; 78 int c_iarg2; 79 struct nl_cache_ops * c_ops; 80}; 81 82struct nl_cache_assoc 83{ 84 struct nl_cache * ca_cache; 85 change_func_t ca_change; 86}; 87 88struct nl_cache_mngr 89{ 90 int cm_protocol; 91 int cm_flags; 92 int cm_nassocs; 93 struct nl_sock * cm_handle; 94 struct nl_cache_assoc * cm_assocs; 95}; 96 97struct nl_parser_param; 98 99#define LOOSE_COMPARISON 1 100 101#define NL_OBJ_MARK 1 102 103struct nl_object 104{ 105 NLHDR_COMMON 106}; 107 108struct nl_data 109{ 110 size_t d_size; 111 void * d_data; 112}; 113 114struct nl_addr 115{ 116 int a_family; 117 unsigned int a_maxsize; 118 unsigned int a_len; 119 int a_prefixlen; 120 int a_refcnt; 121 char a_addr[0]; 122}; 123 124struct nl_msg 125{ 126 int nm_protocol; 127 int nm_flags; 128 struct sockaddr_nl nm_src; 129 struct sockaddr_nl nm_dst; 130 struct ucred nm_creds; 131 struct nlmsghdr * nm_nlh; 132 size_t nm_size; 133 int nm_refcnt; 134}; 135 136struct rtnl_link_map 137{ 138 uint64_t lm_mem_start; 139 uint64_t lm_mem_end; 140 uint64_t lm_base_addr; 141 uint16_t lm_irq; 142 uint8_t lm_dma; 143 uint8_t lm_port; 144}; 145 146#define IFQDISCSIZ 32 147 148struct rtnl_link 149{ 150 NLHDR_COMMON 151 152 char l_name[IFNAMSIZ]; 153 154 uint32_t l_family; 155 uint32_t l_arptype; 156 uint32_t l_index; 157 uint32_t l_flags; 158 uint32_t l_change; 159 uint32_t l_mtu; 160 uint32_t l_link; 161 uint32_t l_txqlen; 162 uint32_t l_weight; 163 uint32_t l_master; 164 struct nl_addr *l_addr; 165 struct nl_addr *l_bcast; 166 char l_qdisc[IFQDISCSIZ]; 167 struct rtnl_link_map l_map; 168 uint64_t l_stats[RTNL_LINK_STATS_MAX+1]; 169 uint32_t l_flag_mask; 170 uint8_t l_operstate; 171 uint8_t l_linkmode; 172 /* 2 byte hole */ 173 struct rtnl_link_info_ops *l_info_ops; 174 void * l_info; 175}; 176 177struct rtnl_ncacheinfo 178{ 179 uint32_t nci_confirmed; /**< Time since neighbour validty was last confirmed */ 180 uint32_t nci_used; /**< Time since neighbour entry was last ued */ 181 uint32_t nci_updated; /**< Time since last update */ 182 uint32_t nci_refcnt; /**< Reference counter */ 183}; 184 185 186struct rtnl_neigh 187{ 188 NLHDR_COMMON 189 uint32_t n_family; 190 uint32_t n_ifindex; 191 uint16_t n_state; 192 uint8_t n_flags; 193 uint8_t n_type; 194 struct nl_addr *n_lladdr; 195 struct nl_addr *n_dst; 196 uint32_t n_probes; 197 struct rtnl_ncacheinfo n_cacheinfo; 198 uint32_t n_state_mask; 199 uint32_t n_flag_mask; 200}; 201 202 203struct rtnl_addr_cacheinfo 204{ 205 /* Preferred lifetime in seconds */ 206 uint32_t aci_prefered; 207 208 /* Valid lifetime in seconds */ 209 uint32_t aci_valid; 210 211 /* Timestamp of creation in 1/100s seince boottime */ 212 uint32_t aci_cstamp; 213 214 /* Timestamp of last update in 1/100s since boottime */ 215 uint32_t aci_tstamp; 216}; 217 218struct rtnl_addr 219{ 220 NLHDR_COMMON 221 222 uint8_t a_family; 223 uint8_t a_prefixlen; 224 uint8_t a_flags; 225 uint8_t a_scope; 226 uint32_t a_ifindex; 227 228 struct nl_addr *a_peer; 229 struct nl_addr *a_local; 230 struct nl_addr *a_bcast; 231 struct nl_addr *a_anycast; 232 struct nl_addr *a_multicast; 233 234 struct rtnl_addr_cacheinfo a_cacheinfo; 235 236 char a_label[IFNAMSIZ]; 237 uint32_t a_flag_mask; 238}; 239 240struct rtnl_nexthop 241{ 242 uint8_t rtnh_flags; 243 uint8_t rtnh_flag_mask; 244 uint8_t rtnh_weight; 245 /* 1 byte spare */ 246 uint32_t rtnh_ifindex; 247 struct nl_addr * rtnh_gateway; 248 uint32_t ce_mask; /* HACK to support attr macros */ 249 struct nl_list_head rtnh_list; 250 uint32_t rtnh_realms; 251}; 252 253struct rtnl_route 254{ 255 NLHDR_COMMON 256 257 uint8_t rt_family; 258 uint8_t rt_dst_len; 259 uint8_t rt_src_len; 260 uint8_t rt_tos; 261 uint8_t rt_protocol; 262 uint8_t rt_scope; 263 uint8_t rt_type; 264 uint8_t rt_nmetrics; 265 uint32_t rt_flags; 266 struct nl_addr * rt_dst; 267 struct nl_addr * rt_src; 268 uint32_t rt_table; 269 uint32_t rt_iif; 270 uint32_t rt_prio; 271 uint32_t rt_metrics[RTAX_MAX]; 272 uint32_t rt_metrics_mask; 273 uint32_t rt_nr_nh; 274 struct nl_addr * rt_pref_src; 275 struct nl_list_head rt_nexthops; 276 struct rtnl_rtcacheinfo rt_cacheinfo; 277 uint32_t rt_flag_mask; 278}; 279 280struct rtnl_rule 281{ 282 NLHDR_COMMON 283 284 uint64_t r_mark; 285 uint32_t r_prio; 286 uint32_t r_realms; 287 uint32_t r_table; 288 uint8_t r_dsfield; 289 uint8_t r_type; 290 uint8_t r_family; 291 uint8_t r_src_len; 292 uint8_t r_dst_len; 293 char r_iif[IFNAMSIZ]; 294 struct nl_addr *r_src; 295 struct nl_addr *r_dst; 296 struct nl_addr *r_srcmap; 297}; 298 299struct rtnl_neightbl_parms 300{ 301 /** 302 * Interface index of the device this parameter set is assigned 303 * to or 0 for the default set. 304 */ 305 uint32_t ntp_ifindex; 306 307 /** 308 * Number of references to this parameter set. 309 */ 310 uint32_t ntp_refcnt; 311 312 /** 313 * Queue length for pending arp requests, i.e. the number of 314 * packets which are accepted from other layers while the 315 * neighbour address is still being resolved 316 */ 317 uint32_t ntp_queue_len; 318 319 /** 320 * Number of requests to send to the user level ARP daemon. 321 * Specify 0 to disable. 322 */ 323 uint32_t ntp_app_probes; 324 325 /** 326 * Maximum number of retries for unicast solicitation. 327 */ 328 uint32_t ntp_ucast_probes; 329 330 /** 331 * Maximum number of retries for multicast solicitation. 332 */ 333 uint32_t ntp_mcast_probes; 334 335 /** 336 * Base value in milliseconds to ompute reachable time, see RFC2461. 337 */ 338 uint64_t ntp_base_reachable_time; 339 340 /** 341 * Actual reachable time (read-only) 342 */ 343 uint64_t ntp_reachable_time; /* secs */ 344 345 /** 346 * The time in milliseconds between retransmitted Neighbor 347 * Solicitation messages. 348 */ 349 uint64_t ntp_retrans_time; 350 351 /** 352 * Interval in milliseconds to check for stale neighbour 353 * entries. 354 */ 355 uint64_t ntp_gc_stale_time; /* secs */ 356 357 /** 358 * Delay in milliseconds for the first time probe if 359 * the neighbour is reachable. 360 */ 361 uint64_t ntp_probe_delay; /* secs */ 362 363 /** 364 * Maximum delay in milliseconds of an answer to a neighbour 365 * solicitation message. 366 */ 367 uint64_t ntp_anycast_delay; 368 369 /** 370 * Minimum age in milliseconds before a neighbour entry 371 * may be replaced. 372 */ 373 uint64_t ntp_locktime; 374 375 /** 376 * Delay in milliseconds before answering to an ARP request 377 * for which a proxy ARP entry exists. 378 */ 379 uint64_t ntp_proxy_delay; 380 381 /** 382 * Queue length for the delayed proxy arp requests. 383 */ 384 uint32_t ntp_proxy_qlen; 385 386 /** 387 * Mask of available parameter attributes 388 */ 389 uint32_t ntp_mask; 390}; 391 392#define NTBLNAMSIZ 32 393 394/** 395 * Neighbour table 396 * @ingroup neightbl 397 */ 398struct rtnl_neightbl 399{ 400 NLHDR_COMMON 401 402 char nt_name[NTBLNAMSIZ]; 403 uint32_t nt_family; 404 uint32_t nt_gc_thresh1; 405 uint32_t nt_gc_thresh2; 406 uint32_t nt_gc_thresh3; 407 uint64_t nt_gc_interval; 408 struct ndt_config nt_config; 409 struct rtnl_neightbl_parms nt_parms; 410 struct ndt_stats nt_stats; 411}; 412 413struct rtnl_ratespec 414{ 415 uint8_t rs_cell_log; 416 uint16_t rs_feature; 417 uint16_t rs_addend; 418 uint16_t rs_mpu; 419 uint32_t rs_rate; 420}; 421 422struct rtnl_tstats 423{ 424 struct { 425 uint64_t bytes; 426 uint64_t packets; 427 } tcs_basic; 428 429 struct { 430 uint32_t bps; 431 uint32_t pps; 432 } tcs_rate_est; 433 434 struct { 435 uint32_t qlen; 436 uint32_t backlog; 437 uint32_t drops; 438 uint32_t requeues; 439 uint32_t overlimits; 440 } tcs_queue; 441}; 442 443#define TCKINDSIZ 32 444 445#define NL_TCA_GENERIC(pre) \ 446 NLHDR_COMMON \ 447 uint32_t pre ##_family; \ 448 uint32_t pre ##_ifindex; \ 449 uint32_t pre ##_handle; \ 450 uint32_t pre ##_parent; \ 451 uint32_t pre ##_info; \ 452 char pre ##_kind[TCKINDSIZ]; \ 453 struct nl_data * pre ##_opts; \ 454 uint64_t pre ##_stats[RTNL_TC_STATS_MAX+1]; \ 455 struct nl_data * pre ##_xstats; \ 456 struct nl_data * pre ##_subdata; \ 457 458 459struct rtnl_tca 460{ 461 NL_TCA_GENERIC(tc); 462}; 463 464struct rtnl_qdisc 465{ 466 NL_TCA_GENERIC(q); 467 struct rtnl_qdisc_ops *q_ops; 468}; 469 470struct rtnl_class 471{ 472 NL_TCA_GENERIC(c); 473 struct rtnl_class_ops *c_ops; 474}; 475 476struct rtnl_cls 477{ 478 NL_TCA_GENERIC(c); 479 uint16_t c_prio; 480 uint16_t c_protocol; 481 struct rtnl_cls_ops *c_ops; 482}; 483 484struct rtnl_u32 485{ 486 uint32_t cu_divisor; 487 uint32_t cu_hash; 488 uint32_t cu_classid; 489 uint32_t cu_link; 490 struct nl_data * cu_pcnt; 491 struct nl_data * cu_selector; 492 struct nl_data * cu_act; 493 struct nl_data * cu_police; 494 char cu_indev[IFNAMSIZ]; 495 int cu_mask; 496}; 497 498struct rtnl_cgroup 499{ 500 struct rtnl_ematch_tree *cg_ematch; 501 int cg_mask; 502}; 503 504struct rtnl_fw 505{ 506 uint32_t cf_classid; 507 struct nl_data * cf_act; 508 struct nl_data * cf_police; 509 char cf_indev[IFNAMSIZ]; 510 int cf_mask; 511}; 512 513struct rtnl_ematch 514{ 515 uint16_t e_id; 516 uint16_t e_kind; 517 uint16_t e_flags; 518 519 struct nl_list_head e_childs; 520 struct nl_list_head e_list; 521 struct rtnl_ematch_ops *e_ops; 522 523 char e_data[0]; 524}; 525 526struct rtnl_ematch_tree 527{ 528 uint16_t et_progid; 529 struct nl_list_head et_list; 530 531}; 532 533struct rtnl_dsmark_qdisc 534{ 535 uint16_t qdm_indices; 536 uint16_t qdm_default_index; 537 uint32_t qdm_set_tc_index; 538 uint32_t qdm_mask; 539}; 540 541struct rtnl_dsmark_class 542{ 543 uint8_t cdm_bmask; 544 uint8_t cdm_value; 545 uint32_t cdm_mask; 546}; 547 548struct rtnl_fifo 549{ 550 uint32_t qf_limit; 551 uint32_t qf_mask; 552}; 553 554struct rtnl_prio 555{ 556 uint32_t qp_bands; 557 uint8_t qp_priomap[TC_PRIO_MAX+1]; 558 uint32_t qp_mask; 559}; 560 561struct rtnl_tbf 562{ 563 uint32_t qt_limit; 564 uint32_t qt_mpu; 565 struct rtnl_ratespec qt_rate; 566 uint32_t qt_rate_bucket; 567 uint32_t qt_rate_txtime; 568 struct rtnl_ratespec qt_peakrate; 569 uint32_t qt_peakrate_bucket; 570 uint32_t qt_peakrate_txtime; 571 uint32_t qt_mask; 572}; 573 574struct rtnl_sfq 575{ 576 uint32_t qs_quantum; 577 uint32_t qs_perturb; 578 uint32_t qs_limit; 579 uint32_t qs_divisor; 580 uint32_t qs_flows; 581 uint32_t qs_mask; 582}; 583 584struct rtnl_netem_corr 585{ 586 uint32_t nmc_delay; 587 uint32_t nmc_loss; 588 uint32_t nmc_duplicate; 589}; 590 591struct rtnl_netem_reo 592{ 593 uint32_t nmro_probability; 594 uint32_t nmro_correlation; 595}; 596 597struct rtnl_netem_crpt 598{ 599 uint32_t nmcr_probability; 600 uint32_t nmcr_correlation; 601}; 602 603struct rtnl_netem_dist 604{ 605 int16_t * dist_data; 606 size_t dist_size; 607}; 608 609struct rtnl_netem 610{ 611 uint32_t qnm_latency; 612 uint32_t qnm_limit; 613 uint32_t qnm_loss; 614 uint32_t qnm_gap; 615 uint32_t qnm_duplicate; 616 uint32_t qnm_jitter; 617 uint32_t qnm_mask; 618 struct rtnl_netem_corr qnm_corr; 619 struct rtnl_netem_reo qnm_ro; 620 struct rtnl_netem_crpt qnm_crpt; 621 struct rtnl_netem_dist qnm_dist; 622}; 623 624struct rtnl_htb_qdisc 625{ 626 uint32_t qh_rate2quantum; 627 uint32_t qh_defcls; 628 uint32_t qh_mask; 629}; 630 631struct rtnl_htb_class 632{ 633 uint32_t ch_prio; 634 uint32_t ch_mtu; 635 struct rtnl_ratespec ch_rate; 636 struct rtnl_ratespec ch_ceil; 637 uint32_t ch_rbuffer; 638 uint32_t ch_cbuffer; 639 uint32_t ch_quantum; 640 uint8_t ch_overhead; 641 uint8_t ch_mpu; 642 uint32_t ch_mask; 643}; 644 645struct rtnl_cbq 646{ 647 struct tc_cbq_lssopt cbq_lss; 648 struct tc_ratespec cbq_rate; 649 struct tc_cbq_wrropt cbq_wrr; 650 struct tc_cbq_ovl cbq_ovl; 651 struct tc_cbq_fopt cbq_fopt; 652 struct tc_cbq_police cbq_police; 653}; 654 655struct rtnl_red 656{ 657 uint32_t qr_limit; 658 uint32_t qr_qth_min; 659 uint32_t qr_qth_max; 660 uint8_t qr_flags; 661 uint8_t qr_wlog; 662 uint8_t qr_plog; 663 uint8_t qr_scell_log; 664 uint32_t qr_mask; 665}; 666 667struct flnl_request 668{ 669 NLHDR_COMMON 670 671 struct nl_addr * lr_addr; 672 uint32_t lr_fwmark; 673 uint8_t lr_tos; 674 uint8_t lr_scope; 675 uint8_t lr_table; 676}; 677 678 679struct flnl_result 680{ 681 NLHDR_COMMON 682 683 struct flnl_request * fr_req; 684 uint8_t fr_table_id; 685 uint8_t fr_prefixlen; 686 uint8_t fr_nh_sel; 687 uint8_t fr_type; 688 uint8_t fr_scope; 689 uint32_t fr_error; 690}; 691 692#define GENL_OP_HAS_POLICY 1 693#define GENL_OP_HAS_DOIT 2 694#define GENL_OP_HAS_DUMPIT 4 695 696struct genl_family_op 697{ 698 uint32_t o_id; 699 uint32_t o_flags; 700 701 struct nl_list_head o_list; 702}; 703 704struct genl_family 705{ 706 NLHDR_COMMON 707 708 uint16_t gf_id; 709 char gf_name[GENL_NAMSIZ]; 710 uint32_t gf_version; 711 uint32_t gf_hdrsize; 712 uint32_t gf_maxattr; 713 714 struct nl_list_head gf_ops; 715}; 716 717union nfnl_ct_proto 718{ 719 struct { 720 uint16_t src; 721 uint16_t dst; 722 } port; 723 struct { 724 uint16_t id; 725 uint8_t type; 726 uint8_t code; 727 } icmp; 728}; 729 730struct nfnl_ct_dir { 731 struct nl_addr * src; 732 struct nl_addr * dst; 733 union nfnl_ct_proto proto; 734 uint64_t packets; 735 uint64_t bytes; 736}; 737 738union nfnl_ct_protoinfo { 739 struct { 740 uint8_t state; 741 } tcp; 742}; 743 744struct nfnl_ct { 745 NLHDR_COMMON 746 747 uint8_t ct_family; 748 uint8_t ct_proto; 749 union nfnl_ct_protoinfo ct_protoinfo; 750 751 uint32_t ct_status; 752 uint32_t ct_status_mask; 753 uint32_t ct_timeout; 754 uint32_t ct_mark; 755 uint32_t ct_use; 756 uint32_t ct_id; 757 758 struct nfnl_ct_dir ct_orig; 759 struct nfnl_ct_dir ct_repl; 760}; 761 762struct nfnl_log { 763 NLHDR_COMMON 764 765 uint16_t log_group; 766 uint8_t log_copy_mode; 767 uint32_t log_copy_range; 768 uint32_t log_flush_timeout; 769 uint32_t log_alloc_size; 770 uint32_t log_queue_threshold; 771 uint32_t log_flags; 772 uint32_t log_flag_mask; 773}; 774 775struct nfnl_log_msg { 776 NLHDR_COMMON 777 778 uint8_t log_msg_family; 779 uint8_t log_msg_hook; 780 uint16_t log_msg_hwproto; 781 uint32_t log_msg_mark; 782 struct timeval log_msg_timestamp; 783 uint32_t log_msg_indev; 784 uint32_t log_msg_outdev; 785 uint32_t log_msg_physindev; 786 uint32_t log_msg_physoutdev; 787 uint8_t log_msg_hwaddr[8]; 788 int log_msg_hwaddr_len; 789 void * log_msg_payload; 790 int log_msg_payload_len; 791 char * log_msg_prefix; 792 uint32_t log_msg_uid; 793 uint32_t log_msg_gid; 794 uint32_t log_msg_seq; 795 uint32_t log_msg_seq_global; 796}; 797 798struct nfnl_queue { 799 NLHDR_COMMON 800 801 uint16_t queue_group; 802 uint32_t queue_maxlen; 803 uint32_t queue_copy_range; 804 uint8_t queue_copy_mode; 805}; 806 807struct nfnl_queue_msg { 808 NLHDR_COMMON 809 810 uint16_t queue_msg_group; 811 uint8_t queue_msg_family; 812 uint8_t queue_msg_hook; 813 uint16_t queue_msg_hwproto; 814 uint32_t queue_msg_packetid; 815 uint32_t queue_msg_mark; 816 struct timeval queue_msg_timestamp; 817 uint32_t queue_msg_indev; 818 uint32_t queue_msg_outdev; 819 uint32_t queue_msg_physindev; 820 uint32_t queue_msg_physoutdev; 821 uint8_t queue_msg_hwaddr[8]; 822 int queue_msg_hwaddr_len; 823 void * queue_msg_payload; 824 int queue_msg_payload_len; 825 uint32_t queue_msg_verdict; 826}; 827 828#endif 829