• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/netifd/system.c

  1 /*
  2  * netifd - network interface daemon
  3  * Copyright (C) 2012 Felix Fietkau <nbd@openwrt.org>
  4  *
  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
  7  * as published by the Free Software Foundation
  8  *
  9  * This program is distributed in the hope that it will be useful,
 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 12  * GNU General Public License for more details.
 13  */
 14 #define SYSTEM_IMPL
 15 #include "netifd.h"
 16 #include "system.h"
 17 #include <fcntl.h>
 18 
 19 static const struct blobmsg_policy tunnel_attrs[__TUNNEL_ATTR_MAX] = {
 20         [TUNNEL_ATTR_TYPE] = { .name = "mode", .type = BLOBMSG_TYPE_STRING },
 21         [TUNNEL_ATTR_LOCAL] = { .name = "local", .type = BLOBMSG_TYPE_STRING },
 22         [TUNNEL_ATTR_REMOTE] = { .name = "remote", .type = BLOBMSG_TYPE_STRING },
 23         [TUNNEL_ATTR_MTU] = { .name = "mtu", .type = BLOBMSG_TYPE_INT32 },
 24         [TUNNEL_ATTR_DF] = { .name = "df", .type = BLOBMSG_TYPE_BOOL },
 25         [TUNNEL_ATTR_TTL] = { .name = "ttl", .type = BLOBMSG_TYPE_INT32 },
 26         [TUNNEL_ATTR_TOS] = { .name = "tos", .type = BLOBMSG_TYPE_STRING },
 27         [TUNNEL_ATTR_LINK] = { .name = "link", .type = BLOBMSG_TYPE_STRING },
 28         [TUNNEL_ATTR_DATA] = { .name = "data", .type = BLOBMSG_TYPE_TABLE },
 29 };
 30 
 31 const struct uci_blob_param_list tunnel_attr_list = {
 32         .n_params = __TUNNEL_ATTR_MAX,
 33         .params = tunnel_attrs,
 34 };
 35 
 36 static const struct blobmsg_policy vxlan_data_attrs[__VXLAN_DATA_ATTR_MAX] = {
 37         [VXLAN_DATA_ATTR_ID] = { .name = "id", .type = BLOBMSG_TYPE_INT32 },
 38         [VXLAN_DATA_ATTR_PORT] = { .name = "port", .type = BLOBMSG_TYPE_INT32 },
 39         [VXLAN_DATA_ATTR_MACADDR] = { .name = "macaddr", .type = BLOBMSG_TYPE_STRING },
 40         [VXLAN_DATA_ATTR_RXCSUM] = { .name = "rxcsum", .type = BLOBMSG_TYPE_BOOL },
 41         [VXLAN_DATA_ATTR_TXCSUM] = { .name = "txcsum", .type = BLOBMSG_TYPE_BOOL },
 42         [VXLAN_DATA_ATTR_SRCPORTMIN] = { .name = "srcportmin", .type = BLOBMSG_TYPE_INT32 },
 43         [VXLAN_DATA_ATTR_SRCPORTMAX] = { .name = "srcportmax", .type = BLOBMSG_TYPE_INT32 },
 44         [VXLAN_DATA_ATTR_LEARNING] = { .name = "learning", .type = BLOBMSG_TYPE_BOOL },
 45         [VXLAN_DATA_ATTR_RSC] = { .name = "rsc", .type = BLOBMSG_TYPE_BOOL },
 46         [VXLAN_DATA_ATTR_PROXY] = { .name = "proxy", .type = BLOBMSG_TYPE_BOOL },
 47         [VXLAN_DATA_ATTR_L2MISS] = { .name = "l2miss", .type = BLOBMSG_TYPE_BOOL },
 48         [VXLAN_DATA_ATTR_L3MISS] = { .name = "l3miss", .type = BLOBMSG_TYPE_BOOL },
 49         [VXLAN_DATA_ATTR_GBP] = { .name = "gbp", .type = BLOBMSG_TYPE_BOOL },
 50         [VXLAN_DATA_ATTR_AGEING] = { .name = "ageing", .type = BLOBMSG_TYPE_INT32 },
 51         [VXLAN_DATA_ATTR_LIMIT] = { .name = "maxaddress", .type = BLOBMSG_TYPE_INT32 },
 52 };
 53 
 54 const struct uci_blob_param_list vxlan_data_attr_list = {
 55         .n_params = __VXLAN_DATA_ATTR_MAX,
 56         .params = vxlan_data_attrs,
 57 };
 58 
 59 static const struct blobmsg_policy gre_data_attrs[__GRE_DATA_ATTR_MAX] = {
 60         [GRE_DATA_IKEY] = { .name = "ikey", .type = BLOBMSG_TYPE_INT32 },
 61         [GRE_DATA_OKEY] = { .name = "okey", .type = BLOBMSG_TYPE_INT32 },
 62         [GRE_DATA_ICSUM] = { .name = "icsum", .type = BLOBMSG_TYPE_BOOL },
 63         [GRE_DATA_OCSUM] = { .name = "ocsum", .type = BLOBMSG_TYPE_BOOL },
 64         [GRE_DATA_ISEQNO] = { .name = "iseqno", .type = BLOBMSG_TYPE_BOOL },
 65         [GRE_DATA_OSEQNO] = { .name = "oseqno", .type = BLOBMSG_TYPE_BOOL },
 66         [GRE_DATA_ENCAPLIMIT] = { .name = "encaplimit", .type = BLOBMSG_TYPE_STRING },
 67 };
 68 
 69 const struct uci_blob_param_list gre_data_attr_list = {
 70         .n_params = __GRE_DATA_ATTR_MAX,
 71         .params = gre_data_attrs,
 72 };
 73 
 74 static const struct blobmsg_policy vti_data_attrs[__VTI_DATA_ATTR_MAX] = {
 75         [VTI_DATA_IKEY] = { .name = "ikey", .type = BLOBMSG_TYPE_INT32 },
 76         [VTI_DATA_OKEY] = { .name = "okey", .type = BLOBMSG_TYPE_INT32 },
 77 };
 78 
 79 const struct uci_blob_param_list vti_data_attr_list = {
 80         .n_params = __VTI_DATA_ATTR_MAX,
 81         .params = vti_data_attrs,
 82 };
 83 
 84 static const struct blobmsg_policy xfrm_data_attrs[__XFRM_DATA_ATTR_MAX] = {
 85         [XFRM_DATA_IF_ID] = { .name = "ifid", .type = BLOBMSG_TYPE_INT32 },
 86 };
 87 
 88 const struct uci_blob_param_list xfrm_data_attr_list = {
 89         .n_params = __XFRM_DATA_ATTR_MAX,
 90         .params = xfrm_data_attrs,
 91 };
 92 
 93 static const struct blobmsg_policy sixrd_data_attrs[__SIXRD_DATA_ATTR_MAX] = {
 94         [SIXRD_DATA_PREFIX] = { .name = "prefix", .type = BLOBMSG_TYPE_STRING },
 95         [SIXRD_DATA_RELAY_PREFIX] = { .name = "relay-prefix", .type = BLOBMSG_TYPE_STRING },
 96 };
 97 
 98 const struct uci_blob_param_list sixrd_data_attr_list = {
 99         .n_params = __SIXRD_DATA_ATTR_MAX,
100         .params = sixrd_data_attrs,
101 };
102 
103 static const struct blobmsg_policy ipip6_data_attrs[__SIXRD_DATA_ATTR_MAX] = {
104         [IPIP6_DATA_ENCAPLIMIT] = { .name = "encaplimit", .type = BLOBMSG_TYPE_STRING },
105         [IPIP6_DATA_FMRS] = { .name = "fmrs", .type = BLOBMSG_TYPE_ARRAY },
106 };
107 
108 const struct uci_blob_param_list ipip6_data_attr_list = {
109         .n_params = __IPIP6_DATA_ATTR_MAX,
110         .params = ipip6_data_attrs,
111 };
112 
113 static const struct blobmsg_policy fmr_data_attrs[__FMR_DATA_ATTR_MAX] = {
114         [FMR_DATA_PREFIX6] = { .name = "prefix6", .type = BLOBMSG_TYPE_STRING },
115         [FMR_DATA_PREFIX4] = { .name = "prefix4", .type = BLOBMSG_TYPE_STRING },
116         [FMR_DATA_EALEN] = { .name = "ealen", .type = BLOBMSG_TYPE_INT32 },
117         [FMR_DATA_OFFSET] = { .name = "offset", .type = BLOBMSG_TYPE_INT32 },
118 };
119 
120 const struct uci_blob_param_list fmr_data_attr_list = {
121         .n_params = __FMR_DATA_ATTR_MAX,
122         .params = fmr_data_attrs,
123 };
124 
125 const char * const bonding_policy_str[__BONDING_MODE_MAX] = {
126         [BONDING_MODE_BALANCE_RR] = "balance-rr",
127         [BONDING_MODE_ACTIVE_BACKUP] = "active-backup",
128         [BONDING_MODE_BALANCE_XOR] = "balance-xor",
129         [BONDING_MODE_BROADCAST] = "broadcast",
130         [BONDING_MODE_8023AD] = "802.3ad",
131         [BONDING_MODE_BALANCE_TLB] = "balance-tlb",
132         [BONDING_MODE_BALANCE_ALB] = "balance-alb",
133 };
134 
135 void system_fd_set_cloexec(int fd)
136 {
137 #ifdef FD_CLOEXEC
138         fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
139 #endif
140 }
141 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt