Browse Source

add ipv6 extension target and move from ipt_ to xt_

git.mgm/mediaproxy-ng/2.0
Richard Fuchs 14 years ago
parent
commit
993fc8784e
1 changed files with 26 additions and 10 deletions
  1. +26
    -10
      iptables-extension/libxt_MEDIAPROXY.c

+ 26
- 10
iptables-extension/libxt_MEDIAPROXY.c View File

@ -1,4 +1,4 @@
/* gcc -O2 -Wall -shared -fPIC -o libipt_MEDIAPROXY.so libipt_MEDIAPROXY-1.4.c */
/* gcc -O2 -Wall -shared -fPIC -o libxt_MEDIAPROXY.so libxt_MEDIAPROXY.c */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -7,8 +7,9 @@
#include <netinet/in.h> #include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <xtables.h> #include <xtables.h>
#include <linux/netfilter_ipv4/ip_tables.h>
#include "../kernel-module/ipt_MEDIAPROXY.h"
#include <linux/netfilter.h>
#include <linux/netfilter/x_tables.h>
#include "../kernel-module/xt_MEDIAPROXY.h"
static void help(void) { static void help(void) {
@ -26,7 +27,7 @@ static int parse(int c,
const void *entry, const void *entry,
struct xt_entry_target **target) { struct xt_entry_target **target) {
struct ipt_mediaproxy_info *info = (void *) (*target)->data;
struct xt_mediaproxy_info *info = (void *) (*target)->data;
if (c == '1') { if (c == '1') {
info->id = atoi(optarg); info->id = atoi(optarg);
@ -45,13 +46,13 @@ static void final_check(unsigned int flags) {
} }
static void print(const void *ip, const struct xt_entry_target *target, int numeric) { static void print(const void *ip, const struct xt_entry_target *target, int numeric) {
struct ipt_mediaproxy_info *info = (void *) target->data;
struct xt_mediaproxy_info *info = (void *) target->data;
printf("id %u", info->id); printf("id %u", info->id);
} }
static void save(const void *ip, const struct xt_entry_target *target) { static void save(const void *ip, const struct xt_entry_target *target) {
struct ipt_mediaproxy_info *info = (void *) target->data;
struct xt_mediaproxy_info *info = (void *) target->data;
printf("--id %u", info->id); printf("--id %u", info->id);
} }
@ -62,12 +63,26 @@ static struct option opts[] = {
}; };
static struct xtables_target mediaproxy = {
static struct xtables_target mediaproxy4 = {
.name = "MEDIAPROXY", .name = "MEDIAPROXY",
.family = NFPROTO_IPV4, .family = NFPROTO_IPV4,
.version = XTABLES_VERSION, .version = XTABLES_VERSION,
.size = XT_ALIGN(sizeof(struct ipt_mediaproxy_info)),
.userspacesize = XT_ALIGN(sizeof(struct ipt_mediaproxy_info)),
.size = XT_ALIGN(sizeof(struct xt_mediaproxy_info)),
.userspacesize = XT_ALIGN(sizeof(struct xt_mediaproxy_info)),
.help = help,
.parse = parse,
.final_check = final_check,
.print = print,
.save = save,
.extra_opts = opts,
};
static struct xtables_target mediaproxy6 = {
.name = "MEDIAPROXY",
.family = NFPROTO_IPV6,
.version = XTABLES_VERSION,
.size = XT_ALIGN(sizeof(struct xt_mediaproxy_info)),
.userspacesize = XT_ALIGN(sizeof(struct xt_mediaproxy_info)),
.help = help, .help = help,
.parse = parse, .parse = parse,
.final_check = final_check, .final_check = final_check,
@ -77,5 +92,6 @@ static struct xtables_target mediaproxy = {
}; };
void _init(void) { void _init(void) {
xtables_register_target(&mediaproxy);
xtables_register_target(&mediaproxy4);
xtables_register_target(&mediaproxy6);
} }

Loading…
Cancel
Save