Changeset View
Changeset View
Standalone View
Standalone View
lib/libroute/libroute.h
- This file was added.
/* | |||||||||
* Copyright (c) 2020 Ahsan Barkati | |||||||||
* | |||||||||
* Redistribution and use in source and binary forms, with or without | |||||||||
* modification, are permitted provided that the following conditions | |||||||||
* are met: | |||||||||
* 1. Redistributions of source code must retain the above copyright | |||||||||
* notice, this list of conditions and the following disclaimer. | |||||||||
* 2. Redistributions in binary form must reproduce the above copyright | |||||||||
* notice, this list of conditions and the following disclaimer in the | |||||||||
* documentation and/or other materials provided with the distribution. | |||||||||
* | |||||||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |||||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |||||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |||||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |||||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |||||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |||||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |||||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||||||
* SUCH DAMAGE. | |||||||||
* | |||||||||
* $FreeBSD$ | |||||||||
*/ | |||||||||
#include <sys/cdefs.h> | |||||||||
#include <sys/param.h> | |||||||||
#include <sys/file.h> | |||||||||
#include <sys/socket.h> | |||||||||
#include <sys/ioctl.h> | |||||||||
#include <sys/sysctl.h> | |||||||||
#include <sys/types.h> | |||||||||
#include <net/if.h> | |||||||||
#include <net/route.h> | |||||||||
#include <net/if_dl.h> | |||||||||
#include <netinet/in.h> | |||||||||
#include <netinet/if_ether.h> | |||||||||
#include <arpa/inet.h> | |||||||||
#include <netdb.h> | |||||||||
#include <ctype.h> | |||||||||
#include <paths.h> | |||||||||
#include <stdbool.h> | |||||||||
#include <stdio.h> | |||||||||
#include <stdlib.h> | |||||||||
#include <string.h> | |||||||||
#include <unistd.h> | |||||||||
#include <ifaddrs.h> | |||||||||
typedef struct rt_msg_t { | |||||||||
struct rt_msghdr m_rtm; | |||||||||
char m_space[512]; | |||||||||
} rt_msg_t; | |||||||||
typedef struct rt_handle_t rt_handle; | |||||||||
rt_handle* libroute_open(int); | |||||||||
thj: the star here should be bound to the function name. This is the below for str_to_sockaddr and… | |||||||||
void libroute_close(rt_handle*); | |||||||||
int libroute_modify(rt_handle*, struct rt_msg_t*, struct sockaddr*, struct sockaddr*, int, int); | |||||||||
int libroute_add(rt_handle*, struct sockaddr*, struct sockaddr*); | |||||||||
int libroute_change(rt_handle*, struct sockaddr*, struct sockaddr*); | |||||||||
int libroute_del(rt_handle*, struct sockaddr*); | |||||||||
int libroute_get(rt_handle*, struct sockaddr*); | |||||||||
int libroute_setfib(rt_handle *, int); | |||||||||
int libroute_errno(rt_handle *); | |||||||||
struct sockaddr* str_to_sockaddr(rt_handle *h, char *); | |||||||||
thjUnsubmitted Not Done Inline Actions
I think this should be called str_to_sockaddr4 thj: I think this should be called str_to_sockaddr4 | |||||||||
struct sockaddr* str_to_sockaddr6(rt_handle *h, char *); | |||||||||
Done Inline ActionsIs this function intended to be used by users of lib route, or is this internal? If it's the former it needs a lib route prefix, if it's the latter it shouldn't be in our header file (and it should be static in the .c file). kp: Is this function intended to be used by users of lib route, or is this internal?
If it's the… |
the star here should be bound to the function name. This is the below for str_to_sockaddr and str_to_sockaddr6