static int check_sender_args(int argc, char * const * argv, struct sender_command_data *scd)
{
int i;
- /* this has to match sender.h */
- const char *subcmds[] = {"add", "delete", "allow", "deny", "on", "off", NULL};
+ const char *subcmds[] = {SENDER_SUBCOMMANDS NULL};
scd->sender_num = -1;
if (argc < 3)
return -E_COMMAND_SYNTAX;
if (!senders[scd->sender_num].client_cmds[scd->cmd_num])
return -E_SENDER_CMD;
switch (scd->cmd_num) {
- case SENDER_ON:
- case SENDER_OFF:
+ case SENDER_on:
+ case SENDER_off:
if (argc != 3)
return -E_COMMAND_SYNTAX;
break;
- case SENDER_DENY:
- case SENDER_ALLOW:
+ case SENDER_deny:
+ case SENDER_allow:
if (argc != 4 || parse_cidr(argv[3], scd->host,
sizeof(scd->host), &scd->netmask) == NULL)
return -E_COMMAND_SYNTAX;
break;
- case SENDER_ADD:
- case SENDER_DELETE:
+ case SENDER_add:
+ case SENDER_delete:
if (argc != 4)
return -E_COMMAND_SYNTAX;
return parse_fec_url(argv[3], scd);
}
switch (scd.cmd_num) {
- case SENDER_ADD:
- case SENDER_DELETE:
+ case SENDER_add:
+ case SENDER_delete:
assert(senders[scd.sender_num].resolve_target);
ret = senders[scd.sender_num].resolve_target(cc->argv[3], &scd);
if (ret < 0)
s->shutdown_clients = dccp_shutdown_clients;
s->resolve_target = NULL;
s->help = generic_sender_help;
- s->client_cmds[SENDER_ON] = dccp_com_on;
- s->client_cmds[SENDER_OFF] = dccp_com_off;
- s->client_cmds[SENDER_DENY] = dccp_com_deny;
- s->client_cmds[SENDER_ALLOW] = dccp_com_allow;
- s->client_cmds[SENDER_ADD] = NULL;
- s->client_cmds[SENDER_DELETE] = NULL;
+ s->client_cmds[SENDER_on] = dccp_com_on;
+ s->client_cmds[SENDER_off] = dccp_com_off;
+ s->client_cmds[SENDER_deny] = dccp_com_deny;
+ s->client_cmds[SENDER_allow] = dccp_com_allow;
+ s->client_cmds[SENDER_add] = NULL;
+ s->client_cmds[SENDER_delete] = NULL;
k = conf.dccp_data_slices_per_group_arg;
n = conf.dccp_slices_per_group_arg;
s->shutdown_clients = http_shutdown_clients;
s->resolve_target = NULL;
s->help = generic_sender_help;
- s->client_cmds[SENDER_ON] = http_com_on;
- s->client_cmds[SENDER_OFF] = http_com_off;
- s->client_cmds[SENDER_DENY] = http_com_deny;
- s->client_cmds[SENDER_ALLOW] = http_com_allow;
- s->client_cmds[SENDER_ADD] = NULL;
- s->client_cmds[SENDER_DELETE] = NULL;
+ s->client_cmds[SENDER_on] = http_com_on;
+ s->client_cmds[SENDER_off] = http_com_off;
+ s->client_cmds[SENDER_deny] = http_com_deny;
+ s->client_cmds[SENDER_allow] = http_com_allow;
+ s->client_cmds[SENDER_add] = NULL;
+ s->client_cmds[SENDER_delete] = NULL;
init_sender_status(hss, conf.http_access_arg, conf.http_access_given,
conf.http_port_arg, conf.http_max_clients_arg,
/** \file send.h Sender-related defines and structures. */
-/** The sender subcommands. */
+#define SENDER_SUBCOMMANDS \
+ SENDER_SUBCOMMAND(add) /**< Add a target (udp only). */ \
+ SENDER_SUBCOMMAND(delete) /**< Delete a target (udp only). */ \
+ SENDER_SUBCOMMAND(allow) /**< Allow connections from given IP address(es). */ \
+ SENDER_SUBCOMMAND(deny) /**< Deny connections from given IP address(es). */ \
+ SENDER_SUBCOMMAND(on) /**< Activate the sender. */ \
+ SENDER_SUBCOMMAND(off) /**< Deactivate the sender. */ \
+
+#define SENDER_SUBCOMMAND(_name) SENDER_ ## _name,
enum sender_subcommand {
- SENDER_ADD, /**< Add a target (udp only). */
- SENDER_DELETE, /**< Delete a target (udp only). */
- SENDER_ALLOW, /**< Allow connections from given IP address(es). */
- SENDER_DENY, /**< Deny connections from given IP address(es). */
- SENDER_ON, /**< Activate the sender. */
- SENDER_OFF, /**< Deactivate the sender. */
+ SENDER_SUBCOMMANDS
NUM_SENDER_CMDS /**< Used as array size in struct \ref sender. */
};
+#undef SENDER_SUBCOMMAND
+#define SENDER_SUBCOMMAND(_name) #_name,
/**
* Describes one supported sender of para_server.
static int udp_com_on(__a_unused struct sender_command_data *scd)
{
- sender_status = SENDER_ON;
+ sender_status = SENDER_on;
return 1;
}
static int udp_com_off(__a_unused struct sender_command_data *scd)
{
udp_shutdown_targets();
- sender_status = SENDER_OFF;
+ sender_status = SENDER_off;
return 1;
}
{
int ret;
- if (sender_status == SENDER_OFF)
+ if (sender_status == SENDER_off)
return;
if (len == 0)
return;
"status: %s\n"
"port: %s\n"
"targets: %s\n",
- (sender_status == SENDER_ON)? "on" : "off",
+ (sender_status == SENDER_on)? "on" : "off",
stringify_port(conf.udp_default_port_arg, "udp"),
tgts? tgts : "(none)"
);
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;
+ 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 (!conf.udp_no_autostart_given)
- sender_status = SENDER_ON;
+ sender_status = SENDER_on;
PARA_DEBUG_LOG("udp sender init complete\n");
}