dbus: Share the same function for type to type-as-string conversion
[hostap-gosc2009.git] / src / drivers / priv_netlink.h
blob23eff83fadd43dcd3feeac0b2612b44f7141c343
1 /*
2 * wpa_supplicant - Private copy of Linux netlink/rtnetlink definitions.
3 * Copyright (c) 2003-2005, Jouni Malinen <j@w1.fi>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
10 * license.
12 * See README and COPYING for more details.
15 #ifndef PRIV_NETLINK_H
16 #define PRIV_NETLINK_H
19 * This should be replaced with user space header once one is available with C
20 * library, etc..
23 #ifndef IFF_LOWER_UP
24 #define IFF_LOWER_UP 0x10000 /* driver signals L1 up */
25 #endif
26 #ifndef IFF_DORMANT
27 #define IFF_DORMANT 0x20000 /* driver signals dormant */
28 #endif
30 #ifndef IFLA_IFNAME
31 #define IFLA_IFNAME 3
32 #endif
33 #ifndef IFLA_WIRELESS
34 #define IFLA_WIRELESS 11
35 #endif
36 #ifndef IFLA_OPERSTATE
37 #define IFLA_OPERSTATE 16
38 #endif
39 #ifndef IFLA_LINKMODE
40 #define IFLA_LINKMODE 17
41 #define IF_OPER_DORMANT 5
42 #define IF_OPER_UP 6
43 #endif
45 #define NLM_F_REQUEST 1
47 #define NETLINK_ROUTE 0
48 #define RTMGRP_LINK 1
49 #define RTM_BASE 0x10
50 #define RTM_NEWLINK (RTM_BASE + 0)
51 #define RTM_DELLINK (RTM_BASE + 1)
52 #define RTM_SETLINK (RTM_BASE + 3)
54 #define NLMSG_ALIGNTO 4
55 #define NLMSG_ALIGN(len) (((len) + NLMSG_ALIGNTO - 1) & ~(NLMSG_ALIGNTO - 1))
56 #define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr)))
57 #define NLMSG_LENGTH(len) ((len) + NLMSG_ALIGN(sizeof(struct nlmsghdr)))
58 #define NLMSG_SPACE(len) NLMSG_ALIGN(NLMSG_LENGTH(len))
59 #define NLMSG_DATA(nlh) ((void*) (((char*) nlh) + NLMSG_LENGTH(0)))
60 #define NLMSG_NEXT(nlh,len) ((len) -= NLMSG_ALIGN((nlh)->nlmsg_len), \
61 (struct nlmsghdr *) \
62 (((char *)(nlh)) + NLMSG_ALIGN((nlh)->nlmsg_len)))
63 #define NLMSG_OK(nlh,len) ((len) >= (int) sizeof(struct nlmsghdr) && \
64 (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \
65 (int) (nlh)->nlmsg_len <= (len))
66 #define NLMSG_PAYLOAD(nlh,len) ((nlh)->nlmsg_len - NLMSG_SPACE((len)))
68 #define RTA_ALIGNTO 4
69 #define RTA_ALIGN(len) (((len) + RTA_ALIGNTO - 1) & ~(RTA_ALIGNTO - 1))
70 #define RTA_OK(rta,len) \
71 ((len) > 0 && (rta)->rta_len >= sizeof(struct rtattr) && \
72 (rta)->rta_len <= (len))
73 #define RTA_NEXT(rta,attrlen) \
74 ((attrlen) -= RTA_ALIGN((rta)->rta_len), \
75 (struct rtattr *) (((char *)(rta)) + RTA_ALIGN((rta)->rta_len)))
76 #define RTA_LENGTH(len) (RTA_ALIGN(sizeof(struct rtattr)) + (len))
77 #define RTA_DATA(rta) ((void *) (((char *) (rta)) + RTA_LENGTH(0)))
80 struct sockaddr_nl
82 sa_family_t nl_family;
83 unsigned short nl_pad;
84 u32 nl_pid;
85 u32 nl_groups;
88 struct nlmsghdr
90 u32 nlmsg_len;
91 u16 nlmsg_type;
92 u16 nlmsg_flags;
93 u32 nlmsg_seq;
94 u32 nlmsg_pid;
97 struct ifinfomsg
99 unsigned char ifi_family;
100 unsigned char __ifi_pad;
101 unsigned short ifi_type;
102 int ifi_index;
103 unsigned ifi_flags;
104 unsigned ifi_change;
107 struct rtattr
109 unsigned short rta_len;
110 unsigned short rta_type;
113 #endif /* PRIV_NETLINK_H */