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

Byte-ordering is incorrect when trying to use ppid attribute of sctp_send #46

Open
btsimon97 opened this issue Jan 31, 2023 · 2 comments
Assignees

Comments

@btsimon97
Copy link

When trying to use the ppid attribute, the integer value is sent over the wire with the byte order swapped from the correct value for the specified number.

For example, if I were to specify a PPID of 46 (the ppid of Diameter which in hex is 0x0000002e) in Python, the ppid that is sent over the wire is instead 771751936 (which in hex is 0x2e000000).

If I instead specified a ppid of 0x2e000000, the ppid sent over the wire is 46 (0x0000002e). This seems to indicate that a byte-ordering error is occurring between when the integer is specified in python and when it is sent over the wire.

@p1-bmu
Copy link
Contributor

p1-bmu commented Jan 31, 2023

The Linux SCTP API handles the PPID as a big-endian, so do PySCTP. I know it's misleading, but the intention is to stick with the Linux API. Therefore, you need to use ntohl and htonl from the socket module for converting the value to your CPU endianness.

You can have a look on the sctp_echo_server to see how PPID and others parameters are managed:
https://github.com/P1sec/pysctp/blob/modern_api/sctp_echo_srv.py

@CorruptBandit
Copy link

I think we need a flag to have the ability to switch between big and little endian for the PPID

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

3 participants