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