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

LWIP Broadcast socket option added #14752

Merged
merged 1 commit into from
Jun 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
16 changes: 16 additions & 0 deletions connectivity/lwipstack/source/LWIPStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,22 @@ nsapi_error_t LWIP::setsockopt(nsapi_socket_t handle, int level, int optname, co
}
return 0;

case NSAPI_BROADCAST:
if (NETCONNTYPE_GROUP(s->conn->type) != NETCONN_UDP) {
return NSAPI_ERROR_UNSUPPORTED;
}

if (optlen != sizeof(int)) {
return NSAPI_ERROR_UNSUPPORTED;
}

if (*(const int *)optval) {
ip_set_option(s->conn->pcb.ip, SOF_BROADCAST);
} else {
ip_reset_option(s->conn->pcb.ip, SOF_BROADCAST);
}
return 0;

case NSAPI_ADD_MEMBERSHIP:
case NSAPI_DROP_MEMBERSHIP: {
if (optlen != sizeof(nsapi_ip_mreq_t)) {
Expand Down
1 change: 1 addition & 0 deletions connectivity/netsocket/include/netsocket/nsapi_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ typedef enum nsapi_socket_option {
NSAPI_LATENCY, /*!< Read estimated latency to destination */
NSAPI_STAGGER, /*!< Read estimated stagger value to destination */
NSAPI_IPTOS, /*!< Set IP type of service to set specific precedence */
NSAPI_BROADCAST /*!< Set broadcast flag for UDP socket */
} nsapi_socket_option_t;

typedef enum nsapi_tlssocket_level {
Expand Down