NetworkInador/lib/network-inador.h

77 lines
2.6 KiB
C
Raw Normal View History

/*
* main.c
* This file is part of Network-inador
*
* Copyright (C) 2024 - 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 __NETWORK_INADOR_H__
#define __NETWORK_INADOR_H__
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <sys/types.h>
#include <unistd.h>
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE !FALSE
#endif
typedef struct _NetworkInadorHandle NetworkInadorHandle;
/* Función que define una lectura desde un FD */
typedef void (*NetworkInadorInputFunc) (void *, int, int);
typedef void (*NetworkInadorChildWatchFunc) (void *, pid_t, int);
struct NetworkInadorOps {
/* Vigilar FDs */
unsigned int (*input_add) (int fd, int cond, NetworkInadorInputFunc func, void *user_data);
void (*input_remove) (unsigned int);
/* Vigilar procesos */
unsigned int (*process_watch) (pid_t pid, NetworkInadorChildWatchFunc, void *user_data);
void (*process_unwatch) (unsigned int);
/* Ver si agregamos timers aquí */
};
NetworkInadorHandle * network_inador_init_handle (struct NetworkInadorOps *network_inador_ops);
void network_inador_destroy_handle (NetworkInadorHandle *handle);
void network_inador_setup_child_handler (NetworkInadorHandle *handle);
/* Funciones básicas de interfaces */
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);
/* Funciones básicas de dhcp */
int interfaces_dhcp_client_run (NetworkInadorHandle *handle, int index, int type, uint32_t flags);
int interfaces_dhcp_client_stop (NetworkInadorHandle *handle, int index);
#endif /* __NETWORK_INADOR_H__ */