Skip to content

Commit

Permalink
Fixes to byte/str handling in the dhcp client
Browse files Browse the repository at this point in the history
  • Loading branch information
vodik committed Aug 10, 2017
1 parent 99a14e6 commit 646b3c4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pnet/dhcp4/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import sys
import struct
import socket
import enum
Expand All @@ -11,6 +12,10 @@
COOKIE = b'c\x82Sc' # [0x63, 0x82, 0x53, 0x63])


if sys.version_info >= (3, 0):
ord = lambda x: x


class DHCPOpCode(enum.IntEnum):
Request = 1
Reply = 2
Expand Down Expand Up @@ -105,7 +110,7 @@ def message_type(self):

def get_vendor_info():
sysname, _, release, _, machine = os.uname()
return b'pydhcp4:{}-{}:{}'.format(sysname, release, machine)
return 'pydhcp4:{}-{}:{}'.format(sysname, release, machine)


def get_client_id(chaddr):
Expand Down
5 changes: 5 additions & 0 deletions pnet/dhcp4/options.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import sys
import enum


if sys.version_info >= (3, 0):
ord = lambda x: x


class DHCPOption(enum.IntEnum):
Padding = 0
SubnetMask = 1
Expand Down

0 comments on commit 646b3c4

Please sign in to comment.