[SLOF] [PATCH v2 2/3] ping: add netmask in the ping argument

Nikunj A Dadhania nikunj at linux.vnet.ibm.com
Mon May 2 20:21:05 AEST 2016


Nikunj A Dadhania <nikunj at linux.vnet.ibm.com> writes:
> diff --git a/clients/net-snk/app/netapps/ping.c b/clients/net-snk/app/netapps/ping.c
> index 4facf06..3e4d440 100644
> --- a/clients/net-snk/app/netapps/ping.c
> +++ b/clients/net-snk/app/netapps/ping.c
> @@ -35,13 +35,15 @@ struct ping_args {
>  		unsigned int integer;
>  	} gateway_ip;
>  	unsigned int timeout;
> +	/* Netmask 192.168.1.10/24 format */
> +	unsigned int netmask;
>  };
>
>  static void
>  usage(void)
>  {
>  	printf
> -	    ("\nping device-path:[device-args,]server-ip,[client-ip],[gateway-ip][,timeout]\n");
> +	    ("\nping device-path:[device-args,]server-ip,[client-ip[\\nn]],[gateway-ip][,timeout]\n");
>
>  }
>
> @@ -82,7 +84,7 @@ parse_args(const char *args, struct ping_args *ping_args)
>  	}
>
>  	argncpy(args, 0, buf, 64);
> -	if (!strtoip(buf, ping_args->client_ip.string)) {
> +	if (!strtoip_netmask(buf, ping_args->client_ip.string, &ping_args->netmask)) {
>  		/* this should have been the client (our) IP address */
>  		return -1;
>  	} else {
> @@ -112,6 +114,7 @@ ping(int argc, char *argv[])
>  	int fd_device;
>  	struct ping_args ping_args;
>  	uint8_t own_mac[6];
> +	uint32_t netmask;
>
>  	memset(&ping_args, 0, sizeof(struct ping_args));
>
> @@ -163,6 +166,9 @@ ping(int argc, char *argv[])
>
>  	} else {
>  		memcpy(&fn_ip.own_ip, &ping_args.client_ip.integer, 4);
> +		if (ping_args.netmask)
> +			set_ipv4_netmask(ping_args.netmask);

Missed the following:

+               else
+                       set_ipv4_netmask(0xFFFFFF00UL);

is this a safe assumption when user has not provided any netmask
variable?

Regards
Nikunj



More information about the SLOF mailing list