server: Make array of senders constant.
[paraslash.git] / udp_send.c
index 49c17631487db2cabedb4acd5444bb589d602762..eea1c93355c1461ada446942ef4d2d91f71cef46 100644 (file)
@@ -412,32 +412,37 @@ static char *udp_help(void)
        );
 }
 
        );
 }
 
-/**
- * The init function of para_server's udp sender.
- *
- * \param s Pointer to the udp sender struct.
- *
- * It initializes all function pointers of \a s and the list of udp targets.
- */
-void udp_send_init(struct sender *s)
+/* Initialize the list of udp targets. */
+static void udp_send_init(void)
 {
        INIT_LIST_HEAD(&targets);
 {
        INIT_LIST_HEAD(&targets);
-       s->status = udp_status;
-       s->help = udp_help;
-       s->send = NULL;
-       s->pre_select = NULL;
-       s->post_select = NULL;
-       s->shutdown_clients = udp_shutdown_targets;
-       s->resolve_target = udp_resolve_target;
-       s->client_cmds[SENDER_on] = udp_com_on;
-       s->client_cmds[SENDER_off] = udp_com_off;
-       s->client_cmds[SENDER_deny] = NULL;
-       s->client_cmds[SENDER_allow] = NULL;
-       s->client_cmds[SENDER_add] = udp_com_add;
-       s->client_cmds[SENDER_delete] = udp_com_delete;
        sender_status = SENDER_off;
        udp_init_target_list();
        if (!OPT_GIVEN(UDP_NO_AUTOSTART))
                sender_status = SENDER_on;
        PARA_DEBUG_LOG("udp sender init complete\n");
 }
        sender_status = SENDER_off;
        udp_init_target_list();
        if (!OPT_GIVEN(UDP_NO_AUTOSTART))
                sender_status = SENDER_on;
        PARA_DEBUG_LOG("udp sender init complete\n");
 }
+
+/**
+ * The UDP sender.
+ *
+ * In contrast to the other senders the UDP sender is active in the sense that
+ * it initiates the network connection according to its list of targets rather
+ * than passively waiting for clients to connect. Like DCCP streams, UDP
+ * streams are always sent FEC-encoded. The UDP sender is the only sender which
+ * supports IP multicasting.
+ */
+const struct sender udp_sender = {
+       .name = "udp",
+       .init = udp_send_init,
+       .shutdown_clients = udp_shutdown_targets,
+       .resolve_target = udp_resolve_target,
+       .client_cmds = {
+               [SENDER_on] = udp_com_on,
+               [SENDER_off] = udp_com_off,
+               [SENDER_add] = udp_com_add,
+               [SENDER_delete] = udp_com_delete,
+       },
+       .help = udp_help,
+       .status = udp_status,
+};