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

Comparing gvpe/src/vpn.C (file contents):
Revision 1.51 by pcg, Sun Aug 10 14:48:57 2008 UTC vs.
Revision 1.52 by pcg, Sun Aug 10 22:18:58 2008 UTC

765// from THISNODE to dst 765// from THISNODE to dst
766connection *vpn::find_router_for (const connection *dst) 766connection *vpn::find_router_for (const connection *dst)
767{ 767{
768 connection *router = 0; 768 connection *router = 0;
769 769
770 // first try to find a router with a direct connection 770 // first try to find a router with a direct connection, route there
771 // regardless of any other considerations.
771 { 772 {
772 u32 prio = 1; 773 u32 prio = 1;
773 774
774 for (conns_vector::iterator i = conns.begin (); i != conns.end (); ++i) 775 for (conns_vector::iterator i = conns.begin (); i != conns.end (); ++i)
775 { 776 {
776 connection *c = *i; 777 connection *c = *i;
777 778
778 if (c->conf->routerprio > prio 779 if (c->conf->routerprio > prio
779 && c->conf != THISNODE 780 && c->conf != THISNODE
780 && c != dst
781 && can_direct (c->conf, dst->conf)) 781 && can_direct (c->conf, dst->conf)
782 && c->ictx && c->octx)
782 { 783 {
783 if (c->ictx && c->octx)
784 {
785 prio = c->conf->routerprio; 784 prio = c->conf->routerprio;
786 router = c; 785 router = c;
787 }
788 else
789 c->establish_connection ();
790 } 786 }
791 } 787 }
792 } 788 }
793 789
794 if (router) 790 if (router)
795 return router; 791 return router;
796 792
797 // second try find the router with the highest priority higher than ours 793 // second try find the router with the highest priority, higher than ours
798 { 794 {
799 u32 prio = 1; 795 u32 prio = THISNODE->routerprio ? THISNODE->routerprio : 1;
800 796
801 for (conns_vector::iterator i = conns.begin (); i != conns.end (); ++i) 797 for (conns_vector::iterator i = conns.begin (); i != conns.end (); ++i)
802 { 798 {
803 connection *c = *i; 799 connection *c = *i;
804 800
805 if (c->conf->routerprio > prio 801 if (c->conf->routerprio > prio
806 && c->conf->routerprio > THISNODE->routerprio
807 && c != dst 802 && c != dst
808 && c->conf != THISNODE) 803 && c->conf != THISNODE
804 && c->ictx && c->octx)
809 { 805 {
810 if (c->ictx && c->octx)
811 {
812 prio = c->conf->routerprio; 806 prio = c->conf->routerprio;
813 router = c; 807 router = c;
814 }
815 else
816 c->establish_connection ();
817 } 808 }
818 } 809 }
819 } 810 }
811
820 return router; 812 return router;
821} 813}
822 814
823void vpn::connection_established (connection *c) 815void vpn::connection_established (connection *c)
824{ 816{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines