Clean-up routing table design.

This commit is contained in:
Gregory Nutt
2013-10-05 12:05:51 -06:00
parent 02b8a8bf19
commit 566857bcbd
13 changed files with 239 additions and 143 deletions
+6 -7
View File
@@ -61,10 +61,10 @@
*
* Parameters:
* sockfd - Any socket descriptor
* target - Target address (required)
* netmask - Network mask defining the sub-net (required)
* gateway - Gateway address associated with the hop (optional)
* ifno - Interface number, e.g., the 0 in "eth0"
* target - Target address on external network(required)
* netmask - Network mask defining the external network (required)
* router - Router address that on our network that can forward to the
* external network.
*
* Returned Value:
* OK on success; -1 on failure with the errno variable set appropriately.
@@ -73,16 +73,15 @@
int addroute(int sockfd, FAR struct sockaddr_storage *target,
FAR struct sockaddr_storage *netmask,
FAR struct sockaddr_storage *gateway, int ifno)
FAR struct sockaddr_storage *router)
{
struct rtentry entry;
/* Set up the rtentry structure */
entry.rt_ifno = ifno; /* Interface number, e.g., the 0 in "eth0" */
entry.rt_target = target; /* Target address */
entry.rt_netmask = netmask; /* Network mask defining the sub-net */
entry.rt_gateway = gateway; /* Gateway address associated with the hop */
entry.rt_router = router; /* Router address associated with the hop */
/* Then perform the ioctl */
+4 -5
View File
@@ -46,6 +46,7 @@
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <stdint.h>
#include <string.h>
#include <net/route.h>
/***************************************************************************
@@ -61,8 +62,8 @@
*
* Parameters:
* sockfd - Any socket descriptor
* target - Target address (required)
* netmask - Network mask defining the sub-net (required)
* target - Target address on the remote network (required)
* netmask - Network mask defining the external network (required)
*
* Returned Value:
* OK on success; -1 on failure with the errno variable set appropriately.
@@ -76,12 +77,10 @@ int delroute(int sockfd, FAR struct sockaddr_storage *target,
/* Set up the rtentry structure */
memset(&entry, 0, sizeof(struct rtentry));
entry.rt_target = target; /* Target address */
entry.rt_netmask = netmask; /* Network mask defining the sub-net */
entry.rt_ifno = 0; /* (not used for deletion) */
entry.rt_gateway = NULL; /* (not used for deletion) */
/* Then perform the ioctl */
return ioctl(sockfd, SIOCDELRT, (unsigned long)((uintptr_t)&entry));