3636import argparse
3737
3838
39- IPPROTO_DIVERT = 258
39+ PF_DIVERT = 44
4040
4141
4242def parse_args ():
@@ -52,22 +52,22 @@ def parse_args():
5252
5353def ipdivert_ip_output_remote_success (args ):
5454 packet = sc .IP (dst = args .dip ) / sc .ICMP (type = 'echo-request' )
55- with socket .socket (socket . AF_INET , socket .SOCK_RAW , IPPROTO_DIVERT ) as s :
55+ with socket .socket (PF_DIVERT , socket .SOCK_RAW , 0 ) as s :
5656 s .bind (('0.0.0.0' , args .divert_port ))
5757 s .sendto (bytes (packet ), ('0.0.0.0' , 0 ))
5858
5959
6060def ipdivert_ip6_output_remote_success (args ):
6161 packet = sc .IPv6 (dst = args .dip ) / sc .ICMPv6EchoRequest ()
62- with socket .socket (socket . AF_INET , socket .SOCK_RAW , IPPROTO_DIVERT ) as s :
62+ with socket .socket (PF_DIVERT , socket .SOCK_RAW , 0 ) as s :
6363 s .bind (('0.0.0.0' , args .divert_port ))
6464 s .sendto (bytes (packet ), ('0.0.0.0' , 0 ))
6565
6666
6767def ipdivert_ip_input_local_success (args ):
6868 """Sends IPv4 packet to OS stack as inbound local packet."""
6969 packet = sc .IP (dst = args .dip ,src = args .sip ) / sc .ICMP (type = 'echo-request' )
70- with socket .socket (socket . AF_INET , socket .SOCK_RAW , IPPROTO_DIVERT ) as s :
70+ with socket .socket (PF_DIVERT , socket .SOCK_RAW , 0 ) as s :
7171 s .bind (('0.0.0.0' , args .divert_port ))
7272 s .sendto (bytes (packet ), (args .dip , 0 ))
7373
0 commit comments