Example #1
0
int cmd_igmpv1_query (struct cli_def *cli, char *command, char *argv[], int argc)
{
	int sum;
	
	if ( (strcmp(argv[argc-1],"?")==0) || (argc>1) ) {
		cli_print(cli, "Configure a IGMPv1 query.\n");
		cli_print(cli, "OPTIONAL ARGUMENT: [<checksum>]\n");
		cli_print(cli, "<checksum>   ... user-defined checksum (usually wrong by intention) in \r");
		cli_print(cli, "                 hexadecimal notation (e. g. 'c7b3').\n");
		return CLI_OK;
	}
   
	if (argc==1) {
		if (mz_strishex(argv[0])==0) {
			cli_print(cli, "Checksum must only contain hexadecimal numbers!\n");
			return CLI_OK;
		}
		sum = (int) xstr2int(argv[0]);
		if (sum>0xffff) {
			cli_print(cli, "Checksum must be a 2-byte value!\n");
			return CLI_OK;
		}
	} else sum = -1;

	clipkt->ip_dst = str2ip32("224.0.0.1");
	clipkt->ip_ttl = 1;
	clipkt->ndelay.tv_sec = 125;
	clipkt->ndelay.tv_nsec = 0;
	if (mops_create_igmpv2 (clipkt, 0, IGMP_GENERAL_QUERY, 0, sum, 0))
		cli_print(cli, "Invalid parameters!\n");

	return CLI_OK;
}
Example #2
0
int cmd_igmpv2_specquery (struct cli_def *cli, char *command, char *argv[], int argc)
{
	int mrt=100, sum=-1;
	u_int8_t IP[4];
	u_int32_t mip=0;
	
	if ( (strcmp(argv[argc-1],"?")==0) || (argc>3) ) {
		cli_print(cli, "Configure a IGMPv2 group-specific query.\n");
		cli_print(cli, "ARGUMENTS: <IP-address> [<MRT> [<checksum>]]\n");
		cli_print(cli, "<IP-Address>  ... multicast group to be queried (can be ANY IP address!)\r");
		cli_print(cli, "<MRT>         ... maximum response time in 100 msec units (default: 10 s)\r");
		cli_print(cli, "<checksum>    ... user-defined checksum (usually wrong by intention) in \r");
		cli_print(cli, "                  hexadecimal notation (e. g. 'c7b3').\n");
		return CLI_OK;
	}
   

	if (argc==0) {
		cli_print(cli, "You must at least specify the group address\n");
		return CLI_OK;
	}
	
	if (argc>=1) {
		if (mops_pdesc_ip (IP, argv[0])==0) // check if format is really an IP address
		        mip = str2ip32(argv[0]);
		else {
			cli_print(cli, "Invalid IP address\n");
			return CLI_OK;
		}		
	}
	
	if (argc>=2) {
		if (mz_strisnum(argv[1])==0) {
			cli_print(cli, "Maximum response time must only contain numbers!\n");
			return CLI_OK;
		}
		mrt = (int) str2int(argv[1]);
	}
	
	if (argc==3) {
		if (mz_strishex(argv[2])==0) {
			cli_print(cli, "Checksum must only contain hexadecimal numbers!\n");
			return CLI_OK;
		}
		sum = (int) xstr2int(argv[2]);
		if (sum>0xffff) {
			cli_print(cli, "Checksum must be a 2-byte value!\n");
			return CLI_OK;
		}
	} 

	clipkt->ip_dst = mip;
	clipkt->ip_ttl = 1;
	clipkt->ndelay.tv_sec = 125;
	clipkt->ndelay.tv_nsec = 0;
	if (mops_create_igmpv2 (clipkt, 0, IGMP_GSPEC_QUERY, mrt, sum, mip))
		cli_print(cli, "Invalid parameters!\n");

	return CLI_OK;
}
Example #3
0
int cmd_rtp_ssrc (struct cli_def *cli, char *command, char *argv[], int argc)
{
	struct mops_ext_rtp * pd = clipkt->p_desc;
	unsigned long long int ssrc = 0xcafefeed;

	if ( (strcmp(argv[argc-1],"?")==0) || (argc!=1)) {
		cli_print(cli, "Configure the RTP SSRC (source identifier) (0..ffffffff, default: random!).\n");
		cli_print(cli, "NOTE: The SSRC value is used by another Mausezahn receiver to identify a original\r");
		cli_print(cli, "Mausezahn RTP stream. By default, Mausezahn receivers check for the magic number\r");
		cli_print(cli, "'cafebabe' (hex). Use another number for another RTP stream (e. g. bidirectional\r");
		cli_print(cli, "measurements).\n");
		return CLI_OK;
	}
	
	if (mz_strishex(argv[0])==0) {
		cli_print(cli, "Invalid number.\n");
		return CLI_OK;
	}
	
	ssrc =  xstr2lint(argv[0]);
	if (ssrc>0xffffffff) {
		cli_print(cli, "Range exceeded (0..ffffffff).\n");
		return CLI_OK;
	}
	pd->ssrc = (u_int32_t) ssrc;
	return CLI_OK;
}
Example #4
0
int cmd_igmpv1_report (struct cli_def *cli, char *command, char *argv[], int argc)
{
	int sum;
	u_int8_t IP[4];
	u_int32_t mip=0;
	
	if ( (strcmp(argv[argc-1],"?")==0) || (argc>2) || (argc==0)) {
		cli_print(cli, "Configure a IGMPv1 membership report.\n");
		cli_print(cli, "ARGUMENTS: <IP-Address> [<checksum>]\n");
		cli_print(cli, "<IP-Address>   ... multicast group address to be reported (but ANY IP\r");
		cli_print(cli, "                   address allowed, Mausezahn is really generous...)\r");
		cli_print(cli, "<checksum>     ... user-defined checksum (usually wrong by intention) in \r");
		cli_print(cli, "                   hexadecimal notation (e. g. 'c7b3').\n");
		return CLI_OK;
	}
   
	
	if (argc>=1) {
		if (mops_pdesc_ip (IP, argv[0])==0) // check if format is really an IP address
		        mip = str2ip32(argv[0]);
		else {
			cli_print(cli, "Invalid IP address\n");
			return CLI_OK;
		}
	} 
       
	if (argc==2) {
		if (mz_strishex(argv[1])==0) {
			cli_print(cli, "Checksum must only contain hexadecimal numbers!\n");
			return CLI_OK;
		}
		sum = (int) xstr2int(argv[1]);
		if (sum>0xffff) {
			cli_print(cli, "Checksum must be a 2-byte value!\n");
			return CLI_OK;
		}
	} else sum = -1;

	clipkt->ip_dst = mip;
	clipkt->ip_ttl = 1;
	clipkt->ndelay.tv_sec = 1;
	clipkt->ndelay.tv_nsec = 0;

	if (mops_create_igmpv2 (clipkt, 0, IGMP_V1_REPORT, 0, sum, mip))
		cli_print(cli, "Invalid parameters!\n");

	return CLI_OK;
}
Example #5
0
int cmd_igmpv2_leave (struct cli_def *cli, char *command, char *argv[], int argc)
{
	int sum;
	u_int8_t IP[4];
	u_int32_t mip=0;
	
	if ( (strcmp(argv[argc-1],"?")==0) || (argc>2) || (argc==0)) {
		cli_print(cli, "Configure a IGMPv2 leave group message.\n");
		cli_print(cli, "ARGUMENTS: <IP-Address> [<checksum>]\n");
		cli_print(cli, "<IP-Address>   ... multicast group address that should be left; use\r");
        	cli_print(cli, "                   the special address 0.0.0.0 for a 'general leave'\r");
		cli_print(cli, "<checksum>     ... user-defined checksum (usually wrong by intention) in \r");
		cli_print(cli, "                   hexadecimal notation (e. g. 'c7b3').\n");
		return CLI_OK;
	}
   
	
	if (argc>=1) {
		if (mops_pdesc_ip (IP, argv[0])==0) // check if format is really an IP address
		        mip = str2ip32(argv[0]);
		else {
			cli_print(cli, "Invalid IP address\n");
			return CLI_OK;
		}
	}
       
	if (argc==2) {
		if (mz_strishex(argv[1])==0) {
			cli_print(cli, "Checksum must only contain hexadecimal numbers!\n");
			return CLI_OK;
		}
		sum = (int) xstr2int(argv[1]);
		if (sum>0xffff) {
			cli_print(cli, "Checksum must be a 2-byte value!\n");
			return CLI_OK;
		}
	} else sum = -1;

	clipkt->ip_dst = str2ip32("224.0.0.2");
	clipkt->ip_ttl = 1;
	clipkt->ndelay.tv_sec = 1;
	clipkt->ndelay.tv_nsec = 0;

	if (mops_create_igmpv2 (clipkt, 0, IGMP_LEAVE, 0, sum, mip))
		cli_print(cli, "Invalid parameters!\n");

	return CLI_OK;
}
Example #6
0
int cmd_igmpv2_genquery (struct cli_def *cli, char *command, char *argv[], int argc)
{
	int mrt, sum;
	
	if ( (strcmp(argv[argc-1],"?")==0) || (argc>2) ) {
		cli_print(cli, "Configure a IGMPv2 general query.\n");
		cli_print(cli, "ARGUMENTS: [<MRT> [<checksum>]]\n");
		cli_print(cli, "<MRT>        ... maximum response time in 100 msec units (default: 10 s)\r");
		cli_print(cli, "<checksum>   ... user-defined checksum (usually wrong by intention) in \r");
		cli_print(cli, "                 hexadecimal notation (e. g. 'c7b3').\n");
		return CLI_OK;
	}
   
	if (argc>=1) {
		if (mz_strisnum(argv[0])==0) {
			cli_print(cli, "Maximum response time must only contain numbers!\n");
			return CLI_OK;
		}
		mrt = (int) str2int(argv[0]);
	} else mrt = 100; // default: 10 s
	
	if (argc==2) {
		if (mz_strishex(argv[1])==0) {
			cli_print(cli, "Checksum must only contain hexadecimal numbers!\n");
			return CLI_OK;
		}
		sum = (int) xstr2int(argv[1]);
		if (sum>0xffff) {
			cli_print(cli, "Checksum must be a 2-byte value!\n");
			return CLI_OK;
		}

	} else sum = -1;

	clipkt->ip_dst = str2ip32("224.0.0.1");
	clipkt->ip_ttl = 1;
	clipkt->ndelay.tv_sec = 125;
	clipkt->ndelay.tv_nsec = 0;
	if (mops_create_igmpv2 (clipkt, 0, IGMP_GENERAL_QUERY, mrt, sum, 0)) 
		cli_print(cli, "Invalid parameters!\n");

	return CLI_OK;
}
Example #7
0
int cmd_rtp_cclist (struct cli_def *cli, char *command, char *argv[], int argc)
{
	struct mops_ext_rtp * pd = clipkt->p_desc;
	unsigned long long int csrc=0;
	char str[80];
	int i=0, n=0;

	
	if ((strcmp(argv[argc-1],"?")==0) || (argc==0)) {
		cli_print(cli, "Specify a CSRC list consisting of 1-15 CSRC values.\r");
		cli_print(cli, "Each CSRC is a 4-byte value and must be specified in hexadecimal notation,\r");
		cli_print(cli, "hence each value must be within 0..ffffffff.\n");
		return CLI_OK;
	}
	
	if ((n=argc)>15) {
		cli_print(cli, "The CSRC list must not exceed 15 items!\n");
		return CLI_OK;
	}
	
	for (i=0; i<n; i++) {
		if (mz_strishex(argv[i])==0) {
			sprintf(str, "Parameter %i: Invalid number!", i);
			cli_print(cli, "%s\n", str);
			return CLI_OK;
		}
		csrc =  xstr2lint(argv[i]);
		if (csrc>0xffffffff) {
			sprintf(str, "Parameter %i: Range exceeded (0..ffffffff)", i);
			cli_print(cli, "%s\n", str);
			return CLI_OK;
		}
		pd->csrc[i] = (u_int32_t) csrc;
	}
	pd->cc = n; // this one can be accessed and modified to "wrong" values by the user
	pd->cc_real = n;
	
	return CLI_OK;
}
Example #8
0
int cmd_rtp_time (struct cli_def *cli, char *command, char *argv[], int argc)
{
	struct mops_ext_rtp * pd = clipkt->p_desc;
	unsigned long long int t = 0;

	if ( (strcmp(argv[argc-1],"?")==0) || (argc!=1)) {
		cli_print(cli, "Configure the RTP initial timestamp (0..ffffffff, default: 0).\n");
		return CLI_OK;
	}
	
	if (mz_strishex(argv[0])==0) {
		cli_print(cli, "Invalid number.\n");
		return CLI_OK;
	}
	t =  xstr2lint(argv[0]);
	if (t>0xffffffff) {
		cli_print(cli, "Range exceeded (0..ffffffff).\n");
		return CLI_OK;
	}
	pd->tst = (u_int32_t) t;
	return CLI_OK;
}
Example #9
0
int cmd_rtp_sqnr (struct cli_def *cli, const char *command, char *argv[], int argc)
{
    struct mops_ext_rtp * pd = clipkt->p_desc;
    unsigned long long int sqnr = 0;

    if ( (strcmp(argv[argc-1],"?")==0) || (argc!=1)) {
        cli_print(cli, "Configure the RTP initial sequence number (0..ffffffff, default: 0).\n");
        return CLI_OK;
    }

    if (mz_strishex(argv[0])==0) {
        cli_print(cli, "Invalid number.\n");
        return CLI_OK;
    }
    sqnr =  xstr2lint(argv[0]);
    if (sqnr>0xffffffff) {
        cli_print(cli, "Range exceeded (0..ffffffff).\n");
        return CLI_OK;
    }
    pd->sqnr = (u_int32_t) sqnr;
    return CLI_OK;
}