summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-10-08 13:46:19 +0200
committerThomas Haller <thaller@redhat.com>2018-10-10 11:30:06 +0200
commita358cf2cd15d81cd6f325781d30d682c8863b40c (patch)
treebc5074e5a257eab526636c583d22b80de426c09f /lib
parentb004e4006374c9f0311461010c9082411c6ef563 (diff)
downloadlibnl-a358cf2cd15d81cd6f325781d30d682c8863b40c.tar.gz
route/act: style fixes in "lib/route/act/vlan.c"
Diffstat (limited to 'lib')
-rw-r--r--lib/route/act/vlan.c158
1 files changed, 79 insertions, 79 deletions
diff --git a/lib/route/act/vlan.c b/lib/route/act/vlan.c
index e570ae38..3d7699d7 100644
--- a/lib/route/act/vlan.c
+++ b/lib/route/act/vlan.c
@@ -1,10 +1,10 @@
/*
* lib/route/act/vlan.c vlan action
*
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation version 2.1
- * of the License.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
*
* Copyright (c) 2018 Volodymyr Bendiuga <volodymyr.bendiuga@gmail.com>
*/
@@ -25,22 +25,22 @@
#include <netlink/route/act/vlan.h>
-#define VLAN_F_VID 1 << 0
-#define VLAN_F_PROTO 1 << 1
-#define VLAN_F_PRIO 1 << 2
-#define VLAN_F_ACT 1 << 3
-#define VLAN_F_MODE 1 << 4
+#define VLAN_F_VID (1 << 0)
+#define VLAN_F_PROTO (1 << 1)
+#define VLAN_F_PRIO (1 << 2)
+#define VLAN_F_ACT (1 << 3)
+#define VLAN_F_MODE (1 << 4)
static struct nla_policy vlan_policy[TCA_VLAN_MAX + 1] = {
- [TCA_VLAN_PARMS] = { .minlen = sizeof(struct tc_vlan) },
- [TCA_VLAN_PUSH_VLAN_ID] = { .type = NLA_U16 },
- [TCA_VLAN_PUSH_VLAN_PROTOCOL] = { .type = NLA_U16 },
- [TCA_VLAN_PUSH_VLAN_PRIORITY] = { .type = NLA_U8 },
+ [TCA_VLAN_PARMS] = { .minlen = sizeof(struct tc_vlan) },
+ [TCA_VLAN_PUSH_VLAN_ID] = { .type = NLA_U16 },
+ [TCA_VLAN_PUSH_VLAN_PROTOCOL] = { .type = NLA_U16 },
+ [TCA_VLAN_PUSH_VLAN_PRIORITY] = { .type = NLA_U8 },
};
static int vlan_msg_parser(struct rtnl_tc *tc, void *data)
{
- struct rtnl_vlan *v = data;
+ struct rtnl_vlan *v = data;
struct nlattr *tb[TCA_VLAN_MAX + 1];
int err;
@@ -52,43 +52,43 @@ static int vlan_msg_parser(struct rtnl_tc *tc, void *data)
if (!tb[TCA_VLAN_PARMS])
return -NLE_MISSING_ATTR;
else {
- nla_memcpy(&v->v_parm, tb[TCA_VLAN_PARMS], sizeof(v->v_parm));
+ nla_memcpy(&v->v_parm, tb[TCA_VLAN_PARMS], sizeof(v->v_parm));
v->v_flags |= VLAN_F_ACT;
v->v_flags |= VLAN_F_MODE;
}
if (tb[TCA_VLAN_PUSH_VLAN_ID]) {
- v->v_vid = nla_get_u16(tb[TCA_VLAN_PUSH_VLAN_ID]);
+ v->v_vid = nla_get_u16(tb[TCA_VLAN_PUSH_VLAN_ID]);
v->v_flags |= VLAN_F_VID;
}
if (tb[TCA_VLAN_PUSH_VLAN_PROTOCOL]) {
- v->v_proto = nla_get_u16(tb[TCA_VLAN_PUSH_VLAN_PROTOCOL]);
+ v->v_proto = nla_get_u16(tb[TCA_VLAN_PUSH_VLAN_PROTOCOL]);
v->v_flags |= VLAN_F_PROTO;
}
if (tb[TCA_VLAN_PUSH_VLAN_PRIORITY]) {
- v->v_prio = nla_get_u8(tb[TCA_VLAN_PUSH_VLAN_PRIORITY]);
+ v->v_prio = nla_get_u8(tb[TCA_VLAN_PUSH_VLAN_PRIORITY]);
v->v_flags |= VLAN_F_PRIO;
}
- return 0;
+ return 0;
}
static int vlan_msg_fill(struct rtnl_tc *tc, void *data, struct nl_msg *msg)
{
- struct rtnl_vlan *v = data;
+ struct rtnl_vlan *v = data;
if (!v)
- return 0;
+ return 0;
if (!(v->v_flags & VLAN_F_MODE))
- return -NLE_MISSING_ATTR;
+ return -NLE_MISSING_ATTR;
NLA_PUT(msg, TCA_VLAN_PARMS, sizeof(v->v_parm), &v->v_parm);
/* vid is required for PUSH & MODIFY modes */
if ((v->v_parm.v_action != TCA_VLAN_ACT_POP) && !(v->v_flags & VLAN_F_VID))
- return -NLE_MISSING_ATTR;
+ return -NLE_MISSING_ATTR;
if (v->v_flags & VLAN_F_VID)
NLA_PUT_U16(msg, TCA_VLAN_PUSH_VLAN_ID, v->v_vid);
@@ -99,9 +99,9 @@ static int vlan_msg_fill(struct rtnl_tc *tc, void *data, struct nl_msg *msg)
if (v->v_flags & VLAN_F_PRIO)
NLA_PUT_U8(msg, TCA_VLAN_PUSH_VLAN_PRIORITY, v->v_prio);
- return 0;
+ return 0;
- nla_put_failure:
+nla_put_failure:
return -NLE_NOMEM;
}
@@ -111,14 +111,14 @@ static void vlan_free_data(struct rtnl_tc *tc, void *data)
static int vlan_clone(void *_dst, void *_src)
{
- struct rtnl_vlan *dst = _dst, *src = _src;
+ struct rtnl_vlan *dst = _dst, *src = _src;
memcpy(&dst->v_parm, &src->v_parm, sizeof(src->v_parm));
return 0;
}
static void vlan_dump_line(struct rtnl_tc *tc, void *data,
- struct nl_dump_params *p)
+ struct nl_dump_params *p)
{
struct rtnl_vlan *v = data;
@@ -126,13 +126,13 @@ static void vlan_dump_line(struct rtnl_tc *tc, void *data,
return;
if (!(v->v_flags & VLAN_F_ACT))
- return;
+ return;
if (TC_ACT_EXT_CMP(v->v_parm.action, TC_ACT_GOTO_CHAIN))
- nl_dump(p, " goto chain %u", v->v_parm.action & TC_ACT_EXT_VAL_MASK);
+ nl_dump(p, " goto chain %u", v->v_parm.action & TC_ACT_EXT_VAL_MASK);
if (TC_ACT_EXT_CMP(v->v_parm.action, TC_ACT_JUMP))
- nl_dump(p, " jump %u", v->v_parm.action & TC_ACT_EXT_VAL_MASK);
+ nl_dump(p, " jump %u", v->v_parm.action & TC_ACT_EXT_VAL_MASK);
switch(v->v_parm.action){
case TC_ACT_UNSPEC:
@@ -157,29 +157,29 @@ static void vlan_dump_line(struct rtnl_tc *tc, void *data,
}
static void vlan_dump_details(struct rtnl_tc *tc, void *data,
- struct nl_dump_params *p)
+ struct nl_dump_params *p)
{
- struct rtnl_vlan *v = data;
+ struct rtnl_vlan *v = data;
if (!v)
return;
if (v->v_flags & VLAN_F_MODE) {
- switch (v->v_parm.v_action) {
+ switch (v->v_parm.v_action) {
case TCA_VLAN_ACT_POP:
- nl_dump(p, " mode POP");
+ nl_dump(p, " mode POP");
break;
case TCA_VLAN_ACT_PUSH:
- nl_dump(p, " mode PUSH");
+ nl_dump(p, " mode PUSH");
break;
case TCA_VLAN_ACT_MODIFY:
- nl_dump(p, " mode MODIFY");
+ nl_dump(p, " mode MODIFY");
break;
}
}
if (v->v_flags & VLAN_F_VID)
- nl_dump(p, " vlan id %u", v->v_vid);
+ nl_dump(p, " vlan id %u", v->v_vid);
if (v->v_flags & VLAN_F_PRIO)
nl_dump(p, " priority %u", v->v_prio);
@@ -195,19 +195,19 @@ static void vlan_dump_details(struct rtnl_tc *tc, void *data,
/**
* Set vlan mode
- * @arg act vlan action
- * @arg mode one of (TCA_VLAN_ACT_*: POP, PUSH, MODIFY)
+ * @arg act vlan action
+ * @arg mode one of (TCA_VLAN_ACT_*: POP, PUSH, MODIFY)
* @return 0 on success or a negative error code.
*/
int rtnl_vlan_set_mode(struct rtnl_act *act, int mode)
{
- struct rtnl_vlan *v;
+ struct rtnl_vlan *v;
if (!(v = (struct rtnl_vlan *) rtnl_tc_data(TC_CAST(act))))
return -NLE_NOMEM;
if (mode > TCA_VLAN_ACT_MODIFY)
- return -NLE_RANGE;
+ return -NLE_RANGE;
v->v_parm.v_action = mode;
v->v_flags |= VLAN_F_MODE;
@@ -217,31 +217,31 @@ int rtnl_vlan_set_mode(struct rtnl_act *act, int mode)
/**
* Get vlan mode
- * @arg act vlan action
+ * @arg act vlan action
* @return vlan mode on success or a negative error code.
*/
int rtnl_vlan_get_mode(struct rtnl_act *act)
{
- struct rtnl_vlan *v;
+ struct rtnl_vlan *v;
if (!(v = (struct rtnl_vlan *) rtnl_tc_data_peek(TC_CAST(act))))
return -NLE_NOMEM;
if (!(v->v_flags & VLAN_F_MODE))
- return -NLE_MISSING_ATTR;
+ return -NLE_MISSING_ATTR;
return v->v_parm.v_action;
}
/**
* Set general action
- * @arg act vlan action
- * @arg action one of (TCA_ACT_*: PIPE, SHOT, GOTO_CHAIN, etc)
+ * @arg act vlan action
+ * @arg action one of (TCA_ACT_*: PIPE, SHOT, GOTO_CHAIN, etc)
* @return 0 on success or a negative error code.
*/
int rtnl_vlan_set_action(struct rtnl_act *act, int action)
{
- struct rtnl_vlan *v;
+ struct rtnl_vlan *v;
if (!(v = (struct rtnl_vlan *) rtnl_tc_data(TC_CAST(act))))
return -NLE_NOMEM;
@@ -254,31 +254,31 @@ int rtnl_vlan_set_action(struct rtnl_act *act, int action)
/**
* Get general action
- * @arg act vlan action
+ * @arg act vlan action
* @return general action on success or a negative error code.
*/
int rtnl_vlan_get_action(struct rtnl_act *act)
{
- struct rtnl_vlan *v;
+ struct rtnl_vlan *v;
if (!(v = (struct rtnl_vlan *) rtnl_tc_data_peek(TC_CAST(act))))
return -NLE_NOMEM;
if (!(v->v_flags & VLAN_F_ACT))
- return -NLE_MISSING_ATTR;
+ return -NLE_MISSING_ATTR;
return v->v_parm.action;
}
/**
* Set protocol
- * @arg act vlan action
- * @arg protocol one of (ETH_P_8021Q || ETH_P_8021AD)
+ * @arg act vlan action
+ * @arg protocol one of (ETH_P_8021Q || ETH_P_8021AD)
* @return 0 on success or a negative error code.
*/
int rtnl_vlan_set_protocol(struct rtnl_act *act, uint16_t protocol)
{
- struct rtnl_vlan *v;
+ struct rtnl_vlan *v;
if (!(v = (struct rtnl_vlan *) rtnl_tc_data(TC_CAST(act))))
return -NLE_NOMEM;
@@ -291,37 +291,37 @@ int rtnl_vlan_set_protocol(struct rtnl_act *act, uint16_t protocol)
/**
* Get protocol
- * @arg act vlan action
+ * @arg act vlan action
* @return protocol on success or a negative error code.
*/
uint16_t rtnl_vlan_get_protocol(struct rtnl_act *act)
{
- struct rtnl_vlan *v;
+ struct rtnl_vlan *v;
if (!(v = (struct rtnl_vlan *) rtnl_tc_data_peek(TC_CAST(act))))
return -NLE_NOMEM;
if (!(v->v_flags & VLAN_F_PROTO))
- return -NLE_MISSING_ATTR;
+ return -NLE_MISSING_ATTR;
return v->v_proto;
}
/**
* Set vlan id
- * @arg act vlan action
- * @arg vid vlan id
+ * @arg act vlan action
+ * @arg vid vlan id
* @return 0 on success or a negative error code.
*/
int rtnl_vlan_set_vlan_id(struct rtnl_act *act, uint16_t vid)
{
- struct rtnl_vlan *v;
+ struct rtnl_vlan *v;
if (!(v = (struct rtnl_vlan *) rtnl_tc_data(TC_CAST(act))))
return -NLE_NOMEM;
if (vid > 4095)
- return -NLE_RANGE;
+ return -NLE_RANGE;
v->v_vid = vid;
v->v_flags |= VLAN_F_VID;
@@ -331,37 +331,37 @@ int rtnl_vlan_set_vlan_id(struct rtnl_act *act, uint16_t vid)
/**
* Get vlan id
- * @arg act vlan action
+ * @arg act vlan action
* @return vlan id on success or a negative error code.
*/
uint16_t rtnl_vlan_get_vlan_id(struct rtnl_act *act)
{
- struct rtnl_vlan *v;
+ struct rtnl_vlan *v;
if (!(v = (struct rtnl_vlan *) rtnl_tc_data_peek(TC_CAST(act))))
return -NLE_NOMEM;
if (!(v->v_flags & VLAN_F_VID))
- return -NLE_MISSING_ATTR;
+ return -NLE_MISSING_ATTR;
return v->v_vid;
}
/**
* Set vlan prio
- * @arg act vlan action
- * @arg prio vlan priority (0 - 7)
+ * @arg act vlan action
+ * @arg prio vlan priority (0 - 7)
* @return 0 on success or a negative error code.
*/
int rtnl_vlan_set_vlan_prio(struct rtnl_act *act, uint8_t prio)
{
- struct rtnl_vlan *v;
+ struct rtnl_vlan *v;
if (!(v = (struct rtnl_vlan *) rtnl_tc_data(TC_CAST(act))))
return -NLE_NOMEM;
if (prio > 7)
- return -NLE_RANGE;
+ return -NLE_RANGE;
v->v_prio = prio;
v->v_flags |= VLAN_F_PRIO;
@@ -371,18 +371,18 @@ int rtnl_vlan_set_vlan_prio(struct rtnl_act *act, uint8_t prio)
/**
* Get vlan prio
- * @arg act vlan action
+ * @arg act vlan action
* @return vlan prio on success or a negative error code.
*/
uint8_t rtnl_vlan_get_vlan_prio(struct rtnl_act *act)
{
- struct rtnl_vlan *v;
+ struct rtnl_vlan *v;
if (!(v = (struct rtnl_vlan *) rtnl_tc_data_peek(TC_CAST(act))))
return -NLE_NOMEM;
if (!(v->v_flags & VLAN_F_PRIO))
- return -NLE_MISSING_ATTR;
+ return -NLE_MISSING_ATTR;
return v->v_prio;
}
@@ -390,16 +390,16 @@ uint8_t rtnl_vlan_get_vlan_prio(struct rtnl_act *act)
/** @} */
static struct rtnl_tc_ops vlan_ops = {
- .to_kind = "vlan",
- .to_type = RTNL_TC_TYPE_ACT,
- .to_size = sizeof(struct rtnl_vlan),
- .to_msg_parser = vlan_msg_parser,
- .to_free_data = vlan_free_data,
- .to_clone = vlan_clone,
- .to_msg_fill = vlan_msg_fill,
+ .to_kind = "vlan",
+ .to_type = RTNL_TC_TYPE_ACT,
+ .to_size = sizeof(struct rtnl_vlan),
+ .to_msg_parser = vlan_msg_parser,
+ .to_free_data = vlan_free_data,
+ .to_clone = vlan_clone,
+ .to_msg_fill = vlan_msg_fill,
.to_dump = {
- [NL_DUMP_LINE] = vlan_dump_line,
- [NL_DUMP_DETAILS] = vlan_dump_details,
+ [NL_DUMP_LINE] = vlan_dump_line,
+ [NL_DUMP_DETAILS] = vlan_dump_details,
},
};