Many changes, Some possible fixes/optimisations in inet.c and the addition of inet_sendfile64

This commit is contained in:
MissValeska 2014-12-23 20:37:57 -08:00
parent 8e0c1ce00c
commit f439b7d549
5 changed files with 28 additions and 8 deletions

View File

@ -955,7 +955,7 @@ andns_rslv(char *msg, int msglen, char *answer, int *answ_len)
printf("andns_rslv msg %s answer %s", msg, answer);
if(netsplit.netsplit_inet_mode == 1)
inet_mode (msg);
inet_mode(msg);
proto = GET_NK_BIT(msg);
if (proto == NK_DNS)

View File

@ -1060,10 +1060,10 @@ inet_send(int s, const void *msg, size_t len, int flags)
* it will just come back here to repeat the process as needed. */
case EMSGSIZE:
inet_send(s, msg, len/2, flags);
err=inet_send(s, (const char *)msg+(len/2),
len-(len/2), flags);
err = inet_send(s, msg+(len/2), (len+1)/2);
printf("%lu", err);
break;
default:
error("inet_send: Cannot send(): %s", strerror(errno));
return err;
@ -1113,8 +1113,9 @@ inet_sendto(int s, const void *msg, size_t len, int flags,
switch (errno) {
case EMSGSIZE:
inet_sendto(s, msg, len/2, flags, to, tolen);
err=inet_sendto(s, (const char *)msg+(len/2),
len-(len/2), flags, to, tolen);
err = inet_sendto(s, msg+(len/2), (len+1)/2, flags, to, tolen);
printf("%lu", err);
break;
case EFAULT:
/* Must be modified to accept IPv6 addresses
@ -1172,5 +1173,23 @@ inet_sendfile(int out_fd, int in_fd, off_t * offset, size_t count)
if ((err = sendfile(out_fd, in_fd, offset, count)) == -1)
error("inet_sendfile: Cannot sendfile(): %s", strerror(errno));
if (err < count) {
count = count - err;
err = inet_sendfile(out_fd, in_fd, offset, count);
}
return err;
}
ssize_t
inet_sendfile64(int out_fd, int in_fd, off64_t * offset, size_t count)
{
ssize_t err;
if ((err = sendfile64(out_fd, in_fd, offset, count)) == -1)
error("inet_sendfile: Cannot sendfile(): %s", strerror(errno));
if (err < count) {
count = count - err;
err = inet_sendfile64(out_fd, in_fd, offset, count);
}
return err;
}

View File

@ -209,5 +209,6 @@ ssize_t inet_sendto_timeout(int s, const void *msg, size_t len, int flags,
const struct sockaddr *to, socklen_t tolen,
u_int timeout);
ssize_t inet_sendfile(int out_fd, int in_fd, off_t * offset, size_t count);
ssize_t inet_sendfile64(int out_fd, int in_fd, off64_t * offset, size_t count);
#endif /*INET_H */

View File

@ -465,7 +465,7 @@ mark_init(int igw)
}
restore_output_rule_init(rule);
error("Rule in mark_init: %s", rule);
error("Rule in mark_init: %s", *rule);
res = insert_rule(rule, &t, CHAIN_OUTPUT, 0);
if (res) {

View File

@ -181,7 +181,7 @@ usage(void)
" -k Kills the running instance of ntkd\n"
" -C Runs the console server for Ntk-Console to connect to\n"
" -e Excludes an interface from usage I.E all interfaces except this one\n"
" -n Experimental argument to implement ntk netsplit\n http://netsukuku.freaknet.org/docs/main_doc/ntk_rfc/Ntk_net_split\n");
" -n Experimental argument to implement ntk netsplit inet/INET or ntk/NTK\n http://netsukuku.freaknet.org/docs/main_doc/ntk_rfc/Ntk_net_split\n");
}
/*