+
+ /* If we ourselves have indirectdata flag set, we should send only to our uplink! */
+
+ if(myself->flags & EXPORTINDIRECTDATA)
+ {
+ for(cl = conn_list; cl != NULL && !cl->status.outgoing; cl = cl->next);
+ if(!cl)
+ { /* No open outgoing connection has been found. */
+ if(debug_lvl > 3)
+ syslog(LOG_NOTICE, _("There is no remote host I can send this packet to!"));
+ return -1;
+ }
+ }
+ else
+
+ /* If indirectdata flag is set for the destination we just looked up,
+ * then real_ip is actually the vpn_ip of the gateway tincd
+ * it is behind.
+ */
+
+ if(cl->flags & INDIRECTDATA)
+ {
+ if(debug_lvl > 3)
+ syslog(LOG_NOTICE, _("Indirect packet to " IP_ADDR_S " via " IP_ADDR_S),
+ IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
+ if((cl = lookup_conn(cl->real_ip)) == NULL)
+ {
+ if(debug_lvl > 3)
+ syslog(LOG_NOTICE, _("Indirect look up " IP_ADDR_S " in connection list failed!"),
+ IP_ADDR_V(to));
+
+ /* Gateway tincd dead? Should we kill it? (GS) */
+
+ return -1;
+ }
+ if(cl->flags & INDIRECTDATA) /* This should not happen */
+ {
+ if(debug_lvl > 3)
+ syslog(LOG_NOTICE, _("Double indirection for " IP_ADDR_S),
+ IP_ADDR_V(to));
+ return -1;
+ }
+ }