… | |
… | |
58 | #define MAX_SEND_INTERVAL 2. // optimistic? |
58 | #define MAX_SEND_INTERVAL 2. // optimistic? |
59 | |
59 | |
60 | #define LATENCY_FACTOR 0.5 // RTT * LATENCY_FACTOR == sending rate |
60 | #define LATENCY_FACTOR 0.5 // RTT * LATENCY_FACTOR == sending rate |
61 | #define MAX_OUTSTANDING 100 // max. outstanding requests |
61 | #define MAX_OUTSTANDING 100 // max. outstanding requests |
62 | #define MAX_WINDOW 1000 // max. for MAX_OUTSTANDING, and backlog |
62 | #define MAX_WINDOW 1000 // max. for MAX_OUTSTANDING, and backlog |
63 | #define MAX_BACKLOG (32*1024) // size of gvpe protocol backlog (bytes), must be > MAXSIZE |
63 | #define MAX_BACKLOG (64*1024) // size of gvpe protocol backlog (bytes), must be > MAXSIZE |
64 | |
64 | |
65 | #define MAX_DOMAIN_SIZE 240 // 255 is legal limit, but bind doesn't compress well |
65 | #define MAX_DOMAIN_SIZE 240 // 255 is legal limit, but bind doesn't compress well |
66 | // 240 leaves about 4 bytes of server reply data |
66 | // 240 leaves about 4 bytes of server reply data |
67 | // every two request bytes less give room for one reply byte |
67 | // every request byte less give room for two reply bytes |
68 | |
68 | |
69 | #define SEQNO_MASK 0x0fff |
69 | #define SEQNO_MASK 0x3fff |
70 | #define SEQNO_EQ(a,b) ( 0 == ( ((a) ^ (b)) & SEQNO_MASK) ) |
70 | #define SEQNO_EQ(a,b) ( 0 == ( ((a) ^ (b)) & SEQNO_MASK) ) |
71 | |
71 | |
72 | #define MAX_LBL_SIZE 63 |
72 | #define MAX_LBL_SIZE 63 |
73 | #define MAX_PKT_SIZE 512 |
73 | #define MAX_PKT_SIZE 512 |
74 | |
74 | |
… | |
… | |
793 | } |
793 | } |
794 | |
794 | |
795 | while (vpn_packet *pkt = rcvdq.get ()) |
795 | while (vpn_packet *pkt = rcvdq.get ()) |
796 | { |
796 | { |
797 | sockinfo si; |
797 | sockinfo si; |
798 | si.host = 0x01010101; si.port = htons (c->conf->id); si.prot = PROT_DNSv4; |
798 | si.host = htonl (c->conf->id); si.port = 0; si.prot = PROT_DNSv4; |
799 | |
799 | |
800 | vpn->recv_vpn_packet (pkt, si); |
800 | vpn->recv_vpn_packet (pkt, si); |
801 | |
801 | |
802 | delete pkt; |
802 | delete pkt; |
803 | } |
803 | } |
… | |
… | |
1180 | } |
1180 | } |
1181 | |
1181 | |
1182 | bool |
1182 | bool |
1183 | vpn::send_dnsv4_packet (vpn_packet *pkt, const sockinfo &si, int tos) |
1183 | vpn::send_dnsv4_packet (vpn_packet *pkt, const sockinfo &si, int tos) |
1184 | { |
1184 | { |
1185 | int client = ntohs (si.port); |
1185 | int client = ntohl (si.host); |
1186 | |
1186 | |
1187 | assert (0 < client && client <= conns.size ()); |
1187 | assert (0 < client && client <= conns.size ()); |
1188 | |
1188 | |
1189 | connection *c = conns [client - 1]; |
1189 | connection *c = conns [client - 1]; |
1190 | |
1190 | |
… | |
… | |
1286 | } |
1286 | } |
1287 | |
1287 | |
1288 | if (send) |
1288 | if (send) |
1289 | { |
1289 | { |
1290 | last_sent = NOW; |
1290 | last_sent = NOW; |
1291 | if (rand () & 15 != 0)//D |
|
|
1292 | sendto (vpn->dnsv4_fd, |
1291 | sendto (vpn->dnsv4_fd, |
1293 | send->pkt->at (0), send->pkt->len, 0, |
1292 | send->pkt->at (0), send->pkt->len, 0, |
1294 | vpn->dns_forwarder.sav4 (), vpn->dns_forwarder.salenv4 ()); |
1293 | vpn->dns_forwarder.sav4 (), vpn->dns_forwarder.salenv4 ()); |
1295 | } |
1294 | } |
1296 | |
1295 | |