diff --git a/tools/btsnoop.c b/tools/btsnoop.c
index 306e643..a65d8c5 100644
--- a/tools/btsnoop.c
+++ b/tools/btsnoop.c
}
memcpy(hdr.id, btsnoop_id, sizeof(btsnoop_id));
- hdr.version = htonl(btsnoop_version);
- hdr.type = htonl(2001);
+ hdr.version = htobe32(btsnoop_version);
+ hdr.type = htobe32(2001);
written = write(fd, &hdr, BTSNOOP_HDR_SIZE);
if (written < 0) {
return -1;
}
- if (ntohl(hdr.version) != btsnoop_version) {
+ if (be32toh(hdr.version) != btsnoop_version) {
fprintf(stderr, "invalid btsnoop version\n");
close(fd);
return -1;
}
if (type)
- *type = ntohl(hdr.type);
+ *type = be32toh(hdr.type);
return fd;
}
continue;
}
- ts = ntoh64(input_pkt[i].ts);
+ ts = be64toh(input_pkt[i].ts);
- if (ts < ntoh64(input_pkt[select_input].ts))
+ if (ts < be64toh(input_pkt[select_input].ts))
select_input = i;
}
if (select_input < 0)
goto close_output;
- toread = ntohl(input_pkt[select_input].size);
- flags = ntohl(input_pkt[select_input].flags);
+ toread = be32toh(input_pkt[select_input].size);
+ flags = be32toh(input_pkt[select_input].flags);
len = read(input_fd[select_input], buf, toread);
if (len < 0 || len != (ssize_t) toread) {
goto next_packet;
}
- written = input_pkt[select_input].size = htonl(toread - 1);
- written = input_pkt[select_input].len = htonl(toread - 1);
+ written = input_pkt[select_input].size = htobe32(toread - 1);
+ written = input_pkt[select_input].len = htobe32(toread - 1);
switch (buf[0]) {
case 0x01:
}
index = select_input;
- input_pkt[select_input].flags = htonl((index << 16) | opcode);
+ input_pkt[select_input].flags = htobe32((index << 16) | opcode);
written = write(output_fd, &input_pkt[select_input], BTSNOOP_PKT_SIZE);
if (written != BTSNOOP_PKT_SIZE) {
if (len < 0 || len != BTSNOOP_PKT_SIZE)
goto close_input;
- toread = ntohl(pkt.size);
- flags = ntohl(pkt.flags);
+ toread = be32toh(pkt.size);
+ flags = be32toh(pkt.flags);
opcode = flags & 0x00ff;
if (len < 0 || len != BTSNOOP_PKT_SIZE)
goto close_input;
- toread = ntohl(pkt.size);
- flags = ntohl(pkt.flags);
+ toread = be32toh(pkt.size);
+ flags = be32toh(pkt.flags);
opcode = flags & 0x00ff;
if (len < 0 || len != BTSNOOP_PKT_SIZE)
goto close_input;
- toread = ntohl(pkt.size);
+ toread = be32toh(pkt.size);
len = read(fd, buf, toread);
if (len < 0 || len != (ssize_t) toread) {