summaryrefslogtreecommitdiff
path: root/src/rtnl.c
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2010-05-18 23:37:42 +0200
committerSamuel Ortiz <sameo@linux.intel.com>2010-05-18 23:48:47 +0200
commit3889170e7e5adb01b024470ba41e4a24a1a24187 (patch)
treed0435a2a7c252cdd7c6ec27edaab02c75722d6d0 /src/rtnl.c
parentf40402072bde92e6a1d2ad57d55993f83dc08d7d (diff)
downloadconnman-3889170e7e5adb01b024470ba41e4a24a1a24187.tar.gz
connman-3889170e7e5adb01b024470ba41e4a24a1a24187.tar.bz2
connman-3889170e7e5adb01b024470ba41e4a24a1a24187.zip
Use helper for checking rtnl message validity
Diffstat (limited to 'src/rtnl.c')
-rw-r--r--src/rtnl.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/rtnl.c b/src/rtnl.c
index 147d2dad..edeae4ca 100644
--- a/src/rtnl.c
+++ b/src/rtnl.c
@@ -783,16 +783,29 @@ static void rtnl_route(struct nlmsghdr *hdr)
}
}
+static connman_bool_t is_route_rtmsg(struct rtmsg *msg)
+{
+
+ if (msg->rtm_table != RT_TABLE_MAIN)
+ return FALSE;
+
+ if (msg->rtm_protocol != RTPROT_BOOT &&
+ msg->rtm_protocol != RTPROT_KERNEL)
+ return FALSE;
+
+ if (msg->rtm_type != RTN_UNICAST)
+ return FALSE;
+
+ return TRUE;
+}
+
static void rtnl_newroute(struct nlmsghdr *hdr)
{
struct rtmsg *msg = (struct rtmsg *) NLMSG_DATA(hdr);
rtnl_route(hdr);
- if (msg->rtm_table == RT_TABLE_MAIN &&
- (msg->rtm_protocol == RTPROT_BOOT ||
- msg->rtm_protocol == RTPROT_KERNEL) &&
- msg->rtm_type == RTN_UNICAST)
+ if (is_route_rtmsg(msg))
process_newroute(msg->rtm_family, msg->rtm_scope,
msg, RTM_PAYLOAD(hdr));
}
@@ -803,10 +816,7 @@ static void rtnl_delroute(struct nlmsghdr *hdr)
rtnl_route(hdr);
- if (msg->rtm_table == RT_TABLE_MAIN &&
- (msg->rtm_protocol == RTPROT_BOOT ||
- msg->rtm_protocol == RTPROT_KERNEL) &&
- msg->rtm_type == RTN_UNICAST)
+ if (is_route_rtmsg(msg))
process_delroute(msg->rtm_family, msg->rtm_scope,
msg, RTM_PAYLOAD(hdr));
}