diff --git a/extensions/expr b/extensions/expr
new file mode 100644
index 0000000..f00b70d
--- /dev/null
+++ b/extensions/expr
@@ -0,0 +1,179 @@
+#include <stdio.h>
+#include <stdint.h>
+#include <libHX/option.h>
+
+enum ttl_rel {
+ REL_EQ,
+ REL_LT,
+ REL_GT,
+};
+
+static bool ttl_inv;
+static uint8_t ttl_value;
+static unsigned int ttl_rel;
+
+/**
+ * @name: name of the option
+ * @act: pointer to variable to indicate the action
+ */
+struct edesc {
+ const char *name;
+ unsigned int *act;
+};
+
+static const struct HXoption ttl_options[] = {
+ {.name = "ttl-eq", .act = &ttl_rel, .avl = TTL_EQ,
+ .type = XTO_UINT8, .ptr = &ttl_value,
+ .inv = &ttl_inv, .opt_id = 0x01, .opt_conflict = 0xFF,
+ .help = "Match time to live value"},
+ {.ln = "ttl-lt", .type = XTO_UINT8, .ptr = &ttl_value,
+ .inv = &ttl_inv, .optid = 0x02, .optconflict = 0xFF,
+ .help = "Match TTL < value"},
+ {.ln = "ttl-gt", .type = XTO_UINT8, .ptr = &ttl_value,
+ .val = TTL_GT,
+ .help = "Match TTL > value"},
+ HXOPT_TABLEEND,
+};
+
+static const char *const ttl_relsym[] = {"=", "<", ">"};
+
+static int ttl_mt_expr(void)
+{
+ snprintf(exprbuf, sizeof(exprbuf), "*8(nh+1)%s%hhu", ttl_relsym, ttl_rel);
+}
+
+static struct expr_expander ttl_reg[] = {
+ {.name = "ttl", .build_expr = ttl_mt_expr},
+ {.name = "TTL", .build_expr = ttl_tg_expr},
+};
+
+
+ if (invert)
+ info->mode = IPT_TTL_NE;
+ else
+ info->mode = IPT_TTL_EQ;
+
+ /* is 0 allowed? */
+ info->ttl = value;
+ break;
+ case '3':
+ if (!xtables_strtoui(optarg, NULL, &value, 0, UINT8_MAX))
+ exit_error(PARAMETER_PROBLEM,
+ "ttl: Expected value between 0 and 255");
+
+ if (invert)
+ exit_error(PARAMETER_PROBLEM,
+ "ttl: unexpected `!'");
+
+ info->mode = IPT_TTL_LT;
+ info->ttl = value;
+ break;
+ case '4':
+ if (!xtables_strtoui(optarg, NULL, &value, 0, UINT8_MAX))
+ exit_error(PARAMETER_PROBLEM,
+ "ttl: Expected value between 0 and 255");
+
+ if (invert)
+ exit_error(PARAMETER_PROBLEM,
+ "ttl: unexpected `!'");
+
+ info->mode = IPT_TTL_GT;
+ info->ttl = value;
+ break;
+ default:
+ return 0;
+
+ }
+
+ if (*flags)
+ exit_error(PARAMETER_PROBLEM,
+ "Can't specify TTL option twice");
+ *flags = 1;
+
+ return 1;
+}
+
+static void ttl_check(unsigned int flags)
+{
+ if (!flags)
+ exit_error(PARAMETER_PROBLEM,
+ "TTL match: You must specify one of "
+ "`--ttl-eq', `--ttl-lt', `--ttl-gt");
+}
+
+static void ttl_print(const void *ip, const struct xt_entry_match *match,
+ int numeric)
+{
+ const struct ipt_ttl_info *info =
+ (struct ipt_ttl_info *) match->data;
+
+ printf("TTL match ");
+ switch (info->mode) {
+ case IPT_TTL_EQ:
+ printf("TTL == ");
+ break;
+ case IPT_TTL_NE:
+ printf("TTL != ");
+ break;
+ case IPT_TTL_LT:
+ printf("TTL < ");
+ break;
+ case IPT_TTL_GT:
+ printf("TTL > ");
+ break;
+ }
+ printf("%u ", info->ttl);
+}
+
+static void ttl_save(const void *ip, const struct xt_entry_match *match)
+{
+ const struct ipt_ttl_info *info =
+ (struct ipt_ttl_info *) match->data;
+
+ switch (info->mode) {
+ case IPT_TTL_EQ:
+ printf("--ttl-eq ");
+ break;
+ case IPT_TTL_NE:
+ printf("! --ttl-eq ");
+ break;
+ case IPT_TTL_LT:
+ printf("--ttl-lt ");
+ break;
+ case IPT_TTL_GT:
+ printf("--ttl-gt ");
+ break;
+ default:
+ /* error */
+ break;
+ }
+ printf("%u ", info->ttl);
+}
+
+static const struct option ttl_opts[] = {
+ { "ttl", 1, NULL, '2' },
+ { "ttl-eq", 1, NULL, '2'},
+ { "ttl-lt", 1, NULL, '3'},
+ { "ttl-gt", 1, NULL, '4'},
+ { .name = NULL }
+};
+
+static struct xtables_match ttl_mt_reg = {
+ .name = "ttl",
+ .version = XTABLES_VERSION,
+ .family = NFPROTO_IPV4,
+ .size = XT_ALIGN(sizeof(struct ipt_ttl_info)),
+ .userspacesize = XT_ALIGN(sizeof(struct ipt_ttl_info)),
+ .help = ttl_help,
+ .parse = ttl_parse,
+ .final_check = ttl_check,
+ .print = ttl_print,
+ .save = ttl_save,
+ .extra_opts = ttl_opts,
+};
+
+
+void _init(void)
+{
+ xtables_register_match(&ttl_mt_reg);
+}