Skip to content

Commit e3a195d

Browse files
authored
Merge pull request #10075 from josepho0918/mqx
Improve compatibility for XINET_PTON
2 parents e328585 + a8528f4 commit e3a195d

3 files changed

Lines changed: 37 additions & 8 deletions

File tree

src/internal.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13318,9 +13318,17 @@ static int MatchIPv6(const char* pattern, int patternLen,
1331813318
XMEMSET(&addr2, 0, sizeof(addr2));
1331913319

1332013320
/* Try parsing both as IPv6 */
13321-
if (XINET_PTON(WOLFSSL_IP6, patBuf, &addr1) != 1)
13321+
#ifdef FREESCALE_MQX
13322+
if (XINET_PTON(WOLFSSL_IP6, patBuf, &addr1.sin6_addr, sizeof(addr1.sin6_addr)) != RTCS_OK)
13323+
#else
13324+
if (XINET_PTON(WOLFSSL_IP6, patBuf, &addr1.sin6_addr) != 1)
13325+
#endif
1332213326
return 0;
13323-
if (XINET_PTON(WOLFSSL_IP6, strBuf, &addr2) != 1)
13327+
#ifdef FREESCALE_MQX
13328+
if (XINET_PTON(WOLFSSL_IP6, strBuf, &addr2.sin6_addr, sizeof(addr2.sin6_addr)) != RTCS_OK)
13329+
#else
13330+
if (XINET_PTON(WOLFSSL_IP6, strBuf, &addr2.sin6_addr) != 1)
13331+
#endif
1332413332
return 0;
1332513333

1332613334
/* Compare raw address bytes */

src/sniffer.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1824,7 +1824,7 @@ static int SetNamedPrivateKey(const char* name, const char* address, int port,
18241824
if (serverIp.ip4 == XINADDR_NONE) {
18251825
#ifdef FUSION_RTOS
18261826
if (XINET_PTON(AF_INET6, address, serverIp.ip6,
1827-
sizeof(serverIp.ip4)) == 1)
1827+
sizeof(serverIp.ip6)) == 1)
18281828
#elif defined(FREESCALE_MQX)
18291829
if (XINET_PTON(AF_INET6, address, serverIp.ip6,
18301830
sizeof(serverIp.ip6)) == RTCS_OK)
@@ -7676,7 +7676,10 @@ static int addKeyLogSnifferServerHelper(const char* address,
76767676
if (serverIp.ip4 == XINADDR_NONE) {
76777677
#ifdef FUSION_RTOS
76787678
if (XINET_PTON(AF_INET6, address, serverIp.ip6,
7679-
sizeof(serverIp.ip4)) == 1)
7679+
sizeof(serverIp.ip6)) == 1)
7680+
#elif defined(FREESCALE_MQX)
7681+
if (XINET_PTON(AF_INET6, address, serverIp.ip6,
7682+
sizeof(serverIp.ip6)) == RTCS_OK)
76807683
#else
76817684
if (XINET_PTON(AF_INET6, address, serverIp.ip6) == 1)
76827685
#endif
@@ -7801,7 +7804,7 @@ int ssl_RemoveSession(const char* clientIp, int clientPort,
78017804
if (clientAddr.ip4 == XINADDR_NONE) {
78027805
#ifdef FUSION_RTOS
78037806
if (XINET_PTON(AF_INET6, clientIp, clientAddr.ip6,
7804-
sizeof(clientAddr.ip4)) == 1)
7807+
sizeof(clientAddr.ip6)) == 1)
78057808
#elif defined(FREESCALE_MQX)
78067809
if (XINET_PTON(AF_INET6, clientIp, clientAddr.ip6,
78077810
sizeof(clientAddr.ip6)) == RTCS_OK)
@@ -7823,10 +7826,10 @@ int ssl_RemoveSession(const char* clientIp, int clientPort,
78237826
if (serverAddr.ip4 == XINADDR_NONE) {
78247827
#ifdef FUSION_RTOS
78257828
if (XINET_PTON(AF_INET6, serverIp, serverAddr.ip6,
7826-
sizeof(serverAddr.ip4)) == 1)
7829+
sizeof(serverAddr.ip6)) == 1)
78277830
#elif defined(FREESCALE_MQX)
7828-
if (XINET_PTON(AF_INET6, clientIp, clientAddr.ip6,
7829-
sizeof(clientAddr.ip6)) == RTCS_OK)
7831+
if (XINET_PTON(AF_INET6, serverIp, serverAddr.ip6,
7832+
sizeof(serverAddr.ip6)) == RTCS_OK)
78307833
#else
78317834
if (XINET_PTON(AF_INET6, serverIp, serverAddr.ip6) == 1)
78327835
#endif

src/x509.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3087,15 +3087,25 @@ int wolfSSL_X509_add_altname(WOLFSSL_X509* x509, const char* name, int type)
30873087
int ptonRet;
30883088

30893089
/* Check if this is an ip4 address */
3090+
#ifdef FREESCALE_MQX
3091+
ptonRet = XINET_PTON(WOLFSSL_IP4, name, ip4, sizeof(ip4));
3092+
if (ptonRet == RTCS_OK) {
3093+
#else
30903094
ptonRet = XINET_PTON(WOLFSSL_IP4, name, ip4);
30913095
if (ptonRet == 1) {
3096+
#endif
30923097
return wolfSSL_X509_add_altname_ex(x509, (const char*)ip4, 4,
30933098
type);
30943099
}
30953100

30963101
/* Check for ip6 */
3102+
#ifdef FREESCALE_MQX
3103+
ptonRet = XINET_PTON(WOLFSSL_IP6, name, ip6, sizeof(ip6));
3104+
if (ptonRet == RTCS_OK) {
3105+
#else
30973106
ptonRet = XINET_PTON(WOLFSSL_IP6, name, ip6);
30983107
if (ptonRet == 1) {
3108+
#endif
30993109
return wolfSSL_X509_add_altname_ex(x509, (const char*)ip6, 16,
31003110
type);
31013111
}
@@ -5523,12 +5533,20 @@ static int MatchIpName(const char* name, int nameSz, WOLFSSL_GENERAL_NAME* gn)
55235533
/* IPv4 constraint 8 bytes (IP + mask),
55245534
* IPv6 constraint 32 bytes (IP + mask) */
55255535
if (constraintLen == 8) {
5536+
#ifdef FREESCALE_MQX
5537+
if (XINET_PTON(WOLFSSL_IP4, ipStr, ipBytes, sizeof(ipBytes)) == RTCS_OK) {
5538+
#else
55265539
if (XINET_PTON(WOLFSSL_IP4, ipStr, ipBytes) == 1) {
5540+
#endif
55275541
ipLen = 4;
55285542
}
55295543
}
55305544
else if (constraintLen == 32) {
5545+
#ifdef FREESCALE_MQX
5546+
if (XINET_PTON(WOLFSSL_IP6, ipStr, ipBytes, sizeof(ipBytes)) == RTCS_OK) {
5547+
#else
55315548
if (XINET_PTON(WOLFSSL_IP6, ipStr, ipBytes) == 1) {
5549+
#endif
55325550
ipLen = 16;
55335551
}
55345552
}

0 commit comments

Comments
 (0)