74 lines
1.6 KiB
C
74 lines
1.6 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 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);
|
|||
|
|
|||
|
|
|||
|
/*<2A><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD>Ϣ*/
|
|||
|
|
|||
|
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
|