软著源代码范例XJ
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Main.c(代码处:在不少于每页50行的情况下,提供整个软件代码的开头30页和结尾30页)
#include
#include
#include
#include "netinet/in.h"
#include "arpa/inet.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include "acct_counter.h"
#include "nic_common.h"
#include "nic_cfgmsg.h"
#include "nic_meter.h"
#include "nic_vmu.h"
#include "nic_ipcmsg.h"
#include "nic_aclmsg.h"
#include "nic_lisa.h"
#include "acl_ipv6_socket.h"
#include "process_command.h"
#define ACL_SOCKET_NUM 4
#define ACL_SOCKET_VALID 1
#define ACL_SOCKET_INVALID 0
#define NIC_IPC_MSG_BUFF_SIZE 2000
#define MAX_ACL_RULE 2000
int g_fd = -1;
char *cmd_name = NULL;
typedef struct acl_ipv6_socket {
uint8_t valid;
uint8_t nic_id;
int acl_socket;
char *ifname;
} acl_ipv6_socket_t;
acl_ipv6_socket_t g_acl_ipv6_sockets[ACL_SOCKET_NUM] = {
{ACL_SOCKET_INVALID, 0, 0, "nic0"},
{ACL_SOCKET_INVALID, 1, 0, "nic1"},
{ACL_SOCKET_INVALID, 2, 0, "nic2"},
{ACL_SOCKET_INVALID, 3, 0, "nic3"}
};
FILE *g_log_file = NULL;
#define ACL_LOG(file, args...) \
if (file) \
fprintf(file, ##args)
#define CLOSE_FILE(file) \
if (file) \
fclose(file);
int acl_check_if_name(char *if_name)
{
int i, if_num = 0;
#ifdef __CN61__
if_num = 4;
#elif defined(__CN66__)
if_num = 2;
#endif
if (if_num == 0) {
return -1;
}
for (i = 0; i < if_num; i++) {
if (strcmp(if_name, g_acl_if_name[i]) == 0) {
return 0;
}
}
return -1;
}
#if defined(DP_ACL_KEYWORD)
/*not support: utf8---->per_utf8
gbk---->per_gbk*/
int acl_convert(char *fromset, char *toset,
char *from, size_t from_len, char *to, size_t max_to_len) {
int ret = 0;
if (NULL == fromset || NULL == toset || NULL == from) {
printf("Error.\n");
}
iconv_t cd;
cd = iconv_open(toset, fromset);