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