mirror of
https://github.com/ChronosX88/netsukuku.git
synced 2024-11-26 04:02:19 +00:00
Almost done with packet fragmentation
This commit is contained in:
parent
ec70f4cb47
commit
2231df0ea7
21
src/inet.c
21
src/inet.c
@ -552,6 +552,8 @@ int new_socket(int sock_type)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("Socket FD: %i ", sockfd);
|
||||||
|
|
||||||
return sockfd;
|
return sockfd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1064,12 +1066,25 @@ ssize_t inet_sendto(int s, const void *msg, size_t len, int flags,
|
|||||||
error("Packet artificially fragmented: %d", stderr);
|
error("Packet artificially fragmented: %d", stderr);
|
||||||
error("\nData Length: %u", len);
|
error("\nData Length: %u", len);
|
||||||
int bytesleft = len;
|
int bytesleft = len;
|
||||||
while(bytesleft > 1024) {
|
int sendbuf;
|
||||||
inet_sendto(s, msg, 1024, flags, to, tolen);
|
socklen_t optlen;
|
||||||
bytesleft -= 1024;
|
optlen = sizeof(sendbuf);
|
||||||
|
int res = getsockopt(s, SOL_SOCKET, SO_SNDBUF, &sendbuf, &optlen);
|
||||||
|
|
||||||
|
error("GetSockOpt: %i \n", res);
|
||||||
|
|
||||||
|
while(bytesleft != 0) {
|
||||||
|
if(bytesleft > 64000) {
|
||||||
|
inet_sendto(s, msg, 64000, flags, to, tolen);
|
||||||
|
bytesleft -= 64000;
|
||||||
//err=inet_sendto(s, ((const char *)msg+(len/2)),
|
//err=inet_sendto(s, ((const char *)msg+(len/2)),
|
||||||
//len-(len/2), flags, to, tolen);
|
//len-(len/2), flags, to, tolen);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
inet_sendto(s, msg, bytesleft, flags, to, tolen);
|
||||||
|
bytesleft = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case EFAULT:
|
case EFAULT:
|
||||||
error("The value of to is: %d", to);
|
error("The value of to is: %d", to);
|
||||||
|
Loading…
Reference in New Issue
Block a user