Use size_t for buffer sizes. Improve error handling in some places.
Remove a __DECONST() that was needed before this interface cleanup.
This commit is contained in:
parent
21b40f3c1b
commit
c7185249d7
@ -559,7 +559,8 @@ pvc_add(int argc, char **argv, const struct cmd *cmdp)
|
||||
const struct traffics *trafp;
|
||||
char *cp;
|
||||
u_long v;
|
||||
int buf_len, s;
|
||||
ssize_t buf_len;
|
||||
int s;
|
||||
|
||||
/*
|
||||
* Initialize opcode and flags
|
||||
@ -577,29 +578,23 @@ pvc_add(int argc, char **argv, const struct cmd *cmdp)
|
||||
}
|
||||
bzero(air.air_int_intf, sizeof(air.air_int_intf));
|
||||
strcpy(air.air_int_intf, argv[0]);
|
||||
buf_len = sizeof(struct air_int_rsp);
|
||||
air.air_opcode = AIOCS_INF_INT;
|
||||
buf_len = do_info_ioctl(&air, buf_len);
|
||||
if (buf_len < 0) {
|
||||
fprintf(stderr, "%s: ", prog);
|
||||
buf_len = do_info_ioctl(&air, sizeof(struct air_int_rsp));
|
||||
if (buf_len == -1) {
|
||||
switch (errno) {
|
||||
case ENOPROTOOPT:
|
||||
case EOPNOTSUPP:
|
||||
perror("Internal error");
|
||||
break;
|
||||
err(1, "Internal error");
|
||||
case ENXIO:
|
||||
fprintf(stderr, "%s is not an ATM device\n",
|
||||
argv[0]);
|
||||
break;
|
||||
errx(1, "%s is not an ATM device", argv[0]);
|
||||
default:
|
||||
perror("ioctl (AIOCINFO)");
|
||||
break;
|
||||
err(1, "ioctl (AIOCINFO)");
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
int_info = (struct air_int_rsp *)(void *)air.air_buf_addr;
|
||||
strcpy(apr.aar_pvc_intf, argv[0]);
|
||||
argc--; argv++;
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
/*
|
||||
* Validate vpi/vci values
|
||||
@ -769,35 +764,30 @@ pvc_add(int argc, char **argv, const struct cmd *cmdp)
|
||||
sock_error(errno);
|
||||
}
|
||||
if (ioctl(s, AIOCADD, (caddr_t)&apr) < 0) {
|
||||
fprintf(stderr, "%s: ", prog);
|
||||
switch (errno) {
|
||||
case EPROTONOSUPPORT:
|
||||
case ENOPROTOOPT:
|
||||
perror("Internal error");
|
||||
break;
|
||||
err(1, "Internal error");
|
||||
case EINVAL:
|
||||
fprintf(stderr, "Invalid parameter\n");
|
||||
break;
|
||||
errx(1, "Invalid parameter");
|
||||
case EEXIST:
|
||||
fprintf(stderr, "PVC already exists\n");
|
||||
errx(1, "PVC already exists");
|
||||
break;
|
||||
case ENETDOWN:
|
||||
fprintf(stderr, "ATM network is inoperable\n");
|
||||
errx(1, "ATM network is inoperable");
|
||||
break;
|
||||
case ENOMEM:
|
||||
fprintf(stderr, "Kernel memory exhausted\n");
|
||||
errx(1, "Kernel memory exhausted");
|
||||
break;
|
||||
case EPERM:
|
||||
fprintf(stderr, "Must be super user to use add subcommand\n");
|
||||
errx(1, "Must be super user to use add subcommand");
|
||||
break;
|
||||
case ERANGE:
|
||||
fprintf(stderr, "Invalid VPI or VCI value\n");
|
||||
errx(1, "Invalid VPI or VCI value");
|
||||
break;
|
||||
default:
|
||||
perror("ioctl (AIOCADD) add PVC");
|
||||
break;
|
||||
err(1, "ioctl (AIOCADD) add PVC");
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
(void)close(s);
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ const char * get_adapter_name(const char *);
|
||||
int get_hex_addr(char *, u_char *, int);
|
||||
const char * format_mac_addr(const Mac_addr *);
|
||||
int parse_ip_prefix(const char *, struct in_addr *);
|
||||
int compress_prefix_list(struct in_addr *, int);
|
||||
size_t compress_prefix_list(struct in_addr *, size_t);
|
||||
void check_netif_name(const char *);
|
||||
void sock_error(int);
|
||||
|
||||
|
@ -52,6 +52,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <err.h>
|
||||
|
||||
#include "atm.h"
|
||||
|
||||
@ -135,9 +136,10 @@ show_eni_stats(intf, argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int buf_len, stats_type;
|
||||
struct atminfreq air;
|
||||
struct air_vinfo_rsp *stats;
|
||||
int stats_type;
|
||||
ssize_t buf_len;
|
||||
struct atminfreq air;
|
||||
struct air_vinfo_rsp *stats;
|
||||
|
||||
/*
|
||||
* Get statistics type qualifier
|
||||
@ -153,10 +155,10 @@ show_eni_stats(intf, argc, argv)
|
||||
} else if (!strcasecmp("driver", argv[0])) {
|
||||
stats_type = SHOW_DRIVER;
|
||||
} else {
|
||||
fprintf(stderr, "%s: Illegal or unsupported statistics type\n", prog);
|
||||
exit(1);
|
||||
errx(1, "Illegal or unsupported statistics type");
|
||||
}
|
||||
argc--; argv++;
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
/*
|
||||
* Get vendor-specific statistics from the kernel
|
||||
@ -165,22 +167,16 @@ show_eni_stats(intf, argc, argv)
|
||||
air.air_opcode = AIOCS_INF_VST;
|
||||
strcpy(air.air_vinfo_intf, intf);
|
||||
buf_len = do_info_ioctl(&air, sizeof(struct air_vinfo_rsp) + 1024);
|
||||
if (buf_len < 0) {
|
||||
fprintf(stderr, "%s: ", prog);
|
||||
if (buf_len == -1) {
|
||||
switch (errno) {
|
||||
case ENOPROTOOPT:
|
||||
case EOPNOTSUPP:
|
||||
perror("Internal error");
|
||||
break;
|
||||
err(1, "Internal error");
|
||||
case ENXIO:
|
||||
fprintf(stderr, "%s is not an ATM device\n",
|
||||
intf);
|
||||
break;
|
||||
errx(1, "%s is not an ATM device", intf);
|
||||
default:
|
||||
perror("ioctl (AIOCINFO)");
|
||||
break;
|
||||
err(1, "ioctl (AIOCINFO)");
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
stats = (struct air_vinfo_rsp *)(void *)air.air_buf_addr;
|
||||
|
||||
|
@ -54,6 +54,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <err.h>
|
||||
|
||||
#include "atm.h"
|
||||
|
||||
@ -151,7 +152,8 @@ show_fore200_stats(intf, argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int buf_len, stats_type;
|
||||
int stats_type;
|
||||
ssize_t buf_len;
|
||||
struct air_cfg_rsp *cfg;
|
||||
struct air_vinfo_rsp *stats;
|
||||
struct atminfreq air;
|
||||
@ -174,8 +176,7 @@ show_fore200_stats(intf, argc, argv)
|
||||
} else if (!strcasecmp("driver", argv[0])) {
|
||||
stats_type = SHOW_DRIVER;
|
||||
} else {
|
||||
fprintf(stderr, "%s: Illegal statistics type\n", prog);
|
||||
exit(1);
|
||||
errx(1, "Illegal statistics type");
|
||||
}
|
||||
argc--; argv++;
|
||||
|
||||
@ -186,22 +187,16 @@ show_fore200_stats(intf, argc, argv)
|
||||
air.air_opcode = AIOCS_INF_CFG;
|
||||
strcpy(air.air_cfg_intf, intf);
|
||||
buf_len = do_info_ioctl(&air, sizeof(struct air_cfg_rsp));
|
||||
if (buf_len < 0) {
|
||||
fprintf(stderr, "%s: ", prog);
|
||||
if (buf_len == -1) {
|
||||
switch (errno) {
|
||||
case ENOPROTOOPT:
|
||||
case EOPNOTSUPP:
|
||||
perror("Internal error");
|
||||
break;
|
||||
err(1, "Internal error");
|
||||
case ENXIO:
|
||||
fprintf(stderr, "%s is not an ATM device\n",
|
||||
intf);
|
||||
break;
|
||||
errx(1, "%s is not an ATM device", intf);
|
||||
default:
|
||||
perror("ioctl (AIOCINFO)");
|
||||
break;
|
||||
err(1, "ioctl (AIOCINFO)");
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
cfg = (struct air_cfg_rsp *)(void *)air.air_buf_addr;
|
||||
|
||||
@ -212,22 +207,16 @@ show_fore200_stats(intf, argc, argv)
|
||||
air.air_opcode = AIOCS_INF_VST;
|
||||
strcpy(air.air_vinfo_intf, intf);
|
||||
buf_len = do_info_ioctl(&air, sizeof(struct air_vinfo_rsp) + 1024);
|
||||
if (buf_len < 0) {
|
||||
fprintf(stderr, "%s: ", prog);
|
||||
if (buf_len == -1) {
|
||||
switch (errno) {
|
||||
case ENOPROTOOPT:
|
||||
case EOPNOTSUPP:
|
||||
perror("Internal error");
|
||||
break;
|
||||
err(1, "Internal error");
|
||||
case ENXIO:
|
||||
fprintf(stderr, "%s is not an ATM device\n",
|
||||
intf);
|
||||
break;
|
||||
errx(1, "%s is not an ATM device", intf);
|
||||
default:
|
||||
perror("ioctl (AIOCINFO)");
|
||||
break;
|
||||
err(1, "ioctl (AIOCINFO)");
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
stats = (struct air_vinfo_rsp *)(void *)air.air_buf_addr;
|
||||
|
||||
|
@ -85,7 +85,7 @@ ip_pvcadd(int argc, char **argv, const struct cmd *cmdp,
|
||||
{
|
||||
char *cp;
|
||||
char nhelp[128];
|
||||
int netif_no;
|
||||
u_int netif_no;
|
||||
u_int i, netif_pref_len;
|
||||
|
||||
/*
|
||||
@ -109,30 +109,24 @@ ip_pvcadd(int argc, char **argv, const struct cmd *cmdp,
|
||||
bzero(app->aar_pvc_intf, sizeof(app->aar_pvc_intf));
|
||||
netif_pref_len = strlen(intp->anp_nif_pref);
|
||||
cp = &argv[0][netif_pref_len];
|
||||
netif_no = atoi(cp);
|
||||
netif_no = (u_int)strtoul(cp, NULL, 10);
|
||||
for (i = 0; i < strlen(cp); i++) {
|
||||
if (cp[i] < '0' || cp[i] > '9') {
|
||||
netif_no = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((strlen(argv[0]) > sizeof(app->aar_pvc_intf) - 1) ||
|
||||
(netif_no < 0)) {
|
||||
fprintf(stderr, "%s: Illegal network interface name\n",
|
||||
prog);
|
||||
exit(1);
|
||||
}
|
||||
if (strlen(argv[0]) > sizeof(app->aar_pvc_intf) - 1)
|
||||
errx(1, "Illegal network interface name '%s'", argv[0]);
|
||||
|
||||
if (strncasecmp(intp->anp_nif_pref, argv[0], netif_pref_len) ||
|
||||
strlen (argv[0]) <= netif_pref_len ||
|
||||
netif_no > intp->anp_nif_cnt - 1) {
|
||||
fprintf(stderr, "%s: network interface %s is not associated with interface %s\n",
|
||||
prog,
|
||||
argv[0],
|
||||
intp->anp_intf);
|
||||
exit(1);
|
||||
}
|
||||
strlen(argv[0]) <= netif_pref_len || netif_no >= intp->anp_nif_cnt)
|
||||
errx(1, "network interface %s is not associated with "
|
||||
"interface %s", argv[0], intp->anp_intf);
|
||||
|
||||
strcpy(app->aar_pvc_intf, argv[0]);
|
||||
argc--; argv++;
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
/*
|
||||
* Set PVC destination address
|
||||
|
@ -79,7 +79,10 @@ __RCSID("@(#) $FreeBSD$");
|
||||
void
|
||||
set_arpserver(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
{
|
||||
int i, len, prefix_len = 0, rc, s;
|
||||
int rc, s;
|
||||
u_int i;
|
||||
ssize_t len;
|
||||
size_t prefix_len = 0;
|
||||
char *intf;
|
||||
Atm_addr server;
|
||||
struct sockaddr_in *lis;
|
||||
@ -138,12 +141,11 @@ set_arpserver(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
* with the network interface and insert them into the
|
||||
* list of permitted LIS prefixes.
|
||||
*/
|
||||
len = sizeof(struct air_netif_rsp);
|
||||
bzero(&air, sizeof(air));
|
||||
air.air_opcode = AIOCS_INF_NIF;
|
||||
strcpy(air.air_int_intf, intf);
|
||||
len = do_info_ioctl(&air, len);
|
||||
if (len < 0) {
|
||||
len = do_info_ioctl(&air, sizeof(struct air_netif_rsp));
|
||||
if (len == -1) {
|
||||
fprintf(stderr, "%s: ", prog);
|
||||
switch (errno) {
|
||||
case ENOPROTOOPT:
|
||||
@ -371,7 +373,8 @@ set_netif(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
struct atmsetreq anr;
|
||||
char str[16];
|
||||
char *cp;
|
||||
int nifs, s;
|
||||
int s;
|
||||
u_long nifs;
|
||||
|
||||
/*
|
||||
* Set IOCTL opcode
|
||||
@ -402,8 +405,9 @@ set_netif(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
/*
|
||||
* Validate interface count
|
||||
*/
|
||||
nifs = (int) strtol(argv[0], &cp, 0);
|
||||
if ((*cp != '\0') || (nifs < 0) || (nifs > MAX_NIFS)) {
|
||||
errno = 0;
|
||||
nifs = strtoul(argv[0], &cp, 0);
|
||||
if (errno != 0 || *cp != '\0' || nifs > MAX_NIFS) {
|
||||
fprintf(stderr, "%s: Invalid interface count\n", prog);
|
||||
exit(1);
|
||||
}
|
||||
@ -412,7 +416,7 @@ set_netif(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
/*
|
||||
* Make sure the resulting name won't be too long
|
||||
*/
|
||||
sprintf(str, "%d", nifs - 1);
|
||||
sprintf(str, "%lu", nifs - 1);
|
||||
if ((strlen(str) + strlen(anr.asr_nif_pref)) >
|
||||
sizeof(anr.asr_nif_intf) - 1) {
|
||||
fprintf(stderr, "%s: Network interface prefix too long\n", prog);
|
||||
|
@ -86,7 +86,7 @@ static int arp_compare(const void *, const void *);
|
||||
void
|
||||
show_arp(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
{
|
||||
int buf_len, arp_info_len;
|
||||
size_t arp_info_len;
|
||||
struct atminfreq air;
|
||||
struct air_arp_rsp *arp_info, *arp_info_base;
|
||||
struct sockaddr_in *sain;
|
||||
@ -116,11 +116,10 @@ show_arp(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
* Get ARP information from the kernel
|
||||
*/
|
||||
bzero(&air, sizeof(air));
|
||||
buf_len = sizeof(struct air_arp_rsp) * 10;
|
||||
air.air_opcode = AIOCS_INF_ARP;
|
||||
air.air_arp_addr = host_addr.sa;
|
||||
arp_info_len = do_info_ioctl(&air, buf_len);
|
||||
if (arp_info_len < 0) {
|
||||
arp_info_len = do_info_ioctl(&air, sizeof(struct air_arp_rsp) * 10);
|
||||
if ((ssize_t)arp_info_len == -1) {
|
||||
fprintf(stderr, "%s: ", prog);
|
||||
switch (errno) {
|
||||
case ENOPROTOOPT:
|
||||
@ -150,7 +149,7 @@ show_arp(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
/*
|
||||
* Print the relevant information
|
||||
*/
|
||||
while (arp_info_len > 0) {
|
||||
while (arp_info_len >= sizeof(struct air_arp_rsp)) {
|
||||
print_arp_info(arp_info);
|
||||
arp_info++;
|
||||
arp_info_len -= sizeof(struct air_arp_rsp);
|
||||
@ -181,7 +180,7 @@ show_arp(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
void
|
||||
show_arpserv(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
{
|
||||
int asrv_info_len, buf_len = sizeof(struct air_asrv_rsp) * 3;
|
||||
size_t buf_len, asrv_info_len;
|
||||
struct atminfreq air;
|
||||
struct air_asrv_rsp *asrv_info, *asrv_info_base;
|
||||
|
||||
@ -203,8 +202,8 @@ show_arpserv(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
* Get interface information from the kernel
|
||||
*/
|
||||
air.air_opcode = AIOCS_INF_ASV;
|
||||
buf_len = do_info_ioctl(&air, buf_len);
|
||||
if (buf_len < 0) {
|
||||
buf_len = do_info_ioctl(&air, sizeof(struct air_asrv_rsp) * 3);
|
||||
if ((ssize_t)buf_len == -1) {
|
||||
fprintf(stderr, "%s: ", prog);
|
||||
switch (errno) {
|
||||
case ENOPROTOOPT:
|
||||
@ -227,14 +226,13 @@ show_arpserv(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
*/
|
||||
asrv_info_base = asrv_info =
|
||||
(struct air_asrv_rsp *)(void *)air.air_buf_addr;
|
||||
for (; (size_t)buf_len >= sizeof(struct air_asrv_rsp);
|
||||
asrv_info = (struct air_asrv_rsp *)
|
||||
((u_long)asrv_info + asrv_info_len),
|
||||
buf_len -= asrv_info_len) {
|
||||
while (buf_len >= sizeof(struct air_asrv_rsp)) {
|
||||
print_asrv_info(asrv_info);
|
||||
asrv_info_len = sizeof(struct air_asrv_rsp) +
|
||||
asrv_info->asp_nprefix *
|
||||
sizeof(struct in_addr) * 2;
|
||||
asrv_info->asp_nprefix * sizeof(struct in_addr) * 2;
|
||||
asrv_info = (struct air_asrv_rsp *)(void *)
|
||||
((char *)asrv_info + asrv_info_len);
|
||||
buf_len -= asrv_info_len;
|
||||
}
|
||||
free(asrv_info_base);
|
||||
}
|
||||
@ -258,7 +256,7 @@ show_arpserv(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
void
|
||||
show_config(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
{
|
||||
int buf_len = sizeof(struct air_asrv_rsp) * 3;
|
||||
size_t buf_len;
|
||||
struct atminfreq air;
|
||||
struct air_cfg_rsp *cfg_info, *cfg_info_base;
|
||||
|
||||
@ -280,8 +278,8 @@ show_config(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
* Get configuration information from the kernel
|
||||
*/
|
||||
air.air_opcode = AIOCS_INF_CFG;
|
||||
buf_len = do_info_ioctl(&air, buf_len);
|
||||
if (buf_len < 0) {
|
||||
buf_len = do_info_ioctl(&air, sizeof(struct air_asrv_rsp) * 3);
|
||||
if ((ssize_t)buf_len == -1) {
|
||||
fprintf(stderr, "%s: ", prog);
|
||||
switch (errno) {
|
||||
case ENOPROTOOPT:
|
||||
@ -304,7 +302,7 @@ show_config(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
*/
|
||||
cfg_info_base = cfg_info =
|
||||
(struct air_cfg_rsp *)(void *)air.air_buf_addr;
|
||||
for (; (size_t)buf_len >= sizeof(struct air_cfg_rsp); cfg_info++,
|
||||
for (; buf_len >= sizeof(struct air_cfg_rsp); cfg_info++,
|
||||
buf_len -= sizeof(struct air_cfg_rsp)) {
|
||||
print_cfg_info(cfg_info);
|
||||
}
|
||||
@ -330,7 +328,7 @@ show_config(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
void
|
||||
show_intf(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
{
|
||||
int buf_len = sizeof(struct air_int_rsp) * 3;
|
||||
size_t buf_len;
|
||||
struct atminfreq air;
|
||||
struct air_int_rsp *int_info, *int_info_base;
|
||||
|
||||
@ -352,8 +350,8 @@ show_intf(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
* Get interface information from the kernel
|
||||
*/
|
||||
air.air_opcode = AIOCS_INF_INT;
|
||||
buf_len = do_info_ioctl(&air, buf_len);
|
||||
if (buf_len < 0) {
|
||||
buf_len = do_info_ioctl(&air, sizeof(struct air_int_rsp) * 3);
|
||||
if ((ssize_t)buf_len == -1) {
|
||||
fprintf(stderr, "%s: ", prog);
|
||||
switch (errno) {
|
||||
case ENOPROTOOPT:
|
||||
@ -376,7 +374,7 @@ show_intf(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
*/
|
||||
int_info_base = int_info =
|
||||
(struct air_int_rsp *)(void *)air.air_buf_addr;
|
||||
for (; (size_t)buf_len >= sizeof(struct air_int_rsp); int_info++,
|
||||
for (; buf_len >= sizeof(struct air_int_rsp); int_info++,
|
||||
buf_len -= sizeof(struct air_int_rsp)) {
|
||||
print_intf_info(int_info);
|
||||
}
|
||||
@ -402,7 +400,8 @@ show_intf(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
void
|
||||
show_ip_vcc(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
{
|
||||
int buf_len, ip_info_len, rc;
|
||||
int rc;
|
||||
size_t ip_info_len;
|
||||
char *if_name = (char *)0;
|
||||
struct atminfreq air;
|
||||
struct air_ip_vcc_rsp *ip_info, *ip_info_base;
|
||||
@ -459,11 +458,10 @@ show_ip_vcc(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
/*
|
||||
* Get IP map information from the kernel
|
||||
*/
|
||||
buf_len = sizeof(struct air_ip_vcc_rsp) * 10;
|
||||
air.air_opcode = AIOCS_INF_IPM;
|
||||
air.air_ip_addr = host_addr.sa;
|
||||
ip_info_len = do_info_ioctl(&air, buf_len);
|
||||
if (ip_info_len < 0) {
|
||||
ip_info_len = do_info_ioctl(&air, sizeof(struct air_ip_vcc_rsp) * 10);
|
||||
if ((ssize_t)ip_info_len == -1) {
|
||||
fprintf(stderr, "%s: ", prog);
|
||||
switch (errno) {
|
||||
case ENOPROTOOPT:
|
||||
@ -493,7 +491,7 @@ show_ip_vcc(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
/*
|
||||
* Print the relevant information
|
||||
*/
|
||||
while (ip_info_len>0) {
|
||||
while (ip_info_len >= sizeof(struct air_ip_vcc_rsp)) {
|
||||
if (!if_name || !strcmp(if_name, ip_info->aip_intf)) {
|
||||
print_ip_vcc_info(ip_info);
|
||||
}
|
||||
@ -505,7 +503,6 @@ show_ip_vcc(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
* Release the information from the kernel
|
||||
*/
|
||||
free(ip_info_base);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -527,7 +524,7 @@ show_ip_vcc(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
void
|
||||
show_netif(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
{
|
||||
int buf_len = sizeof(struct air_netif_rsp) * 3;
|
||||
size_t buf_len;
|
||||
struct atminfreq air;
|
||||
struct air_netif_rsp *int_info, *int_info_base;
|
||||
|
||||
@ -548,8 +545,8 @@ show_netif(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
* Get network interface information from the kernel
|
||||
*/
|
||||
air.air_opcode = AIOCS_INF_NIF;
|
||||
buf_len = do_info_ioctl(&air, buf_len);
|
||||
if (buf_len < 0) {
|
||||
buf_len = do_info_ioctl(&air, sizeof(struct air_netif_rsp) * 3);
|
||||
if ((ssize_t)buf_len == -1) {
|
||||
fprintf(stderr, "%s: ", prog);
|
||||
switch (errno) {
|
||||
case ENOPROTOOPT:
|
||||
@ -572,7 +569,7 @@ show_netif(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
*/
|
||||
int_info_base = int_info =
|
||||
(struct air_netif_rsp *) air.air_buf_addr;
|
||||
for (; (size_t)buf_len >= sizeof(struct air_netif_rsp); int_info++,
|
||||
for (; buf_len >= sizeof(struct air_netif_rsp); int_info++,
|
||||
buf_len -= sizeof(struct air_netif_rsp)) {
|
||||
print_netif_info(int_info);
|
||||
}
|
||||
@ -598,7 +595,7 @@ show_netif(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
void
|
||||
show_intf_stats(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
{
|
||||
int buf_len;
|
||||
size_t buf_len;
|
||||
char intf[IFNAMSIZ];
|
||||
struct atminfreq air;
|
||||
struct air_phy_stat_rsp *pstat_info, *pstat_info_base;
|
||||
@ -626,11 +623,10 @@ show_intf_stats(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
/*
|
||||
* Get adapter configuration information
|
||||
*/
|
||||
buf_len = sizeof(struct air_cfg_rsp);
|
||||
air.air_opcode = AIOCS_INF_CFG;
|
||||
strcpy(air.air_cfg_intf, intf);
|
||||
buf_len = do_info_ioctl(&air, buf_len);
|
||||
if (buf_len < 0) {
|
||||
buf_len = do_info_ioctl(&air, sizeof(struct air_cfg_rsp));
|
||||
if ((ssize_t)buf_len == -1) {
|
||||
fprintf(stderr, "%s: ", prog);
|
||||
switch (errno) {
|
||||
case ENOPROTOOPT:
|
||||
@ -670,11 +666,11 @@ show_intf_stats(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
/*
|
||||
* Get generic interface statistics
|
||||
*/
|
||||
buf_len = sizeof(struct air_phy_stat_rsp) * 3;
|
||||
air.air_opcode = AIOCS_INF_PIS;
|
||||
strcpy(air.air_physt_intf, intf);
|
||||
buf_len = do_info_ioctl(&air, buf_len);
|
||||
if (buf_len < 0) {
|
||||
buf_len = do_info_ioctl(&air,
|
||||
sizeof(struct air_phy_stat_rsp) * 3);
|
||||
if ((ssize_t)buf_len == -1) {
|
||||
fprintf(stderr, "%s: ", prog);
|
||||
switch (errno) {
|
||||
case ENOPROTOOPT:
|
||||
@ -697,7 +693,7 @@ show_intf_stats(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
*/
|
||||
pstat_info_base = pstat_info = (struct air_phy_stat_rsp *)
|
||||
(void *)air.air_buf_addr;
|
||||
for (; (size_t)buf_len >= sizeof(struct air_phy_stat_rsp);
|
||||
for (; buf_len >= sizeof(struct air_phy_stat_rsp);
|
||||
pstat_info++,
|
||||
buf_len-=sizeof(struct air_phy_stat_rsp)) {
|
||||
print_intf_stats(pstat_info);
|
||||
@ -725,7 +721,7 @@ show_intf_stats(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
void
|
||||
show_vcc_stats(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
{
|
||||
int vcc_info_len;
|
||||
size_t vcc_info_len;
|
||||
int vpi = -1, vci = -1;
|
||||
char *cp, *intf = NULL;
|
||||
struct air_vcc_rsp *vcc_info, *vcc_info_base;
|
||||
@ -774,7 +770,7 @@ show_vcc_stats(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
vcc_info_len = get_vcc_info(intf, &vcc_info);
|
||||
if (vcc_info_len == 0)
|
||||
exit(1);
|
||||
else if (vcc_info_len < 0) {
|
||||
else if ((ssize_t)vcc_info_len == -1) {
|
||||
fprintf(stderr, "%s: ", prog);
|
||||
switch (errno) {
|
||||
case ENOPROTOOPT:
|
||||
@ -803,7 +799,7 @@ show_vcc_stats(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
* Display the VCC statistics
|
||||
*/
|
||||
vcc_info_base = vcc_info;
|
||||
for (; (size_t)vcc_info_len >= sizeof(struct air_vcc_rsp);
|
||||
for (; vcc_info_len >= sizeof(struct air_vcc_rsp);
|
||||
vcc_info_len-=sizeof(struct air_vcc_rsp),
|
||||
vcc_info++) {
|
||||
if (vpi != -1 && vcc_info->avp_vpi != vpi)
|
||||
@ -834,7 +830,7 @@ show_vcc_stats(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
void
|
||||
show_vcc(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
{
|
||||
int vcc_info_len;
|
||||
size_t vcc_info_len;
|
||||
int vpi = -1, vci = -1, show_pvc = 0, show_svc = 0;
|
||||
char *cp, *intf = NULL;
|
||||
struct air_vcc_rsp *vcc_info, *vcc_info_base;
|
||||
@ -890,7 +886,7 @@ show_vcc(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
vcc_info_len = get_vcc_info(intf, &vcc_info);
|
||||
if (vcc_info_len == 0)
|
||||
exit(1);
|
||||
else if (vcc_info_len < 0) {
|
||||
else if ((ssize_t)vcc_info_len == -1) {
|
||||
fprintf(stderr, "%s: ", prog);
|
||||
switch (errno) {
|
||||
case ENOPROTOOPT:
|
||||
@ -919,7 +915,7 @@ show_vcc(int argc, char **argv, const struct cmd *cmdp __unused)
|
||||
* Display the VCC information
|
||||
*/
|
||||
vcc_info_base = vcc_info;
|
||||
for (; (size_t)vcc_info_len >= sizeof(struct air_vcc_rsp);
|
||||
for (; vcc_info_len >= sizeof(struct air_vcc_rsp);
|
||||
vcc_info_len-=sizeof(struct air_vcc_rsp),
|
||||
vcc_info++) {
|
||||
if (vpi != -1 && vcc_info->avp_vpi != vpi)
|
||||
@ -955,7 +951,7 @@ void
|
||||
show_version(int argc __unused, char **argv __unused,
|
||||
const struct cmd *cmdp __unused)
|
||||
{
|
||||
int buf_len = sizeof(struct air_version_rsp);
|
||||
size_t buf_len;
|
||||
struct atminfreq air;
|
||||
struct air_version_rsp *ver_info, *ver_info_base;
|
||||
|
||||
@ -963,8 +959,8 @@ show_version(int argc __unused, char **argv __unused,
|
||||
* Get network interface information from the kernel
|
||||
*/
|
||||
air.air_opcode = AIOCS_INF_VER;
|
||||
buf_len = do_info_ioctl(&air, buf_len);
|
||||
if (buf_len < 0) {
|
||||
buf_len = do_info_ioctl(&air, sizeof(struct air_version_rsp));
|
||||
if ((ssize_t)buf_len == -1) {
|
||||
fprintf(stderr, "%s: ", prog);
|
||||
switch (errno) {
|
||||
case ENOPROTOOPT:
|
||||
@ -986,7 +982,7 @@ show_version(int argc __unused, char **argv __unused,
|
||||
*/
|
||||
ver_info_base = ver_info =
|
||||
(struct air_version_rsp *)(void *)air.air_buf_addr;
|
||||
for (; (size_t)buf_len >= sizeof(struct air_version_rsp); ver_info++,
|
||||
for (; buf_len >= sizeof(struct air_version_rsp); ver_info++,
|
||||
buf_len -= sizeof(struct air_version_rsp)) {
|
||||
print_version_info(ver_info);
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ get_bus_type(int bus)
|
||||
const char *
|
||||
get_adapter_name(const char *intf)
|
||||
{
|
||||
int buf_len;
|
||||
size_t buf_len;
|
||||
struct atminfreq air;
|
||||
struct air_cfg_rsp *cfg;
|
||||
static char name[256];
|
||||
@ -268,7 +268,7 @@ get_adapter_name(const char *intf)
|
||||
air.air_opcode = AIOCS_INF_CFG;
|
||||
strcpy(air.air_cfg_intf, intf);
|
||||
buf_len = do_info_ioctl(&air, sizeof(struct air_cfg_rsp));
|
||||
if ((size_t)buf_len < sizeof(struct air_cfg_rsp))
|
||||
if (buf_len < sizeof(struct air_cfg_rsp))
|
||||
return("-");
|
||||
cfg = (struct air_cfg_rsp *)(void *)air.air_buf_addr;
|
||||
|
||||
@ -440,10 +440,10 @@ parse_ip_prefix(const char *cp, struct in_addr *op)
|
||||
* length of compressed list
|
||||
*
|
||||
*/
|
||||
int
|
||||
compress_prefix_list(struct in_addr *ipp, int ilen)
|
||||
size_t
|
||||
compress_prefix_list(struct in_addr *ipp, size_t ilen)
|
||||
{
|
||||
int i, j, n;
|
||||
u_int i, j, n;
|
||||
struct in_addr *ip1, *ip2, *m1, *m2;
|
||||
|
||||
/*
|
||||
@ -557,7 +557,7 @@ check_netif_name(const char *nif)
|
||||
/*
|
||||
* Look up the name in the kernel
|
||||
*/
|
||||
rc = verify_nif_name(__DECONST(char *, nif)); /* XXX */
|
||||
rc = verify_nif_name(nif);
|
||||
|
||||
/*
|
||||
* Check the result
|
||||
|
Loading…
x
Reference in New Issue
Block a user