2013-10-02 20:58:37 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* include/net/route.h
|
|
|
|
*
|
2021-02-03 18:33:49 +08:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2013-10-02 20:58:37 +08:00
|
|
|
*
|
2021-02-03 18:33:49 +08:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2013-10-02 20:58:37 +08:00
|
|
|
*
|
2021-02-03 18:33:49 +08:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2013-10-02 20:58:37 +08:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __INCLUDE_NET_ROUTE_H
|
|
|
|
#define __INCLUDE_NET_ROUTE_H
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <sys/socket.h>
|
2023-04-13 23:33:56 +08:00
|
|
|
#include <netinet/in.h>
|
2013-10-02 20:58:37 +08:00
|
|
|
|
|
|
|
#include <nuttx/net/ioctl.h>
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
2022-11-18 11:40:10 +08:00
|
|
|
#define RTF_UP 0x0001 /* Route usable. */
|
|
|
|
#define RTF_GATEWAY 0x0002 /* Destination is a gateway. */
|
|
|
|
#define RTF_HOST 0x0004 /* Host entry (net otherwise). */
|
|
|
|
|
2013-10-02 20:58:37 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Types
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/* This structure describes the route information passed with the SIOCADDRT
|
|
|
|
* and SIOCDELRT ioctl commands (see include/nuttx/net/ioctl.h).
|
|
|
|
*/
|
|
|
|
|
2013-10-03 00:51:48 +08:00
|
|
|
struct rtentry
|
2013-10-02 20:58:37 +08:00
|
|
|
{
|
2019-11-11 02:35:15 +08:00
|
|
|
struct sockaddr_storage rt_dst; /* Address of the network */
|
|
|
|
struct sockaddr_storage rt_gateway; /* Gateway address associated with
|
|
|
|
* the hop */
|
|
|
|
struct sockaddr_storage rt_genmask; /* Network mask defining the sub-net */
|
|
|
|
uint16_t rt_flags;
|
2022-11-18 11:40:10 +08:00
|
|
|
FAR char *rt_dev; /* Forcing the device at add. */
|
2013-10-02 20:58:37 +08:00
|
|
|
};
|
|
|
|
|
2023-04-13 23:33:56 +08:00
|
|
|
struct in6_rtmsg
|
|
|
|
{
|
|
|
|
struct in6_addr rtmsg_dst;
|
|
|
|
struct in6_addr rtmsg_src;
|
|
|
|
struct in6_addr rtmsg_gateway;
|
|
|
|
uint32_t rtmsg_type;
|
|
|
|
uint16_t rtmsg_dst_len;
|
|
|
|
uint16_t rtmsg_src_len;
|
|
|
|
uint32_t rtmsg_metric;
|
|
|
|
unsigned long int rtmsg_info;
|
|
|
|
uint32_t rtmsg_flags;
|
|
|
|
int rtmsg_ifindex;
|
|
|
|
};
|
|
|
|
|
2013-10-02 20:58:37 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Data
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
#define EXTERN extern "C"
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#else
|
|
|
|
#define EXTERN extern
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Function Prototypes
|
|
|
|
****************************************************************************/
|
|
|
|
|
2013-10-03 00:51:48 +08:00
|
|
|
/****************************************************************************
|
2017-04-22 06:33:14 +08:00
|
|
|
* Name: net_addroute
|
2013-10-03 00:51:48 +08:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Add a new route to the routing table. This is just a convenience
|
|
|
|
* wrapper for the SIOCADDRT ioctl call.
|
|
|
|
*
|
2018-03-13 23:52:27 +08:00
|
|
|
* Input Parameters:
|
2013-10-03 00:51:48 +08:00
|
|
|
* sockfd - Any socket descriptor
|
2013-10-06 02:05:51 +08:00
|
|
|
* 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.
|
2013-10-03 00:51:48 +08:00
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* OK on success; -1 on failure with the errno variable set appropriately.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int addroute(int sockfd, FAR struct sockaddr_storage *target,
|
|
|
|
FAR struct sockaddr_storage *netmask,
|
2013-10-06 02:05:51 +08:00
|
|
|
FAR struct sockaddr_storage *router);
|
2013-10-03 00:51:48 +08:00
|
|
|
|
|
|
|
/****************************************************************************
|
2017-04-22 06:33:14 +08:00
|
|
|
* Name: net_delroute
|
2013-10-03 00:51:48 +08:00
|
|
|
*
|
|
|
|
* Description:
|
2020-02-01 02:09:01 +08:00
|
|
|
* Delete a route from the routing table. This is just a convenience
|
|
|
|
* wrapper for the SIOCDELRT ioctl call.
|
2013-10-03 00:51:48 +08:00
|
|
|
*
|
2018-03-13 23:52:27 +08:00
|
|
|
* Input Parameters:
|
2013-10-03 00:51:48 +08:00
|
|
|
* sockfd - Any socket descriptor
|
2013-10-06 02:05:51 +08:00
|
|
|
* target - Target address on the remote network (required)
|
|
|
|
* netmask - Network mask defining the external network (required)
|
2013-10-03 00:51:48 +08:00
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* OK on success; -1 on failure with the errno variable set appropriately.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int delroute(int sockfd, FAR struct sockaddr_storage *target,
|
|
|
|
FAR struct sockaddr_storage *netmask);
|
|
|
|
|
2013-10-02 20:58:37 +08:00
|
|
|
#undef EXTERN
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* __INCLUDE_NET_ROUTE_H */
|