Make WARNS=6 clean.
MFC after: 1 week
This commit is contained in:
parent
295fbd498e
commit
04ebad3842
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=213099
@ -5,7 +5,6 @@ PROG= tftpd
|
|||||||
MAN= tftpd.8
|
MAN= tftpd.8
|
||||||
SRCS= tftp-file.c tftp-io.c tftp-options.c tftp-transfer.c tftp-utils.c
|
SRCS= tftp-file.c tftp-io.c tftp-options.c tftp-transfer.c tftp-utils.c
|
||||||
SRCS+= tftpd.c
|
SRCS+= tftpd.c
|
||||||
WARNS= 3
|
|
||||||
WFORMAT=0
|
WFORMAT=0
|
||||||
LDFLAGS= -lwrap
|
LDFLAGS= -lwrap
|
||||||
|
|
||||||
|
@ -103,13 +103,13 @@ static size_t
|
|||||||
convert_to_net(char *buffer, size_t count, int init)
|
convert_to_net(char *buffer, size_t count, int init)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
static size_t n = 0, read = 0;
|
static size_t n = 0, in = 0;
|
||||||
static int newline = 0;
|
static int newline = 0;
|
||||||
|
|
||||||
if (init) {
|
if (init) {
|
||||||
newline = 0;
|
newline = 0;
|
||||||
n = 0;
|
n = 0;
|
||||||
read = 0;
|
in = 0;
|
||||||
return 0 ;
|
return 0 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,13 +124,13 @@ convert_to_net(char *buffer, size_t count, int init)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (i < count) {
|
while (i < count) {
|
||||||
if (n == read) {
|
if (n == in) {
|
||||||
/* When done we're done */
|
/* When done we're done */
|
||||||
if (feof(file)) break;
|
if (feof(file)) break;
|
||||||
|
|
||||||
/* Otherwise read another bunch */
|
/* Otherwise read another bunch */
|
||||||
read = fread(convbuffer, 1, count, file);
|
in = fread(convbuffer, 1, count, file);
|
||||||
if (read == 0) break;
|
if (in == 0) break;
|
||||||
n = 0;
|
n = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,7 +250,7 @@ read_close(void)
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
synchnet(int peer)
|
synchnet(int peer __unused)
|
||||||
{
|
{
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -79,7 +79,8 @@ int options_extra_enabled = 1;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
int
|
int
|
||||||
option_tsize(int peer, struct tftphdr *tp, int mode, struct stat *stbuf)
|
option_tsize(int peer __unused, struct tftphdr *tp __unused, int mode,
|
||||||
|
struct stat *stbuf)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (options[OPT_TSIZE].o_request == NULL)
|
if (options[OPT_TSIZE].o_request == NULL)
|
||||||
@ -159,21 +160,19 @@ option_rollover(int peer)
|
|||||||
int
|
int
|
||||||
option_blksize(int peer)
|
option_blksize(int peer)
|
||||||
{
|
{
|
||||||
int *maxdgram;
|
u_long maxdgram;
|
||||||
char maxbuffer[100];
|
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
if (options[OPT_BLKSIZE].o_request == NULL)
|
if (options[OPT_BLKSIZE].o_request == NULL)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
/* maximum size of an UDP packet according to the system */
|
/* maximum size of an UDP packet according to the system */
|
||||||
len = sizeof(maxbuffer);
|
len = sizeof(maxdgram);
|
||||||
if (sysctlbyname("net.inet.udp.maxdgram",
|
if (sysctlbyname("net.inet.udp.maxdgram",
|
||||||
maxbuffer, &len, NULL, 0) < 0) {
|
&maxdgram, &len, NULL, 0) < 0) {
|
||||||
tftp_log(LOG_ERR, "sysctl: net.inet.udp.maxdgram");
|
tftp_log(LOG_ERR, "sysctl: net.inet.udp.maxdgram");
|
||||||
return (acting_as_client ? 1 : 0);
|
return (acting_as_client ? 1 : 0);
|
||||||
}
|
}
|
||||||
maxdgram = (int *)maxbuffer;
|
|
||||||
|
|
||||||
int size = atoi(options[OPT_BLKSIZE].o_request);
|
int size = atoi(options[OPT_BLKSIZE].o_request);
|
||||||
if (size < BLKSIZE_MIN || size > BLKSIZE_MAX) {
|
if (size < BLKSIZE_MIN || size > BLKSIZE_MAX) {
|
||||||
@ -191,20 +190,20 @@ option_blksize(int peer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size > *maxdgram) {
|
if (size > (int)maxdgram) {
|
||||||
if (acting_as_client) {
|
if (acting_as_client) {
|
||||||
tftp_log(LOG_ERR,
|
tftp_log(LOG_ERR,
|
||||||
"Invalid blocksize (%d bytes), "
|
"Invalid blocksize (%d bytes), "
|
||||||
"net.inet.udp.maxdgram sysctl limits it to "
|
"net.inet.udp.maxdgram sysctl limits it to "
|
||||||
"%d bytes.\n", size, *maxdgram);
|
"%d bytes.\n", size, maxdgram);
|
||||||
send_error(peer, EBADOP);
|
send_error(peer, EBADOP);
|
||||||
return (1);
|
return (1);
|
||||||
} else {
|
} else {
|
||||||
tftp_log(LOG_WARNING,
|
tftp_log(LOG_WARNING,
|
||||||
"Invalid blocksize (%d bytes), "
|
"Invalid blocksize (%d bytes), "
|
||||||
"net.inet.udp.maxdgram sysctl limits it to "
|
"net.inet.udp.maxdgram sysctl limits it to "
|
||||||
"%d bytes.\n", size, *maxdgram);
|
"%d bytes.\n", size, maxdgram);
|
||||||
size = *maxdgram;
|
size = maxdgram;
|
||||||
/* No reason to return */
|
/* No reason to return */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -220,10 +219,9 @@ option_blksize(int peer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
option_blksize2(int peer)
|
option_blksize2(int peer __unused)
|
||||||
{
|
{
|
||||||
int *maxdgram;
|
u_long maxdgram;
|
||||||
char maxbuffer[100];
|
|
||||||
int size, i;
|
int size, i;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
@ -236,13 +234,12 @@ option_blksize2(int peer)
|
|||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
/* maximum size of an UDP packet according to the system */
|
/* maximum size of an UDP packet according to the system */
|
||||||
len = sizeof(maxbuffer);
|
len = sizeof(maxdgram);
|
||||||
if (sysctlbyname("net.inet.udp.maxdgram",
|
if (sysctlbyname("net.inet.udp.maxdgram",
|
||||||
maxbuffer, &len, NULL, 0) < 0) {
|
&maxdgram, &len, NULL, 0) < 0) {
|
||||||
tftp_log(LOG_ERR, "sysctl: net.inet.udp.maxdgram");
|
tftp_log(LOG_ERR, "sysctl: net.inet.udp.maxdgram");
|
||||||
return (acting_as_client ? 1 : 0);
|
return (acting_as_client ? 1 : 0);
|
||||||
}
|
}
|
||||||
maxdgram = (int *)maxbuffer;
|
|
||||||
|
|
||||||
size = atoi(options[OPT_BLKSIZE2].o_request);
|
size = atoi(options[OPT_BLKSIZE2].o_request);
|
||||||
for (i = 0; sizes[i] != 0; i++) {
|
for (i = 0; sizes[i] != 0; i++) {
|
||||||
@ -254,13 +251,13 @@ option_blksize2(int peer)
|
|||||||
return (acting_as_client ? 1 : 0);
|
return (acting_as_client ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size > *maxdgram) {
|
if (size > (int)maxdgram) {
|
||||||
for (i = 0; sizes[i+1] != 0; i++) {
|
for (i = 0; sizes[i+1] != 0; i++) {
|
||||||
if (*maxdgram < sizes[i+1]) break;
|
if ((int)maxdgram < sizes[i+1]) break;
|
||||||
}
|
}
|
||||||
tftp_log(LOG_INFO,
|
tftp_log(LOG_INFO,
|
||||||
"Invalid blocksize2 (%d bytes), net.inet.udp.maxdgram "
|
"Invalid blocksize2 (%d bytes), net.inet.udp.maxdgram "
|
||||||
"sysctl limits it to %d bytes.\n", size, *maxdgram);
|
"sysctl limits it to %d bytes.\n", size, maxdgram);
|
||||||
size = sizes[i];
|
size = sizes[i];
|
||||||
/* No need to return */
|
/* No need to return */
|
||||||
}
|
}
|
||||||
@ -279,7 +276,7 @@ option_blksize2(int peer)
|
|||||||
* Append the available options to the header
|
* Append the available options to the header
|
||||||
*/
|
*/
|
||||||
uint16_t
|
uint16_t
|
||||||
make_options(int peer, char *buffer, uint16_t size) {
|
make_options(int peer __unused, char *buffer, uint16_t size) {
|
||||||
int i;
|
int i;
|
||||||
char *value;
|
char *value;
|
||||||
const char *option;
|
const char *option;
|
||||||
|
@ -59,7 +59,7 @@ int acting_as_client;
|
|||||||
* first timeout) to 'timeoutnetwork' (i.e. the last timeout)
|
* first timeout) to 'timeoutnetwork' (i.e. the last timeout)
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
settimeouts(int _timeoutpacket, int _timeoutnetwork, int _maxtimeouts)
|
settimeouts(int _timeoutpacket, int _timeoutnetwork, int _maxtimeouts __unused)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ unmappedaddr(struct sockaddr_in6 *sin6)
|
|||||||
!IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr))
|
!IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr))
|
||||||
return;
|
return;
|
||||||
sin4 = (struct sockaddr_in *)sin6;
|
sin4 = (struct sockaddr_in *)sin6;
|
||||||
addr = *(u_int32_t *)&sin6->sin6_addr.s6_addr[12];
|
memcpy(&addr, &sin6->sin6_addr.s6_addr[12], sizeof(addr));
|
||||||
port = sin6->sin6_port;
|
port = sin6->sin6_port;
|
||||||
memset(sin4, 0, sizeof(struct sockaddr_in));
|
memset(sin4, 0, sizeof(struct sockaddr_in));
|
||||||
sin4->sin_addr.s_addr = addr;
|
sin4->sin_addr.s_addr = addr;
|
||||||
@ -170,7 +170,7 @@ struct packettypes packettypes[] = {
|
|||||||
{ 0, NULL },
|
{ 0, NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
packettype(int type)
|
packettype(int type)
|
||||||
{
|
{
|
||||||
static char failed[100];
|
static char failed[100];
|
||||||
@ -231,7 +231,7 @@ debug_finds(char *s)
|
|||||||
return (i);
|
return (i);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
debug_show(int d)
|
debug_show(int d)
|
||||||
{
|
{
|
||||||
static char s[100];
|
static char s[100];
|
||||||
@ -317,4 +317,3 @@ printstats(const char *direction, int verbose, struct tftp_stats *ts)
|
|||||||
printf(" [%.0f bits/sec]", (ts->amount*8.)/delta);
|
printf(" [%.0f bits/sec]", (ts->amount*8.)/delta);
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,17 +64,17 @@ ssize_t get_field(int peer, char *buffer, ssize_t size);
|
|||||||
*/
|
*/
|
||||||
struct packettypes {
|
struct packettypes {
|
||||||
int value;
|
int value;
|
||||||
char *name;
|
const char *const name;
|
||||||
};
|
};
|
||||||
extern struct packettypes packettypes[];
|
extern struct packettypes packettypes[];
|
||||||
char *packettype(int);
|
const char *packettype(int);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* RP_
|
* RP_
|
||||||
*/
|
*/
|
||||||
struct rp_errors {
|
struct rp_errors {
|
||||||
int error;
|
int error;
|
||||||
char *desc;
|
const char *const desc;
|
||||||
};
|
};
|
||||||
extern struct rp_errors rp_errors[];
|
extern struct rp_errors rp_errors[];
|
||||||
char *rp_strerror(int error);
|
char *rp_strerror(int error);
|
||||||
@ -89,15 +89,15 @@ char *rp_strerror(int error);
|
|||||||
#define DEBUG_ACCESS 0x0008
|
#define DEBUG_ACCESS 0x0008
|
||||||
struct debugs {
|
struct debugs {
|
||||||
int value;
|
int value;
|
||||||
char *name;
|
const char *const name;
|
||||||
char *desc;
|
const char *const desc;
|
||||||
};
|
};
|
||||||
extern int debug;
|
extern int debug;
|
||||||
extern struct debugs debugs[];
|
extern struct debugs debugs[];
|
||||||
extern int packetdroppercentage;
|
extern int packetdroppercentage;
|
||||||
int debug_find(char *s);
|
int debug_find(char *s);
|
||||||
int debug_finds(char *s);
|
int debug_finds(char *s);
|
||||||
char *debug_show(int d);
|
const char *debug_show(int d);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Log routines
|
* Log routines
|
||||||
|
@ -97,7 +97,7 @@ static int suppress_naks;
|
|||||||
static int logging;
|
static int logging;
|
||||||
static int ipchroot;
|
static int ipchroot;
|
||||||
static int create_new = 0;
|
static int create_new = 0;
|
||||||
static char *newfile_format = "%Y%m%d";
|
static const char *newfile_format = "%Y%m%d";
|
||||||
static int increase_name = 0;
|
static int increase_name = 0;
|
||||||
static mode_t mask = S_IWGRP | S_IWOTH;
|
static mode_t mask = S_IWGRP | S_IWOTH;
|
||||||
|
|
||||||
@ -785,7 +785,6 @@ static void
|
|||||||
tftp_xmitfile(int peer, const char *mode)
|
tftp_xmitfile(int peer, const char *mode)
|
||||||
{
|
{
|
||||||
uint16_t block;
|
uint16_t block;
|
||||||
uint32_t amount;
|
|
||||||
time_t now;
|
time_t now;
|
||||||
struct tftp_stats ts;
|
struct tftp_stats ts;
|
||||||
|
|
||||||
@ -799,13 +798,12 @@ tftp_xmitfile(int peer, const char *mode)
|
|||||||
read_close();
|
read_close();
|
||||||
if (debug&DEBUG_SIMPLE)
|
if (debug&DEBUG_SIMPLE)
|
||||||
tftp_log(LOG_INFO, "Sent %d bytes in %d seconds",
|
tftp_log(LOG_INFO, "Sent %d bytes in %d seconds",
|
||||||
amount, time(NULL) - now);
|
ts.amount, time(NULL) - now);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tftp_recvfile(int peer, const char *mode)
|
tftp_recvfile(int peer, const char *mode)
|
||||||
{
|
{
|
||||||
uint32_t filesize;
|
|
||||||
uint16_t block;
|
uint16_t block;
|
||||||
struct timeval now1, now2;
|
struct timeval now1, now2;
|
||||||
struct tftp_stats ts;
|
struct tftp_stats ts;
|
||||||
@ -820,6 +818,7 @@ tftp_recvfile(int peer, const char *mode)
|
|||||||
tftp_receive(peer, &block, &ts, NULL, 0);
|
tftp_receive(peer, &block, &ts, NULL, 0);
|
||||||
|
|
||||||
write_close();
|
write_close();
|
||||||
|
gettimeofday(&now2, NULL);
|
||||||
|
|
||||||
if (debug&DEBUG_SIMPLE) {
|
if (debug&DEBUG_SIMPLE) {
|
||||||
double f;
|
double f;
|
||||||
@ -832,9 +831,8 @@ tftp_recvfile(int peer, const char *mode)
|
|||||||
(now2.tv_usec - now1.tv_usec) / 100000.0;
|
(now2.tv_usec - now1.tv_usec) / 100000.0;
|
||||||
tftp_log(LOG_INFO,
|
tftp_log(LOG_INFO,
|
||||||
"Download of %d bytes in %d blocks completed after %0.1f seconds\n",
|
"Download of %d bytes in %d blocks completed after %0.1f seconds\n",
|
||||||
filesize, block, f);
|
ts.amount, block, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
# @(#)Makefile 8.1 (Berkeley) 6/6/93
|
# @(#)Makefile 8.1 (Berkeley) 6/6/93
|
||||||
# $FreeBSD$
|
# $FreeBSD$
|
||||||
|
|
||||||
.PATH: ${.CURDIR}/../../libexec/tftpd
|
.PATH: ${.CURDIR}/../../libexec/tftpd
|
||||||
|
|
||||||
PROG= tftp
|
PROG= tftp
|
||||||
SRCS= main.c tftp-file.c tftp-io.c tftp-options.c tftp-transfer.c
|
SRCS= main.c tftp-file.c tftp-io.c tftp-options.c tftp-transfer.c
|
||||||
SRCS+= tftp-utils.c tftp.c
|
SRCS+= tftp-utils.c tftp.c
|
||||||
WARNS= 3
|
|
||||||
CFLAGS+=-I${.CURDIR}/../../libexec/tftpd
|
CFLAGS+=-I${.CURDIR}/../../libexec/tftpd
|
||||||
DPADD= ${LIBEDIT} ${LIBTERMCAP}
|
DPADD= ${LIBEDIT} ${LIBTERMCAP}
|
||||||
LDADD= -ledit -ltermcap
|
LDADD= -ledit -ltermcap
|
||||||
|
@ -222,8 +222,8 @@ urihandling(char *URI)
|
|||||||
char uri[ARG_MAX];
|
char uri[ARG_MAX];
|
||||||
char *host = NULL;
|
char *host = NULL;
|
||||||
char *path = NULL;
|
char *path = NULL;
|
||||||
char *options = NULL;
|
char *opts = NULL;
|
||||||
char *mode = "octet";
|
const char *tmode = "octet";
|
||||||
char *s;
|
char *s;
|
||||||
char line[MAXLINE];
|
char line[MAXLINE];
|
||||||
int i;
|
int i;
|
||||||
@ -241,14 +241,14 @@ urihandling(char *URI)
|
|||||||
|
|
||||||
if ((s = strchr(path, ';')) != NULL) {
|
if ((s = strchr(path, ';')) != NULL) {
|
||||||
*s = '\0';
|
*s = '\0';
|
||||||
options = s + 1;
|
opts = s + 1;
|
||||||
|
|
||||||
if (strncmp(options, "mode=", 5) == 0) {
|
if (strncmp(opts, "mode=", 5) == 0) {
|
||||||
mode = options;
|
tmode = opts;
|
||||||
mode += 5;
|
tmode += 5;
|
||||||
|
|
||||||
for (i = 0; modes[i].m_name != NULL; i++) {
|
for (i = 0; modes[i].m_name != NULL; i++) {
|
||||||
if (strcmp(modes[i].m_name, mode) == 0)
|
if (strcmp(modes[i].m_name, tmode) == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (modes[i].m_name == NULL) {
|
if (modes[i].m_name == NULL) {
|
||||||
@ -697,7 +697,7 @@ tail(char *filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
command_prompt()
|
command_prompt(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
return ("tftp> ");
|
return ("tftp> ");
|
||||||
@ -964,27 +964,25 @@ setblocksize(int argc, char *argv[])
|
|||||||
if (argc != 1) {
|
if (argc != 1) {
|
||||||
int size = atoi(argv[1]);
|
int size = atoi(argv[1]);
|
||||||
size_t max;
|
size_t max;
|
||||||
char maxbuffer[100];
|
u_long maxdgram;
|
||||||
int *maxdgram;
|
|
||||||
|
|
||||||
max = sizeof(maxbuffer);
|
max = sizeof(maxdgram);
|
||||||
if (sysctlbyname("net.inet.udp.maxdgram",
|
if (sysctlbyname("net.inet.udp.maxdgram",
|
||||||
maxbuffer, &max, NULL, 0) < 0) {
|
&maxdgram, &max, NULL, 0) < 0) {
|
||||||
perror("sysctl: net.inet.udp.maxdgram");
|
perror("sysctl: net.inet.udp.maxdgram");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
maxdgram = (int *)maxbuffer;
|
|
||||||
|
|
||||||
if (size < BLKSIZE_MIN || size > BLKSIZE_MAX) {
|
if (size < BLKSIZE_MIN || size > BLKSIZE_MAX) {
|
||||||
printf("Blocksize should be between %d and %d bytes.\n",
|
printf("Blocksize should be between %d and %d bytes.\n",
|
||||||
BLKSIZE_MIN, BLKSIZE_MAX);
|
BLKSIZE_MIN, BLKSIZE_MAX);
|
||||||
return;
|
return;
|
||||||
} else if (size > *maxdgram - 4) {
|
} else if (size > (int)maxdgram - 4) {
|
||||||
printf("Blocksize can't be bigger than %d bytes due "
|
printf("Blocksize can't be bigger than %ld bytes due "
|
||||||
"to the net.inet.udp.maxdgram sysctl limitation.\n",
|
"to the net.inet.udp.maxdgram sysctl limitation.\n",
|
||||||
*maxdgram - 4);
|
maxdgram - 4);
|
||||||
asprintf(&options[OPT_BLKSIZE].o_request,
|
asprintf(&options[OPT_BLKSIZE].o_request,
|
||||||
"%d", *maxdgram - 4);
|
"%ld", maxdgram - 4);
|
||||||
} else {
|
} else {
|
||||||
asprintf(&options[OPT_BLKSIZE].o_request, "%d", size);
|
asprintf(&options[OPT_BLKSIZE].o_request, "%d", size);
|
||||||
}
|
}
|
||||||
@ -1005,21 +1003,19 @@ setblocksize2(int argc, char *argv[])
|
|||||||
int size = atoi(argv[1]);
|
int size = atoi(argv[1]);
|
||||||
int i;
|
int i;
|
||||||
size_t max;
|
size_t max;
|
||||||
char maxbuffer[100];
|
u_long maxdgram;
|
||||||
int *maxdgram;
|
|
||||||
|
|
||||||
int sizes[] = {
|
int sizes[] = {
|
||||||
8, 16, 32, 64, 128, 256, 512, 1024,
|
8, 16, 32, 64, 128, 256, 512, 1024,
|
||||||
2048, 4096, 8192, 16384, 32768, 0
|
2048, 4096, 8192, 16384, 32768, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
max = sizeof(maxbuffer);
|
max = sizeof(maxdgram);
|
||||||
if (sysctlbyname("net.inet.udp.maxdgram",
|
if (sysctlbyname("net.inet.udp.maxdgram",
|
||||||
maxbuffer, &max, NULL, 0) < 0) {
|
&maxdgram, &max, NULL, 0) < 0) {
|
||||||
perror("sysctl: net.inet.udp.maxdgram");
|
perror("sysctl: net.inet.udp.maxdgram");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
maxdgram = (int *)maxbuffer;
|
|
||||||
|
|
||||||
for (i = 0; sizes[i] != 0; i++) {
|
for (i = 0; sizes[i] != 0; i++) {
|
||||||
if (sizes[i] == size) break;
|
if (sizes[i] == size) break;
|
||||||
@ -1034,12 +1030,12 @@ setblocksize2(int argc, char *argv[])
|
|||||||
printf("Blocksize2 should be between "
|
printf("Blocksize2 should be between "
|
||||||
"%d and %d bytes.\n", BLKSIZE_MIN, BLKSIZE_MAX);
|
"%d and %d bytes.\n", BLKSIZE_MIN, BLKSIZE_MAX);
|
||||||
return;
|
return;
|
||||||
} else if (size > *maxdgram - 4) {
|
} else if (size > (int)maxdgram - 4) {
|
||||||
printf("Blocksize2 can't be bigger than %d bytes due "
|
printf("Blocksize2 can't be bigger than %ld bytes due "
|
||||||
"to the net.inet.udp.maxdgram sysctl limitation.\n",
|
"to the net.inet.udp.maxdgram sysctl limitation.\n",
|
||||||
*maxdgram - 4);
|
maxdgram - 4);
|
||||||
for (i = 0; sizes[i+1] != 0; i++) {
|
for (i = 0; sizes[i+1] != 0; i++) {
|
||||||
if (*maxdgram < sizes[i+1]) break;
|
if ((int)maxdgram < sizes[i+1]) break;
|
||||||
}
|
}
|
||||||
asprintf(&options[OPT_BLKSIZE2].o_request,
|
asprintf(&options[OPT_BLKSIZE2].o_request,
|
||||||
"%d", sizes[i]);
|
"%d", sizes[i]);
|
||||||
|
Loading…
Reference in New Issue
Block a user