108 lines
3.0 KiB
C
108 lines
3.0 KiB
C
/*
|
|
* interfaces.h
|
|
* This file is part of Network-inador
|
|
*
|
|
* Copyright (C) 2019, 2020 - 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 __INTERFACES_H__
|
|
#define __INTERFACES_H__
|
|
|
|
#include <netlink/socket.h>
|
|
#include <netlink/msg.h>
|
|
#include <stdarg.h>
|
|
#include <stdint.h>
|
|
|
|
#include <linux/ipv6.h>
|
|
#include <linux/if_link.h>
|
|
|
|
#include "flist.h"
|
|
#include "network-inador-private.h"
|
|
|
|
#include "dhcpc_defs.h"
|
|
#include "wireless_struct.h"
|
|
|
|
/* Información extra de IPv6 para la interfaz */
|
|
struct inet6_data {
|
|
uint32_t i6_flags;
|
|
struct ifla_cacheinfo i6_cacheinfo;
|
|
uint32_t i6_conf[DEVCONF_MAX];
|
|
uint8_t i6_addr_gen_mode;
|
|
};
|
|
|
|
typedef struct {
|
|
NetworkInadorHandle *handle;
|
|
uint32_t index;
|
|
char name[IFNAMSIZ];
|
|
uint32_t link_type;
|
|
uint16_t arp_type;
|
|
unsigned char real_hw[ETHER_ADDR_LEN * 2 + 1];
|
|
|
|
/* Para las interfaces dentro de un bridge */
|
|
uint32_t master_index;
|
|
|
|
uint32_t mtu;
|
|
|
|
/* Para las interfaces vlan */
|
|
unsigned int vlan_parent;
|
|
|
|
/* Banderas estilo ioctl */
|
|
short flags;
|
|
|
|
int is_wireless;
|
|
|
|
char wireless_protocol[IFNAMSIZ];
|
|
|
|
/* Tipo */
|
|
char rtnl_type[IFNAMSIZ];
|
|
|
|
/* Para los parámetros de IPv4 e IPv6 */
|
|
struct inet6_data inet6_data;
|
|
|
|
/* La lista de direcciones IP, ambas */
|
|
FList *address;
|
|
|
|
InterfaceDHCPClientInfo dhcpc;
|
|
|
|
/* Información wireless */
|
|
WirelessInfo *wireless;
|
|
} Interface;
|
|
|
|
void interfaces_init (NetworkInadorHandle *handle);
|
|
int interface_receive_message_newlink (struct nl_msg *msg, void *arg);
|
|
int interface_receive_message_dellink (struct nl_msg *msg, void *arg);
|
|
|
|
int _interfaces_wait_ack_or_error (struct nl_msg *msg, void *arg);
|
|
int _interfaces_wait_error (struct sockaddr_nl *nla, struct nlmsgerr *l_err, void *arg);
|
|
|
|
Interface * _interfaces_locate_by_index (FList *list, int index);
|
|
Interface * _interfaces_locate_by_name (FList *list, const char *name);
|
|
|
|
int interfaces_change_mac_address (NetworkInadorHandle *handle, int index, void *new_mac);
|
|
int interfaces_change_mtu (NetworkInadorHandle *handle, int index, uint32_t new_mtu);
|
|
int interfaces_change_set_up (NetworkInadorHandle *handle, int index);
|
|
int interfaces_change_set_down (NetworkInadorHandle *handle, int index);
|
|
int interfaces_change_name (NetworkInadorHandle *handle, int index, char * new_name);
|
|
|
|
//int interfaces_set_sysctl_ipv6_params (NetworkInadorHandle *handle, int index, int param, ...);
|
|
|
|
void interfaces_clean_up (NetworkInadorHandle *handle);
|
|
|
|
#endif
|
|
|