Skip to content

fix Windows DF option #107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pythonping/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ def ping(target,
provider = payload_provider.Repeat(payload, count)
options = ()
if df:
options = network.Socket.DONT_FRAGMENT
if sys.platform.startswith('win'):
options = network.Socket.DONT_FRAGMENT_WIN
else:
options = network.Socket.DONT_FRAGMENT

# Fix to allow for pythonping multithreaded usage;
# no need to protect this loop as no one will ever surpass 0xFFFF amount of threads
Expand Down
1 change: 1 addition & 0 deletions pythonping/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

class Socket:
DONT_FRAGMENT = (socket.SOL_IP, 10, 1) # Option value for raw socket
DONT_FRAGMENT_WIN = (socket.IPPROTO_IP, 14, 1) # use IP_DONTFRAGMENT 14 from ws2ipdef.h
PROTO_LOOKUP = {"icmp": socket.IPPROTO_ICMP, "tcp": socket.IPPROTO_TCP, "udp": socket.IPPROTO_UDP,
"ip": socket.IPPROTO_IP, "raw": socket.IPPROTO_RAW}

Expand Down