mirror of
https://github.com/hufrea/byedpi.git
synced 2024-11-20 12:25:05 +00:00
Use original tcp_info struct
This commit is contained in:
parent
3d790d699a
commit
af5ad735f3
19
desync.c
19
desync.c
@ -9,14 +9,12 @@
|
|||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <netinet/tcp.h>
|
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/sendfile.h>
|
#include <sys/sendfile.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <linux/tcp.h>
|
||||||
#include <desync.h>
|
|
||||||
|
|
||||||
#ifdef MFD_CLOEXEC
|
#ifdef MFD_CLOEXEC
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
@ -24,6 +22,8 @@
|
|||||||
#else
|
#else
|
||||||
#define memfd_create(name, flags) fileno(tmpfile())
|
#define memfd_create(name, flags) fileno(tmpfile())
|
||||||
#endif
|
#endif
|
||||||
|
#else
|
||||||
|
#include <netinet/tcp.h>
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
@ -86,24 +86,25 @@ static inline void delay(long ms)
|
|||||||
void wait_send(int sfd)
|
void wait_send(int sfd)
|
||||||
{
|
{
|
||||||
for (int i = 0; params.wait_send && i < 500; i++) {
|
for (int i = 0; params.wait_send && i < 500; i++) {
|
||||||
struct tcpi tcpi = {};
|
struct tcp_info tcpi = {};
|
||||||
socklen_t ts = sizeof(tcpi);
|
socklen_t ts = sizeof(tcpi);
|
||||||
|
|
||||||
if (getsockopt(sfd, IPPROTO_TCP,
|
if (getsockopt(sfd, IPPROTO_TCP,
|
||||||
TCP_INFO, (char *)&tcpi, &ts) < 0) {
|
TCP_INFO, (char *)&tcpi, &ts) < 0) {
|
||||||
uniperror("getsockopt TCP_INFO");
|
perror("getsockopt TCP_INFO");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (tcpi.state != 1) {
|
if (tcpi.tcpi_state != 1) {
|
||||||
LOG(LOG_E, "state: %d\n", tcpi.state);
|
LOG(LOG_E, "state: %d\n", tcpi.tcpi_state);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ts < sizeof(tcpi)) {
|
size_t s = (char *)&tcpi.tcpi_notsent_bytes - (char *)&tcpi.tcpi_state;
|
||||||
|
if (ts < s) {
|
||||||
LOG(LOG_E, "tcpi_notsent_bytes not provided\n");
|
LOG(LOG_E, "tcpi_notsent_bytes not provided\n");
|
||||||
params.wait_send = 0;
|
params.wait_send = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (tcpi.notsent_bytes == 0) {
|
if (tcpi.tcpi_notsent_bytes == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LOG(LOG_S, "not sent after %d ms\n", i);
|
LOG(LOG_S, "not sent after %d ms\n", i);
|
||||||
|
9
desync.h
9
desync.h
@ -1,10 +1 @@
|
|||||||
ssize_t desync(int sfd, char *buffer, size_t bfsize, ssize_t n, ssize_t offset, struct sockaddr *dst, int dp_c);
|
ssize_t desync(int sfd, char *buffer, size_t bfsize, ssize_t n, ssize_t offset, struct sockaddr *dst, int dp_c);
|
||||||
|
|
||||||
struct tcpi {
|
|
||||||
uint8_t state;
|
|
||||||
uint8_t r[3];
|
|
||||||
uint32_t rr[5];
|
|
||||||
uint32_t unacked;
|
|
||||||
uint32_t rrr[29];
|
|
||||||
uint32_t notsent_bytes;
|
|
||||||
};
|
|
Loading…
Reference in New Issue
Block a user