]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
extensions: libipt_LOG/libip6t_LOG: support macdecode option
authorPatrick McHardy <kaber@trash.net>
Mon, 28 Jun 2010 12:51:35 +0000 (14:51 +0200)
committerPatrick McHardy <kaber@trash.net>
Mon, 28 Jun 2010 12:51:35 +0000 (14:51 +0200)
Signed-off-by: Patrick McHardy <kaber@trash.net>
extensions/libip6t_LOG.c
extensions/libipt_LOG.c
include/linux/netfilter_ipv4/ipt_LOG.h
include/linux/netfilter_ipv6/ip6t_LOG.h

index 423d9884b9d5fce4a5c9a75f4197a8477c596466..ff9edc68bdbe492e4c0e90903a2c36926665f3d7 100644 (file)
@@ -25,7 +25,8 @@ static void LOG_help(void)
 " --log-tcp-sequence           Log TCP sequence numbers.\n"
 " --log-tcp-options            Log TCP options.\n"
 " --log-ip-options             Log IP options.\n"
-" --log-uid                    Log UID owning the local socket.\n");
+" --log-uid                    Log UID owning the local socket.\n"
+" --log-macdecode              Decode MAC addresses and protocol.\n");
 }
 
 static const struct option LOG_opts[] = {
@@ -35,6 +36,7 @@ static const struct option LOG_opts[] = {
        { .name = "log-tcp-options",  .has_arg = 0, .val = '2' },
        { .name = "log-ip-options",   .has_arg = 0, .val = '3' },
        { .name = "log-uid",          .has_arg = 0, .val = '4' },
+       { .name = "log-macdecode",    .has_arg = 0, .val = '5' },
        { .name = NULL }
 };
 
@@ -96,6 +98,7 @@ parse_level(const char *level)
 #define IP6T_LOG_OPT_TCPOPT 0x08
 #define IP6T_LOG_OPT_IPOPT 0x10
 #define IP6T_LOG_OPT_UID 0x20
+#define IP6T_LOG_OPT_MACDECODE 0x40
 
 static int LOG_parse(int c, char **argv, int invert, unsigned int *flags,
                      const void *entry, struct xt_entry_target **target)
@@ -179,6 +182,15 @@ static int LOG_parse(int c, char **argv, int invert, unsigned int *flags,
                *flags |= IP6T_LOG_OPT_UID;
                break;
 
+       case '5':
+               if (*flags & IP6T_LOG_OPT_MACDECODE)
+                       xtables_error(PARAMETER_PROBLEM,
+                                     "Can't specify --log-macdecode twice");
+
+               loginfo->logflags |= IP6T_LOG_MACDECODE;
+               *flags |= IP6T_LOG_OPT_MACDECODE;
+               break;
+
        default:
                return 0;
        }
@@ -213,6 +225,8 @@ static void LOG_print(const void *ip, const struct xt_entry_target *target,
                        printf("ip-options ");
                if (loginfo->logflags & IP6T_LOG_UID)
                        printf("uid ");
+               if (loginfo->logflags & IP6T_LOG_MACDECODE)
+                       printf("macdecode ");
                if (loginfo->logflags & ~(IP6T_LOG_MASK))
                        printf("unknown-flags ");
        }
@@ -240,6 +254,8 @@ static void LOG_save(const void *ip, const struct xt_entry_target *target)
                printf("--log-ip-options ");
        if (loginfo->logflags & IP6T_LOG_UID)
                printf("--log-uid ");
+       if (loginfo->logflags & IP6T_LOG_MACDECODE)
+               printf("--log-macdecode ");
 }
 
 static struct xtables_target log_tg6_reg = {
index 9afb91d6d73a77db92368a7e021955191764e6ed..73c8f32d050c6b883b0c343dca909545f0988cbd 100644 (file)
@@ -25,7 +25,8 @@ static void LOG_help(void)
 " --log-tcp-sequence           Log TCP sequence numbers.\n\n"
 " --log-tcp-options            Log TCP options.\n\n"
 " --log-ip-options             Log IP options.\n\n"
-" --log-uid                    Log UID owning the local socket.\n\n");
+" --log-uid                    Log UID owning the local socket.\n\n"
+" --log-macdecode              Decode MAC addresses and protocol.\n\n");
 }
 
 static const struct option LOG_opts[] = {
@@ -35,6 +36,7 @@ static const struct option LOG_opts[] = {
        { .name = "log-tcp-options",  .has_arg = 0, .val = '2' },
        { .name = "log-ip-options",   .has_arg = 0, .val = '3' },
        { .name = "log-uid",          .has_arg = 0, .val = '4' },
+       { .name = "log-macdecode",    .has_arg = 0, .val = '5' },
        { .name = NULL }
 };
 
@@ -96,6 +98,7 @@ parse_level(const char *level)
 #define IPT_LOG_OPT_TCPOPT 0x08
 #define IPT_LOG_OPT_IPOPT 0x10
 #define IPT_LOG_OPT_UID 0x20
+#define IPT_LOG_OPT_MACDECODE 0x40
 
 static int LOG_parse(int c, char **argv, int invert, unsigned int *flags,
                      const void *entry, struct xt_entry_target **target)
@@ -179,6 +182,14 @@ static int LOG_parse(int c, char **argv, int invert, unsigned int *flags,
                *flags |= IPT_LOG_OPT_UID;
                break;
 
+       case '5':
+               if (*flags & IPT_LOG_OPT_MACDECODE)
+                       xtables_error(PARAMETER_PROBLEM,
+                                     "Can't specifiy --log-macdecode twice");
+
+               loginfo->logflags |= IPT_LOG_MACDECODE;
+               *flags |= IPT_LOG_OPT_MACDECODE;
+               break;
        default:
                return 0;
        }
@@ -213,6 +224,8 @@ static void LOG_print(const void *ip, const struct xt_entry_target *target,
                        printf("ip-options ");
                if (loginfo->logflags & IPT_LOG_UID)
                        printf("uid ");
+               if (loginfo->logflags & IPT_LOG_MACDECODE)
+                       printf("macdecode ");
                if (loginfo->logflags & ~(IPT_LOG_MASK))
                        printf("unknown-flags ");
        }
@@ -242,6 +255,8 @@ static void LOG_save(const void *ip, const struct xt_entry_target *target)
                printf("--log-ip-options ");
        if (loginfo->logflags & IPT_LOG_UID)
                printf("--log-uid ");
+       if (loginfo->logflags & IPT_LOG_MACDECODE)
+               printf("--log-macdecode ");
 }
 
 static struct xtables_target log_tg_reg = {
index 90fa6525ef9c8bb731015bfd6e4f309a717a4c38..dcdbadf9fd4a94180ed0705db436e4470bf0e9dd 100644 (file)
@@ -7,7 +7,8 @@
 #define IPT_LOG_IPOPT          0x04    /* Log IP options */
 #define IPT_LOG_UID            0x08    /* Log UID owning local socket */
 #define IPT_LOG_NFLOG          0x10    /* Unsupported, don't reuse */
-#define IPT_LOG_MASK           0x1f
+#define IPT_LOG_MACDECODE      0x20    /* Decode MAC header */
+#define IPT_LOG_MASK           0x2f
 
 struct ipt_log_info {
        unsigned char level;
index 0d0119b0458c7f6d23190118ac342005edd0d419..9dd5579e02ec75b82a503fc818d292e19b6b78c0 100644 (file)
@@ -7,7 +7,8 @@
 #define IP6T_LOG_IPOPT         0x04    /* Log IP options */
 #define IP6T_LOG_UID           0x08    /* Log UID owning local socket */
 #define IP6T_LOG_NFLOG         0x10    /* Unsupported, don't use */
-#define IP6T_LOG_MASK          0x1f
+#define IP6T_LOG_MACDECODE     0x20    /* Decode MAC header */
+#define IP6T_LOG_MASK          0x2f
 
 struct ip6t_log_info {
        unsigned char level;