@@ -5145,8 +5145,8 @@ static struct ip *tx_ip(struct mg_tcpip_if *ifp, uint8_t *mac_dst,
5145
5145
memcpy(eth->src, ifp->mac, sizeof(eth->src)); // Use our MAC
5146
5146
eth->type = mg_htons(0x800);
5147
5147
memset(ip, 0, sizeof(*ip));
5148
- ip->ver = 0x45; // Version 4, header length 5 words
5149
- ip->frag = 0x40; // Don't fragment
5148
+ ip->ver = 0x45; // Version 4, header length 5 words
5149
+ ip->frag = mg_htons( 0x40) ; // Don't fragment
5150
5150
ip->len = mg_htons((uint16_t) (sizeof(*ip) + plen));
5151
5151
ip->ttl = 64;
5152
5152
ip->proto = proto;
@@ -5706,7 +5706,8 @@ static void rx_tcp(struct mg_tcpip_if *ifp, struct pkt *pkt) {
5706
5706
}
5707
5707
5708
5708
static void rx_ip(struct mg_tcpip_if *ifp, struct pkt *pkt) {
5709
- if (pkt->ip->frag & IP_MORE_FRAGS_MSK || pkt->ip->frag & IP_FRAG_OFFSET_MSK) {
5709
+ uint16_t frag = mg_ntohs(pkt->ip->frag);
5710
+ if (frag & IP_MORE_FRAGS_MSK || frag & IP_FRAG_OFFSET_MSK) {
5710
5711
if (pkt->ip->proto == 17) pkt->udp = (struct udp *) (pkt->ip + 1);
5711
5712
if (pkt->ip->proto == 6) pkt->tcp = (struct tcp *) (pkt->ip + 1);
5712
5713
struct mg_connection *c = getpeer(ifp->mgr, pkt, false);
@@ -5870,7 +5871,8 @@ static void mg_tcpip_poll(struct mg_tcpip_if *ifp, uint64_t now) {
5870
5871
5871
5872
// Process timeouts
5872
5873
for (c = ifp->mgr->conns; c != NULL; c = c->next) {
5873
- if ((c->is_udp && !c->is_arplooking) || c->is_listening || c->is_resolving) continue;
5874
+ if ((c->is_udp && !c->is_arplooking) || c->is_listening || c->is_resolving)
5875
+ continue;
5874
5876
struct connstate *s = (struct connstate *) (c + 1);
5875
5877
uint32_t rem_ip;
5876
5878
memcpy(&rem_ip, c->rem.ip, sizeof(uint32_t));
@@ -9472,6 +9474,7 @@ int mg_aes_gcm_decrypt(unsigned char *output, const unsigned char *input,
9472
9474
9473
9475
9474
9476
9477
+
9475
9478
#if MG_TLS == MG_TLS_BUILTIN
9476
9479
9477
9480
#define CHACHA20 1
@@ -9554,15 +9557,6 @@ struct tls_data {
9554
9557
struct tls_enc enc;
9555
9558
};
9556
9559
9557
- #define MG_LOAD_BE16(p) ((uint16_t) ((MG_U8P(p)[0] << 8U) | MG_U8P(p)[1]))
9558
- #define MG_LOAD_BE24(p) \
9559
- ((uint32_t) ((MG_U8P(p)[0] << 16U) | (MG_U8P(p)[1] << 8U) | MG_U8P(p)[2]))
9560
- #define MG_STORE_BE16(p, n) \
9561
- do { \
9562
- MG_U8P(p)[0] = ((n) >> 8U) & 255; \
9563
- MG_U8P(p)[1] = (n) &255; \
9564
- } while (0)
9565
-
9566
9560
#define TLS_RECHDR_SIZE 5 // 1 byte type, 2 bytes version, 2 bytes length
9567
9561
#define TLS_MSGHDR_SIZE 4 // 1 byte type, 3 bytes length
9568
9562
0 commit comments