修复错误
This commit is contained in:
parent
a5baeac084
commit
a7ff1174c0
15
libiptc.c
15
libiptc.c
@ -1,6 +1,5 @@
|
|||||||
#include "libiptc.h"
|
#include "libiptc.h"
|
||||||
|
|
||||||
|
|
||||||
int x_get_rule(const char *chain, struct xtc_handle *handle, char *ipv4)
|
int x_get_rule(const char *chain, struct xtc_handle *handle, char *ipv4)
|
||||||
{
|
{
|
||||||
int r=1;
|
int r=1;
|
||||||
@ -83,7 +82,7 @@ struct ipt_entry_match *get_match(const char *sports, const char *dports, unsign
|
|||||||
size = IPT_ALIGN(sizeof(*match)) + IPT_ALIGN(sizeof(*udpinfo));
|
size = IPT_ALIGN(sizeof(*match)) + IPT_ALIGN(sizeof(*udpinfo));
|
||||||
match = (struct ipt_entry_match *)calloc(1, size);
|
match = (struct ipt_entry_match *)calloc(1, size);
|
||||||
match->u.match_size = size;
|
match->u.match_size = size;
|
||||||
memmove(match->u.user.name, protocol, IPT_FUNCTION_MAXNAMELEN);
|
strncpy(match->u.user.name, protocol, IPT_FUNCTION_MAXNAMELEN-2);
|
||||||
|
|
||||||
udpinfo = (struct ipt_udp *)match->data;
|
udpinfo = (struct ipt_udp *)match->data;
|
||||||
udpinfo->spts[1] = udpinfo->dpts[1] = 0xFFFF;
|
udpinfo->spts[1] = udpinfo->dpts[1] = 0xFFFF;
|
||||||
@ -103,8 +102,8 @@ struct ipt_entry_match *get_match(const char *sports, const char *dports, unsign
|
|||||||
int iptc_add_rule(const char *table, const char *chain, int protocol, const char *iniface, const char *outiface, unsigned int src,
|
int iptc_add_rule(const char *table, const char *chain, int protocol, const char *iniface, const char *outiface, unsigned int src,
|
||||||
unsigned int dest, const char *srcports, const char *destports, const char *target, const char *dnat_to, const int append)
|
unsigned int dest, const char *srcports, const char *destports, const char *target, const char *dnat_to, const int append)
|
||||||
{
|
{
|
||||||
struct xtc_handle *handle = NULL;
|
struct xtc_handle *handle;
|
||||||
struct ipt_entry *chain_entry = NULL;
|
struct ipt_entry *chain_entry;
|
||||||
struct ipt_entry_match *entry_match = NULL;
|
struct ipt_entry_match *entry_match = NULL;
|
||||||
struct ipt_entry_target *entry_target = NULL;
|
struct ipt_entry_target *entry_target = NULL;
|
||||||
ipt_chainlabel labelit;
|
ipt_chainlabel labelit;
|
||||||
@ -123,9 +122,9 @@ int iptc_add_rule(const char *table, const char *chain, int protocol, const char
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (iniface)
|
if (iniface)
|
||||||
memmove(chain_entry->ip.iniface, iniface, IFNAMSIZ);
|
strncpy(chain_entry->ip.iniface, iniface, IFNAMSIZ);
|
||||||
if (outiface)
|
if (outiface)
|
||||||
memmove(chain_entry->ip.outiface, outiface, IFNAMSIZ);
|
strncpy(chain_entry->ip.outiface, outiface, IFNAMSIZ);
|
||||||
|
|
||||||
chain_entry->ip.proto = protocol;
|
chain_entry->ip.proto = protocol;
|
||||||
if (IPPROTO_UDP == protocol)
|
if (IPPROTO_UDP == protocol)
|
||||||
@ -138,7 +137,7 @@ int iptc_add_rule(const char *table, const char *chain, int protocol, const char
|
|||||||
size = IPT_ALIGN(sizeof(struct ipt_entry_target)) + IPT_ALIGN(sizeof(int));
|
size = IPT_ALIGN(sizeof(struct ipt_entry_target)) + IPT_ALIGN(sizeof(int));
|
||||||
entry_target = (struct ipt_entry_target *)calloc(1, size);
|
entry_target = (struct ipt_entry_target *)calloc(1, size);
|
||||||
entry_target->u.user.target_size = size;
|
entry_target->u.user.target_size = size;
|
||||||
memmove(entry_target->u.user.name, target, IPT_FUNCTION_MAXNAMELEN);
|
strncpy(entry_target->u.user.name, target, IPT_FUNCTION_MAXNAMELEN);
|
||||||
}
|
}
|
||||||
if (entry_match) {
|
if (entry_match) {
|
||||||
match_size = entry_match->u.match_size;
|
match_size = entry_match->u.match_size;
|
||||||
@ -168,7 +167,7 @@ int iptc_add_rule(const char *table, const char *chain, int protocol, const char
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
memmove(labelit, chain, sizeof(ipt_chainlabel));
|
strncpy(labelit, chain, sizeof(ipt_chainlabel));
|
||||||
//printf("Chain name:%s\n", chain);
|
//printf("Chain name:%s\n", chain);
|
||||||
result = iptc_is_chain(chain, handle);
|
result = iptc_is_chain(chain, handle);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
|
Loading…
Reference in New Issue
Block a user