86 lines
2.1 KiB
C
86 lines
2.1 KiB
C
/*
|
|
* routes.h
|
|
* This file is part of Network-inador
|
|
*
|
|
* Copyright (C) 2022 - Félix Arreola Rodríguez
|
|
*
|
|
* Network-inador is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* Network-inador is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with Network-inador; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
* Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
#ifndef __ROUTES_H__
|
|
#define __ROUTES_H__
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <netlink/socket.h>
|
|
#include <netlink/msg.h>
|
|
|
|
#include "network-inador-private.h"
|
|
#include "struct_addr_union.h"
|
|
#include "flist.h"
|
|
|
|
/* Un Next-hop */
|
|
typedef struct {
|
|
struct_addr gw;
|
|
uint32_t out_index;
|
|
uint8_t nh_weight;
|
|
uint8_t nh_flags;
|
|
} RouteNH;
|
|
|
|
/* La tabla de ruteo */
|
|
typedef struct {
|
|
sa_family_t family; /* AF_INET, AF_INET6 */
|
|
|
|
uint8_t type; /* Unicast, local, broadcast, etc... */
|
|
uint32_t table;
|
|
struct_addr dest;
|
|
uint8_t prefix;
|
|
uint8_t tos;
|
|
|
|
uint8_t protocol;
|
|
uint8_t scope;
|
|
|
|
struct_addr prefsrc;
|
|
uint32_t priority;
|
|
|
|
/* Los brincos */
|
|
FList *nexthops;
|
|
|
|
/* Variable usada para determinar si debemos eliminar la ruta */
|
|
int for_delete;
|
|
} Route;
|
|
|
|
typedef struct {
|
|
uint32_t table;
|
|
char name[256];
|
|
|
|
int for_delete, was_new;
|
|
} RouteTable;
|
|
|
|
void routes_init (NetworkInadorHandle *handle);
|
|
void routes_ask (NetworkInadorHandle *handle);
|
|
int routes_receive_message_newroute (struct nl_msg *msg, void *arg);
|
|
int routes_receive_message_delroute (struct nl_msg *msg, void *arg);
|
|
int routes_add (NetworkInadorHandle *handle, Route *route);
|
|
int routes_del (NetworkInadorHandle *handle, Route *route);
|
|
|
|
void route_ask_delayed_delroute (NetworkInadorHandle *handle);
|
|
|
|
void routes_clean_up (NetworkInadorHandle *handle);
|
|
|
|
#endif /* __ROUTES_H__ */
|
|
|