Disconnect hostapd from building in base
[dragonfly.git] / contrib / hostapd / src / drivers / priv_netlink.h
CommitLineData
a875087d
JL
1/*
2 * wpa_supplicant - Private copy of Linux netlink/rtnetlink definitions.
3 * Copyright (c) 2003-2005, Jouni Malinen <j@w1.fi>
4 *
4781064b
JM
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
a875087d
JL
7 */
8
ebfa2275
SZ
9#ifndef PRIV_NETLINK_H
10#define PRIV_NETLINK_H
11
a875087d 12/*
ebfa2275
SZ
13 * This should be replaced with user space header once one is available with C
14 * library, etc..
15 */
16
a875087d
JL
17#ifndef IFF_LOWER_UP
18#define IFF_LOWER_UP 0x10000 /* driver signals L1 up */
19#endif
20#ifndef IFF_DORMANT
21#define IFF_DORMANT 0x20000 /* driver signals dormant */
22#endif
23
ebfa2275
SZ
24#ifndef IFLA_IFNAME
25#define IFLA_IFNAME 3
26#endif
27#ifndef IFLA_WIRELESS
28#define IFLA_WIRELESS 11
29#endif
a875087d
JL
30#ifndef IFLA_OPERSTATE
31#define IFLA_OPERSTATE 16
32#endif
33#ifndef IFLA_LINKMODE
34#define IFLA_LINKMODE 17
35#define IF_OPER_DORMANT 5
36#define IF_OPER_UP 6
37#endif
38
39#define NLM_F_REQUEST 1
ebfa2275
SZ
40
41#define NETLINK_ROUTE 0
42#define RTMGRP_LINK 1
43#define RTM_BASE 0x10
44#define RTM_NEWLINK (RTM_BASE + 0)
45#define RTM_DELLINK (RTM_BASE + 1)
a875087d 46#define RTM_SETLINK (RTM_BASE + 3)
ebfa2275
SZ
47
48#define NLMSG_ALIGNTO 4
49#define NLMSG_ALIGN(len) (((len) + NLMSG_ALIGNTO - 1) & ~(NLMSG_ALIGNTO - 1))
4781064b 50#define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr)))
ebfa2275 51#define NLMSG_LENGTH(len) ((len) + NLMSG_ALIGN(sizeof(struct nlmsghdr)))
4781064b 52#define NLMSG_SPACE(len) NLMSG_ALIGN(NLMSG_LENGTH(len))
ebfa2275 53#define NLMSG_DATA(nlh) ((void*) (((char*) nlh) + NLMSG_LENGTH(0)))
4781064b
JM
54#define NLMSG_NEXT(nlh,len) ((len) -= NLMSG_ALIGN((nlh)->nlmsg_len), \
55 (struct nlmsghdr *) \
56 (((char *)(nlh)) + NLMSG_ALIGN((nlh)->nlmsg_len)))
57#define NLMSG_OK(nlh,len) ((len) >= (int) sizeof(struct nlmsghdr) && \
58 (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \
59 (int) (nlh)->nlmsg_len <= (len))
60#define NLMSG_PAYLOAD(nlh,len) ((nlh)->nlmsg_len - NLMSG_SPACE((len)))
ebfa2275
SZ
61
62#define RTA_ALIGNTO 4
63#define RTA_ALIGN(len) (((len) + RTA_ALIGNTO - 1) & ~(RTA_ALIGNTO - 1))
64#define RTA_OK(rta,len) \
65((len) > 0 && (rta)->rta_len >= sizeof(struct rtattr) && \
66(rta)->rta_len <= (len))
67#define RTA_NEXT(rta,attrlen) \
68((attrlen) -= RTA_ALIGN((rta)->rta_len), \
69(struct rtattr *) (((char *)(rta)) + RTA_ALIGN((rta)->rta_len)))
a875087d
JL
70#define RTA_LENGTH(len) (RTA_ALIGN(sizeof(struct rtattr)) + (len))
71#define RTA_DATA(rta) ((void *) (((char *) (rta)) + RTA_LENGTH(0)))
4781064b 72#define RTA_PAYLOAD(rta) ((int) ((rta)->rta_len) - RTA_LENGTH(0))
ebfa2275
SZ
73
74
75struct sockaddr_nl
76{
77 sa_family_t nl_family;
78 unsigned short nl_pad;
79 u32 nl_pid;
80 u32 nl_groups;
81};
82
83struct nlmsghdr
84{
85 u32 nlmsg_len;
86 u16 nlmsg_type;
87 u16 nlmsg_flags;
88 u32 nlmsg_seq;
89 u32 nlmsg_pid;
90};
91
92struct ifinfomsg
93{
94 unsigned char ifi_family;
95 unsigned char __ifi_pad;
96 unsigned short ifi_type;
97 int ifi_index;
98 unsigned ifi_flags;
99 unsigned ifi_change;
100};
101
102struct rtattr
103{
104 unsigned short rta_len;
105 unsigned short rta_type;
106};
107
108#endif /* PRIV_NETLINK_H */