Skip to content
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

Why is the encoding mode of 'ifreq' 16s16x? #4392

Closed
Orobas-D opened this issue May 18, 2024 · 1 comment
Closed

Why is the encoding mode of 'ifreq' 16s16x? #4392

Orobas-D opened this issue May 18, 2024 · 1 comment

Comments

@Orobas-D
Copy link

Orobas-D commented May 18, 2024

Sorry, I'm a beginner, I'm just curious, but I noticed that in the <if.h> header file, the 'ifreq' structure can be 16 bytes. Why is there still a need to fill in 16 empty bytes?Is it because of compatibility issues?
scapy.arch.bpf.supersocket. _L2bpfSocket

try:
    fcntl.ioctl(
        self.bpf_fd, BIOCSETIF,
        struct.pack("16s16x", self.iface.encode())
     )
except IOError:
     raise Scapy_Exception("BIOCSETIF failed on %s" % self.iface)
     self.assigned_interface = self.iface

It seems that changing it to the following format also works fine.

try:
    fcntl.ioctl(
        self.bpf_fd, BIOCSETIF,
        struct.pack(str(len(self.iface)) + "s", self.iface.encode())
     )
except IOError:
     raise Scapy_Exception("BIOCSETIF failed on %s" % self.iface)
     self.assigned_interface = self.iface

MacOS:14.4

@gpotter2
Copy link
Member

Hi,
Please note that this is not a forum but a bugtracker. Please ask your question on the gitter or on stack overflow.
Thanks for your understanding

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants