ipp2p: adhere to codingstyle

This commit is contained in:
Jan Engelhardt
2008-03-26 06:53:08 +01:00
parent edcbcee84e
commit c237fe2486
2 changed files with 1034 additions and 921 deletions

View File

@@ -7,358 +7,398 @@
#include <xtables.h> #include <xtables.h>
#include "xt_ipp2p.h" #include "xt_ipp2p.h"
static void static void ipp2p_mt_help(void)
help(void)
{ {
printf( printf(
"IPP2P v%s options:\n" "IPP2P v%s options:\n"
" --ipp2p Grab all known p2p packets\n" " --ipp2p Grab all known p2p packets\n"
" --edk [TCP&UDP] All known eDonkey/eMule/Overnet packets\n" " --edk [tcp,udp] All known eDonkey/eMule/Overnet packets\n"
" --dc [TCP] All known Direct Connect packets\n" " --dc [tcp] All known Direct Connect packets\n"
" --kazaa [TCP&UDP] All known KaZaA packets\n" " --kazaa [tcp,udp] All known KaZaA packets\n"
" --gnu [TCP&UDP] All known Gnutella packets\n" " --gnu [tcp,udp] All known Gnutella packets\n"
" --bit [TCP&UDP] All known BitTorrent packets\n" " --bit [tcp,udp] All known BitTorrent packets\n"
" --apple [TCP] All known AppleJuice packets\n" " --apple [tcp] All known AppleJuice packets\n"
" --winmx [TCP] All known WinMX\n" " --winmx [tcp] All known WinMX\n"
" --soul [TCP] All known SoulSeek\n" " --soul [tcp] All known SoulSeek\n"
" --ares [TCP] All known Ares\n\n" " --ares [tcp] All known Ares\n\n"
" EXPERIMENTAL protocols (please send feedback to: ipp2p@ipp2p.org) :\n" "EXPERIMENTAL protocols (please send feedback to: ipp2p@ipp2p.org) :\n"
" --mute [TCP] All known Mute packets\n" " --mute [tcp] All known Mute packets\n"
" --waste [TCP] All known Waste packets\n" " --waste [tcp] All known Waste packets\n"
" --xdcc [TCP] All known XDCC packets (only xdcc login)\n\n" " --xdcc [tcp] All known XDCC packets (only xdcc login)\n\n"
" DEBUG SUPPPORT, use only if you know why\n" "DEBUG SUPPPORT, use only if you know why\n"
" --debug Generate kernel debug output, THIS WILL SLOW DOWN THE FILTER\n" " --debug Generate kernel debug output, THIS WILL SLOW DOWN THE FILTER\n"
"\nNote that the follwing options will have the same meaning:\n" "\nNote that the follwing options will have the same meaning:\n"
" '--ipp2p' is equal to '--edk --dc --kazaa --gnu --bit --apple --winmx --soul --ares'\n" " '--ipp2p' is equal to '--edk --dc --kazaa --gnu --bit --apple --winmx --soul --ares'\n"
"\nIPP2P was intended for TCP only. Due to increasing usage of UDP we needed to change this.\n" "\nIPP2P was intended for TCP only. Due to increasing usage of UDP we needed to change this.\n"
"You can now use -p udp to search UDP packets only or without -p switch to search UDP and TCP packets.\n" "You can now use -p udp to search UDP packets only or without -p switch to search UDP and TCP packets.\n"
"\nSee README included with this package for more details or visit http://www.ipp2p.org\n" "\nSee README included with this package for more details or visit http://www.ipp2p.org\n"
"\nExamples:\n" "\nExamples:\n"
" iptables -A FORWARD -m ipp2p --ipp2p -j MARK --set-mark 0x01\n" " iptables -A FORWARD -m ipp2p --ipp2p -j MARK --set-mark 0x01\n"
" iptables -A FORWARD -p udp -m ipp2p --kazaa --bit -j DROP\n" " iptables -A FORWARD -p udp -m ipp2p --kazaa --bit -j DROP\n"
" iptables -A FORWARD -p tcp -m ipp2p --edk --soul -j DROP\n\n" " iptables -A FORWARD -p tcp -m ipp2p --edk --soul -j DROP\n\n"
, IPP2P_VERSION); , IPP2P_VERSION);
} }
static struct option opts[] = { static struct option ipp2p_mt_opts[] = {
{ "ipp2p", 0, 0, '1' }, { "ipp2p", 0, 0, '1' },
{ "edk", 0, 0, '2' }, { "edk", 0, 0, '2' },
{ "dc", 0, 0, '7' }, { "dc", 0, 0, '7' },
{ "gnu", 0, 0, '9' }, { "gnu", 0, 0, '9' },
{ "kazaa", 0, 0, 'a' }, { "kazaa", 0, 0, 'a' },
{ "bit", 0, 0, 'b' }, { "bit", 0, 0, 'b' },
{ "apple", 0, 0, 'c' }, { "apple", 0, 0, 'c' },
{ "soul", 0, 0, 'd' }, { "soul", 0, 0, 'd' },
{ "winmx", 0, 0, 'e' }, { "winmx", 0, 0, 'e' },
{ "ares", 0, 0, 'f' }, { "ares", 0, 0, 'f' },
{ "mute", 0, 0, 'g' }, { "mute", 0, 0, 'g' },
{ "waste", 0, 0, 'h' }, { "waste", 0, 0, 'h' },
{ "xdcc", 0, 0, 'i' }, { "xdcc", 0, 0, 'i' },
{ "debug", 0, 0, 'j' }, { "debug", 0, 0, 'j' },
{0} {0},
}; };
static int static int ipp2p_mt_parse(int c, char **argv, int invert, unsigned int *flags,
parse(int c, char **argv, int invert, unsigned int *flags, const void *entry, struct xt_entry_match **match)
const void *entry,
struct xt_entry_match **match)
{ {
struct ipt_p2p_info *info = (struct ipt_p2p_info *)(*match)->data; struct ipt_p2p_info *info = (struct ipt_p2p_info *)(*match)->data;
switch (c) { switch (c) {
case '1': /*cmd: ipp2p*/ case '1': /*cmd: ipp2p*/
if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P) if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"ipp2p: `--ipp2p' may only be " "ipp2p: `--ipp2p' may only be "
"specified once!"); "specified once!");
/* if ((*flags & SHORT_HAND_DATA) == SHORT_HAND_DATA) /* if ((*flags & SHORT_HAND_DATA) == SHORT_HAND_DATA)
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"ipp2p: `--ipp2p-data' may only be " "ipp2p: `--ipp2p-data' may only be "
"specified alone!");*/ "specified alone!");*/
if ((*flags) != 0) if ((*flags) != 0)
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"ipp2p: `--ipp2p' may only be " "ipp2p: `--ipp2p' may only be "
"specified alone!"); "specified alone!");
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!"); if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
*flags += SHORT_HAND_IPP2P; *flags += SHORT_HAND_IPP2P;
info->cmd = *flags; info->cmd = *flags;
break; break;
case '2': /*cmd: edk*/ case '2': /*cmd: edk*/
if ((*flags & IPP2P_EDK) == IPP2P_EDK) if ((*flags & IPP2P_EDK) == IPP2P_EDK)
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"ipp2p: `--edk' may only be " "ipp2p: `--edk' may only be "
"specified once"); "specified once");
if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P) if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"ipp2p: `--ipp2p' may only be " "ipp2p: `--ipp2p' may only be "
"specified alone!"); "specified alone!");
/* if ((*flags & SHORT_HAND_DATA) == SHORT_HAND_DATA) /* if ((*flags & SHORT_HAND_DATA) == SHORT_HAND_DATA)
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"ipp2p: `--ipp2p-data' may only be " "ipp2p: `--ipp2p-data' may only be "
"specified alone!");*/ "specified alone!");*/
if ((*flags & IPP2P_DATA_EDK) == IPP2P_DATA_EDK) if ((*flags & IPP2P_DATA_EDK) == IPP2P_DATA_EDK)
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"ipp2p: use `--edk' OR `--edk-data' but not both of them!"); "ipp2p: use `--edk' OR `--edk-data' but not both of them!");
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!"); if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
*flags += IPP2P_EDK; *flags += IPP2P_EDK;
info->cmd = *flags; info->cmd = *flags;
break; break;
case '7': /*cmd: dc*/ case '7': /*cmd: dc*/
if ((*flags & IPP2P_DC) == IPP2P_DC) if ((*flags & IPP2P_DC) == IPP2P_DC)
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"ipp2p: `--dc' may only be " "ipp2p: `--dc' may only be "
"specified once!"); "specified once!");
if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P) if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"ipp2p: `--ipp2p' may only be " "ipp2p: `--ipp2p' may only be "
"specified alone!"); "specified alone!");
/* if ((*flags & SHORT_HAND_DATA) == SHORT_HAND_DATA) /* if ((*flags & SHORT_HAND_DATA) == SHORT_HAND_DATA)
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"ipp2p: `--ipp2p-data' may only be " "ipp2p: `--ipp2p-data' may only be "
"specified alone!");*/ "specified alone!");*/
if ((*flags & IPP2P_DATA_DC) == IPP2P_DATA_DC) if ((*flags & IPP2P_DATA_DC) == IPP2P_DATA_DC)
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"ipp2p: use `--dc' OR `--dc-data' but not both of them!"); "ipp2p: use `--dc' OR `--dc-data' but not both of them!");
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!"); if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
*flags += IPP2P_DC; *flags += IPP2P_DC;
info->cmd = *flags; info->cmd = *flags;
break; break;
case '9': /*cmd: gnu*/ case '9': /*cmd: gnu*/
if ((*flags & IPP2P_GNU) == IPP2P_GNU) if ((*flags & IPP2P_GNU) == IPP2P_GNU)
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"ipp2p: `--gnu' may only be " "ipp2p: `--gnu' may only be "
"specified once!"); "specified once!");
/* if ((*flags & SHORT_HAND_DATA) == SHORT_HAND_DATA) /* if ((*flags & SHORT_HAND_DATA) == SHORT_HAND_DATA)
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"ipp2p: `--ipp2p-data' may only be " "ipp2p: `--ipp2p-data' may only be "
"specified alone!");*/ "specified alone!");*/
if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P) if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"ipp2p: `--ipp2p' may only be " "ipp2p: `--ipp2p' may only be "
"specified alone!"); "specified alone!");
if ((*flags & IPP2P_DATA_GNU) == IPP2P_DATA_GNU) if ((*flags & IPP2P_DATA_GNU) == IPP2P_DATA_GNU)
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"ipp2p: use `--gnu' OR `--gnu-data' but not both of them!"); "ipp2p: use `--gnu' OR `--gnu-data' but not both of them!");
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!"); if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
*flags += IPP2P_GNU; *flags += IPP2P_GNU;
info->cmd = *flags; info->cmd = *flags;
break; break;
case 'a': /*cmd: kazaa*/ case 'a': /*cmd: kazaa*/
if ((*flags & IPP2P_KAZAA) == IPP2P_KAZAA) if ((*flags & IPP2P_KAZAA) == IPP2P_KAZAA)
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"ipp2p: `--kazaa' may only be " "ipp2p: `--kazaa' may only be "
"specified once!"); "specified once!");
/* if ((*flags & SHORT_HAND_DATA) == SHORT_HAND_DATA) /* if ((*flags & SHORT_HAND_DATA) == SHORT_HAND_DATA)
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"ipp2p: `--ipp2p-data' may only be " "ipp2p: `--ipp2p-data' may only be "
"specified alone!");*/ "specified alone!");*/
if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P) if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"ipp2p: `--ipp2p' may only be " "ipp2p: `--ipp2p' may only be "
"specified alone!"); "specified alone!");
if ((*flags & IPP2P_DATA_KAZAA) == IPP2P_DATA_KAZAA) if ((*flags & IPP2P_DATA_KAZAA) == IPP2P_DATA_KAZAA)
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"ipp2p: use `--kazaa' OR `--kazaa-data' but not both of them!"); "ipp2p: use `--kazaa' OR `--kazaa-data' but not both of them!");
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!"); if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
*flags += IPP2P_KAZAA; *flags += IPP2P_KAZAA;
info->cmd = *flags; info->cmd = *flags;
break; break;
case 'b': /*cmd: bit*/ case 'b': /*cmd: bit*/
if ((*flags & IPP2P_BIT) == IPP2P_BIT) if ((*flags & IPP2P_BIT) == IPP2P_BIT)
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"ipp2p: `--bit' may only be " "ipp2p: `--bit' may only be "
"specified once!"); "specified once!");
if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P) if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"ipp2p: `--ipp2p' may only be " "ipp2p: `--ipp2p' may only be "
"specified alone!"); "specified alone!");
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!"); if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
*flags += IPP2P_BIT; *flags += IPP2P_BIT;
info->cmd = *flags; info->cmd = *flags;
break; break;
case 'c': /*cmd: apple*/ case 'c': /*cmd: apple*/
if ((*flags & IPP2P_APPLE) == IPP2P_APPLE) if ((*flags & IPP2P_APPLE) == IPP2P_APPLE)
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"ipp2p: `--apple' may only be " "ipp2p: `--apple' may only be "
"specified once!"); "specified once!");
if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P) if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"ipp2p: `--ipp2p' may only be " "ipp2p: `--ipp2p' may only be "
"specified alone!"); "specified alone!");
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!"); if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
*flags += IPP2P_APPLE; *flags += IPP2P_APPLE;
info->cmd = *flags; info->cmd = *flags;
break; break;
case 'd': /*cmd: soul*/ case 'd': /*cmd: soul*/
if ((*flags & IPP2P_SOUL) == IPP2P_SOUL) if ((*flags & IPP2P_SOUL) == IPP2P_SOUL)
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"ipp2p: `--soul' may only be " "ipp2p: `--soul' may only be "
"specified once!"); "specified once!");
if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P) if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"ipp2p: `--ipp2p' may only be " "ipp2p: `--ipp2p' may only be "
"specified alone!"); "specified alone!");
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!"); if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
*flags += IPP2P_SOUL; *flags += IPP2P_SOUL;
info->cmd = *flags; info->cmd = *flags;
break; break;
case 'e': /*cmd: winmx*/ case 'e': /*cmd: winmx*/
if ((*flags & IPP2P_WINMX) == IPP2P_WINMX) if ((*flags & IPP2P_WINMX) == IPP2P_WINMX)
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"ipp2p: `--winmx' may only be " "ipp2p: `--winmx' may only be "
"specified once!"); "specified once!");
if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P) if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"ipp2p: `--ipp2p' may only be " "ipp2p: `--ipp2p' may only be "
"specified alone!"); "specified alone!");
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!"); if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
*flags += IPP2P_WINMX; *flags += IPP2P_WINMX;
info->cmd = *flags; info->cmd = *flags;
break; break;
case 'f': /*cmd: ares*/ case 'f': /*cmd: ares*/
if ((*flags & IPP2P_ARES) == IPP2P_ARES) if ((*flags & IPP2P_ARES) == IPP2P_ARES)
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"ipp2p: `--ares' may only be " "ipp2p: `--ares' may only be "
"specified once!"); "specified once!");
if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P) if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"ipp2p: `--ipp2p' may only be " "ipp2p: `--ipp2p' may only be "
"specified alone!"); "specified alone!");
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!"); if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
*flags += IPP2P_ARES; *flags += IPP2P_ARES;
info->cmd = *flags; info->cmd = *flags;
break; break;
case 'g': /*cmd: mute*/ case 'g': /*cmd: mute*/
if ((*flags & IPP2P_MUTE) == IPP2P_MUTE) if ((*flags & IPP2P_MUTE) == IPP2P_MUTE)
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"ipp2p: `--mute' may only be " "ipp2p: `--mute' may only be "
"specified once!"); "specified once!");
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!"); if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
*flags += IPP2P_MUTE; *flags += IPP2P_MUTE;
info->cmd = *flags; info->cmd = *flags;
break; break;
case 'h': /*cmd: waste*/ case 'h': /*cmd: waste*/
if ((*flags & IPP2P_WASTE) == IPP2P_WASTE) if ((*flags & IPP2P_WASTE) == IPP2P_WASTE)
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"ipp2p: `--waste' may only be " "ipp2p: `--waste' may only be "
"specified once!"); "specified once!");
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!"); if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
*flags += IPP2P_WASTE; *flags += IPP2P_WASTE;
info->cmd = *flags; info->cmd = *flags;
break; break;
case 'i': /*cmd: xdcc*/ case 'i': /*cmd: xdcc*/
if ((*flags & IPP2P_XDCC) == IPP2P_XDCC) if ((*flags & IPP2P_XDCC) == IPP2P_XDCC)
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"ipp2p: `--ares' may only be " "ipp2p: `--ares' may only be "
"specified once!"); "specified once!");
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!"); if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
*flags += IPP2P_XDCC; *flags += IPP2P_XDCC;
info->cmd = *flags; info->cmd = *flags;
break; break;
case 'j': /*cmd: debug*/ case 'j': /*cmd: debug*/
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!"); if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
info->debug = 1; info->debug = 1;
break; break;
default: default:
// exit_error(PARAMETER_PROBLEM, // exit_error(PARAMETER_PROBLEM,
// "\nipp2p-parameter problem: for ipp2p usage type: iptables -m ipp2p --help\n"); // "\nipp2p-parameter problem: for ipp2p usage type: iptables -m ipp2p --help\n");
return 0; return 0;
} }
return 1; return 1;
}
static void ipp2p_mt_check(unsigned int flags)
{
if (!flags)
exit_error(PARAMETER_PROBLEM,
"\nipp2p-parameter problem: for ipp2p usage type: iptables -m ipp2p --help\n");
} }
static void static void
final_check(unsigned int flags) ipp2p_mt_print(const void *entry, const struct xt_entry_match *match,
int numeric)
{ {
if (!flags) struct ipt_p2p_info *info = (struct ipt_p2p_info *)match->data;
exit_error(PARAMETER_PROBLEM,
"\nipp2p-parameter problem: for ipp2p usage type: iptables -m ipp2p --help\n"); printf("ipp2p v%s", IPP2P_VERSION);
if ((info->cmd & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
printf(" --ipp2p");
/*
if ((info->cmd & SHORT_HAND_DATA) == SHORT_HAND_DATA)
printf(" --ipp2p-data");
*/
if ((info->cmd & IPP2P_KAZAA) == IPP2P_KAZAA)
printf(" --kazaa");
/*
if ((info->cmd & IPP2P_DATA_KAZAA) == IPP2P_DATA_KAZAA)
printf(" --kazaa-data");
if ((info->cmd & IPP2P_DATA_GNU) == IPP2P_DATA_GNU)
printf(" --gnu-data");
*/
if ((info->cmd & IPP2P_GNU) == IPP2P_GNU) printf(" --gnu");
if ((info->cmd & IPP2P_EDK) == IPP2P_EDK) printf(" --edk");
/*
if ((info->cmd & IPP2P_DATA_EDK) == IPP2P_DATA_EDK)
printf(" --edk-data");
if ((info->cmd & IPP2P_DATA_DC) == IPP2P_DATA_DC)
printf(" --dc-data");
*/
if ((info->cmd & IPP2P_DC) == IPP2P_DC)
printf(" --dc");
if ((info->cmd & IPP2P_BIT) == IPP2P_BIT)
printf(" --bit");
if ((info->cmd & IPP2P_APPLE) == IPP2P_APPLE)
printf(" --apple");
if ((info->cmd & IPP2P_SOUL) == IPP2P_SOUL)
printf(" --soul");
if ((info->cmd & IPP2P_WINMX) == IPP2P_WINMX)
printf(" --winmx");
if ((info->cmd & IPP2P_ARES) == IPP2P_ARES)
printf(" --ares");
if ((info->cmd & IPP2P_MUTE) == IPP2P_MUTE)
printf(" --mute");
if ((info->cmd & IPP2P_WASTE) == IPP2P_WASTE)
printf(" --waste");
if ((info->cmd & IPP2P_XDCC) == IPP2P_XDCC)
printf(" --xdcc");
if (info->debug != 0)
printf(" --debug");
printf(" ");
} }
static void static void ipp2p_mt_save(const void *entry, const struct xt_entry_match *match)
print(const void *ip,
const struct xt_entry_match *match,
int numeric)
{ {
struct ipt_p2p_info *info = (struct ipt_p2p_info *)match->data; struct ipt_p2p_info *info = (struct ipt_p2p_info *)match->data;
printf("ipp2p v%s", IPP2P_VERSION); if ((info->cmd & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
if ((info->cmd & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P) printf(" --ipp2p"); printf("--ipp2p ");
// if ((info->cmd & SHORT_HAND_DATA) == SHORT_HAND_DATA) printf(" --ipp2p-data"); /*
if ((info->cmd & IPP2P_KAZAA) == IPP2P_KAZAA) printf(" --kazaa"); if ((info->cmd & SHORT_HAND_DATA) == SHORT_HAND_DATA)
// if ((info->cmd & IPP2P_DATA_KAZAA) == IPP2P_DATA_KAZAA) printf(" --kazaa-data"); printf("--ipp2p-data ");
// if ((info->cmd & IPP2P_DATA_GNU) == IPP2P_DATA_GNU) printf(" --gnu-data"); */
if ((info->cmd & IPP2P_GNU) == IPP2P_GNU) printf(" --gnu"); if ((info->cmd & IPP2P_KAZAA) == IPP2P_KAZAA)
if ((info->cmd & IPP2P_EDK) == IPP2P_EDK) printf(" --edk"); printf("--kazaa ");
// if ((info->cmd & IPP2P_DATA_EDK) == IPP2P_DATA_EDK) printf(" --edk-data"); /* if ((info->cmd & IPP2P_DATA_KAZAA) == IPP2P_DATA_KAZAA)
// if ((info->cmd & IPP2P_DATA_DC) == IPP2P_DATA_DC) printf(" --dc-data"); printf("--kazaa-data ");
if ((info->cmd & IPP2P_DC) == IPP2P_DC) printf(" --dc"); if ((info->cmd & IPP2P_DATA_GNU) == IPP2P_DATA_GNU)
if ((info->cmd & IPP2P_BIT) == IPP2P_BIT) printf(" --bit"); printf("--gnu-data ");
if ((info->cmd & IPP2P_APPLE) == IPP2P_APPLE) printf(" --apple"); */
if ((info->cmd & IPP2P_SOUL) == IPP2P_SOUL) printf(" --soul"); if ((info->cmd & IPP2P_GNU) == IPP2P_GNU)
if ((info->cmd & IPP2P_WINMX) == IPP2P_WINMX) printf(" --winmx"); printf("--gnu ");
if ((info->cmd & IPP2P_ARES) == IPP2P_ARES) printf(" --ares"); if ((info->cmd & IPP2P_EDK) == IPP2P_EDK)
if ((info->cmd & IPP2P_MUTE) == IPP2P_MUTE) printf(" --mute"); printf("--edk ");
if ((info->cmd & IPP2P_WASTE) == IPP2P_WASTE) printf(" --waste"); /* if ((info->cmd & IPP2P_DATA_EDK) == IPP2P_DATA_EDK)
if ((info->cmd & IPP2P_XDCC) == IPP2P_XDCC) printf(" --xdcc"); printf("--edk-data ");
if (info->debug != 0) printf(" --debug"); if ((info->cmd & IPP2P_DATA_DC) == IPP2P_DATA_DC)
printf(" "); printf("--dc-data ");
} */
if ((info->cmd & IPP2P_DC) == IPP2P_DC)
static void printf("--dc ");
save(const void *ip, const struct xt_entry_match *match) if ((info->cmd & IPP2P_BIT) == IPP2P_BIT)
{ printf("--bit ");
struct ipt_p2p_info *info = (struct ipt_p2p_info *)match->data; if ((info->cmd & IPP2P_APPLE) == IPP2P_APPLE)
printf("--apple ");
if ((info->cmd & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P) printf("--ipp2p "); if ((info->cmd & IPP2P_SOUL) == IPP2P_SOUL)
// if ((info->cmd & SHORT_HAND_DATA) == SHORT_HAND_DATA) printf("--ipp2p-data "); printf("--soul ");
if ((info->cmd & IPP2P_KAZAA) == IPP2P_KAZAA) printf("--kazaa "); if ((info->cmd & IPP2P_WINMX) == IPP2P_WINMX)
// if ((info->cmd & IPP2P_DATA_KAZAA) == IPP2P_DATA_KAZAA) printf("--kazaa-data "); printf("--winmx ");
// if ((info->cmd & IPP2P_DATA_GNU) == IPP2P_DATA_GNU) printf("--gnu-data "); if ((info->cmd & IPP2P_ARES) == IPP2P_ARES)
if ((info->cmd & IPP2P_GNU) == IPP2P_GNU) printf("--gnu "); printf("--ares ");
if ((info->cmd & IPP2P_EDK) == IPP2P_EDK) printf("--edk "); if ((info->cmd & IPP2P_MUTE) == IPP2P_MUTE)
// if ((info->cmd & IPP2P_DATA_EDK) == IPP2P_DATA_EDK) printf("--edk-data "); printf(" --mute");
// if ((info->cmd & IPP2P_DATA_DC) == IPP2P_DATA_DC) printf("--dc-data "); if ((info->cmd & IPP2P_WASTE) == IPP2P_WASTE)
if ((info->cmd & IPP2P_DC) == IPP2P_DC) printf("--dc "); printf(" --waste");
if ((info->cmd & IPP2P_BIT) == IPP2P_BIT) printf("--bit "); if ((info->cmd & IPP2P_XDCC) == IPP2P_XDCC)
if ((info->cmd & IPP2P_APPLE) == IPP2P_APPLE) printf("--apple "); printf(" --xdcc");
if ((info->cmd & IPP2P_SOUL) == IPP2P_SOUL) printf("--soul "); if (info->debug != 0)
if ((info->cmd & IPP2P_WINMX) == IPP2P_WINMX) printf("--winmx "); printf("--debug ");
if ((info->cmd & IPP2P_ARES) == IPP2P_ARES) printf("--ares ");
if ((info->cmd & IPP2P_MUTE) == IPP2P_MUTE) printf(" --mute");
if ((info->cmd & IPP2P_WASTE) == IPP2P_WASTE) printf(" --waste");
if ((info->cmd & IPP2P_XDCC) == IPP2P_XDCC) printf(" --xdcc");
if (info->debug != 0) printf("--debug ");
} }
static static struct xtables_match ipp2p_mt_reg = {
struct xtables_match ipp2p= .version = XTABLES_VERSION,
{ .name = "ipp2p",
.name = "ipp2p", .revision = 0,
.version = XTABLES_VERSION, .family = AF_INET,
.size = XT_ALIGN(sizeof(struct ipt_p2p_info)), .size = XT_ALIGN(sizeof(struct ipt_p2p_info)),
.userspacesize = XT_ALIGN(sizeof(struct ipt_p2p_info)), .userspacesize = XT_ALIGN(sizeof(struct ipt_p2p_info)),
.help = &help, .help = ipp2p_mt_help,
.parse = &parse, .parse = ipp2p_mt_parse,
.final_check = &final_check, .final_check = ipp2p_mt_check,
.print = &print, .print = ipp2p_mt_print,
.save = &save, .save = ipp2p_mt_save,
.extra_opts = opts .extra_opts = ipp2p_mt_opts,
}; };
void _init(void) void _init(void)
{ {
xtables_register_match(&ipp2p); xtables_register_match(&ipp2p_mt_reg);
} }

File diff suppressed because it is too large Load Diff