geoip: use tabs not spaces and indent

This commit is contained in:
Jan Engelhardt
2008-03-17 13:35:17 +01:00
parent 9f45aa737a
commit 205a006ac9
3 changed files with 382 additions and 387 deletions

View File

@@ -1,5 +1,5 @@
/* Shared library add-on to iptables to add geoip match support.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -184,7 +184,8 @@ parse_geoip_cc(const char *ccstr, u_int16_t *cc, struct geoip_info **mem)
u_int16_t cctmp;
buffer = strdup(ccstr);
if (!buffer) exit_error(OTHER_PROBLEM,
if (!buffer)
exit_error(OTHER_PROBLEM,
"geoip: insufficient memory available");
for (cp = buffer, i = 0; cp && i < XT_GEOIP_MAX; cp = next, i++)
@@ -200,18 +201,19 @@ parse_geoip_cc(const char *ccstr, u_int16_t *cc, struct geoip_info **mem)
}
}
if (cp) exit_error(PARAMETER_PROBLEM,
if (cp)
exit_error(PARAMETER_PROBLEM,
"geoip: too many countries specified");
free(buffer);
if (count == 0) exit_error(PARAMETER_PROBLEM,
if (count == 0)
exit_error(PARAMETER_PROBLEM,
"geoip: don't know what happened");
return count;
}
static int
geoip_parse(int c, char **argv, int invert, unsigned int *flags,
static int geoip_parse(int c, char **argv, int invert, unsigned int *flags,
const void *entry, struct xt_entry_match **match)
{
struct xt_geoip_match_info *info = (void *)(*match)->data;
@@ -264,11 +266,13 @@ geoip_print(const void *ip, const struct xt_entry_match *match, int numeric)
if (info->flags & XT_GEOIP_SRC)
printf("Source ");
else printf("Destination ");
else
printf("Destination ");
if (info->count > 1)
printf("countries: ");
else printf("country: ");
else
printf("country: ");
if (info->flags & XT_GEOIP_INV)
printf("! ");
@@ -289,7 +293,8 @@ geoip_save(const void *ip, const struct xt_entry_match *match)
if (info->flags & XT_GEOIP_SRC)
printf("--source-country ");
else printf("--destination-country ");
else
printf("--destination-country ");
for (i = 0; i < info->count; i++)
printf("%s%c%c", i ? "," : "", COUNTRY(info->cc[i]));
@@ -307,10 +312,10 @@ static struct xtables_match geoip_match = {
.final_check = geoip_final_check,
.print = geoip_print,
.save = geoip_save,
.extra_opts = geoip_opts
.extra_opts = geoip_opts,
};
void _init(void)
static void _init(void)
{
xtables_register_match(&geoip_match);
}

View File

@@ -49,7 +49,8 @@ static struct geoip_info *add_node(struct geoip_info *memcpy)
p->ref = 1;
p->next = head;
p->prev = NULL;
if (p->next) p->next->prev = p;
if (p->next)
p->next->prev = p;
head = p;
spin_unlock_bh(&geoip_lock);
@@ -57,7 +58,7 @@ static struct geoip_info *add_node(struct geoip_info *memcpy)
}
static void remove_node(struct geoip_info *p)
{
{
spin_lock_bh(&geoip_lock);
if (p->next) { /* Am I following a node ? */
@@ -99,14 +100,9 @@ static struct geoip_info *find_node(u_int16_t cc)
return NULL;
}
static bool xt_geoip_mt(const struct sk_buff *skb,
const struct net_device *in,
const struct net_device *out,
const struct xt_match *match,
const void *matchinfo,
int offset,
unsigned int protoff,
bool *hotdrop)
static bool xt_geoip_mt(const struct sk_buff *skb, const struct net_device *in,
const struct net_device *out, const struct xt_match *match,
const void *matchinfo, int offset, unsigned int protoff, bool *hotdrop)
{
const struct xt_geoip_match_info *info = matchinfo;
const struct geoip_info *node; /* This keeps the code sexy */
@@ -138,13 +134,9 @@ static bool xt_geoip_mt(const struct sk_buff *skb,
return (info->flags & XT_GEOIP_INV) ? 1 : 0;
}
static bool xt_geoip_mt_checkentry(const char *tablename,
const void *ip,
const struct xt_match *match,
void *matchinfo,
unsigned int hook_mas)
static bool xt_geoip_mt_checkentry(const char *table, const void *entry,
const struct xt_match *match, void *matchinfo, unsigned int hook_mask)
{
struct xt_geoip_match_info *info = matchinfo;
struct geoip_info *node;
u_int8_t i;
@@ -172,8 +164,7 @@ static bool xt_geoip_mt_checkentry(const char *tablename,
return 1;
}
static void xt_geoip_mt_destroy(const struct xt_match *matcn,
void *matchinfo)
static void xt_geoip_mt_destroy(const struct xt_match *match, void *matchinfo)
{
struct xt_geoip_match_info *info = matchinfo;
struct geoip_info *node; /* this keeps the code sexy */
@@ -205,9 +196,9 @@ static void xt_geoip_mt_destroy(const struct xt_match *matcn,
static struct xt_match xt_geoip_match __read_mostly = {
.family = AF_INET,
.name = "geoip",
.match = &xt_geoip_mt,
.checkentry = &xt_geoip_mt_checkentry,
.destroy = &xt_geoip_mt_destroy,
.match = xt_geoip_mt,
.checkentry = xt_geoip_mt_checkentry,
.destroy = xt_geoip_mt_destroy,
.matchsize = sizeof(struct xt_geoip_match_info),
.me = THIS_MODULE,
};

View File

@@ -10,8 +10,8 @@
* Samuel Jean
* Nicolas Bouliane
*/
#ifndef _XT_GEOIP_H
#define _XT_GEOIP_H
#ifndef _LINUX_NETFILTER_XT_GEOIP_H
#define _LINUX_NETFILTER_XT_GEOIP_H 1
#define XT_GEOIP_SRC 0x01 /* Perform check on Source IP */
#define XT_GEOIP_DST 0x02 /* Perform check on Destination IP */
@@ -44,5 +44,4 @@ struct xt_geoip_match_info {
#define COUNTRY(cc) (cc >> 8), (cc & 0x00FF)
#endif
#endif /* _LINUX_NETFILTER_XT_GEOIP_H */