silc_free(packetdata.dst_id);
}
-/* Forwards packet. Packets sent with this function will be marked as
- forwarded (in the SILC header flags) so that the receiver knows that
- we have forwarded the packet to it. Forwarded packets are handled
- specially by the receiver as they are not destined to the receiver
- originally. However, the receiver knows this because the forwarded
- flag has been set (and the flag is authenticated). */
-
-void silc_server_packet_forward(SilcServer server,
- SilcSocketConnection sock,
- unsigned char *data, unsigned int data_len,
- int force_send)
-{
- SilcIDListData idata;
- SilcCipher cipher = NULL;
- SilcHmac hmac = NULL;
-
- SILC_LOG_DEBUG(("Forwarding packet"));
-
- /* Get data used in the packet sending, keys and stuff */
- idata = (SilcIDListData)sock->user_data;
-
- /* Prepare outgoing data buffer for packet sending */
- silc_packet_send_prepare(sock, 0, 0, data_len);
-
- /* Put the data to the buffer */
- if (data && data_len)
- silc_buffer_put(sock->outbuf, data, data_len);
-
- /* Add the FORWARDED flag to packet flags */
- sock->outbuf->data[2] |= (unsigned char)SILC_PACKET_FLAG_FORWARDED;
-
- if (idata) {
- cipher = idata->send_key;
- hmac = idata->hmac;
- }
-
- /* Encrypt the packet */
- silc_packet_encrypt(cipher, hmac, sock->outbuf, sock->outbuf->len);
-
- SILC_LOG_HEXDUMP(("Forwarded packet, len %d", sock->outbuf->len),
- sock->outbuf->data, sock->outbuf->len);
-
- /* Now actually send the packet */
- silc_server_packet_send_real(server, sock, force_send);
-}
-
/* Broadcast received packet to our primary route. This function is used
by router to further route received broadcast packet. It is expected
that the broadcast flag from the packet is checked before calling this
continue;
}
+ if (server->server_type == SILC_ROUTER && !route)
+ continue;
+
+ if (server->server_type == SILC_SERVER && client->router)
+ continue;
+
/* Send to locally connected client */
if (client) {
continue;
}
- /* XXX Check client's mode on the channel. */
+ if (server->server_type == SILC_SERVER && client->router)
+ continue;
/* Get data used in packet header encryption, keys and stuff. */
sock = (SilcSocketConnection)client->connection;
continue;
}
+ if (server->server_type == SILC_SERVER && client->router)
+ continue;
+
/* Send to locally connected client */
if (c) {
SILC_LOG_DEBUG(("Start"));
- clid = silc_id_id2str(client_id, SILC_ID_CLIENT);
- if (!clid)
- return;
-
chid = silc_id_id2str(channel_id, SILC_ID_CHANNEL);
if (!chid)
return;
+ clid = silc_id_id2str(client_id, SILC_ID_CLIENT);
+ if (!clid)
+ return;
+
packet = silc_buffer_alloc(2 + 2 + channel_id_len + client_id_len);
silc_buffer_pull_tail(packet, SILC_BUFFER_END(packet));
silc_buffer_format(packet,
/* Send Channel Key payload to distribute the new channel key. Normal server
sends this to router when new client joins to existing channel. Router
- sends this to the local server who forwarded join command in case where
- the channel did not exist yet. Both normal and router servers uses this
+ sends this to the local server who sent the join command in case where
+ the channel did not exist yet. Both normal and router servers uses this
also to send this to locally connected clients on the channel. This
- must not be broadcasted packet. */
+ must not be broadcasted packet. Routers do not send this to each other. */
void silc_server_send_channel_key(SilcServer server,
SilcChannelEntry channel,