2013-10-02 14:58:37 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* include/net/route.h
|
|
|
|
*
|
2021-02-03 11:33:49 +01: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 14:58:37 +02:00
|
|
|
*
|
2021-02-03 11:33:49 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2013-10-02 14:58:37 +02:00
|
|
|
*
|
2021-02-03 11:33:49 +01: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 14:58:37 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __INCLUDE_NET_ROUTE_H
|
|
|
|
#define __INCLUDE_NET_ROUTE_H
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <sys/socket.h>
|
2023-04-13 17:33:56 +02:00
|
|
|
#include <netinet/in.h>
|
2013-10-02 14:58:37 +02:00
|
|
|
|
|
|
|
#include <nuttx/net/ioctl.h>
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
2022-11-18 04:40:10 +01: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 14:58:37 +02: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-02 18:51:48 +02:00
|
|
|
struct rtentry
|
2013-10-02 14:58:37 +02:00
|
|
|
{
|
2019-11-10 19:35:15 +01: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 04:40:10 +01:00
|
|
|
FAR char *rt_dev; /* Forcing the device at add. */
|
2013-10-02 14:58:37 +02:00
|
|
|
};
|
|
|
|
|
2023-04-13 17:33:56 +02: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 14:58:37 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Data
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
#define EXTERN extern "C"
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#else
|
|
|
|
#define EXTERN extern
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Function Prototypes
|
|
|
|
****************************************************************************/
|
|
|
|
|
2013-10-02 18:51:48 +02:00
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: net_addroute
|
2013-10-02 18:51:48 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Add a new route to the routing table. This is just a convenience
|
|
|
|
* wrapper for the SIOCADDRT ioctl call.
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2013-10-02 18:51:48 +02:00
|
|
|
* sockfd - Any socket descriptor
|
2013-10-05 20:05:51 +02: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-02 18:51:48 +02: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-05 20:05:51 +02:00
|
|
|
FAR struct sockaddr_storage *router);
|
2013-10-02 18:51:48 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: net_delroute
|
2013-10-02 18:51:48 +02:00
|
|
|
*
|
|
|
|
* Description:
|
2020-01-31 19:09:01 +01:00
|
|
|
* Delete a route from the routing table. This is just a convenience
|
|
|
|
* wrapper for the SIOCDELRT ioctl call.
|
2013-10-02 18:51:48 +02:00
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2013-10-02 18:51:48 +02:00
|
|
|
* sockfd - Any socket descriptor
|
2013-10-05 20:05:51 +02:00
|
|
|
* target - Target address on the remote network (required)
|
|
|
|
* netmask - Network mask defining the external network (required)
|
2013-10-02 18:51:48 +02: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 14:58:37 +02:00
|
|
|
#undef EXTERN
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* __INCLUDE_NET_ROUTE_H */
|