1 /* module that allows mangling of the arp payload */
2 #include <linux/module.h>
3 #include <linux/netfilter.h>
4 #include <linux/netfilter_arp/arpt_mangle.h>
8 MODULE_AUTHOR("Bart De Schuymer <bdschuym@pandora.be>");
9 MODULE_DESCRIPTION("arptables arp payload mangle target");
12 target(struct sk_buff
*skb
,
13 const struct net_device
*in
, const struct net_device
*out
,
14 unsigned int hooknum
, const struct xt_target
*target
,
17 const struct arpt_mangle
*mangle
= targinfo
;
19 unsigned char *arpptr
;
22 <<<<<<< HEAD
:net
/ipv4
/netfilter
/arpt_mangle
.c
23 if (skb_make_writable(skb
, skb
->len
))
25 if (!skb_make_writable(skb
, skb
->len
))
26 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:net
/ipv4
/netfilter
/arpt_mangle
.c
30 arpptr
= skb_network_header(skb
) + sizeof(*arp
);
33 /* We assume that pln and hln were checked in the match */
34 if (mangle
->flags
& ARPT_MANGLE_SDEV
) {
35 if (ARPT_DEV_ADDR_LEN_MAX
< hln
||
36 (arpptr
+ hln
> skb_tail_pointer(skb
)))
38 memcpy(arpptr
, mangle
->src_devaddr
, hln
);
41 if (mangle
->flags
& ARPT_MANGLE_SIP
) {
42 if (ARPT_MANGLE_ADDR_LEN_MAX
< pln
||
43 (arpptr
+ pln
> skb_tail_pointer(skb
)))
45 memcpy(arpptr
, &mangle
->u_s
.src_ip
, pln
);
48 if (mangle
->flags
& ARPT_MANGLE_TDEV
) {
49 if (ARPT_DEV_ADDR_LEN_MAX
< hln
||
50 (arpptr
+ hln
> skb_tail_pointer(skb
)))
52 memcpy(arpptr
, mangle
->tgt_devaddr
, hln
);
55 if (mangle
->flags
& ARPT_MANGLE_TIP
) {
56 if (ARPT_MANGLE_ADDR_LEN_MAX
< pln
||
57 (arpptr
+ pln
> skb_tail_pointer(skb
)))
59 memcpy(arpptr
, &mangle
->u_t
.tgt_ip
, pln
);
61 return mangle
->target
;
65 checkentry(const char *tablename
, const void *e
, const struct xt_target
*target
,
66 void *targinfo
, unsigned int hook_mask
)
68 const struct arpt_mangle
*mangle
= targinfo
;
70 if (mangle
->flags
& ~ARPT_MANGLE_MASK
||
71 !(mangle
->flags
& ARPT_MANGLE_MASK
))
74 if (mangle
->target
!= NF_DROP
&& mangle
->target
!= NF_ACCEPT
&&
75 mangle
->target
!= ARPT_CONTINUE
)
80 static struct arpt_target arpt_mangle_reg __read_mostly
= {
83 .targetsize
= sizeof(struct arpt_mangle
),
84 .checkentry
= checkentry
,
88 static int __init
arpt_mangle_init(void)
90 if (arpt_register_target(&arpt_mangle_reg
))
96 static void __exit
arpt_mangle_fini(void)
98 arpt_unregister_target(&arpt_mangle_reg
);
101 module_init(arpt_mangle_init
);
102 module_exit(arpt_mangle_fini
);