mirror of
git://git.code.sf.net/p/xtables-addons/xtables-addons
synced 2025-09-07 13:15:12 +02:00
ipp2p: internally simplify selecting protocol searches
This commit is contained in:
@@ -11,7 +11,6 @@ static void ipp2p_mt_help(void)
|
||||
{
|
||||
printf(
|
||||
"IPP2P v%s options:\n"
|
||||
" --ipp2p Grab all known p2p packets\n"
|
||||
" --edk [tcp,udp] All known eDonkey/eMule/Overnet packets\n"
|
||||
" --dc [tcp] All known Direct Connect packets\n"
|
||||
" --kazaa [tcp,udp] All known KaZaA packets\n"
|
||||
@@ -27,8 +26,6 @@ static void ipp2p_mt_help(void)
|
||||
" --xdcc [tcp] All known XDCC packets (only xdcc login)\n\n"
|
||||
"DEBUG SUPPPORT, use only if you know why\n"
|
||||
" --debug Generate kernel debug output, THIS WILL SLOW DOWN THE FILTER\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"
|
||||
"\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"
|
||||
"\nSee README included with this package for more details or visit http://www.ipp2p.org\n"
|
||||
@@ -40,7 +37,6 @@ static void ipp2p_mt_help(void)
|
||||
}
|
||||
|
||||
static const struct option ipp2p_mt_opts[] = {
|
||||
{ "ipp2p", 0, 0, '1' },
|
||||
{ "edk", 0, 0, '2' },
|
||||
{ "dc", 0, 0, '7' },
|
||||
{ "gnu", 0, 0, '9' },
|
||||
@@ -63,37 +59,11 @@ static int ipp2p_mt_parse(int c, char **argv, int invert, unsigned int *flags,
|
||||
struct ipt_p2p_info *info = (struct ipt_p2p_info *)(*match)->data;
|
||||
|
||||
switch (c) {
|
||||
case '1': /*cmd: ipp2p*/
|
||||
if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--ipp2p' may only be "
|
||||
"specified once!");
|
||||
/* if ((*flags & SHORT_HAND_DATA) == SHORT_HAND_DATA)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--ipp2p-data' may only be "
|
||||
"specified alone!");*/
|
||||
if ((*flags) != 0)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--ipp2p' may only be "
|
||||
"specified alone!");
|
||||
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
|
||||
*flags += SHORT_HAND_IPP2P;
|
||||
info->cmd = *flags;
|
||||
break;
|
||||
|
||||
case '2': /*cmd: edk*/
|
||||
if ((*flags & IPP2P_EDK) == IPP2P_EDK)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--edk' may only be "
|
||||
"specified once");
|
||||
if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--ipp2p' may only be "
|
||||
"specified alone!");
|
||||
/* if ((*flags & SHORT_HAND_DATA) == SHORT_HAND_DATA)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--ipp2p-data' may only be "
|
||||
"specified alone!");*/
|
||||
if ((*flags & IPP2P_DATA_EDK) == IPP2P_DATA_EDK)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: use `--edk' OR `--edk-data' but not both of them!");
|
||||
@@ -107,14 +77,6 @@ static int ipp2p_mt_parse(int c, char **argv, int invert, unsigned int *flags,
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--dc' may only be "
|
||||
"specified once!");
|
||||
if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--ipp2p' may only be "
|
||||
"specified alone!");
|
||||
/* if ((*flags & SHORT_HAND_DATA) == SHORT_HAND_DATA)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--ipp2p-data' may only be "
|
||||
"specified alone!");*/
|
||||
if ((*flags & IPP2P_DATA_DC) == IPP2P_DATA_DC)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: use `--dc' OR `--dc-data' but not both of them!");
|
||||
@@ -128,14 +90,6 @@ static int ipp2p_mt_parse(int c, char **argv, int invert, unsigned int *flags,
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--gnu' may only be "
|
||||
"specified once!");
|
||||
/* if ((*flags & SHORT_HAND_DATA) == SHORT_HAND_DATA)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--ipp2p-data' may only be "
|
||||
"specified alone!");*/
|
||||
if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--ipp2p' may only be "
|
||||
"specified alone!");
|
||||
if ((*flags & IPP2P_DATA_GNU) == IPP2P_DATA_GNU)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: use `--gnu' OR `--gnu-data' but not both of them!");
|
||||
@@ -149,14 +103,6 @@ static int ipp2p_mt_parse(int c, char **argv, int invert, unsigned int *flags,
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--kazaa' may only be "
|
||||
"specified once!");
|
||||
/* if ((*flags & SHORT_HAND_DATA) == SHORT_HAND_DATA)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--ipp2p-data' may only be "
|
||||
"specified alone!");*/
|
||||
if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--ipp2p' may only be "
|
||||
"specified alone!");
|
||||
if ((*flags & IPP2P_DATA_KAZAA) == IPP2P_DATA_KAZAA)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: use `--kazaa' OR `--kazaa-data' but not both of them!");
|
||||
@@ -170,11 +116,6 @@ static int ipp2p_mt_parse(int c, char **argv, int invert, unsigned int *flags,
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--bit' may only be "
|
||||
"specified once!");
|
||||
if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--ipp2p' may only be "
|
||||
"specified alone!");
|
||||
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
|
||||
*flags += IPP2P_BIT;
|
||||
info->cmd = *flags;
|
||||
break;
|
||||
@@ -184,10 +125,6 @@ static int ipp2p_mt_parse(int c, char **argv, int invert, unsigned int *flags,
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--apple' may only be "
|
||||
"specified once!");
|
||||
if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--ipp2p' may only be "
|
||||
"specified alone!");
|
||||
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
|
||||
*flags += IPP2P_APPLE;
|
||||
info->cmd = *flags;
|
||||
@@ -198,10 +135,6 @@ static int ipp2p_mt_parse(int c, char **argv, int invert, unsigned int *flags,
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--soul' may only be "
|
||||
"specified once!");
|
||||
if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--ipp2p' may only be "
|
||||
"specified alone!");
|
||||
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
|
||||
*flags += IPP2P_SOUL;
|
||||
info->cmd = *flags;
|
||||
@@ -212,10 +145,6 @@ static int ipp2p_mt_parse(int c, char **argv, int invert, unsigned int *flags,
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--winmx' may only be "
|
||||
"specified once!");
|
||||
if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--ipp2p' may only be "
|
||||
"specified alone!");
|
||||
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
|
||||
*flags += IPP2P_WINMX;
|
||||
info->cmd = *flags;
|
||||
@@ -226,10 +155,6 @@ static int ipp2p_mt_parse(int c, char **argv, int invert, unsigned int *flags,
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--ares' may only be "
|
||||
"specified once!");
|
||||
if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--ipp2p' may only be "
|
||||
"specified alone!");
|
||||
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
|
||||
*flags += IPP2P_ARES;
|
||||
info->cmd = *flags;
|
||||
@@ -283,104 +208,43 @@ static void ipp2p_mt_check(unsigned int flags)
|
||||
"\nipp2p-parameter problem: for ipp2p usage type: iptables -m ipp2p --help\n");
|
||||
}
|
||||
|
||||
static const char *const ipp2p_cmds[] = {
|
||||
[IPP2N_EDK] = "--edk",
|
||||
[IPP2N_DATA_KAZAA] = "--kazaa-data",
|
||||
[IPP2N_DATA_EDK] = "--edk-data",
|
||||
[IPP2N_DATA_DC] = "--dc-data",
|
||||
[IPP2N_DC] = "--dc",
|
||||
[IPP2N_DATA_GNU] = "--gnu-data",
|
||||
[IPP2N_GNU] = "--gnu",
|
||||
[IPP2N_KAZAA] = "--kazaa",
|
||||
[IPP2N_BIT] = "--bit",
|
||||
[IPP2N_APPLE] = "--apple",
|
||||
[IPP2N_SOUL] = "--soul",
|
||||
[IPP2N_WINMX] = "--winmx",
|
||||
[IPP2N_ARES] = "--ares",
|
||||
[IPP2N_MUTE] = "--mute",
|
||||
[IPP2N_WASTE] = "--waste",
|
||||
[IPP2N_XDCC] = "--xdcc",
|
||||
};
|
||||
|
||||
static void
|
||||
ipp2p_mt_print(const void *entry, const struct xt_entry_match *match,
|
||||
int numeric)
|
||||
{
|
||||
const struct ipt_p2p_info *info = (const void *)match->data;
|
||||
unsigned int i;
|
||||
|
||||
for (i = IPP2N_EDK; i <= IPP2N_XDCC; ++i)
|
||||
if (info->cmd & (1 << i))
|
||||
printf("%s ", ipp2p_cmds[i]);
|
||||
|
||||
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(" ");
|
||||
printf("--debug ");
|
||||
}
|
||||
|
||||
static void ipp2p_mt_save(const void *entry, const struct xt_entry_match *match)
|
||||
{
|
||||
const struct ipt_p2p_info *info = (const void *)match->data;
|
||||
|
||||
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 ");
|
||||
ipp2p_mt_print(entry, match, true);
|
||||
}
|
||||
|
||||
static struct xtables_match ipp2p_mt_reg = {
|
||||
|
Reference in New Issue
Block a user