Remove unnecessary errno = 0;
This commit is contained in:
parent
539dbf9f14
commit
2d43d3273a
|
@ -2,7 +2,6 @@
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <errno.h>
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <linux/if_packet.h>
|
#include <linux/if_packet.h>
|
||||||
#include <net/ethernet.h>
|
#include <net/ethernet.h>
|
||||||
|
@ -21,11 +20,9 @@ void drop_privileges(void) {
|
||||||
uid_t uid = getuid();
|
uid_t uid = getuid();
|
||||||
gid_t gid = getgid();
|
gid_t gid = getgid();
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
if (setresgid(gid, gid, gid) == -1) {
|
if (setresgid(gid, gid, gid) == -1) {
|
||||||
err(1, "setresgid");
|
err(1, "setresgid");
|
||||||
}
|
}
|
||||||
errno = 0;
|
|
||||||
if (setresuid(uid, uid, uid) == -1) {
|
if (setresuid(uid, uid, uid) == -1) {
|
||||||
err(1, "setresuid");
|
err(1, "setresuid");
|
||||||
}
|
}
|
||||||
|
@ -41,7 +38,6 @@ int main(int argc, char **argv) {
|
||||||
const char *target_ip = argv[2];
|
const char *target_ip = argv[2];
|
||||||
|
|
||||||
// Create a packet socket
|
// Create a packet socket
|
||||||
errno = 0;
|
|
||||||
int packet_socket = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
|
int packet_socket = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
|
||||||
if (packet_socket == -1) {
|
if (packet_socket == -1) {
|
||||||
err(1, "socket");
|
err(1, "socket");
|
||||||
|
@ -53,7 +49,6 @@ int main(int argc, char **argv) {
|
||||||
// Find the index of the network interface
|
// Find the index of the network interface
|
||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
strncpy(ifr.ifr_name, interface_name, IFNAMSIZ);
|
strncpy(ifr.ifr_name, interface_name, IFNAMSIZ);
|
||||||
errno = 0;
|
|
||||||
if (ioctl(packet_socket, SIOCGIFINDEX, &ifr) == -1) {
|
if (ioctl(packet_socket, SIOCGIFINDEX, &ifr) == -1) {
|
||||||
err(1, "ioctl");
|
err(1, "ioctl");
|
||||||
}
|
}
|
||||||
|
@ -63,7 +58,6 @@ int main(int argc, char **argv) {
|
||||||
sll.sll_family = AF_PACKET;
|
sll.sll_family = AF_PACKET;
|
||||||
sll.sll_protocol = htons(ETH_P_ALL);
|
sll.sll_protocol = htons(ETH_P_ALL);
|
||||||
sll.sll_ifindex = ifr.ifr_ifindex;
|
sll.sll_ifindex = ifr.ifr_ifindex;
|
||||||
errno = 0;
|
|
||||||
if (bind(packet_socket, (const struct sockaddr*)&sll, sizeof(sll)) == -1) {
|
if (bind(packet_socket, (const struct sockaddr*)&sll, sizeof(sll)) == -1) {
|
||||||
err(1, "bind");
|
err(1, "bind");
|
||||||
}
|
}
|
||||||
|
@ -96,7 +90,6 @@ int main(int argc, char **argv) {
|
||||||
memset(&frame[0], 0xff, 6);
|
memset(&frame[0], 0xff, 6);
|
||||||
|
|
||||||
// Source MAC
|
// Source MAC
|
||||||
errno = 0;
|
|
||||||
strncpy(ifr.ifr_name, interface_name, IFNAMSIZ);
|
strncpy(ifr.ifr_name, interface_name, IFNAMSIZ);
|
||||||
if (ioctl(packet_socket, SIOCGIFHWADDR, &ifr) == -1) {
|
if (ioctl(packet_socket, SIOCGIFHWADDR, &ifr) == -1) {
|
||||||
err(1, "ioctl");
|
err(1, "ioctl");
|
||||||
|
@ -133,7 +126,6 @@ int main(int argc, char **argv) {
|
||||||
memcpy(&frame[22], &frame[6], 6);
|
memcpy(&frame[22], &frame[6], 6);
|
||||||
|
|
||||||
// Sender protocol address
|
// Sender protocol address
|
||||||
errno = 0;
|
|
||||||
strncpy(ifr.ifr_name, interface_name, IFNAMSIZ);
|
strncpy(ifr.ifr_name, interface_name, IFNAMSIZ);
|
||||||
if (ioctl(packet_socket, SIOCGIFADDR, &ifr) == -1) {
|
if (ioctl(packet_socket, SIOCGIFADDR, &ifr) == -1) {
|
||||||
err(1, "ioctl");
|
err(1, "ioctl");
|
||||||
|
@ -150,20 +142,17 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
// Target protocol address
|
// Target protocol address
|
||||||
memset(&sin, 0, sizeof(sin));
|
memset(&sin, 0, sizeof(sin));
|
||||||
errno = 0;
|
|
||||||
if (inet_pton(AF_INET, target_ip, &sin.sin_addr) == -1) {
|
if (inet_pton(AF_INET, target_ip, &sin.sin_addr) == -1) {
|
||||||
err(1, "inet_pton");
|
err(1, "inet_pton");
|
||||||
}
|
}
|
||||||
memcpy(&frame[38], &sin.sin_addr.s_addr, 4);
|
memcpy(&frame[38], &sin.sin_addr.s_addr, 4);
|
||||||
|
|
||||||
// Send the frame
|
// Send the frame
|
||||||
errno = 0;
|
|
||||||
if (write(packet_socket, frame, sizeof(frame)) != sizeof(frame)) {
|
if (write(packet_socket, frame, sizeof(frame)) != sizeof(frame)) {
|
||||||
err(1, "write");
|
err(1, "write");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close the socket (tho I'm not 100% sure it's needed)
|
// Close the socket (tho I'm not 100% sure it's needed)
|
||||||
errno = 0;
|
|
||||||
if (close(packet_socket) == -1) {
|
if (close(packet_socket) == -1) {
|
||||||
err(1, "close");
|
err(1, "close");
|
||||||
}
|
}
|
||||||
|
|
28
ethermess.c
28
ethermess.c
|
@ -2,7 +2,6 @@
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <errno.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
@ -106,7 +105,6 @@ ssize_t msgid_cache_add(const unsigned char mac[6]) {
|
||||||
|
|
||||||
unsigned char random_byte(void) {
|
unsigned char random_byte(void) {
|
||||||
unsigned char randomness;
|
unsigned char randomness;
|
||||||
errno = 0;
|
|
||||||
if (read(urandom, &randomness, 1) != 1) {
|
if (read(urandom, &randomness, 1) != 1) {
|
||||||
err(1, "read");
|
err(1, "read");
|
||||||
}
|
}
|
||||||
|
@ -115,7 +113,6 @@ unsigned char random_byte(void) {
|
||||||
|
|
||||||
time_t monotonic_time(void) {
|
time_t monotonic_time(void) {
|
||||||
struct timespec now;
|
struct timespec now;
|
||||||
errno = 0;
|
|
||||||
if (clock_gettime(CLOCK_MONOTONIC, &now) == -1) {
|
if (clock_gettime(CLOCK_MONOTONIC, &now) == -1) {
|
||||||
err(1, "clock_gettime");
|
err(1, "clock_gettime");
|
||||||
}
|
}
|
||||||
|
@ -141,18 +138,15 @@ void drop_privileges(void) {
|
||||||
uid_t uid = getuid();
|
uid_t uid = getuid();
|
||||||
gid_t gid = getgid();
|
gid_t gid = getgid();
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
if (setresgid(gid, gid, gid) == -1) {
|
if (setresgid(gid, gid, gid) == -1) {
|
||||||
err(1, "setresgid");
|
err(1, "setresgid");
|
||||||
}
|
}
|
||||||
errno = 0;
|
|
||||||
if (setresuid(uid, uid, uid) == -1) {
|
if (setresuid(uid, uid, uid) == -1) {
|
||||||
err(1, "setresuid");
|
err(1, "setresuid");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void send_frame(const unsigned char *frame, size_t frame_length) {
|
void send_frame(const unsigned char *frame, size_t frame_length) {
|
||||||
errno = 0;
|
|
||||||
if (write(packet_socket, frame, frame_length) == -1) {
|
if (write(packet_socket, frame, frame_length) == -1) {
|
||||||
err(1, "write");
|
err(1, "write");
|
||||||
}
|
}
|
||||||
|
@ -281,7 +275,6 @@ void send_ack(const unsigned char destination[6], uint16_t msgid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void read_command(void) {
|
void read_command(void) {
|
||||||
errno = 0;
|
|
||||||
int cmd = getchar();
|
int cmd = getchar();
|
||||||
if (cmd == EOF) {
|
if (cmd == EOF) {
|
||||||
err(1, "getchar");
|
err(1, "getchar");
|
||||||
|
@ -362,12 +355,10 @@ void handle_status(const unsigned char source_mac[6], const unsigned char *data,
|
||||||
char mac[18];
|
char mac[18];
|
||||||
format_mac(source_mac, mac);
|
format_mac(source_mac, mac);
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
if (printf("%s status: ", mac) == -1) {
|
if (printf("%s status: ", mac) == -1) {
|
||||||
err(1, "printf");
|
err(1, "printf");
|
||||||
}
|
}
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
if (status == EMS_UNAVAILABLE) {
|
if (status == EMS_UNAVAILABLE) {
|
||||||
if (printf("(unavailable) ") == -1) {
|
if (printf("(unavailable) ") == -1) {
|
||||||
err(1, "printf");
|
err(1, "printf");
|
||||||
|
@ -379,18 +370,15 @@ void handle_status(const unsigned char source_mac[6], const unsigned char *data,
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < (size_t)nick_length; i++) {
|
for (size_t i = 0; i < (size_t)nick_length; i++) {
|
||||||
errno = 0;
|
|
||||||
if (putchar(nick[i]) == EOF) {
|
if (putchar(nick[i]) == EOF) {
|
||||||
err(1, "putchar");
|
err(1, "putchar");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
if (putchar('\n') == EOF) {
|
if (putchar('\n') == EOF) {
|
||||||
err(1, "putchar");
|
err(1, "putchar");
|
||||||
}
|
}
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
if (fflush(stdout) == EOF) {
|
if (fflush(stdout) == EOF) {
|
||||||
err(1, "fflush");
|
err(1, "fflush");
|
||||||
}
|
}
|
||||||
|
@ -422,12 +410,10 @@ void handle_msgid(const unsigned char source_mac[6], const unsigned char *data,
|
||||||
char mac[18];
|
char mac[18];
|
||||||
format_mac(source_mac, mac);
|
format_mac(source_mac, mac);
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
if (printf("%s awaits message ID %" PRIu16 "\n", mac, msgid_cache[cache_index].next_send) == 0) {
|
if (printf("%s awaits message ID %" PRIu16 "\n", mac, msgid_cache[cache_index].next_send) == 0) {
|
||||||
err(1, "printf");
|
err(1, "printf");
|
||||||
}
|
}
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
if (fflush(stdout) == EOF) {
|
if (fflush(stdout) == EOF) {
|
||||||
err(1, "fflush");
|
err(1, "fflush");
|
||||||
}
|
}
|
||||||
|
@ -465,24 +451,20 @@ void handle_message(const unsigned char source_mac[6], const unsigned char *data
|
||||||
char mac[18];
|
char mac[18];
|
||||||
format_mac(source_mac, mac);
|
format_mac(source_mac, mac);
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
if (printf("%s (%" PRIu16 "): ", mac, msgid) == -1) {
|
if (printf("%s (%" PRIu16 "): ", mac, msgid) == -1) {
|
||||||
err(1, "printf");
|
err(1, "printf");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < message_length; i++) {
|
for (size_t i = 0; i < message_length; i++) {
|
||||||
errno = 0;
|
|
||||||
if (putchar(message[i]) == EOF) {
|
if (putchar(message[i]) == EOF) {
|
||||||
err(1, "putchar");
|
err(1, "putchar");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
if (putchar('\n') == EOF) {
|
if (putchar('\n') == EOF) {
|
||||||
err(1, "putchar");
|
err(1, "putchar");
|
||||||
}
|
}
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
if (fflush(stdout) == EOF) {
|
if (fflush(stdout) == EOF) {
|
||||||
err(1, "fflush");
|
err(1, "fflush");
|
||||||
}
|
}
|
||||||
|
@ -507,7 +489,6 @@ void handle_ack(const unsigned char source_mac[6], const unsigned char *data, si
|
||||||
char mac[18];
|
char mac[18];
|
||||||
format_mac(source_mac, mac);
|
format_mac(source_mac, mac);
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
if (printf("%s ack %" PRIu16 "\n", mac, msgid) == -1) {
|
if (printf("%s ack %" PRIu16 "\n", mac, msgid) == -1) {
|
||||||
err(1, "printf");
|
err(1, "printf");
|
||||||
}
|
}
|
||||||
|
@ -520,7 +501,6 @@ void handle_ack(const unsigned char source_mac[6], const unsigned char *data, si
|
||||||
void process_frame(void) {
|
void process_frame(void) {
|
||||||
unsigned char frame[1518]; // Largest a 802.3 frame can be without FCS
|
unsigned char frame[1518]; // Largest a 802.3 frame can be without FCS
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
ssize_t res = recv(packet_socket, frame, sizeof(frame), 0);
|
ssize_t res = recv(packet_socket, frame, sizeof(frame), 0);
|
||||||
if (res == -1) {
|
if (res == -1) {
|
||||||
err(1, "recv");
|
err(1, "recv");
|
||||||
|
@ -650,7 +630,6 @@ void eventloop(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
int ready = poll(pollfds, sizeof(pollfds) / sizeof(*pollfds), wait_ms);
|
int ready = poll(pollfds, sizeof(pollfds) / sizeof(*pollfds), wait_ms);
|
||||||
if (ready == -1) {
|
if (ready == -1) {
|
||||||
err(1, "poll");
|
err(1, "poll");
|
||||||
|
@ -698,7 +677,6 @@ int main(int argc, char **argv) {
|
||||||
urandom = open("/dev/urandom", O_RDONLY);
|
urandom = open("/dev/urandom", O_RDONLY);
|
||||||
|
|
||||||
// Create a packet socket
|
// Create a packet socket
|
||||||
errno = 0;
|
|
||||||
packet_socket = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
|
packet_socket = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
|
||||||
if (packet_socket == -1) {
|
if (packet_socket == -1) {
|
||||||
err(1, "socket");
|
err(1, "socket");
|
||||||
|
@ -710,7 +688,6 @@ int main(int argc, char **argv) {
|
||||||
// Find the index of the network interface
|
// Find the index of the network interface
|
||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
strncpy(ifr.ifr_name, interface_name, IFNAMSIZ);
|
strncpy(ifr.ifr_name, interface_name, IFNAMSIZ);
|
||||||
errno = 0;
|
|
||||||
if (ioctl(packet_socket, SIOCGIFINDEX, &ifr) == -1) {
|
if (ioctl(packet_socket, SIOCGIFINDEX, &ifr) == -1) {
|
||||||
err(1, "ioctl");
|
err(1, "ioctl");
|
||||||
}
|
}
|
||||||
|
@ -720,13 +697,11 @@ int main(int argc, char **argv) {
|
||||||
sll.sll_family = AF_PACKET;
|
sll.sll_family = AF_PACKET;
|
||||||
sll.sll_protocol = htons(ETH_P_ALL);
|
sll.sll_protocol = htons(ETH_P_ALL);
|
||||||
sll.sll_ifindex = ifr.ifr_ifindex;
|
sll.sll_ifindex = ifr.ifr_ifindex;
|
||||||
errno = 0;
|
|
||||||
if (bind(packet_socket, (const struct sockaddr*)&sll, sizeof(sll)) == -1) {
|
if (bind(packet_socket, (const struct sockaddr*)&sll, sizeof(sll)) == -1) {
|
||||||
err(1, "bind");
|
err(1, "bind");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get our own MAC
|
// Get our own MAC
|
||||||
errno = 0;
|
|
||||||
strncpy(ifr.ifr_name, interface_name, IFNAMSIZ);
|
strncpy(ifr.ifr_name, interface_name, IFNAMSIZ);
|
||||||
if (ioctl(packet_socket, SIOCGIFHWADDR, &ifr) == -1) {
|
if (ioctl(packet_socket, SIOCGIFHWADDR, &ifr) == -1) {
|
||||||
err(1, "ioctl");
|
err(1, "ioctl");
|
||||||
|
@ -766,19 +741,16 @@ int main(int argc, char **argv) {
|
||||||
eventloop();
|
eventloop();
|
||||||
|
|
||||||
// Close the socket (tho I'm not 100% sure it's needed)
|
// Close the socket (tho I'm not 100% sure it's needed)
|
||||||
errno = 0;
|
|
||||||
if (close(packet_socket) == -1) {
|
if (close(packet_socket) == -1) {
|
||||||
err(1, "close");
|
err(1, "close");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flush stdout
|
// Flush stdout
|
||||||
errno = 0;
|
|
||||||
if (fflush(stdout) == EOF) {
|
if (fflush(stdout) == EOF) {
|
||||||
err(1, "fflush");
|
err(1, "fflush");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close urandom
|
// Close urandom
|
||||||
errno = 0;
|
|
||||||
if (close(urandom) == -1) {
|
if (close(urandom) == -1) {
|
||||||
err(1, "close");
|
err(1, "close");
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <errno.h>
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <linux/if_packet.h>
|
#include <linux/if_packet.h>
|
||||||
#include <net/ethernet.h>
|
#include <net/ethernet.h>
|
||||||
|
@ -35,11 +34,9 @@ void drop_privileges(void) {
|
||||||
uid_t uid = getuid();
|
uid_t uid = getuid();
|
||||||
gid_t gid = getgid();
|
gid_t gid = getgid();
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
if (setresgid(gid, gid, gid) == -1) {
|
if (setresgid(gid, gid, gid) == -1) {
|
||||||
err(1, "setresgid");
|
err(1, "setresgid");
|
||||||
}
|
}
|
||||||
errno = 0;
|
|
||||||
if (setresuid(uid, uid, uid) == -1) {
|
if (setresuid(uid, uid, uid) == -1) {
|
||||||
err(1, "setresuid");
|
err(1, "setresuid");
|
||||||
}
|
}
|
||||||
|
@ -52,7 +49,6 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a packet socket
|
// Create a packet socket
|
||||||
errno = 0;
|
|
||||||
int packet_socket = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
|
int packet_socket = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
|
||||||
if (packet_socket == -1) {
|
if (packet_socket == -1) {
|
||||||
err(1, "socket");
|
err(1, "socket");
|
||||||
|
@ -64,7 +60,6 @@ int main(int argc, char **argv) {
|
||||||
// Find the index of the network interface
|
// Find the index of the network interface
|
||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
strncpy(ifr.ifr_name, argv[1], IFNAMSIZ);
|
strncpy(ifr.ifr_name, argv[1], IFNAMSIZ);
|
||||||
errno = 0;
|
|
||||||
if (ioctl(packet_socket, SIOCGIFINDEX, &ifr) == -1) {
|
if (ioctl(packet_socket, SIOCGIFINDEX, &ifr) == -1) {
|
||||||
err(1, "ioctl");
|
err(1, "ioctl");
|
||||||
}
|
}
|
||||||
|
@ -74,7 +69,6 @@ int main(int argc, char **argv) {
|
||||||
sll.sll_family = AF_PACKET;
|
sll.sll_family = AF_PACKET;
|
||||||
sll.sll_protocol = htons(ETH_P_ALL);
|
sll.sll_protocol = htons(ETH_P_ALL);
|
||||||
sll.sll_ifindex = ifr.ifr_ifindex;
|
sll.sll_ifindex = ifr.ifr_ifindex;
|
||||||
errno = 0;
|
|
||||||
if (bind(packet_socket, (const struct sockaddr*)&sll, sizeof(sll)) == -1) {
|
if (bind(packet_socket, (const struct sockaddr*)&sll, sizeof(sll)) == -1) {
|
||||||
err(1, "bind");
|
err(1, "bind");
|
||||||
}
|
}
|
||||||
|
@ -86,7 +80,6 @@ int main(int argc, char **argv) {
|
||||||
err(1, "fflush");
|
err(1, "fflush");
|
||||||
}
|
}
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
ssize_t frame_length = recv(packet_socket, frame, sizeof(frame), MSG_TRUNC);
|
ssize_t frame_length = recv(packet_socket, frame, sizeof(frame), MSG_TRUNC);
|
||||||
if (frame_length == -1) {
|
if (frame_length == -1) {
|
||||||
err(1, "recv");
|
err(1, "recv");
|
||||||
|
@ -95,7 +88,6 @@ int main(int argc, char **argv) {
|
||||||
frame_length += 4; // Include the FCS in the true length
|
frame_length += 4; // Include the FCS in the true length
|
||||||
|
|
||||||
if (frame_data_length < 14) {
|
if (frame_data_length < 14) {
|
||||||
errno = 0;
|
|
||||||
if (printf("Frame too short to contain header (%zdB)\n", frame_length) == -1) {
|
if (printf("Frame too short to contain header (%zdB)\n", frame_length) == -1) {
|
||||||
err(1, "printf");
|
err(1, "printf");
|
||||||
}
|
}
|
||||||
|
@ -128,12 +120,10 @@ int main(int argc, char **argv) {
|
||||||
ethertype_meaning = "IPv6";
|
ethertype_meaning = "IPv6";
|
||||||
}
|
}
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
if(printf("%s -> %s ethertype: %04" PRIx16, source_mac, destination_mac, ethertype) == -1) {
|
if(printf("%s -> %s ethertype: %04" PRIx16, source_mac, destination_mac, ethertype) == -1) {
|
||||||
err(1, "printf");
|
err(1, "printf");
|
||||||
}
|
}
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
if (ethertype_meaning == NULL) {
|
if (ethertype_meaning == NULL) {
|
||||||
if (printf(", length: %zd", frame_length) == -1) {
|
if (printf(", length: %zd", frame_length) == -1) {
|
||||||
err(1, "printf");
|
err(1, "printf");
|
||||||
|
@ -144,7 +134,6 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
if ((size_t)frame_length > sizeof(frame) + 4) { // +4 for the FCS
|
if ((size_t)frame_length > sizeof(frame) + 4) { // +4 for the FCS
|
||||||
if (printf(" (overlong)\n") == -1) {
|
if (printf(" (overlong)\n") == -1) {
|
||||||
err(1, "printf");
|
err(1, "printf");
|
||||||
|
|
Loading…
Reference in New Issue