… | |
… | |
758 | |
758 | |
759 | for (conns_vector::iterator c = conns.begin (); c != conns.end (); ++c) |
759 | for (conns_vector::iterator c = conns.begin (); c != conns.end (); ++c) |
760 | (*c)->establish_connection (); |
760 | (*c)->establish_connection (); |
761 | } |
761 | } |
762 | |
762 | |
|
|
763 | bool |
763 | bool vpn::can_direct (conf_node *src, conf_node *dst) const |
764 | vpn::can_direct (conf_node *src, conf_node *dst) const |
764 | { |
765 | { |
765 | return src != dst |
766 | return src != dst |
766 | && src->may_direct (dst) |
767 | && src->may_direct (dst) |
767 | && dst->may_direct (src) |
768 | && dst->may_direct (src) |
768 | && (((src->protocols & dst->protocols) && src->connectmode == conf_node::C_ALWAYS) |
769 | && (((src->protocols & dst->protocols) && src->connectmode == conf_node::C_ALWAYS) |
769 | || (src->protocols & dst->connectable_protocols ())); |
770 | || (src->protocols & dst->connectable_protocols ())); |
770 | } |
771 | } |
771 | |
772 | |
772 | // only works for indirect and routed connections: find a router |
773 | // only works for indirect and routed connections: find a router |
773 | // from THISNODE to dst |
774 | // from THISNODE to dst |
|
|
775 | connection * |
774 | connection *vpn::find_router_for (const connection *dst) |
776 | vpn::find_router_for (const connection *dst) |
775 | { |
777 | { |
776 | connection *router = 0; |
778 | connection *router = 0; |
777 | |
779 | |
778 | // first try to find a router with a direct connection, route there |
780 | // first try to find a router with a direct connection, route there |
779 | // regardless of any other considerations. |
781 | // regardless of any other considerations. |
… | |
… | |
818 | } |
820 | } |
819 | |
821 | |
820 | return router; |
822 | return router; |
821 | } |
823 | } |
822 | |
824 | |
|
|
825 | void |
823 | void vpn::connection_established (connection *c) |
826 | vpn::connection_established (connection *c) |
824 | { |
827 | { |
825 | for (conns_vector::iterator i = conns.begin (); i != conns.end (); ++i) |
828 | for (conns_vector::iterator i = conns.begin (); i != conns.end (); ++i) |
826 | { |
829 | { |
827 | connection *o = *i; |
830 | connection *o = *i; |
828 | |
831 | |
… | |
… | |
836 | o->rekey (); |
839 | o->rekey (); |
837 | } |
840 | } |
838 | } |
841 | } |
839 | } |
842 | } |
840 | |
843 | |
|
|
844 | void |
841 | void vpn::send_connect_request (connection *c) |
845 | vpn::send_connect_request (connection *c) |
842 | { |
846 | { |
843 | connection *r = find_router_for (c); |
847 | connection *r = find_router_for (c); |
844 | |
848 | |
845 | if (r) |
849 | if (r) |
846 | { |
850 | { |