1typedef unsigned char __u8; 2typedef unsigned short __u16; 3typedef unsigned int __u32; 4typedef unsigned long __kernel_size_t; 5typedef __kernel_size_t size_t; 6typedef __u8 uint8_t; 7typedef __u16 __be16; 8typedef __u32 __be32; 9struct msghdr { 10 struct iovec * msg_iov; 11 unsigned msg_flags; 12}; 13enum { IPPROTO_ICMP = 1 }; 14struct sk_buff { }; 15static inline __attribute__((always_inline)) struct dst_entry * 16skb_dst(const struct sk_buff *skb) 17{ 18}; 19enum nf_inet_hooks { NF_INET_LOCAL_OUT }; 20struct net_device { 21 unsigned mtu; 22}; 23static inline __attribute__((always_inline)) int 24NF_HOOK_THRESH(uint8_t pf, unsigned int hook, struct sk_buff *skb, 25 struct net_device *in, struct net_device *out, 26 int (*okfn)(struct sk_buff *), int thresh) 27{ 28 int ret = nf_hook_thresh(pf, hook, skb, in, out, okfn, thresh); 29 if (ret == 1) 30 ret = okfn(skb); 31 return ret; 32} 33static inline __attribute__((always_inline)) int 34NF_HOOK(uint8_t pf, unsigned int hook, struct sk_buff *skb, 35 struct net_device *in, struct net_device *out, 36 int (*okfn)(struct sk_buff *)) 37{ 38 return NF_HOOK_THRESH(pf, hook, skb, in, out, okfn, (-((int)(~0U>>1)) - 1)); 39} 40struct dst_entry { 41 struct net_device *dev; 42 int (*output)(struct sk_buff*); 43}; 44static inline __attribute__((always_inline)) int dst_output(struct sk_buff *skb) { 45 return skb_dst(skb)->output(skb); 46}; 47struct iphdr { 48 __u8 protocol; 49}; 50struct inet_sock { 51 __be16 inet_dport; 52 __u8 recverr: 1, hdrincl: 1; 53 struct { } cork; 54}; 55struct icmphdr { 56 __u8 type; 57}; 58struct rtable { 59 union { struct dst_entry dst; } u; 60 __be32 rt_dst; 61}; 62struct sock; 63struct inet_sock *inet_sk (struct sock *); 64struct net *sock_net (struct sock *); 65void *skb_transport_header (struct sk_buff *); 66static int raw_send_hdrinc(struct sock *sk, void *from, size_t length, 67 struct rtable *rt, unsigned int flags) 68{ 69 struct inet_sock *inet = inet_sk(sk); 70 struct net *net = sock_net(sk); 71 struct iphdr *iph; 72 struct sk_buff *skb; 73 if (length > rt->u.dst.dev->mtu) 74 ip_local_error(sk, 90, rt->rt_dst, inet->inet_dport, rt->u.dst.dev->mtu); 75 if (flags&0x10) 76 goto out; 77 if (iph->protocol == IPPROTO_ICMP) 78 icmp_out_count(net, ((struct icmphdr *)skb_transport_header(skb))->type); 79 NF_HOOK(2, NF_INET_LOCAL_OUT, skb, ((void *)0), rt->u.dst.dev, 80 dst_output); 81out: 82 while (0); 83} 84int raw_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) 85{ 86 raw_send_hdrinc(sk, msg->msg_iov, len, (void *)0, msg->msg_flags); 87} 88