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

gudp_ntohs and gudp_htons #1

Merged
merged 2 commits into from
Feb 10, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
20 changes: 19 additions & 1 deletion include/gudp.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,30 @@ uint32_t gudp_ntohl(uint32_t netlong);
/*
* \brief Convert an unsigned integer from host byte order to network byte order.
*
* \param netlong the unsigned integer to convert
* \param hostlong the unsigned integer to convert
*
* \return the converted unsigned integer
*/
uint32_t gudp_htonl(uint32_t hostlong);

/*
* \brief Convert an unsigned short integer from host byte order to network byte order.
*
* \param hostshort the unsigned integer to convert
Lucashsmello marked this conversation as resolved.
Show resolved Hide resolved
*
* \return the converted unsigned short integer
*/
uint16_t gudp_htons(uint16_t hostshort);

/*
* \brief Convert an unsigned short integer from network byte order to host byte order.
*
* \param netshort the unsigned integer to convert
Lucashsmello marked this conversation as resolved.
Show resolved Hide resolved
*
* \return the converted unsigned short integer
*/
uint16_t gudp_ntohs(uint16_t netshort);

/*
* \brief Open a UDP socket in client or server mode.
*
Expand Down
9 changes: 9 additions & 0 deletions src/posix/gudp.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ uint32_t gudp_htonl(uint32_t hostlong) {
return htonl(hostlong);
}

uint16_t gudp_htons(uint16_t hostshort) {
return htons(hostshort);
}

uint16_t gudp_ntohs(uint16_t netshort) {
return ntohs(netshort);
}


struct gudp_socket * gudp_open(enum gudp_mode mode, struct gudp_address address) {

int fd;
Expand Down