|
|
От: | Mike | |
| Дата: | 13.03.23 06:02 | ||
| Оценка: | |||
| код хука модуля | |
| uint Hook_Func(uint hooknum, struct sk_buff *skb, const struct net_device *in, const struct net_device *out, int (*okfn)(struct sk_buff *)) { uint res_ret = NF_ACCEPT; struct iphdr *ip_header; struct udphdr *udp_header; int dest_port; int udp_len; char *udp_data; unsigned long flags = 0; spin_lock_irqsave(&hook_lock, flags); if (skb->protocol == htons(ETH_P_IP)) { ip_header = ip_hdr(skb); if (ip_header->version == 4 && ip_header->protocol == IPPROTO_UDP) { udp_header = (struct udphdr *) (((char *) ip_header) + 20); dest_port = ntohs(udp_header->dest); if (dest_port == SOCK_LOCAL_PORT) { udp_len = ntohs(udp_header->len) — 8; udp_data = ((char *) udp_header) + 8; netpoll_send_udp(tx_back_np.np, udp_data, udp_len); res_ret = NF_DROP; } } } spin_unlock_irqrestore(&hook_lock, flags); return res_ret; } | |