diff options
Diffstat (limited to 'include/linux/rtnetlink.h')
-rw-r--r-- | include/linux/rtnetlink.h | 376 |
1 files changed, 18 insertions, 358 deletions
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h index facd9ee37b76..9c92dc8b9a08 100644 --- a/include/linux/rtnetlink.h +++ b/include/linux/rtnetlink.h | |||
@@ -2,6 +2,7 @@ | |||
2 | #define __LINUX_RTNETLINK_H | 2 | #define __LINUX_RTNETLINK_H |
3 | 3 | ||
4 | #include <linux/netlink.h> | 4 | #include <linux/netlink.h> |
5 | #include <linux/if.h> | ||
5 | 6 | ||
6 | /**** | 7 | /**** |
7 | * Routing/neighbour discovery messages. | 8 | * Routing/neighbour discovery messages. |
@@ -238,10 +239,8 @@ enum rt_class_t | |||
238 | RT_TABLE_DEFAULT=253, | 239 | RT_TABLE_DEFAULT=253, |
239 | RT_TABLE_MAIN=254, | 240 | RT_TABLE_MAIN=254, |
240 | RT_TABLE_LOCAL=255, | 241 | RT_TABLE_LOCAL=255, |
241 | __RT_TABLE_MAX | 242 | RT_TABLE_MAX=0xFFFFFFFF |
242 | }; | 243 | }; |
243 | #define RT_TABLE_MAX (__RT_TABLE_MAX - 1) | ||
244 | |||
245 | 244 | ||
246 | 245 | ||
247 | /* Routing message attributes */ | 246 | /* Routing message attributes */ |
@@ -263,6 +262,7 @@ enum rtattr_type_t | |||
263 | RTA_CACHEINFO, | 262 | RTA_CACHEINFO, |
264 | RTA_SESSION, | 263 | RTA_SESSION, |
265 | RTA_MP_ALGO, | 264 | RTA_MP_ALGO, |
265 | RTA_TABLE, | ||
266 | __RTA_MAX | 266 | __RTA_MAX |
267 | }; | 267 | }; |
268 | 268 | ||
@@ -383,226 +383,6 @@ struct rta_session | |||
383 | } u; | 383 | } u; |
384 | }; | 384 | }; |
385 | 385 | ||
386 | |||
387 | /********************************************************* | ||
388 | * Interface address. | ||
389 | ****/ | ||
390 | |||
391 | struct ifaddrmsg | ||
392 | { | ||
393 | unsigned char ifa_family; | ||
394 | unsigned char ifa_prefixlen; /* The prefix length */ | ||
395 | unsigned char ifa_flags; /* Flags */ | ||
396 | unsigned char ifa_scope; /* See above */ | ||
397 | int ifa_index; /* Link index */ | ||
398 | }; | ||
399 | |||
400 | enum | ||
401 | { | ||
402 | IFA_UNSPEC, | ||
403 | IFA_ADDRESS, | ||
404 | IFA_LOCAL, | ||
405 | IFA_LABEL, | ||
406 | IFA_BROADCAST, | ||
407 | IFA_ANYCAST, | ||
408 | IFA_CACHEINFO, | ||
409 | IFA_MULTICAST, | ||
410 | __IFA_MAX | ||
411 | }; | ||
412 | |||
413 | #define IFA_MAX (__IFA_MAX - 1) | ||
414 | |||
415 | /* ifa_flags */ | ||
416 | |||
417 | #define IFA_F_SECONDARY 0x01 | ||
418 | #define IFA_F_TEMPORARY IFA_F_SECONDARY | ||
419 | |||
420 | #define IFA_F_DEPRECATED 0x20 | ||
421 | #define IFA_F_TENTATIVE 0x40 | ||
422 | #define IFA_F_PERMANENT 0x80 | ||
423 | |||
424 | struct ifa_cacheinfo | ||
425 | { | ||
426 | __u32 ifa_prefered; | ||
427 | __u32 ifa_valid; | ||
428 | __u32 cstamp; /* created timestamp, hundredths of seconds */ | ||
429 | __u32 tstamp; /* updated timestamp, hundredths of seconds */ | ||
430 | }; | ||
431 | |||
432 | |||
433 | #define IFA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifaddrmsg)))) | ||
434 | #define IFA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifaddrmsg)) | ||
435 | |||
436 | /* | ||
437 | Important comment: | ||
438 | IFA_ADDRESS is prefix address, rather than local interface address. | ||
439 | It makes no difference for normally configured broadcast interfaces, | ||
440 | but for point-to-point IFA_ADDRESS is DESTINATION address, | ||
441 | local address is supplied in IFA_LOCAL attribute. | ||
442 | */ | ||
443 | |||
444 | /************************************************************** | ||
445 | * Neighbour discovery. | ||
446 | ****/ | ||
447 | |||
448 | struct ndmsg | ||
449 | { | ||
450 | unsigned char ndm_family; | ||
451 | unsigned char ndm_pad1; | ||
452 | unsigned short ndm_pad2; | ||
453 | int ndm_ifindex; /* Link index */ | ||
454 | __u16 ndm_state; | ||
455 | __u8 ndm_flags; | ||
456 | __u8 ndm_type; | ||
457 | }; | ||
458 | |||
459 | enum | ||
460 | { | ||
461 | NDA_UNSPEC, | ||
462 | NDA_DST, | ||
463 | NDA_LLADDR, | ||
464 | NDA_CACHEINFO, | ||
465 | NDA_PROBES, | ||
466 | __NDA_MAX | ||
467 | }; | ||
468 | |||
469 | #define NDA_MAX (__NDA_MAX - 1) | ||
470 | |||
471 | #define NDA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ndmsg)))) | ||
472 | #define NDA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ndmsg)) | ||
473 | |||
474 | /* | ||
475 | * Neighbor Cache Entry Flags | ||
476 | */ | ||
477 | |||
478 | #define NTF_PROXY 0x08 /* == ATF_PUBL */ | ||
479 | #define NTF_ROUTER 0x80 | ||
480 | |||
481 | /* | ||
482 | * Neighbor Cache Entry States. | ||
483 | */ | ||
484 | |||
485 | #define NUD_INCOMPLETE 0x01 | ||
486 | #define NUD_REACHABLE 0x02 | ||
487 | #define NUD_STALE 0x04 | ||
488 | #define NUD_DELAY 0x08 | ||
489 | #define NUD_PROBE 0x10 | ||
490 | #define NUD_FAILED 0x20 | ||
491 | |||
492 | /* Dummy states */ | ||
493 | #define NUD_NOARP 0x40 | ||
494 | #define NUD_PERMANENT 0x80 | ||
495 | #define NUD_NONE 0x00 | ||
496 | |||
497 | |||
498 | struct nda_cacheinfo | ||
499 | { | ||
500 | __u32 ndm_confirmed; | ||
501 | __u32 ndm_used; | ||
502 | __u32 ndm_updated; | ||
503 | __u32 ndm_refcnt; | ||
504 | }; | ||
505 | |||
506 | |||
507 | /***************************************************************** | ||
508 | * Neighbour tables specific messages. | ||
509 | * | ||
510 | * To retrieve the neighbour tables send RTM_GETNEIGHTBL with the | ||
511 | * NLM_F_DUMP flag set. Every neighbour table configuration is | ||
512 | * spread over multiple messages to avoid running into message | ||
513 | * size limits on systems with many interfaces. The first message | ||
514 | * in the sequence transports all not device specific data such as | ||
515 | * statistics, configuration, and the default parameter set. | ||
516 | * This message is followed by 0..n messages carrying device | ||
517 | * specific parameter sets. | ||
518 | * Although the ordering should be sufficient, NDTA_NAME can be | ||
519 | * used to identify sequences. The initial message can be identified | ||
520 | * by checking for NDTA_CONFIG. The device specific messages do | ||
521 | * not contain this TLV but have NDTPA_IFINDEX set to the | ||
522 | * corresponding interface index. | ||
523 | * | ||
524 | * To change neighbour table attributes, send RTM_SETNEIGHTBL | ||
525 | * with NDTA_NAME set. Changeable attribute include NDTA_THRESH[1-3], | ||
526 | * NDTA_GC_INTERVAL, and all TLVs in NDTA_PARMS unless marked | ||
527 | * otherwise. Device specific parameter sets can be changed by | ||
528 | * setting NDTPA_IFINDEX to the interface index of the corresponding | ||
529 | * device. | ||
530 | ****/ | ||
531 | |||
532 | struct ndt_stats | ||
533 | { | ||
534 | __u64 ndts_allocs; | ||
535 | __u64 ndts_destroys; | ||
536 | __u64 ndts_hash_grows; | ||
537 | __u64 ndts_res_failed; | ||
538 | __u64 ndts_lookups; | ||
539 | __u64 ndts_hits; | ||
540 | __u64 ndts_rcv_probes_mcast; | ||
541 | __u64 ndts_rcv_probes_ucast; | ||
542 | __u64 ndts_periodic_gc_runs; | ||
543 | __u64 ndts_forced_gc_runs; | ||
544 | }; | ||
545 | |||
546 | enum { | ||
547 | NDTPA_UNSPEC, | ||
548 | NDTPA_IFINDEX, /* u32, unchangeable */ | ||
549 | NDTPA_REFCNT, /* u32, read-only */ | ||
550 | NDTPA_REACHABLE_TIME, /* u64, read-only, msecs */ | ||
551 | NDTPA_BASE_REACHABLE_TIME, /* u64, msecs */ | ||
552 | NDTPA_RETRANS_TIME, /* u64, msecs */ | ||
553 | NDTPA_GC_STALETIME, /* u64, msecs */ | ||
554 | NDTPA_DELAY_PROBE_TIME, /* u64, msecs */ | ||
555 | NDTPA_QUEUE_LEN, /* u32 */ | ||
556 | NDTPA_APP_PROBES, /* u32 */ | ||
557 | NDTPA_UCAST_PROBES, /* u32 */ | ||
558 | NDTPA_MCAST_PROBES, /* u32 */ | ||
559 | NDTPA_ANYCAST_DELAY, /* u64, msecs */ | ||
560 | NDTPA_PROXY_DELAY, /* u64, msecs */ | ||
561 | NDTPA_PROXY_QLEN, /* u32 */ | ||
562 | NDTPA_LOCKTIME, /* u64, msecs */ | ||
563 | __NDTPA_MAX | ||
564 | }; | ||
565 | #define NDTPA_MAX (__NDTPA_MAX - 1) | ||
566 | |||
567 | struct ndtmsg | ||
568 | { | ||
569 | __u8 ndtm_family; | ||
570 | __u8 ndtm_pad1; | ||
571 | __u16 ndtm_pad2; | ||
572 | }; | ||
573 | |||
574 | struct ndt_config | ||
575 | { | ||
576 | __u16 ndtc_key_len; | ||
577 | __u16 ndtc_entry_size; | ||
578 | __u32 ndtc_entries; | ||
579 | __u32 ndtc_last_flush; /* delta to now in msecs */ | ||
580 | __u32 ndtc_last_rand; /* delta to now in msecs */ | ||
581 | __u32 ndtc_hash_rnd; | ||
582 | __u32 ndtc_hash_mask; | ||
583 | __u32 ndtc_hash_chain_gc; | ||
584 | __u32 ndtc_proxy_qlen; | ||
585 | }; | ||
586 | |||
587 | enum { | ||
588 | NDTA_UNSPEC, | ||
589 | NDTA_NAME, /* char *, unchangeable */ | ||
590 | NDTA_THRESH1, /* u32 */ | ||
591 | NDTA_THRESH2, /* u32 */ | ||
592 | NDTA_THRESH3, /* u32 */ | ||
593 | NDTA_CONFIG, /* struct ndt_config, read-only */ | ||
594 | NDTA_PARMS, /* nested TLV NDTPA_* */ | ||
595 | NDTA_STATS, /* struct ndt_stats, read-only */ | ||
596 | NDTA_GC_INTERVAL, /* u64, msecs */ | ||
597 | __NDTA_MAX | ||
598 | }; | ||
599 | #define NDTA_MAX (__NDTA_MAX - 1) | ||
600 | |||
601 | #define NDTA_RTA(r) ((struct rtattr*)(((char*)(r)) + \ | ||
602 | NLMSG_ALIGN(sizeof(struct ndtmsg)))) | ||
603 | #define NDTA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ndtmsg)) | ||
604 | |||
605 | |||
606 | /**** | 386 | /**** |
607 | * General form of address family dependent message. | 387 | * General form of address family dependent message. |
608 | ****/ | 388 | ****/ |
@@ -663,138 +443,6 @@ struct prefix_cacheinfo | |||
663 | __u32 valid_time; | 443 | __u32 valid_time; |
664 | }; | 444 | }; |
665 | 445 | ||
666 | /* The struct should be in sync with struct net_device_stats */ | ||
667 | struct rtnl_link_stats | ||
668 | { | ||
669 | __u32 rx_packets; /* total packets received */ | ||
670 | __u32 tx_packets; /* total packets transmitted */ | ||
671 | __u32 rx_bytes; /* total bytes received */ | ||
672 | __u32 tx_bytes; /* total bytes transmitted */ | ||
673 | __u32 rx_errors; /* bad packets received */ | ||
674 | __u32 tx_errors; /* packet transmit problems */ | ||
675 | __u32 rx_dropped; /* no space in linux buffers */ | ||
676 | __u32 tx_dropped; /* no space available in linux */ | ||
677 | __u32 multicast; /* multicast packets received */ | ||
678 | __u32 collisions; | ||
679 | |||
680 | /* detailed rx_errors: */ | ||
681 | __u32 rx_length_errors; | ||
682 | __u32 rx_over_errors; /* receiver ring buff overflow */ | ||
683 | __u32 rx_crc_errors; /* recved pkt with crc error */ | ||
684 | __u32 rx_frame_errors; /* recv'd frame alignment error */ | ||
685 | __u32 rx_fifo_errors; /* recv'r fifo overrun */ | ||
686 | __u32 rx_missed_errors; /* receiver missed packet */ | ||
687 | |||
688 | /* detailed tx_errors */ | ||
689 | __u32 tx_aborted_errors; | ||
690 | __u32 tx_carrier_errors; | ||
691 | __u32 tx_fifo_errors; | ||
692 | __u32 tx_heartbeat_errors; | ||
693 | __u32 tx_window_errors; | ||
694 | |||
695 | /* for cslip etc */ | ||
696 | __u32 rx_compressed; | ||
697 | __u32 tx_compressed; | ||
698 | }; | ||
699 | |||
700 | /* The struct should be in sync with struct ifmap */ | ||
701 | struct rtnl_link_ifmap | ||
702 | { | ||
703 | __u64 mem_start; | ||
704 | __u64 mem_end; | ||
705 | __u64 base_addr; | ||
706 | __u16 irq; | ||
707 | __u8 dma; | ||
708 | __u8 port; | ||
709 | }; | ||
710 | |||
711 | enum | ||
712 | { | ||
713 | IFLA_UNSPEC, | ||
714 | IFLA_ADDRESS, | ||
715 | IFLA_BROADCAST, | ||
716 | IFLA_IFNAME, | ||
717 | IFLA_MTU, | ||
718 | IFLA_LINK, | ||
719 | IFLA_QDISC, | ||
720 | IFLA_STATS, | ||
721 | IFLA_COST, | ||
722 | #define IFLA_COST IFLA_COST | ||
723 | IFLA_PRIORITY, | ||
724 | #define IFLA_PRIORITY IFLA_PRIORITY | ||
725 | IFLA_MASTER, | ||
726 | #define IFLA_MASTER IFLA_MASTER | ||
727 | IFLA_WIRELESS, /* Wireless Extension event - see wireless.h */ | ||
728 | #define IFLA_WIRELESS IFLA_WIRELESS | ||
729 | IFLA_PROTINFO, /* Protocol specific information for a link */ | ||
730 | #define IFLA_PROTINFO IFLA_PROTINFO | ||
731 | IFLA_TXQLEN, | ||
732 | #define IFLA_TXQLEN IFLA_TXQLEN | ||
733 | IFLA_MAP, | ||
734 | #define IFLA_MAP IFLA_MAP | ||
735 | IFLA_WEIGHT, | ||
736 | #define IFLA_WEIGHT IFLA_WEIGHT | ||
737 | IFLA_OPERSTATE, | ||
738 | IFLA_LINKMODE, | ||
739 | __IFLA_MAX | ||
740 | }; | ||
741 | |||
742 | |||
743 | #define IFLA_MAX (__IFLA_MAX - 1) | ||
744 | |||
745 | #define IFLA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg)))) | ||
746 | #define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg)) | ||
747 | |||
748 | /* ifi_flags. | ||
749 | |||
750 | IFF_* flags. | ||
751 | |||
752 | The only change is: | ||
753 | IFF_LOOPBACK, IFF_BROADCAST and IFF_POINTOPOINT are | ||
754 | more not changeable by user. They describe link media | ||
755 | characteristics and set by device driver. | ||
756 | |||
757 | Comments: | ||
758 | - Combination IFF_BROADCAST|IFF_POINTOPOINT is invalid | ||
759 | - If neither of these three flags are set; | ||
760 | the interface is NBMA. | ||
761 | |||
762 | - IFF_MULTICAST does not mean anything special: | ||
763 | multicasts can be used on all not-NBMA links. | ||
764 | IFF_MULTICAST means that this media uses special encapsulation | ||
765 | for multicast frames. Apparently, all IFF_POINTOPOINT and | ||
766 | IFF_BROADCAST devices are able to use multicasts too. | ||
767 | */ | ||
768 | |||
769 | /* IFLA_LINK. | ||
770 | For usual devices it is equal ifi_index. | ||
771 | If it is a "virtual interface" (f.e. tunnel), ifi_link | ||
772 | can point to real physical interface (f.e. for bandwidth calculations), | ||
773 | or maybe 0, what means, that real media is unknown (usual | ||
774 | for IPIP tunnels, when route to endpoint is allowed to change) | ||
775 | */ | ||
776 | |||
777 | /* Subtype attributes for IFLA_PROTINFO */ | ||
778 | enum | ||
779 | { | ||
780 | IFLA_INET6_UNSPEC, | ||
781 | IFLA_INET6_FLAGS, /* link flags */ | ||
782 | IFLA_INET6_CONF, /* sysctl parameters */ | ||
783 | IFLA_INET6_STATS, /* statistics */ | ||
784 | IFLA_INET6_MCAST, /* MC things. What of them? */ | ||
785 | IFLA_INET6_CACHEINFO, /* time values and max reasm size */ | ||
786 | __IFLA_INET6_MAX | ||
787 | }; | ||
788 | |||
789 | #define IFLA_INET6_MAX (__IFLA_INET6_MAX - 1) | ||
790 | |||
791 | struct ifla_cacheinfo | ||
792 | { | ||
793 | __u32 max_reasm_len; | ||
794 | __u32 tstamp; /* ipv6InterfaceTable updated timestamp */ | ||
795 | __u32 reachable_time; | ||
796 | __u32 retrans_time; | ||
797 | }; | ||
798 | 446 | ||
799 | /***************************************************************** | 447 | /***************************************************************** |
800 | * Traffic control messages. | 448 | * Traffic control messages. |
@@ -885,10 +533,13 @@ enum rtnetlink_groups { | |||
885 | RTNLGRP_NOP2, | 533 | RTNLGRP_NOP2, |
886 | RTNLGRP_DECnet_ROUTE, | 534 | RTNLGRP_DECnet_ROUTE, |
887 | #define RTNLGRP_DECnet_ROUTE RTNLGRP_DECnet_ROUTE | 535 | #define RTNLGRP_DECnet_ROUTE RTNLGRP_DECnet_ROUTE |
888 | RTNLGRP_NOP3, | 536 | RTNLGRP_DECnet_RULE, |
537 | #define RTNLGRP_DECnet_RULE RTNLGRP_DECnet_RULE | ||
889 | RTNLGRP_NOP4, | 538 | RTNLGRP_NOP4, |
890 | RTNLGRP_IPV6_PREFIX, | 539 | RTNLGRP_IPV6_PREFIX, |
891 | #define RTNLGRP_IPV6_PREFIX RTNLGRP_IPV6_PREFIX | 540 | #define RTNLGRP_IPV6_PREFIX RTNLGRP_IPV6_PREFIX |
541 | RTNLGRP_IPV6_RULE, | ||
542 | #define RTNLGRP_IPV6_RULE RTNLGRP_IPV6_RULE | ||
892 | __RTNLGRP_MAX | 543 | __RTNLGRP_MAX |
893 | }; | 544 | }; |
894 | #define RTNLGRP_MAX (__RTNLGRP_MAX - 1) | 545 | #define RTNLGRP_MAX (__RTNLGRP_MAX - 1) |
@@ -923,8 +574,6 @@ extern int rtattr_parse(struct rtattr *tb[], int maxattr, struct rtattr *rta, in | |||
923 | #define rtattr_parse_nested(tb, max, rta) \ | 574 | #define rtattr_parse_nested(tb, max, rta) \ |
924 | rtattr_parse((tb), (max), RTA_DATA((rta)), RTA_PAYLOAD((rta))) | 575 | rtattr_parse((tb), (max), RTA_DATA((rta)), RTA_PAYLOAD((rta))) |
925 | 576 | ||
926 | extern struct sock *rtnl; | ||
927 | |||
928 | struct rtnetlink_link | 577 | struct rtnetlink_link |
929 | { | 578 | { |
930 | int (*doit)(struct sk_buff *, struct nlmsghdr*, void *attr); | 579 | int (*doit)(struct sk_buff *, struct nlmsghdr*, void *attr); |
@@ -933,6 +582,10 @@ struct rtnetlink_link | |||
933 | 582 | ||
934 | extern struct rtnetlink_link * rtnetlink_links[NPROTO]; | 583 | extern struct rtnetlink_link * rtnetlink_links[NPROTO]; |
935 | extern int rtnetlink_send(struct sk_buff *skb, u32 pid, u32 group, int echo); | 584 | extern int rtnetlink_send(struct sk_buff *skb, u32 pid, u32 group, int echo); |
585 | extern int rtnl_unicast(struct sk_buff *skb, u32 pid); | ||
586 | extern int rtnl_notify(struct sk_buff *skb, u32 pid, u32 group, | ||
587 | struct nlmsghdr *nlh, gfp_t flags); | ||
588 | extern void rtnl_set_sk_err(u32 group, int error); | ||
936 | extern int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics); | 589 | extern int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics); |
937 | 590 | ||
938 | extern void __rta_fill(struct sk_buff *skb, int attrtype, int attrlen, const void *data); | 591 | extern void __rta_fill(struct sk_buff *skb, int attrtype, int attrlen, const void *data); |
@@ -1065,6 +718,13 @@ extern void __rtnl_unlock(void); | |||
1065 | } \ | 718 | } \ |
1066 | } while(0) | 719 | } while(0) |
1067 | 720 | ||
721 | static inline u32 rtm_get_table(struct rtattr **rta, u8 table) | ||
722 | { | ||
723 | return RTA_GET_U32(rta[RTA_TABLE-1]); | ||
724 | rtattr_failure: | ||
725 | return table; | ||
726 | } | ||
727 | |||
1068 | #endif /* __KERNEL__ */ | 728 | #endif /* __KERNEL__ */ |
1069 | 729 | ||
1070 | 730 | ||