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

add secured flag to received & transmitted messages #760

Merged
merged 4 commits into from
Feb 2, 2024
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
9 changes: 4 additions & 5 deletions port/linux/ipadapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -819,10 +819,10 @@ oc_udp_receive_message(ip_context_t *dev, fd_set *fds, oc_message_t *message)
}
#endif /* OC_IPV4 */

#ifdef OC_SECURITY
#ifdef OC_OSCORE
if (FD_ISSET(dev->secure_sock, fds)) {
int count = recv_msg(dev->secure_sock, message->data, OC_PDU_SIZE,
&message->endpoint, false);
&message->endpoint, false, &message->mcast_dest);
if (count < 0) {
return ADAPTER_STATUS_ERROR;
}
Expand All @@ -846,7 +846,7 @@ oc_udp_receive_message(ip_context_t *dev, fd_set *fds, oc_message_t *message)
return ADAPTER_STATUS_RECEIVE;
}
#endif /* OC_IPV4 */
#endif /* OC_SECURITY */
#endif /* OC_OSCORE */

return ADAPTER_STATUS_NONE;
}
Expand Down Expand Up @@ -1064,8 +1064,7 @@ oc_send_buffer(oc_message_t *message)
}
#endif /* OC_TCP */

//#ifdef OC_SECURITY
#ifdef OC_SECURITY
#ifdef OC_OSCORE
if (message->endpoint.flags & SECURED) {
#ifdef OC_IPV4
if (message->endpoint.flags & IPV4) {
Expand Down
20 changes: 10 additions & 10 deletions port/windows/ipadapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -701,10 +701,10 @@ network_event_thread(void *data)
dev->event_server_handle = server6_event;

//#ifdef OC_SECURITY
#ifdef OC_SECURITY
#ifdef OC_OSCORE
WSAEVENT secure6_event = WSACreateEvent();
OC_WSAEVENTSELECT(dev->secure_sock, secure6_event, FD_READ);
#endif /* OC_SECURITY */
#endif /* OC_OSCORE */

#ifdef OC_IPV4
WSAEVENT mcast4_event = WSACreateEvent();
Expand Down Expand Up @@ -735,7 +735,7 @@ network_event_thread(void *data)
DWORD SERVER6 = events_list_size;
events_list[events_list_size] = server6_event;
events_list_size++;
#if defined(OC_SECURITY)
#if defined(OC_OSCORE)
//#if defined(OC_OSCORE)
DWORD SECURE6 = events_list_size;
events_list[events_list_size] = secure6_event;
Expand All @@ -751,14 +751,14 @@ network_event_thread(void *data)
events_list[events_list_size] = secure4_event;
events_list_size++;
#endif /* OC_IPV4 */
#elif defined(OC_IPV4) /* OC_SECURITY */
#elif defined(OC_IPV4) /* OC_OSCORE */
DWORD MCAST4 = events_list_size;
events_list[events_list_size] = mcast4_event;
events_list_size++;
DWORD SERVER4 = events_list_size;
events_list[events_list_size] = server4_event;
events_list_size++;
#endif /* !OC_SECURITY */
#endif /* !OC_OSCORE */

DWORD i, index;

Expand Down Expand Up @@ -846,10 +846,10 @@ network_event_thread(void *data)
#endif /* OC_IPV4 */

//#ifdef OC_SECURITY
#ifdef OC_SECURITY /* receiving from a secure socket */
#ifdef OC_OSCORE /* receiving from a secure socket */
if (i == SECURE6) {
int count = recv_msg(dev->secure_sock, message->data, OC_PDU_SIZE,
&message->endpoint, false);
&message->endpoint, false, &message->mcast_dest);
if (count < 0) {
oc_message_unref(message);
continue;
Expand All @@ -872,7 +872,7 @@ network_event_thread(void *data)
message->encrypted = 1;
}
#endif /* OC_IPV4 */
#endif /* OC_SECURITY */
#endif /* OC_OSCORE */
common:
#ifdef OC_DEBUG
PRINT("Incoming message of size %zd bytes from ", message->length);
Expand Down Expand Up @@ -1138,7 +1138,7 @@ oc_send_buffer(oc_message_t *message)
#endif /* OC_TCP */

//#ifdef OC_SECURITY
#ifdef OC_SECURITY /* not using secured socket to send*/
#ifdef OC_OSCORE /* not using secured socket to send*/
if (message->endpoint.flags & SECURED) {
#ifdef OC_IPV4
if (message->endpoint.flags & IPV4) {
Expand All @@ -1150,7 +1150,7 @@ oc_send_buffer(oc_message_t *message)
send_sock = dev->secure_sock;
#endif /* !OC_IPV4 */
} else
#endif /* OC_SECURITY */
#endif /* OC_OSCORE */
#ifdef OC_IPV4
if (message->endpoint.flags & IPV4) {
send_sock = dev->server4_sock;
Expand Down
Loading