mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 16:50:55 +08:00
Clean-up routing table design.
This commit is contained in:
@@ -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 */
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user