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