00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef PRIV_NETLINK_H
00016 #define PRIV_NETLINK_H
00017
00018
00019
00020
00021
00022
00023 #ifndef IFF_LOWER_UP
00024 #define IFF_LOWER_UP 0x10000
00025 #endif
00026 #ifndef IFF_DORMANT
00027 #define IFF_DORMANT 0x20000
00028 #endif
00029
00030 #ifndef IFLA_IFNAME
00031 #define IFLA_IFNAME 3
00032 #endif
00033 #ifndef IFLA_WIRELESS
00034 #define IFLA_WIRELESS 11
00035 #endif
00036 #ifndef IFLA_OPERSTATE
00037 #define IFLA_OPERSTATE 16
00038 #endif
00039 #ifndef IFLA_LINKMODE
00040 #define IFLA_LINKMODE 17
00041 #define IF_OPER_DORMANT 5
00042 #define IF_OPER_UP 6
00043 #endif
00044
00045 #define NLM_F_REQUEST 1
00046
00047 #define NETLINK_ROUTE 0
00048 #define RTMGRP_LINK 1
00049 #define RTM_BASE 0x10
00050 #define RTM_NEWLINK (RTM_BASE + 0)
00051 #define RTM_DELLINK (RTM_BASE + 1)
00052 #define RTM_SETLINK (RTM_BASE + 3)
00053
00054 #define NLMSG_ALIGNTO 4
00055 #define NLMSG_ALIGN(len) (((len) + NLMSG_ALIGNTO - 1) & ~(NLMSG_ALIGNTO - 1))
00056 #define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr)))
00057 #define NLMSG_LENGTH(len) ((len) + NLMSG_ALIGN(sizeof(struct nlmsghdr)))
00058 #define NLMSG_SPACE(len) NLMSG_ALIGN(NLMSG_LENGTH(len))
00059 #define NLMSG_DATA(nlh) ((void*) (((char*) nlh) + NLMSG_LENGTH(0)))
00060 #define NLMSG_NEXT(nlh,len) ((len) -= NLMSG_ALIGN((nlh)->nlmsg_len), \
00061 (struct nlmsghdr *) \
00062 (((char *)(nlh)) + NLMSG_ALIGN((nlh)->nlmsg_len)))
00063 #define NLMSG_OK(nlh,len) ((len) >= (int) sizeof(struct nlmsghdr) && \
00064 (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \
00065 (int) (nlh)->nlmsg_len <= (len))
00066 #define NLMSG_PAYLOAD(nlh,len) ((nlh)->nlmsg_len - NLMSG_SPACE((len)))
00067
00068 #define RTA_ALIGNTO 4
00069 #define RTA_ALIGN(len) (((len) + RTA_ALIGNTO - 1) & ~(RTA_ALIGNTO - 1))
00070 #define RTA_OK(rta,len) \
00071 ((len) > 0 && (rta)->rta_len >= sizeof(struct rtattr) && \
00072 (rta)->rta_len <= (len))
00073 #define RTA_NEXT(rta,attrlen) \
00074 ((attrlen) -= RTA_ALIGN((rta)->rta_len), \
00075 (struct rtattr *) (((char *)(rta)) + RTA_ALIGN((rta)->rta_len)))
00076 #define RTA_LENGTH(len) (RTA_ALIGN(sizeof(struct rtattr)) + (len))
00077 #define RTA_DATA(rta) ((void *) (((char *) (rta)) + RTA_LENGTH(0)))
00078
00079
00080 struct sockaddr_nl
00081 {
00082 sa_family_t nl_family;
00083 unsigned short nl_pad;
00084 u32 nl_pid;
00085 u32 nl_groups;
00086 };
00087
00088 struct nlmsghdr
00089 {
00090 u32 nlmsg_len;
00091 u16 nlmsg_type;
00092 u16 nlmsg_flags;
00093 u32 nlmsg_seq;
00094 u32 nlmsg_pid;
00095 };
00096
00097 struct ifinfomsg
00098 {
00099 unsigned char ifi_family;
00100 unsigned char __ifi_pad;
00101 unsigned short ifi_type;
00102 int ifi_index;
00103 unsigned ifi_flags;
00104 unsigned ifi_change;
00105 };
00106
00107 struct rtattr
00108 {
00109 unsigned short rta_len;
00110 unsigned short rta_type;
00111 };
00112
00113 #endif