Esempio n. 1
0
static int parse_qos(const char *buff)
{
        /* possible lines look like this
         * add 130.230.54.142 tx=max_pcr,max_sdu rx=max_pcr,max_sdu
         */
        unsigned char ip[4]; 
	int tx_pcr, tx_sdu, rx_pcr, rx_sdu;
        uint32_t ipaddr;
	struct atm_qos qos; 
        
        memset(&qos, 0, sizeof(struct atm_qos));

	if (sscanf(buff, "del %hhu.%hhu.%hhu.%hhu",
			ip, ip+1, ip+2, ip+3) == 4) {
		ipaddr = *(uint32_t *)ip;
		return atm_mpoa_delete_qos(atm_mpoa_search_qos(ipaddr));
	}

	if (sscanf(buff, "add %hhu.%hhu.%hhu.%hhu tx=%d,%d rx=tx",
			ip, ip+1, ip+2, ip+3, &tx_pcr, &tx_sdu) == 6) {
		rx_pcr = tx_pcr;
		rx_sdu = tx_sdu;
	} else if (sscanf(buff, "add %hhu.%hhu.%hhu.%hhu tx=%d,%d rx=%d,%d",
		ip, ip+1, ip+2, ip+3, &tx_pcr, &tx_sdu, &rx_pcr, &rx_sdu) != 8)
		return 0;

        ipaddr = *(uint32_t *)ip;
	qos.txtp.traffic_class = ATM_CBR;
	qos.txtp.max_pcr = tx_pcr;
	qos.txtp.max_sdu = tx_sdu;
	qos.rxtp.traffic_class = ATM_CBR;
	qos.rxtp.max_pcr = rx_pcr;
	qos.rxtp.max_sdu = rx_sdu;
        qos.aal = ATM_AAL5;
	dprintk("mpoa: mpoa_proc.c: parse_qos(): setting qos paramameters to tx=%d,%d rx=%d,%d\n",
		qos.txtp.max_pcr,
		qos.txtp.max_sdu,
		qos.rxtp.max_pcr,
		qos.rxtp.max_sdu
		);

	atm_mpoa_add_qos(ipaddr, &qos);
	return 1;
}
static int parse_qos(const char *buff)
{
	/*                              
                                                            
  */
	unsigned char ip[4];
	int tx_pcr, tx_sdu, rx_pcr, rx_sdu;
	__be32 ipaddr;
	struct atm_qos qos;

	memset(&qos, 0, sizeof(struct atm_qos));

	if (sscanf(buff, "del %hhu.%hhu.%hhu.%hhu",
			ip, ip+1, ip+2, ip+3) == 4) {
		ipaddr = *(__be32 *)ip;
		return atm_mpoa_delete_qos(atm_mpoa_search_qos(ipaddr));
	}

	if (sscanf(buff, "add %hhu.%hhu.%hhu.%hhu tx=%d,%d rx=tx",
			ip, ip+1, ip+2, ip+3, &tx_pcr, &tx_sdu) == 6) {
		rx_pcr = tx_pcr;
		rx_sdu = tx_sdu;
	} else if (sscanf(buff, "add %hhu.%hhu.%hhu.%hhu tx=%d,%d rx=%d,%d",
		ip, ip+1, ip+2, ip+3, &tx_pcr, &tx_sdu, &rx_pcr, &rx_sdu) != 8)
		return 0;

	ipaddr = *(__be32 *)ip;
	qos.txtp.traffic_class = ATM_CBR;
	qos.txtp.max_pcr = tx_pcr;
	qos.txtp.max_sdu = tx_sdu;
	qos.rxtp.traffic_class = ATM_CBR;
	qos.rxtp.max_pcr = rx_pcr;
	qos.rxtp.max_sdu = rx_sdu;
	qos.aal = ATM_AAL5;
	dprintk("parse_qos(): setting qos paramameters to tx=%d,%d rx=%d,%d\n",
		qos.txtp.max_pcr, qos.txtp.max_sdu,
		qos.rxtp.max_pcr, qos.rxtp.max_sdu);

	atm_mpoa_add_qos(ipaddr, &qos);
	return 1;
}
Esempio n. 3
0
static int parse_qos(const char *buff, int len)
{
        /* possible lines look like this
         * add 130.230.54.142 tx=max_pcr,max_sdu rx=max_pcr,max_sdu
         */
        
        int pos, i;
        uint32_t ipaddr;
        unsigned char ip[4]; 
        char cmd[4], temp[256];
        const char *tmp, *prev;
	struct atm_qos qos; 
	int value[5];
        
        memset(&qos, 0, sizeof(struct atm_qos));
        strncpy(cmd, buff, 3);
        if( strncmp(cmd,"add", 3) &&  strncmp(cmd,"del", 3))
	        return 0;  /* not add or del */

	pos = 4;
        /* next parse ip */
        prev = buff + pos;
        for (i = 0; i < 3; i++) {
                tmp = strchr(prev, '.');
                if (tmp == NULL) return 0;
                memset(temp, '\0', 256);
                memcpy(temp, prev, tmp-prev);
                ip[i] = (char)simple_strtoul(temp, NULL, 0);
		tmp ++; 
		prev = tmp;
        }
	tmp = strchr(prev, ' ');
        if (tmp == NULL) return 0;
        memset(temp, '\0', 256);
        memcpy(temp, prev, tmp-prev);
        ip[i] = (char)simple_strtoul(temp, NULL, 0);
        ipaddr = *(uint32_t *)ip;
                
	if(!strncmp(cmd, "del", 3))
	         return atm_mpoa_delete_qos(atm_mpoa_search_qos(ipaddr));

        /* next transmit values */
	tmp = strstr(buff, "tx=");
	if(tmp == NULL) return 0;
	tmp += 3;
	prev = tmp;
	for( i = 0; i < 1; i++){
	         tmp = strchr(prev, ',');
		 if (tmp == NULL) return 0;
		 memset(temp, '\0', 256);
		 memcpy(temp, prev, tmp-prev);
		 value[i] = (int)simple_strtoul(temp, NULL, 0);
		 tmp ++; 
		 prev = tmp;
	}
	tmp = strchr(prev, ' ');
        if (tmp == NULL) return 0;
	memset(temp, '\0', 256);
        memcpy(temp, prev, tmp-prev);
        value[i] = (int)simple_strtoul(temp, NULL, 0);
	qos.txtp.traffic_class = ATM_CBR;
	qos.txtp.max_pcr = value[0];
	qos.txtp.max_sdu = value[1];

        /* next receive values */
	tmp = strstr(buff, "rx=");
	if(tmp == NULL) return 0;
        if (strstr(buff, "rx=tx")) { /* rx == tx */
                qos.rxtp.traffic_class = qos.txtp.traffic_class;
                qos.rxtp.max_pcr = qos.txtp.max_pcr;
                qos.rxtp.max_cdv = qos.txtp.max_cdv;
                qos.rxtp.max_sdu = qos.txtp.max_sdu;
        } else {
                tmp += 3;
                prev = tmp;
                for( i = 0; i < 1; i++){
                        tmp = strchr(prev, ',');
                        if (tmp == NULL) return 0;
                        memset(temp, '\0', 256);
                        memcpy(temp, prev, tmp-prev);
                        value[i] = (int)simple_strtoul(temp, NULL, 0);
                        tmp ++; 
                        prev = tmp;
                }
                tmp = strchr(prev, '\0');
                if (tmp == NULL) return 0;
                memset(temp, '\0', 256);
                memcpy(temp, prev, tmp-prev);
                value[i] = (int)simple_strtoul(temp, NULL, 0);
                qos.rxtp.traffic_class = ATM_CBR;
                qos.rxtp.max_pcr = value[0];
                qos.rxtp.max_sdu = value[1];
        }
        qos.aal = ATM_AAL5;
	dprintk("mpoa: mpoa_proc.c: parse_qos(): setting qos paramameters to tx=%d,%d rx=%d,%d\n",
		qos.txtp.max_pcr,
		qos.txtp.max_sdu,
		qos.rxtp.max_pcr,
		qos.rxtp.max_sdu
		);

	atm_mpoa_add_qos(ipaddr, &qos);
	return 1;
}