MOD aaa-12 解决IP地址删除不成功的问题
SOL 解决IP地址删除不成功的问题 修改人:zhangliang 检视人:zhangliang
This commit is contained in:
parent
11a44646c0
commit
c2f4479fc1
|
@ -49,7 +49,7 @@ void ip_save_file(ip_config_t *ip_conf, uint config_type)
|
||||||
sprintf(addr_buff, "address %s\n", inet_ntoa(ip_conf->prefix));
|
sprintf(addr_buff, "address %s\n", inet_ntoa(ip_conf->prefix));
|
||||||
masklen2ip(ip_conf->prefixlen, &netmask);
|
masklen2ip(ip_conf->prefixlen, &netmask);
|
||||||
sprintf(mask_buff, "netmask %s\n", inet_ntoa(netmask));
|
sprintf(mask_buff, "netmask %s\n", inet_ntoa(netmask));
|
||||||
printf("%s,%s\r\n",addr_buff, mask_buff);
|
rpc_log_info("%s %s",addr_buff, mask_buff);
|
||||||
|
|
||||||
set_if_config(ip_conf->ifname, addr_name, addr_buff);
|
set_if_config(ip_conf->ifname, addr_name, addr_buff);
|
||||||
set_if_config(ip_conf->ifname, mask_name, mask_buff);
|
set_if_config(ip_conf->ifname, mask_name, mask_buff);
|
||||||
|
@ -233,11 +233,12 @@ ret_code ip_config_set_chk(uint source,uint config_type,
|
||||||
ret = RET_INPUTERR;
|
ret = RET_INPUTERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ipv4_martian(&ip_conf->prefix))
|
if (config_type != CM_CONFIG_DEL && ipv4_martian(&ip_conf->prefix))
|
||||||
{
|
{
|
||||||
ret = RET_IPINVALID;
|
ret = RET_IPINVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ASSERT_RET(ret);
|
ASSERT_RET(ret);
|
||||||
|
|
||||||
if(ip_conf->prefixlen == 0 || ip_conf->prefixlen > IPV4_MAX_PREFIXLEN)
|
if(ip_conf->prefixlen == 0 || ip_conf->prefixlen > IPV4_MAX_PREFIXLEN)
|
||||||
|
|
|
@ -244,7 +244,7 @@ void set_if_config(char *if_name, char *conf_name, char *conf_buff)
|
||||||
f = fopen(conf_path,"r+");
|
f = fopen(conf_path,"r+");
|
||||||
if(f == NULL)
|
if(f == NULL)
|
||||||
{
|
{
|
||||||
printf("OPEN CONFIG FALID\n");
|
rpc_log_error("OPEN CONFIG FALID\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,7 +273,7 @@ void set_if_config(char *if_name, char *conf_name, char *conf_buff)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(leave_line == NULL)
|
if(leave_line == NULL)
|
||||||
{
|
{
|
||||||
leave_line = strstr(config_linebuf, iface_str);
|
leave_line = strstr(config_linebuf, iface_str);
|
||||||
|
|
||||||
|
@ -334,7 +334,7 @@ void set_if_config(char *if_name, char *conf_name, char *conf_buff)
|
||||||
strcat(sum_buf, conf_buff);
|
strcat(sum_buf, conf_buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("---sum_buf---->%s<----------/n",sum_buf);
|
rpc_log_dbg("---sum_buf---->%s<----------\n",sum_buf);
|
||||||
remove(conf_path);
|
remove(conf_path);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
|
@ -342,7 +342,7 @@ void set_if_config(char *if_name, char *conf_name, char *conf_buff)
|
||||||
fp = fopen(conf_path,"w+");
|
fp = fopen(conf_path,"w+");
|
||||||
if(fp == NULL)
|
if(fp == NULL)
|
||||||
{
|
{
|
||||||
printf("OPEN CONFIG FALID/n");
|
rpc_log_error("OPEN CONFIG FALID\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fseek(fp,0,SEEK_SET);
|
fseek(fp,0,SEEK_SET);
|
||||||
|
|
|
@ -98,7 +98,7 @@ int parse_config_type(char *str)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void parse_input_str(int argc, char **argv, int *config_type, ip_config_t *ip_conf)
|
ret_code parse_input_str(int argc, char **argv, int *config_type, ip_config_t *ip_conf)
|
||||||
{
|
{
|
||||||
int intput_cnt = argc;
|
int intput_cnt = argc;
|
||||||
int idx = 1;
|
int idx = 1;
|
||||||
|
@ -113,13 +113,13 @@ void parse_input_str(int argc, char **argv, int *config_type, ip_config_t *ip_co
|
||||||
if(*config_type == CM_CONFIG_GET_ALL
|
if(*config_type == CM_CONFIG_GET_ALL
|
||||||
|| *config_type == 0)
|
|| *config_type == 0)
|
||||||
{
|
{
|
||||||
return;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(intput_cnt < 2)
|
if(intput_cnt < 2)
|
||||||
{
|
{
|
||||||
printf("input error:<type> <if>\n");
|
printf("input error:<type> <if>\n");
|
||||||
return;
|
return RET_INPUTERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
idx++;
|
idx++;
|
||||||
|
@ -129,13 +129,13 @@ void parse_input_str(int argc, char **argv, int *config_type, ip_config_t *ip_co
|
||||||
if(*config_type == CM_CONFIG_GET)
|
if(*config_type == CM_CONFIG_GET)
|
||||||
{
|
{
|
||||||
ip_conf->family = AF_INET;
|
ip_conf->family = AF_INET;
|
||||||
return;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(argc < 4)
|
if(argc < 4)
|
||||||
{
|
{
|
||||||
printf("input error:<type> <if> <ip> <mask>\n");
|
printf("input error:<type> <if> <ip> <mask>\n");
|
||||||
return;
|
return RET_INPUTERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("if %s\n",ip_conf->ifname);
|
printf("if %s\n",ip_conf->ifname);
|
||||||
|
@ -165,7 +165,10 @@ int main(int argc, char **argv)
|
||||||
char* output = NULL;
|
char* output = NULL;
|
||||||
int output_len;
|
int output_len;
|
||||||
|
|
||||||
parse_input_str(argc, argv, &config_type, &ip_conf);
|
if(parse_input_str(argc, argv, &config_type, &ip_conf != RET_OK)
|
||||||
|
{
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
printf("=============================\n");
|
printf("=============================\n");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue