fecdec: Minor cleanups.
[paraslash.git] / command.c
index 9abe04a..b59fae7 100644 (file)
--- a/command.c
+++ b/command.c
@@ -192,7 +192,7 @@ static int check_sender_args(int argc, char * const * argv, struct sender_comman
        case SENDER_ALLOW:
                if (argc != 4 && argc != 5)
                        return -E_COMMAND_SYNTAX;
-               if (!inet_pton(AF_INET, argv[3], &scd->addr))
+               if (!is_valid_ipv4_address(argv[3]))
                        return -E_COMMAND_SYNTAX;
                scd->netmask = 32;
                if (argc == 5) {
@@ -200,20 +200,13 @@ static int check_sender_args(int argc, char * const * argv, struct sender_comman
                        if (scd->netmask < 0 || scd->netmask > 32)
                                return -E_COMMAND_SYNTAX;
                }
+               strncpy(scd->host, argv[3], sizeof(scd->host));
                break;
        case SENDER_ADD:
        case SENDER_DELETE:
-               if (argc != 4 && argc != 5)
-                       return -E_COMMAND_SYNTAX;
-               if (!inet_pton(AF_INET, argv[3], &scd->addr))
+               if (argc != 4)
                        return -E_COMMAND_SYNTAX;
-               scd->port = -1;
-               if (argc == 5) {
-                       scd->port = atoi(argv[4]);
-                       if (scd->port < 0 || scd->port > 65535)
-                               return -E_COMMAND_SYNTAX;
-               }
-               break;
+               return parse_fec_url(argv[3], scd);
        default:
                return -E_COMMAND_SYNTAX;
        }
@@ -254,7 +247,7 @@ int com_sender(int fd, int argc, char * const * argv)
                        usleep(100 * 1000);
                        continue;
                }
-               mmd->sender_cmd_data = scd;
+               memcpy(&mmd->sender_cmd_data, &scd, sizeof(scd));
                mutex_unlock(mmd_mutex);
                break;
        }