82 lines
1.7 KiB
C
82 lines
1.7 KiB
C
#ifndef STATIC_ROUTING_H_
|
|
#define STATIC_ROUTING_H_
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include <errno.h>
|
|
#include <unistd.h>
|
|
#include <sys/types.h>
|
|
#include <sys/socket.h>
|
|
#include <netinet/in.h>
|
|
#include <arpa/inet.h>
|
|
#include <sys/ioctl.h>
|
|
#include <net/if.h>
|
|
|
|
|
|
#define IP_MAX_LENGTH 128
|
|
#define INTERFACE_MAX_LENGTH 20
|
|
#define LINE_MAX_LENGTH 128
|
|
#define ROUTING_TABLE_MAX_NUMBER 100
|
|
|
|
#define STRING_LENGTH 128
|
|
#define IPV4_GET_STATIC_ROUTING "route -n"
|
|
#define IPV6_GET_STATIC_ROUTING "route -6"
|
|
#define IPV4_VERSION 4
|
|
#define IPV6_VERSION 6
|
|
#define ACTION_LENGTH 10
|
|
|
|
#define BOTH_GW_AND_DEV 1
|
|
#define ONLY_GW 2
|
|
#define ONLY_DEV 3
|
|
#define IPV4_MIN_NETMASK 0
|
|
#define IPV4_MAX_NETMASK 32
|
|
|
|
|
|
|
|
#define STATIC_ROUTING_PATH "/etc/network/static_routing"
|
|
|
|
|
|
struct routing_string{
|
|
int version;
|
|
char destip[IP_MAX_LENGTH];
|
|
int netmask;
|
|
char gateway[IP_MAX_LENGTH];
|
|
char dev[INTERFACE_MAX_LENGTH];
|
|
int metric;
|
|
};
|
|
|
|
|
|
|
|
typedef struct routing_string routing_t;
|
|
|
|
|
|
|
|
/*static routing config */
|
|
ret_code routing_config_chk(uint source, uint *config_type,
|
|
pointer input, int *input_len,
|
|
pointer output, int *output_len);
|
|
|
|
ret_code routing_config_proc(uint source, uint config_type,
|
|
pointer input, int input_len,
|
|
pointer output, int *output_len);
|
|
|
|
|
|
ret_code routing_config_get_all(uint source,
|
|
pointer output, int *output_len);
|
|
|
|
|
|
/*»ñÈ¡ËùÓзÓÉÐÅÏ¢*/
|
|
|
|
ret_code all_routing_config_chk(uint source, uint *config_type,
|
|
pointer input, int *input_len,
|
|
pointer output, int *output_len);
|
|
|
|
ret_code all_routing_get_all(uint source,
|
|
pointer output, int *output_len);
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|