source:
npl/system/iptables/iptables-1.4.3.2-imq_xt.diff
@
c5c522c
Last change on this file since c5c522c was c5c522c, checked in by , 8 years ago | |
---|---|
|
|
File size: 3.5 KB |
-
extensions/.IMQ-testx
diff -Naurw iptables-1.4.1/extensions/.IMQ-testx iptables-1.4.1.imq/extensions/.IMQ-testx
old new 1 #!/bin/sh 2 # True if IMQ target patch is applied. 3 [ -f $KERNEL_DIR/include/linux/netfilter/xt_IMQ.h ] && echo IMQ -
extensions/libxt_IMQ.c
diff -Naurw iptables-1.4.1/extensions/libxt_IMQ.c iptables-1.4.1.imq/extensions/libxt_IMQ.c
old new 1 /* Shared library add-on to iptables to add IMQ target support. */ 2 #include <stdio.h> 3 #include <string.h> 4 #include <stdlib.h> 5 #include <getopt.h> 6 7 #include <xtables.h> 8 #include <linux/netfilter/x_tables.h> 9 #include <linux/netfilter/xt_IMQ.h> 10 11 /* Function which prints out usage message. */ 12 static void IMQ_help(void) 13 { 14 printf( 15 "IMQ target options:\n" 16 " --todev <N> enqueue to imq<N>, defaults to 0\n"); 17 18 } 19 20 static struct option IMQ_opts[] = { 21 { "todev", 1, 0, '1' }, 22 { 0 } 23 }; 24 25 /* Initialize the target. */ 26 static void IMQ_init(struct xt_entry_target *t) 27 { 28 struct xt_imq_info *mr = (struct xt_imq_info*)t->data; 29 30 mr->todev = 0; 31 } 32 33 /* Function which parses command options; returns true if it 34 ate an option */ 35 static int IMQ_parse(int c, char **argv, int invert, unsigned int *flags, 36 const void *entry, struct xt_entry_target **target) 37 { 38 struct xt_imq_info *mr = (struct xt_imq_info*)(*target)->data; 39 40 switch(c) { 41 case '1': 42 if (xtables_check_inverse(optarg, &invert, NULL, 0)) 43 xtables_error(PARAMETER_PROBLEM, 44 "Unexpected `!' after --todev"); 45 mr->todev=atoi(optarg); 46 break; 47 default: 48 return 0; 49 } 50 return 1; 51 } 52 53 /* Prints out the targinfo. */ 54 static void IMQ_print(const void *ip, 55 const struct xt_entry_target *target, 56 int numeric) 57 { 58 struct xt_imq_info *mr = (struct xt_imq_info*)target->data; 59 60 printf("IMQ: todev %u ", mr->todev); 61 } 62 63 /* Saves the union ipt_targinfo in parsable form to stdout. */ 64 static void IMQ_save(const void *ip, const struct xt_entry_target *target) 65 { 66 struct xt_imq_info *mr = (struct xt_imq_info*)target->data; 67 68 printf("--todev %u", mr->todev); 69 } 70 71 static struct xtables_target imq_target = { 72 .name = "IMQ", 73 .version = XTABLES_VERSION, 74 .family = NFPROTO_IPV4, 75 .size = XT_ALIGN(sizeof(struct xt_imq_info)), 76 .userspacesize = XT_ALIGN(sizeof(struct xt_imq_info)), 77 .help = IMQ_help, 78 .init = IMQ_init, 79 .parse = IMQ_parse, 80 .print = IMQ_print, 81 .save = IMQ_save, 82 .extra_opts = IMQ_opts, 83 }; 84 85 static struct xtables_target imq_target6 = { 86 .name = "IMQ", 87 .version = XTABLES_VERSION, 88 .family = NFPROTO_IPV6, 89 .size = XT_ALIGN(sizeof(struct xt_imq_info)), 90 .userspacesize = XT_ALIGN(sizeof(struct xt_imq_info)), 91 .help = IMQ_help, 92 .init = IMQ_init, 93 .parse = IMQ_parse, 94 .print = IMQ_print, 95 .save = IMQ_save, 96 .extra_opts = IMQ_opts, 97 }; 98 99 // void __attribute((constructor)) nf_ext_init(void){ 100 void _init(void){ 101 xtables_register_target(&imq_target); 102 xtables_register_target(&imq_target6); 103 } -
include/linux/netfilter/xt_IMQ.h
old new 1 #ifndef _XT_IMQ_H 2 #define _XT_IMQ_H 3 4 struct xt_imq_info { 5 unsigned int todev; /* target imq device */ 6 }; 7 8 #endif /* _XT_IMQ_H */ 9
Note: See TracBrowser
for help on using the repository browser.