Skip to content

lwip - Add check for previously-bound socket #2580

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

Merged
merged 1 commit into from
Sep 10, 2016
Merged
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
5 changes: 5 additions & 0 deletions features/net/FEATURE_IPV4/lwip-interface/lwip_stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,11 @@ static int lwip_socket_bind(nsapi_stack_t *stack, nsapi_socket_t handle, nsapi_a
return NSAPI_ERROR_PARAMETER;
}

if ((s->conn->type == NETCONN_TCP && s->conn->pcb.tcp->local_port != 0) ||
(s->conn->type == NETCONN_UDP && s->conn->pcb.udp->local_port != 0)) {
return NSAPI_ERROR_PARAMETER;
}

err_t err = netconn_bind(s->conn, (ip_addr_t *)addr.bytes, port);
return lwip_err_remap(err);
}
Expand Down