"Fossies" - the Fresh Open Source Software Archive

Member "open-fcoe-3.19/fcoe-utils/include/rtnetlink.h" (15 Apr 2015, 2180 Bytes) of package /linux/misc/open-fcoe-3.19.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "rtnetlink.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Copyright(c) 2010 Intel Corporation. All rights reserved.
    3  *
    4  * This program is free software; you can redistribute it and/or modify it
    5  * under the terms and conditions of the GNU General Public License,
    6  * version 2, as published by the Free Software Foundation.
    7  *
    8  * This program is distributed in the hope it will be useful, but WITHOUT
    9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
   11  * more details.
   12  *
   13  * You should have received a copy of the GNU General Public License along with
   14  * this program; if not, write to the Free Software Foundation, Inc.,
   15  * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
   16  *
   17  * Maintained at www.Open-FCoE.org
   18  */
   19 
   20 #ifndef _RTNETLINK_
   21 #define _RTNETLINK_
   22 
   23 int rtnl_socket(void);
   24 typedef int rtnl_handler(struct nlmsghdr *nh, void *arg);
   25 int rtnl_recv(int s, rtnl_handler *fn, void *arg);
   26 ssize_t send_getlink_dump(int s);
   27 int rtnl_set_iff_up(int ifindex, char *ifname);
   28 int rtnl_set_iff_down(int ifindex, char *ifname);
   29 int vlan_create(int ifindex, int vid, char *name);
   30 int rtnl_find_vlan(int ifindex, int vid, char *ifname);
   31 int rtnl_get_linkname(int ifindex, char *name);
   32 int rtnl_get_sanmac(const char *ifname, unsigned char *addr);
   33 
   34 static inline void parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len)
   35 {
   36     memset(tb, 0, sizeof(struct rtattr *) * (max + 1));
   37     while (RTA_OK(rta, len)) {
   38         if (rta->rta_type <= max)
   39             tb[rta->rta_type] = rta;
   40         rta = RTA_NEXT(rta, len);
   41     }
   42 }
   43 
   44 static inline void parse_nested_rtattr(struct rtattr *tb[], int max, struct rtattr *rta)
   45 {
   46     parse_rtattr(tb, max, RTA_DATA(rta), RTA_PAYLOAD(rta));
   47 }
   48 
   49 static inline void parse_ifinfo(struct rtattr *tb[], struct nlmsghdr *nh)
   50 {
   51     struct ifinfomsg *ifm = NLMSG_DATA(nh);
   52     parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifm), IFLA_PAYLOAD(nh));
   53 }
   54 
   55 static inline void parse_linkinfo(struct rtattr *tb[], struct rtattr *linkinfo)
   56 {
   57     parse_nested_rtattr(tb, IFLA_INFO_MAX, linkinfo);
   58 }
   59 
   60 static inline void parse_vlaninfo(struct rtattr *tb[], struct rtattr *vlan)
   61 {
   62     parse_nested_rtattr(tb, IFLA_VLAN_MAX, vlan);
   63 }
   64 
   65 #endif /* _RTNETLINK_ */