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,25 +7,24 @@
#include <xtables.h>
#include "xt_ipp2p.h"
static void
help(void)
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"
" --gnu [TCP&UDP] All known Gnutella packets\n"
" --bit [TCP&UDP] All known BitTorrent packets\n"
" --apple [TCP] All known AppleJuice packets\n"
" --winmx [TCP] All known WinMX\n"
" --soul [TCP] All known SoulSeek\n"
" --ares [TCP] All known Ares\n\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"
" --gnu [tcp,udp] All known Gnutella packets\n"
" --bit [tcp,udp] All known BitTorrent packets\n"
" --apple [tcp] All known AppleJuice packets\n"
" --winmx [tcp] All known WinMX\n"
" --soul [tcp] All known SoulSeek\n"
" --ares [tcp] All known Ares\n\n"
"EXPERIMENTAL protocols (please send feedback to: ipp2p@ipp2p.org) :\n"
" --mute [TCP] All known Mute packets\n"
" --waste [TCP] All known Waste packets\n"
" --xdcc [TCP] All known XDCC packets (only xdcc login)\n\n"
" --mute [tcp] All known Mute packets\n"
" --waste [tcp] All known Waste packets\n"
" --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"
@@ -40,7 +39,7 @@ help(void)
, IPP2P_VERSION);
}
static struct option opts[] = {
static struct option ipp2p_mt_opts[] = {
{ "ipp2p", 0, 0, '1' },
{ "edk", 0, 0, '2' },
{ "dc", 0, 0, '7' },
@@ -55,13 +54,11 @@ static struct option opts[] = {
{ "waste", 0, 0, 'h' },
{ "xdcc", 0, 0, 'i' },
{ "debug", 0, 0, 'j' },
{0}
{0},
};
static int
parse(int c, char **argv, int invert, unsigned int *flags,
const void *entry,
struct xt_entry_match **match)
static int ipp2p_mt_parse(int c, char **argv, int invert, unsigned int *flags,
const void *entry, struct xt_entry_match **match)
{
struct ipt_p2p_info *info = (struct ipt_p2p_info *)(*match)->data;
@@ -279,8 +276,7 @@ parse(int c, char **argv, int invert, unsigned int *flags,
return 1;
}
static void
final_check(unsigned int flags)
static void ipp2p_mt_check(unsigned int flags)
{
if (!flags)
exit_error(PARAMETER_PROBLEM,
@@ -288,77 +284,121 @@ final_check(unsigned int flags)
}
static void
print(const void *ip,
const struct xt_entry_match *match,
ipp2p_mt_print(const void *entry, const struct xt_entry_match *match,
int numeric)
{
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) 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 & 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");
/*
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
save(const void *ip, const struct xt_entry_match *match)
static void ipp2p_mt_save(const void *entry, const struct xt_entry_match *match)
{
struct ipt_p2p_info *info = (struct ipt_p2p_info *)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 ");
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 ");
}
static
struct xtables_match ipp2p=
{
.name = "ipp2p",
static struct xtables_match ipp2p_mt_reg = {
.version = XTABLES_VERSION,
.name = "ipp2p",
.revision = 0,
.family = AF_INET,
.size = XT_ALIGN(sizeof(struct ipt_p2p_info)),
.userspacesize = XT_ALIGN(sizeof(struct ipt_p2p_info)),
.help = &help,
.parse = &parse,
.final_check = &final_check,
.print = &print,
.save = &save,
.extra_opts = opts
.help = ipp2p_mt_help,
.parse = ipp2p_mt_parse,
.final_check = ipp2p_mt_check,
.print = ipp2p_mt_print,
.save = ipp2p_mt_save,
.extra_opts = ipp2p_mt_opts,
};
void _init(void)
{
xtables_register_match(&ipp2p);
xtables_register_match(&ipp2p_mt_reg);
}

File diff suppressed because it is too large Load Diff