fix(send/echo): add byte order conversion for id and seq
This commit is contained in:
parent
6cda2e8db5
commit
d3daf711b2
1 changed files with 3 additions and 2 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
#include "icmp.h"
|
#include "icmp.h"
|
||||||
#include "icmp_types.h"
|
#include "icmp_types.h"
|
||||||
|
#include <arpa/inet.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
@ -11,8 +12,8 @@ icmp_send_echo(icmp_handle_t *h, struct in_addr dest, uint16_t id,
|
||||||
uint32_t raw;
|
uint32_t raw;
|
||||||
} hdr_rest;
|
} hdr_rest;
|
||||||
|
|
||||||
hdr_rest.echo.id = id;
|
hdr_rest.echo.id = htons(id);
|
||||||
hdr_rest.echo.seq = seq;
|
hdr_rest.echo.seq = htons(seq);
|
||||||
return icmp_send_raw(h, ICMP_TYPE_ECHO_REQUEST, 0, hdr_rest.raw,
|
return icmp_send_raw(h, ICMP_TYPE_ECHO_REQUEST, 0, hdr_rest.raw,
|
||||||
NULL, 0, dest, ttl);
|
NULL, 0, dest, ttl);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue