2018-08-07 15:28:22 -05:00
|
|
|
/*
|
2019-12-31 11:05:50 -06:00
|
|
|
* common.h
|
2018-08-07 15:28:22 -05:00
|
|
|
* This file is part of Network-inador
|
|
|
|
*
|
2019-12-31 11:05:50 -06:00
|
|
|
* Copyright (C) 2019, 2020 - Félix Arreola Rodríguez
|
2018-08-07 15:28:22 -05:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2019-12-31 11:05:50 -06:00
|
|
|
#ifndef __COMMON_H__
|
|
|
|
#define __COMMON_H__
|
2018-08-17 01:16:01 -05:00
|
|
|
|
2020-01-02 12:53:53 -06:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2018-08-08 23:18:35 -05:00
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <net/ethernet.h>
|
2019-12-31 11:05:50 -06:00
|
|
|
#include <linux/if.h>
|
2018-08-23 13:31:27 -05:00
|
|
|
|
|
|
|
#include <glib.h>
|
2019-12-31 11:05:50 -06:00
|
|
|
#include <gmodule.h>
|
2018-08-23 13:31:27 -05:00
|
|
|
|
2019-12-31 11:05:50 -06:00
|
|
|
#ifndef FALSE
|
|
|
|
#define FALSE 0
|
|
|
|
#endif
|
2019-02-16 18:13:15 -06:00
|
|
|
|
2019-12-31 11:05:50 -06:00
|
|
|
#ifndef TRUE
|
|
|
|
#define TRUE !FALSE
|
|
|
|
#endif
|
2019-02-16 18:13:15 -06:00
|
|
|
|
2020-01-02 12:53:53 -06:00
|
|
|
typedef struct _IPAddr {
|
|
|
|
sa_family_t family;
|
|
|
|
union {
|
|
|
|
struct in_addr sin_addr;
|
|
|
|
struct in6_addr sin6_addr;
|
|
|
|
};
|
|
|
|
uint32_t prefix;
|
|
|
|
|
|
|
|
unsigned char flags;
|
|
|
|
unsigned char scope;
|
|
|
|
} IPAddr;
|
|
|
|
|
2018-08-07 15:28:22 -05:00
|
|
|
typedef struct _Interface {
|
|
|
|
char name[IFNAMSIZ];
|
|
|
|
int ifi_type;
|
2018-08-17 19:43:06 -05:00
|
|
|
unsigned char real_hw[ETHER_ADDR_LEN * 2 + 1];
|
2018-08-07 15:28:22 -05:00
|
|
|
unsigned int index;
|
2018-08-17 19:43:06 -05:00
|
|
|
|
|
|
|
/* Para las interfaces dentro de un bridge */
|
2018-08-11 00:12:02 -05:00
|
|
|
unsigned int master_index;
|
|
|
|
|
|
|
|
unsigned int mtu;
|
2018-08-07 15:28:22 -05:00
|
|
|
|
2019-12-31 11:05:50 -06:00
|
|
|
/* Para las interfaces vlan */
|
|
|
|
unsigned int vlan_parent;
|
|
|
|
|
2018-08-17 19:43:06 -05:00
|
|
|
/* Banderas estilo ioctl */
|
2018-08-07 15:28:22 -05:00
|
|
|
short flags;
|
|
|
|
|
|
|
|
char wireless_protocol[IFNAMSIZ];
|
|
|
|
|
2018-08-17 19:43:06 -05:00
|
|
|
/* Tipo */
|
2018-08-07 15:28:22 -05:00
|
|
|
int is_loopback;
|
|
|
|
int is_wireless;
|
|
|
|
int is_bridge;
|
|
|
|
int is_vlan;
|
2018-08-17 19:43:06 -05:00
|
|
|
int is_nlmon;
|
2019-12-31 11:05:50 -06:00
|
|
|
int is_dummy;
|
2018-08-07 15:28:22 -05:00
|
|
|
|
2020-01-02 12:53:53 -06:00
|
|
|
GList *address;
|
2018-08-07 15:28:22 -05:00
|
|
|
|
2019-12-31 11:05:50 -06:00
|
|
|
//DHCPStateInfo dhcp_info;
|
2018-08-23 13:31:27 -05:00
|
|
|
|
2019-02-16 18:13:15 -06:00
|
|
|
/* Información wireless */
|
2019-12-31 11:05:50 -06:00
|
|
|
//WirelessInfo *wireless;
|
2018-08-07 15:28:22 -05:00
|
|
|
} Interface;
|
|
|
|
|
|
|
|
typedef struct {
|
2019-12-31 11:05:50 -06:00
|
|
|
GList *interfaces;
|
|
|
|
//Routev4 *rtable_v4;
|
2018-08-17 01:16:01 -05:00
|
|
|
|
2019-12-31 11:05:50 -06:00
|
|
|
struct nl_sock * nl_sock_route;
|
|
|
|
struct nl_sock * nl_sock_route_events;
|
|
|
|
guint route_events_source;
|
2018-08-07 15:28:22 -05:00
|
|
|
} NetworkInadorHandle;
|
|
|
|
|
2019-12-31 11:05:50 -06:00
|
|
|
#endif /* __COMMON_H__ */
|
2018-08-07 15:28:22 -05:00
|
|
|
|