We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
when building a dhcp packet
from dpkt.dhcp import ( DHCP, DHCP_OPT_MSGTYPE, DHCPDISCOVER ) packet = DHCP(chaddr=b'ffffffffffff').pack()
the pack method fails with: struct.error: argument for 's' must be a bytes object.
struct.error: argument for 's' must be a bytes object.
the opts values are expected to be stored as bytes but the default values are strings.
the fix is really easy, either modify the default value to byte objects
opts = ( (DHCP_OPT_MSGTYPE, chr(DHCPDISCOVER).encode()), (DHCP_OPT_PARAM_REQ, ''.join(map(chr, (DHCP_OPT_REQ_IP, DHCP_OPT_ROUTER, DHCP_OPT_NETMASK, DHCP_OPT_DNS_SVRS))).encode()) ) # list of (type, data) tuples
or add a check in the pack_opts func and transform data there
def pack_opts(self): """Return packed options string.""" if not self.opts: return b'' l_ = [] for t, data in self.opts: if isinstance(data, str): data = data.encode() l_.append(struct.pack("BB%is" % len(data), t, len(data), data)) l_.append(b'\xff') return b''.join(l_)
Details:
The text was updated successfully, but these errors were encountered:
No branches or pull requests
when building a dhcp packet
the pack method fails with:
struct.error: argument for 's' must be a bytes object.
the opts values are expected to be stored as bytes but the default values are strings.
the fix is really easy, either modify the default value to byte objects
or add a check in the pack_opts func and transform data there
Details:
The text was updated successfully, but these errors were encountered: