- if(n->status.sptps) {
- send_sptps_packet(n, packet);
- return;
- }
-
- via = (packet->priority == -1 || n->via == myself) ? n->nexthop : n->via;
-
- if(via != n)
- logger(DEBUG_TRAFFIC, LOG_INFO, "Sending packet to %s via %s (%s)",
- n->name, via->name, n->via->hostname);
-
- if(packet->priority == -1 || ((myself->options | via->options) & OPTION_TCPONLY)) {
- if(!send_tcppacket(via->connection, packet))
- terminate_connection(via->connection, true);
- } else
- send_udppacket(via, packet);
-}
-
-/* Broadcast a packet using the minimum spanning tree */
-
-void broadcast_packet(const node_t *from, vpn_packet_t *packet) {
- splay_node_t *node;
- connection_t *c;
- node_t *n;
-
- // Always give ourself a copy of the packet.
- if(from != myself)
- send_packet(myself, packet);
-
- // In TunnelServer mode, do not forward broadcast packets.
- // The MST might not be valid and create loops.
- if(tunnelserver || broadcast_mode == BMODE_NONE)
- return;
-
- logger(DEBUG_TRAFFIC, LOG_INFO, "Broadcasting packet of %d bytes from %s (%s)",
- packet->len, from->name, from->hostname);
-
- switch(broadcast_mode) {
- // In MST mode, broadcast packets travel via the Minimum Spanning Tree.
- // This guarantees all nodes receive the broadcast packet, and
- // usually distributes the sending of broadcast packets over all nodes.
- case BMODE_MST:
- for(node = connection_tree->head; node; node = node->next) {
- c = node->data;
-
- if(c->status.active && c->status.mst && c != from->nexthop->connection)
- send_packet(c->node, packet);
- }
- break;
-
- // In direct mode, we send copies to each node we know of.
- // However, this only reaches nodes that can be reached in a single hop.
- // We don't have enough information to forward broadcast packets in this case.
- case BMODE_DIRECT:
- if(from != myself)
- break;
-
- for(node = node_udp_tree->head; node; node = node->next) {
- n = node->data;
-
- if(n->status.reachable && ((n->via == myself && n->nexthop == n) || n->via == n))
- send_packet(n, packet);
- }
- break;
-
- default:
- break;
- }