mirror of
git://git.code.sf.net/p/xtables-addons/xtables-addons
synced 2025-09-08 13:44:56 +02:00
geoip: use tabs not spaces and indent
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/* Shared library add-on to iptables to add geoip match support.
|
/* Shared library add-on to iptables to add geoip match support.
|
||||||
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* 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;
|
u_int16_t cctmp;
|
||||||
|
|
||||||
buffer = strdup(ccstr);
|
buffer = strdup(ccstr);
|
||||||
if (!buffer) exit_error(OTHER_PROBLEM,
|
if (!buffer)
|
||||||
|
exit_error(OTHER_PROBLEM,
|
||||||
"geoip: insufficient memory available");
|
"geoip: insufficient memory available");
|
||||||
|
|
||||||
for (cp = buffer, i = 0; cp && i < XT_GEOIP_MAX; cp = next, i++)
|
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");
|
"geoip: too many countries specified");
|
||||||
free(buffer);
|
free(buffer);
|
||||||
|
|
||||||
if (count == 0) exit_error(PARAMETER_PROBLEM,
|
if (count == 0)
|
||||||
|
exit_error(PARAMETER_PROBLEM,
|
||||||
"geoip: don't know what happened");
|
"geoip: don't know what happened");
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int geoip_parse(int c, char **argv, int invert, unsigned int *flags,
|
||||||
geoip_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 xt_geoip_match_info *info = (void *)(*match)->data;
|
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)
|
if (info->flags & XT_GEOIP_SRC)
|
||||||
printf("Source ");
|
printf("Source ");
|
||||||
else printf("Destination ");
|
else
|
||||||
|
printf("Destination ");
|
||||||
|
|
||||||
if (info->count > 1)
|
if (info->count > 1)
|
||||||
printf("countries: ");
|
printf("countries: ");
|
||||||
else printf("country: ");
|
else
|
||||||
|
printf("country: ");
|
||||||
|
|
||||||
if (info->flags & XT_GEOIP_INV)
|
if (info->flags & XT_GEOIP_INV)
|
||||||
printf("! ");
|
printf("! ");
|
||||||
@@ -289,7 +293,8 @@ geoip_save(const void *ip, const struct xt_entry_match *match)
|
|||||||
|
|
||||||
if (info->flags & XT_GEOIP_SRC)
|
if (info->flags & XT_GEOIP_SRC)
|
||||||
printf("--source-country ");
|
printf("--source-country ");
|
||||||
else printf("--destination-country ");
|
else
|
||||||
|
printf("--destination-country ");
|
||||||
|
|
||||||
for (i = 0; i < info->count; i++)
|
for (i = 0; i < info->count; i++)
|
||||||
printf("%s%c%c", i ? "," : "", COUNTRY(info->cc[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,
|
.final_check = geoip_final_check,
|
||||||
.print = geoip_print,
|
.print = geoip_print,
|
||||||
.save = geoip_save,
|
.save = geoip_save,
|
||||||
.extra_opts = geoip_opts
|
.extra_opts = geoip_opts,
|
||||||
};
|
};
|
||||||
|
|
||||||
void _init(void)
|
static void _init(void)
|
||||||
{
|
{
|
||||||
xtables_register_match(&geoip_match);
|
xtables_register_match(&geoip_match);
|
||||||
}
|
}
|
||||||
|
@@ -49,7 +49,8 @@ static struct geoip_info *add_node(struct geoip_info *memcpy)
|
|||||||
p->ref = 1;
|
p->ref = 1;
|
||||||
p->next = head;
|
p->next = head;
|
||||||
p->prev = NULL;
|
p->prev = NULL;
|
||||||
if (p->next) p->next->prev = p;
|
if (p->next)
|
||||||
|
p->next->prev = p;
|
||||||
head = p;
|
head = p;
|
||||||
|
|
||||||
spin_unlock_bh(&geoip_lock);
|
spin_unlock_bh(&geoip_lock);
|
||||||
@@ -99,14 +100,9 @@ static struct geoip_info *find_node(u_int16_t cc)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool xt_geoip_mt(const struct sk_buff *skb,
|
static bool xt_geoip_mt(const struct sk_buff *skb, const struct net_device *in,
|
||||||
const struct net_device *in,
|
const struct net_device *out, const struct xt_match *match,
|
||||||
const struct net_device *out,
|
const void *matchinfo, int offset, unsigned int protoff, bool *hotdrop)
|
||||||
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 xt_geoip_match_info *info = matchinfo;
|
||||||
const struct geoip_info *node; /* This keeps the code sexy */
|
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;
|
return (info->flags & XT_GEOIP_INV) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool xt_geoip_mt_checkentry(const char *tablename,
|
static bool xt_geoip_mt_checkentry(const char *table, const void *entry,
|
||||||
const void *ip,
|
const struct xt_match *match, void *matchinfo, unsigned int hook_mask)
|
||||||
const struct xt_match *match,
|
|
||||||
void *matchinfo,
|
|
||||||
unsigned int hook_mas)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
struct xt_geoip_match_info *info = matchinfo;
|
struct xt_geoip_match_info *info = matchinfo;
|
||||||
struct geoip_info *node;
|
struct geoip_info *node;
|
||||||
u_int8_t i;
|
u_int8_t i;
|
||||||
@@ -172,8 +164,7 @@ static bool xt_geoip_mt_checkentry(const char *tablename,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xt_geoip_mt_destroy(const struct xt_match *matcn,
|
static void xt_geoip_mt_destroy(const struct xt_match *match, void *matchinfo)
|
||||||
void *matchinfo)
|
|
||||||
{
|
{
|
||||||
struct xt_geoip_match_info *info = matchinfo;
|
struct xt_geoip_match_info *info = matchinfo;
|
||||||
struct geoip_info *node; /* this keeps the code sexy */
|
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 = {
|
static struct xt_match xt_geoip_match __read_mostly = {
|
||||||
.family = AF_INET,
|
.family = AF_INET,
|
||||||
.name = "geoip",
|
.name = "geoip",
|
||||||
.match = &xt_geoip_mt,
|
.match = xt_geoip_mt,
|
||||||
.checkentry = &xt_geoip_mt_checkentry,
|
.checkentry = xt_geoip_mt_checkentry,
|
||||||
.destroy = &xt_geoip_mt_destroy,
|
.destroy = xt_geoip_mt_destroy,
|
||||||
.matchsize = sizeof(struct xt_geoip_match_info),
|
.matchsize = sizeof(struct xt_geoip_match_info),
|
||||||
.me = THIS_MODULE,
|
.me = THIS_MODULE,
|
||||||
};
|
};
|
||||||
|
@@ -10,8 +10,8 @@
|
|||||||
* Samuel Jean
|
* Samuel Jean
|
||||||
* Nicolas Bouliane
|
* Nicolas Bouliane
|
||||||
*/
|
*/
|
||||||
#ifndef _XT_GEOIP_H
|
#ifndef _LINUX_NETFILTER_XT_GEOIP_H
|
||||||
#define _XT_GEOIP_H
|
#define _LINUX_NETFILTER_XT_GEOIP_H 1
|
||||||
|
|
||||||
#define XT_GEOIP_SRC 0x01 /* Perform check on Source IP */
|
#define XT_GEOIP_SRC 0x01 /* Perform check on Source IP */
|
||||||
#define XT_GEOIP_DST 0x02 /* Perform check on Destination 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)
|
#define COUNTRY(cc) (cc >> 8), (cc & 0x00FF)
|
||||||
|
|
||||||
#endif
|
#endif /* _LINUX_NETFILTER_XT_GEOIP_H */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user