mtimeout.1: Use correct dash for number ranges.
[misc] / if-mtu.c
CommitLineData
f342fce2 1#include <errno.h>
2#include <stdio.h>
3#include <stdlib.h>
4#include <string.h>
5
6#include <sys/types.h>
7#include <unistd.h>
8#include <sys/socket.h>
9#include <netinet/in.h>
10#include <net/if.h>
11#include <sys/ioctl.h>
12
13int main(int argc, char *argv[])
14{
15 int fd;
16 struct ifreq ifr;
17 if (argc != 2) {
18 fprintf(stderr, "usage: %s IFACE\n", argv[0]);
19 exit(1);
20 }
21 if (strlen(argv[1]) >= sizeof(ifr.ifr_name)) {
22 fprintf(stderr, "%s: interface name `%s' too long\n", argv[0], argv[1]);
23 exit(1);
24 }
25 if ((fd = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
26 fprintf(stderr, "%s: socket: %s\n", argv[0], strerror(errno));
27 exit(1);
28 }
29 strcpy(ifr.ifr_name, argv[1]);
30 if (ioctl(fd, SIOCGIFMTU, &ifr)) {
31 fprintf(stderr, "%s: ioctl(SIOCGIFMTU): %s\n", argv[0], strerror(errno));
32 exit(1);
33 }
34 printf("%d\n", ifr.ifr_mtu);
35 return (0);
36}