ebt_pkttype.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * ebt_pkttype
  3. *
  4. * Authors:
  5. * Bart De Schuymer <bdschuym@pandora.be>
  6. *
  7. * April, 2003
  8. *
  9. */
  10. #include <linux/module.h>
  11. #include <linux/netfilter/x_tables.h>
  12. #include <linux/netfilter_bridge/ebtables.h>
  13. #include <linux/netfilter_bridge/ebt_pkttype.h>
  14. static bool
  15. ebt_pkttype_mt(const struct sk_buff *skb, struct xt_action_param *par)
  16. {
  17. const struct ebt_pkttype_info *info = par->matchinfo;
  18. return (skb->pkt_type == info->pkt_type) ^ info->invert;
  19. }
  20. static int ebt_pkttype_mt_check(const struct xt_mtchk_param *par)
  21. {
  22. const struct ebt_pkttype_info *info = par->matchinfo;
  23. if (info->invert != 0 && info->invert != 1)
  24. return -EINVAL;
  25. /* Allow any pkt_type value */
  26. return 0;
  27. }
  28. static struct xt_match ebt_pkttype_mt_reg __read_mostly = {
  29. .name = "pkttype",
  30. .revision = 0,
  31. .family = NFPROTO_BRIDGE,
  32. .match = ebt_pkttype_mt,
  33. .checkentry = ebt_pkttype_mt_check,
  34. .matchsize = sizeof(struct ebt_pkttype_info),
  35. .me = THIS_MODULE,
  36. };
  37. static int __init ebt_pkttype_init(void)
  38. {
  39. return xt_register_match(&ebt_pkttype_mt_reg);
  40. }
  41. static void __exit ebt_pkttype_fini(void)
  42. {
  43. xt_unregister_match(&ebt_pkttype_mt_reg);
  44. }
  45. module_init(ebt_pkttype_init);
  46. module_exit(ebt_pkttype_fini);
  47. MODULE_DESCRIPTION("Ebtables: Link layer packet type match");
  48. MODULE_LICENSE("GPL");