#include <linux/module.h>
static int ebt_mac_wormhash_contains(const struct ebt_mac_wormhash *wh,
- const char *mac, uint32_t ip)
+ const char *mac, __be32 ip)
{
/* You may be puzzled as to how this code works.
* Some tricks were used, refer to
return 0;
}
-static int get_ip_dst(const struct sk_buff *skb, uint32_t *addr)
+static int get_ip_dst(const struct sk_buff *skb, __be32 *addr)
{
- if (skb->mac.ethernet->h_proto == __constant_htons(ETH_P_IP)) {
- struct iphdr iph;
+ if (eth_hdr(skb)->h_proto == htons(ETH_P_IP)) {
+ struct iphdr _iph, *ih;
- if (skb_copy_bits(skb, 0, &iph, sizeof(iph)))
+ ih = skb_header_pointer(skb, 0, sizeof(_iph), &_iph);
+ if (ih == NULL)
return -1;
- *addr = iph.daddr;
- } else if (skb->mac.ethernet->h_proto == __constant_htons(ETH_P_ARP)) {
- struct arphdr arph;
-
- if (skb_copy_bits(skb, 0, &arph, sizeof(arph)) ||
- arph.ar_pln != sizeof(uint32_t) || arph.ar_hln != ETH_ALEN)
+ *addr = ih->daddr;
+ } else if (eth_hdr(skb)->h_proto == htons(ETH_P_ARP)) {
+ struct arphdr _arph, *ah;
+ __be32 buf, *bp;
+
+ ah = skb_header_pointer(skb, 0, sizeof(_arph), &_arph);
+ if (ah == NULL ||
+ ah->ar_pln != sizeof(__be32) ||
+ ah->ar_hln != ETH_ALEN)
return -1;
- if (skb_copy_bits(skb, sizeof(struct arphdr) +
- 2 * ETH_ALEN + sizeof(uint32_t), addr, sizeof(uint32_t)))
+ bp = skb_header_pointer(skb, sizeof(struct arphdr) +
+ 2 * ETH_ALEN + sizeof(__be32),
+ sizeof(__be32), &buf);
+ if (bp == NULL)
return -1;
+ *addr = *bp;
}
return 0;
}
-static int get_ip_src(const struct sk_buff *skb, uint32_t *addr)
+static int get_ip_src(const struct sk_buff *skb, __be32 *addr)
{
- if (skb->mac.ethernet->h_proto == __constant_htons(ETH_P_IP)) {
- struct iphdr iph;
+ if (eth_hdr(skb)->h_proto == htons(ETH_P_IP)) {
+ struct iphdr _iph, *ih;
- if (skb_copy_bits(skb, 0, &iph, sizeof(iph)))
+ ih = skb_header_pointer(skb, 0, sizeof(_iph), &_iph);
+ if (ih == NULL)
return -1;
- *addr = iph.saddr;
- } else if (skb->mac.ethernet->h_proto == __constant_htons(ETH_P_ARP)) {
- struct arphdr arph;
-
- if (skb_copy_bits(skb, 0, &arph, sizeof(arph)) ||
- arph.ar_pln != sizeof(uint32_t) || arph.ar_hln != ETH_ALEN)
+ *addr = ih->saddr;
+ } else if (eth_hdr(skb)->h_proto == htons(ETH_P_ARP)) {
+ struct arphdr _arph, *ah;
+ __be32 buf, *bp;
+
+ ah = skb_header_pointer(skb, 0, sizeof(_arph), &_arph);
+ if (ah == NULL ||
+ ah->ar_pln != sizeof(__be32) ||
+ ah->ar_hln != ETH_ALEN)
return -1;
- if (skb_copy_bits(skb, sizeof(struct arphdr) +
- ETH_ALEN, addr, sizeof(uint32_t)))
+ bp = skb_header_pointer(skb, sizeof(struct arphdr) +
+ ETH_ALEN, sizeof(__be32), &buf);
+ if (bp == NULL)
return -1;
+ *addr = *bp;
}
return 0;
}
struct ebt_among_info *info = (struct ebt_among_info *) data;
const char *dmac, *smac;
const struct ebt_mac_wormhash *wh_dst, *wh_src;
- uint32_t dip = 0, sip = 0;
+ __be32 dip = 0, sip = 0;
wh_dst = ebt_among_wh_dst(info);
wh_src = ebt_among_wh_src(info);
if (wh_src) {
- smac = skb->mac.ethernet->h_source;
+ smac = eth_hdr(skb)->h_source;
if (get_ip_src(skb, &sip))
return EBT_NOMATCH;
if (!(info->bitmask & EBT_AMONG_SRC_NEG)) {
}
if (wh_dst) {
- dmac = skb->mac.ethernet->h_dest;
+ dmac = eth_hdr(skb)->h_dest;
if (get_ip_dst(skb, &dip))
return EBT_NOMATCH;
if (!(info->bitmask & EBT_AMONG_DST_NEG)) {
.me = THIS_MODULE,
};
-static int __init init(void)
+static int __init ebt_among_init(void)
{
return ebt_register_match(&filter_among);
}
-static void __exit fini(void)
+static void __exit ebt_among_fini(void)
{
ebt_unregister_match(&filter_among);
}
-module_init(init);
-module_exit(fini);
+module_init(ebt_among_init);
+module_exit(ebt_among_fini);
MODULE_LICENSE("GPL");