mirror of
https://github.com/ChronosX88/netsukuku.git
synced 2024-11-26 04:02:19 +00:00
Linux Kernel Version checking
For compatibility between new and old distributions of linux.
This commit is contained in:
parent
9b8df0cd35
commit
cf72a5ec59
@ -27,6 +27,8 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <linux/version.h>
|
||||
|
||||
#include "linux_list.h"
|
||||
|
||||
//#define IPTC_DEBUG2 1
|
||||
@ -44,6 +46,7 @@
|
||||
#define IPT_LIB_DIR "/usr/local/lib/iptables"
|
||||
#endif
|
||||
|
||||
|
||||
static int sockfd = -1;
|
||||
static int sockfd_use = 0;
|
||||
static void *iptc_fn = NULL;
|
||||
@ -634,6 +637,25 @@ static int iptcc_compile_chain(TC_HANDLE_T h, STRUCT_REPLACE *repl, struct chain
|
||||
struct iptcb_chain_start *head;
|
||||
struct iptcb_chain_foot *foot;
|
||||
|
||||
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 7, 0)
|
||||
|
||||
/* only user-defined chains have heaer */
|
||||
if (!iptcc_is_builtin(c)) {
|
||||
/* put chain header in place */
|
||||
head = (void *)repl->entries + c->head_offset;
|
||||
head->e.target_offset = sizeof(STRUCT_ENTRY);
|
||||
head->e.next_offset = IPTCB_CHAIN_START_SIZE;
|
||||
strcpy(head->name.t.u.user.name, ERROR_TARGET);
|
||||
head->name.t.u.target_size =
|
||||
ALIGN(sizeof(struct ipt_error_target));
|
||||
strcpy(head->name.error, c->name);
|
||||
} else {
|
||||
repl->hook_entry[c->hooknum-1] = c->head_offset;
|
||||
repl->underflow[c->hooknum-1] = c->foot_offset;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0)
|
||||
/* only user-defined chains have heaer */
|
||||
if (!iptcc_is_builtin(c)) {
|
||||
/* put chain header in place */
|
||||
@ -643,11 +665,12 @@ static int iptcc_compile_chain(TC_HANDLE_T h, STRUCT_REPLACE *repl, struct chain
|
||||
strcpy(head->name.target.u.user.name, ERROR_TARGET);
|
||||
head->name.target.u.target_size =
|
||||
ALIGN(sizeof(struct ipt_error_target));
|
||||
strcpy(head->name.errorname, c->name);
|
||||
strcpy(head->name.error, c->name);
|
||||
} else {
|
||||
repl->hook_entry[c->hooknum-1] = c->head_offset;
|
||||
repl->underflow[c->hooknum-1] = c->foot_offset;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* iterate over rules */
|
||||
list_for_each_entry(r, &c->rules, list) {
|
||||
@ -744,7 +767,18 @@ static int iptcc_compile_table(TC_HANDLE_T h, STRUCT_REPLACE *repl)
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 7, 0)
|
||||
/* Append error rule at end of chain */
|
||||
error = (void *)repl->entries + repl->size - IPTCB_CHAIN_ERROR_SIZE;
|
||||
error->entry.target_offset = sizeof(STRUCT_ENTRY);
|
||||
error->entry.next_offset = IPTCB_CHAIN_ERROR_SIZE;
|
||||
error->target.t.u.user.target_size =
|
||||
ALIGN(sizeof(struct ipt_error_target));
|
||||
strcpy((char *)&error->target.t.u.user.name, ERROR_TARGET);
|
||||
strcpy((char *)&error->target.error, "ERROR");
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0)
|
||||
/* Append error rule at end of chain */
|
||||
error = (void *)repl->entries + repl->size - IPTCB_CHAIN_ERROR_SIZE;
|
||||
error->entry.target_offset = sizeof(STRUCT_ENTRY);
|
||||
@ -753,7 +787,7 @@ static int iptcc_compile_table(TC_HANDLE_T h, STRUCT_REPLACE *repl)
|
||||
ALIGN(sizeof(struct ipt_error_target));
|
||||
strcpy((char *)&error->target.target.u.user.name, ERROR_TARGET);
|
||||
strcpy((char *)&error->target.errorname, "ERROR");
|
||||
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user