-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add OIS IoT Socket to build system. Implement IoT socket system layer and endpoints (UDP and TCP). Adapting inet and system layers to IoT Socket support. Improving unit-tests for IoT socket support. Add IoT socket support in OIS PlatformManagerImpl. Move initialisation of openiotsdk to after network init. Signed-off-by: paul-szczepanek-arm <[email protected]>
- Loading branch information
Showing
28 changed files
with
2,799 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
diff --git a/src/api/sockets.c b/src/api/sockets.c | ||
index 78526350..fb6e0796 100644 | ||
--- a/src/api/sockets.c | ||
+++ b/src/api/sockets.c | ||
@@ -1158,23 +1158,34 @@ lwip_recvfrom_udp_raw(struct lwip_sock *sock, int flags, struct msghdr *msg, u16 | ||
#if LWIP_NETBUF_RECVINFO | ||
/* Check if packet info was recorded */ | ||
if (buf->flags & NETBUF_FLAG_DESTADDR) { | ||
- if (IP_IS_V4(&buf->toaddr)) { | ||
+#if LWIP_IPV4 || LWIP_IPV6 | ||
+ if (msg->msg_controllen >= CMSG_SPACE(sizeof(struct in_pktinfo))) { | ||
+ struct cmsghdr *chdr = CMSG_FIRSTHDR(msg); /* This will always return a header!! */ | ||
+ chdr->cmsg_level = IPPROTO_IP; | ||
+ chdr->cmsg_type = IP_PKTINFO; | ||
#if LWIP_IPV4 | ||
- if (msg->msg_controllen >= CMSG_SPACE(sizeof(struct in_pktinfo))) { | ||
- struct cmsghdr *chdr = CMSG_FIRSTHDR(msg); /* This will always return a header!! */ | ||
+ if (IP_IS_V4(&buf->toaddr)) { | ||
struct in_pktinfo *pkti = (struct in_pktinfo *)CMSG_DATA(chdr); | ||
- chdr->cmsg_level = IPPROTO_IP; | ||
- chdr->cmsg_type = IP_PKTINFO; | ||
chdr->cmsg_len = CMSG_LEN(sizeof(struct in_pktinfo)); | ||
- pkti->ipi_ifindex = buf->p->if_idx; | ||
- inet_addr_from_ip4addr(&pkti->ipi_addr, ip_2_ip4(netbuf_destaddr(buf))); | ||
msg->msg_controllen = CMSG_SPACE(sizeof(struct in_pktinfo)); | ||
- wrote_msg = 1; | ||
- } else { | ||
- msg->msg_flags |= MSG_CTRUNC; | ||
+ inet_addr_from_ip4addr(&pkti->ipi_addr, ip_2_ip4(netbuf_destaddr(buf))); | ||
+ pkti->ipi_ifindex = buf->p->if_idx; | ||
} | ||
#endif /* LWIP_IPV4 */ | ||
+#if LWIP_IPV6 | ||
+ if (IP_IS_V6(&buf->toaddr)) { | ||
+ struct in6_pktinfo *pkti6 = (struct in6_pktinfo *)CMSG_DATA(chdr); | ||
+ chdr->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo)); | ||
+ msg->msg_controllen = CMSG_SPACE(sizeof(struct in6_pktinfo)); | ||
+ inet6_addr_from_ip6addr(&pkti6->ipi6_addr, ip_2_ip6(netbuf_destaddr(buf))); | ||
+ pkti6->ipi6_ifindex = buf->p->if_idx; | ||
+ } | ||
+#endif /* LWIP_IPV6 */ | ||
+ wrote_msg = 1; | ||
+ } else { | ||
+ msg->msg_flags |= MSG_CTRUNC; | ||
} | ||
+#endif /* LWIP_IPV4 || LWIP_IPV6 */ | ||
} | ||
#endif /* LWIP_NETBUF_RECVINFO */ | ||
|
||
diff --git a/src/include/lwip/sockets.h b/src/include/lwip/sockets.h | ||
index d70d36c4..1c225041 100644 | ||
--- a/src/include/lwip/sockets.h | ||
+++ b/src/include/lwip/sockets.h | ||
@@ -329,6 +329,13 @@ struct in_pktinfo { | ||
}; | ||
#endif /* LWIP_IPV4 */ | ||
|
||
+#if LWIP_IPV6 | ||
+struct in6_pktinfo { | ||
+ unsigned int ipi6_ifindex; /* Interface index */ | ||
+ struct in6_addr ipi6_addr; /* Destination (from header) address */ | ||
+}; | ||
+#endif /* LWIP_IPV6 */ | ||
+ | ||
#if LWIP_IPV6_MLD | ||
/* | ||
* Options and types related to IPv6 multicast membership |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* | ||
* Copyright (c) 2020-2021 Project CHIP Authors | ||
* Copyright (c) 2015-2017 Nest Labs, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** | ||
* Shared state for socket implementations of TCPEndPoint and UDPEndPoint. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <stdint.h> | ||
|
||
namespace chip { | ||
namespace Inet { | ||
|
||
/** | ||
* Definitions shared by all IoT Socket based EndPoint classes. | ||
*/ | ||
class EndPointStateIoTSocket | ||
{ | ||
public: | ||
virtual void SelectCallback(void * readMask, void * writeMask, void * exceptionMask){}; | ||
int32_t GetSocketId() { return mSocket; }; | ||
|
||
static constexpr int32_t kInvalidSocketFd = -1; | ||
|
||
protected: | ||
EndPointStateIoTSocket() : mSocket(kInvalidSocketFd){}; | ||
virtual ~EndPointStateIoTSocket(){}; | ||
|
||
int32_t mSocket; /**< Encapsulated socket descriptor. */ | ||
int32_t mSocketFamily; /**< Protocol family, i.e. IPv4 or IPv6. */ | ||
uint16_t mBoundPort; | ||
}; | ||
|
||
} // namespace Inet | ||
} // namespace chip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.