mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-12 16:50:21 +00:00
nitpicks
This commit is contained in:
1 parent
d47cfa183d
commit
3a4f044e41
2 files changed
+6
-4
No files matched your search
@@ -125,7 +125,7 @@ static struct mg_connection *start_modbus_request(struct mg_mgr *mgr,
|
||||
} else {
|
||||
send16(c, 1); // TID. Use random?
|
||||
send16(c, 0); // Protocol identifier: 0 (modbus)
|
||||
uint16_t *lp = (uint16_t *) &c->send.buf[c->send.len];
|
||||
size_t lp = c->send.len;
|
||||
send16(c, 0); // Length: to be set later
|
||||
size_t len = c->send.len;
|
||||
|
||||
@@ -151,7 +151,8 @@ static struct mg_connection *start_modbus_request(struct mg_mgr *mgr,
|
||||
send8(c, 0); // Object ID: 0 (vendor name)
|
||||
}
|
||||
|
||||
*lp = mg_htons((uint16_t) (c->send.len - len)); // Set length field
|
||||
uint16_t length = mg_htons((uint16_t) (c->send.len - len));
|
||||
memcpy(c->send.buf + lp, &length, sizeof(length)); // Set length field
|
||||
mg_hexdump(c->send.buf, c->send.len);
|
||||
MG_INFO(("%lu SENDING %lu", c->id, c->send.len));
|
||||
|
||||
|
||||
@@ -25,10 +25,11 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
|
||||
c->is_hexdumping = 1;
|
||||
} else if (ev == MG_EV_READ) {
|
||||
struct mg_dns_rr rr; // Parse first question, offset 12 is header size
|
||||
char buf[512];
|
||||
size_t n = mg_dns_parse_rr(c->recv.buf, c->recv.len, 12, true, &rr);
|
||||
MG_INFO(("DNS request parsed, result=%d", (int) n));
|
||||
if (n > 0) {
|
||||
char buf[512];
|
||||
if (n > 0 &&
|
||||
n <= sizeof(buf) - sizeof(struct mg_dns_header) - sizeof(answer)) {
|
||||
struct mg_dns_header *h = (struct mg_dns_header *) buf;
|
||||
memset(buf, 0, sizeof(buf)); // Clear the whole datagram
|
||||
h->txnid = ((struct mg_dns_header *) c->recv.buf)->txnid; // Copy tnxid
|
||||
|
||||
Reference in new issue
Block a user