ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/vpn_dns.C
(Generate patch)

Comparing gvpe/src/vpn_dns.C (file contents):
Revision 1.38 by pcg, Tue Apr 19 04:23:38 2005 UTC vs.
Revision 1.41 by pcg, Wed Nov 22 21:26:41 2006 UTC

14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with gvpe; if not, write to the Free Software 18 along with gvpe; if not, write to the Free Software
19 Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20*/ 20*/
21 21
22// TODO: EDNS0 option to increase dns mtu? 22// TODO: EDNS0 option to increase dns mtu?
23// TODO: re-write dns packet parsing/creation using a safe mem-buffer 23// TODO: re-write dns packet parsing/creation using a safe mem-buffer
24// to ensure no buffer overflows or similar problems. 24// to ensure no buffer overflows or similar problems.
461 r4 = r5 = r6 = r7 = 0; 461 r4 = r5 = r6 = r7 = 0;
462} 462}
463 463
464bool dns_cfg::valid () 464bool dns_cfg::valid ()
465{ 465{
466 // although the protocol itself allows for some configurability,
467 // only the following encoding/decoding settings are implemented.
466 return id1 == 'G' 468 return id1 == 'G'
467 && id2 == 'V' 469 && id2 == 'V'
468 && id3 == 'P' 470 && id3 == 'P'
469 && id4 == 'E' 471 && id4 == 'E'
470 && seq_cdc == 26 472 && seq_cdc == 26
769 771
770 // find next packet 772 // find next packet
771 for (vector<dns_rcv *>::iterator i = rcvpq.end (); i-- != rcvpq.begin (); ) 773 for (vector<dns_rcv *>::iterator i = rcvpq.end (); i-- != rcvpq.begin (); )
772 if (SEQNO_EQ (rcvseq, (*i)->seqno)) 774 if (SEQNO_EQ (rcvseq, (*i)->seqno))
773 { 775 {
776 //printf ("seqno eq %x %x\n", rcvseq, (*i)->seqno);//D
774 // enter the packet into our input stream 777 // enter the packet into our input stream
775 r = *i; 778 r = *i;
776 779
777 // remove the oldest packet, look forward, as it's oldest first 780 // remove the oldest packet, look forward, as it's oldest first
778 for (vector<dns_rcv *>::iterator j = rcvpq.begin (); j != rcvpq.end (); ++j) 781 for (vector<dns_rcv *>::iterator j = rcvpq.begin (); j != rcvpq.end (); ++j)
779 if (SEQNO_EQ ((*j)->seqno, rcvseq - MAX_WINDOW)) 782 if (SEQNO_EQ ((*j)->seqno, rcvseq - MAX_WINDOW))
780 { 783 {
784 //printf ("seqno RR %x %x\n", (*j)->seqno, rcvseq - MAX_WINDOW);//D
781 delete *j; 785 delete *j;
782 rcvpq.erase (j); 786 rcvpq.erase (j);
783 break; 787 break;
784 } 788 }
785 789
1013 { 1017 {
1014 dns_connection *dns = (*i)->dns; 1018 dns_connection *dns = (*i)->dns;
1015 connection *c = dns->c; 1019 connection *c = dns->c;
1016 int seqno = (*i)->seqno; 1020 int seqno = (*i)->seqno;
1017 u8 data[MAXSIZE], *datap = data; 1021 u8 data[MAXSIZE], *datap = data;
1022 //printf ("rcv pkt %x\n", seqno);//D
1018 1023
1019 if ((*i)->retry) 1024 if ((*i)->retry)
1020 { 1025 {
1021 dns->send_interval *= 1.01; 1026 dns->send_interval *= 1.01;
1022 if (dns->send_interval > MAX_SEND_INTERVAL) 1027 if (dns->send_interval > MAX_SEND_INTERVAL)
1228 { 1233 {
1229 send = r; 1234 send = r;
1230 1235
1231 r->retry++; 1236 r->retry++;
1232 r->timeout = NOW + (r->retry * min_latency * conf.dns_timeout_factor); 1237 r->timeout = NOW + (r->retry * min_latency * conf.dns_timeout_factor);
1238 //printf ("RETRY %x (%d, %f)\n", r->seqno, r->retry, r->timeout - NOW);//D
1233 1239
1234 // the following code changes the query section a bit, forcing 1240 // the following code changes the query section a bit, forcing
1235 // the forwarder to generate a new request 1241 // the forwarder to generate a new request
1236 if (r->stdhdr) 1242 if (r->stdhdr)
1237 {
1238 //printf ("reencoded header for ID %d retry %d:%d:%d (%p)\n", htons (r->pkt->id), THISNODE->id, r->seqno, r->retry);
1239 //encode_header ((char *)r->pkt->at (6 * 2 + 1), THISNODE->id, r->seqno, r->retry); 1243 encode_header ((char *)r->pkt->at (6 * 2 + 1), THISNODE->id, r->seqno, r->retry);
1240 }
1241 } 1244 }
1242 } 1245 }
1243 else 1246 else
1244 NEXT (r->timeout); 1247 NEXT (r->timeout);
1245 } 1248 }
1271 } 1274 }
1272 1275
1273 send = new dns_snd (this); 1276 send = new dns_snd (this);
1274 send->gen_stream_req (sndseq, snddq); 1277 send->gen_stream_req (sndseq, snddq);
1275 send->timeout = NOW + min_latency * conf.dns_timeout_factor; 1278 send->timeout = NOW + min_latency * conf.dns_timeout_factor;
1279 //printf ("SEND %x (%f)\n", send->seqno, send->timeout - NOW, min_latency, conf.dns_timeout_factor);//D
1276 1280
1277 sndseq = (sndseq + 1) & SEQNO_MASK; 1281 sndseq = (sndseq + 1) & SEQNO_MASK;
1278 } 1282 }
1279 else 1283 else
1280 NEXT (last_sent + send_interval); 1284 NEXT (last_sent + send_interval);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines