FreeBSD/tools/tools/netmap/pkt-gen.c
/*
 * parse the vale configuration in conf and put it in nmr.
 * Return the flag set if necessary.
 * The configuration may consist of 0 to 4 numbers separated
 * by commas: #tx-slots,#rx-slots,#tx-rings,#rx-rings.
 * Missing numbers or zeroes stand for default values.
 * As an additional convenience, if exactly one number
 * is specified, then this is assigned to both #tx-slots and #rx-slots.
 * If there is no 4th number, then the 3rd is assigned to both #tx-rings
 * and #rx-rings.
 */
parse the vale configuration in conf and put it in nmr.
Return the flag set if necessary.
The configuration may consist of 0 to 4 numbers separated
by commas: #tx-slots,#rx-slots,#tx-rings,#rx-rings.
Missing numbers or zeroes stand for default values.
As an additional convenience, if exactly one number
is specified, then this is assigned to both #tx-slots and #rx-slots.
If there is no 4th number, then the 3rd is assigned to both #tx-rings
and #rx-rings.
parse the vale configuration in conf and put it in nmr . Return the flag set if necessary . The configuration may consist of 0 to 4 numbers separated by commas : #tx - slots #rx - slots #tx - rings #rx - rings . Missing numbers or zeroes stand for default values . As an additional convenience if exactly one number is specified then this is assigned to both #tx - slots and #rx - slots . If there is no 4th number then the 3rd is assigned to both #tx - rings and #rx - rings .
int
parse_nmr_config(const char* conf, struct nmreq *nmr)
{
	char *w, *tok;
	int i, v;
	nmr->nr_tx_rings = nmr->nr_rx_rings = 0;
	nmr->nr_tx_slots = nmr->nr_rx_slots = 0;
	if (conf == NULL || ! *conf)
		return 0;
	w = strdup(conf);
	for (i = 0, tok = strtok(w, ","); tok; i++, tok = strtok(NULL, ",")) {
		v = atoi(tok);
		switch (i) {
		case 0:
			nmr->nr_tx_slots = nmr->nr_rx_slots = v;
			break;
		case 1:
			nmr->nr_rx_slots = v;
			break;
		case 2:
			nmr->nr_tx_rings = nmr->nr_rx_rings = v;
			break;
		case 3:
			nmr->nr_rx_rings = v;
			break;
		default:
			D("ignored config: %s", tok);
			break;
		}
	}
	D("txr %d txd %d rxr %d rxd %d",
			nmr->nr_tx_rings, nmr->nr_tx_slots,
			nmr->nr_rx_rings, nmr->nr_rx_slots);
	free(w);
	return (nmr->nr_tx_rings || nmr->nr_tx_slots ||
                        nmr->nr_rx_rings || nmr->nr_rx_slots) ?
		NM_OPEN_RING_CFG : 0;
}
int parse_nmr_config ( const char * conf , struct nmreq * nmr ) { char * w , * tok ; int i , v ; nmr -> nr_tx_rings = nmr -> nr_rx_rings = 0 ; nmr -> nr_tx_slots = nmr -> nr_rx_slots = 0 ; if ( conf == NULL || ! * conf ) return 0 ; w = strdup ( conf ) ; for ( i = 0 , tok = strtok ( w , " " ) ; tok ; i ++ , tok = strtok ( NULL , " " ) ) { v = atoi ( tok ) ; switch ( i ) { case 0 : nmr -> nr_tx_slots = nmr -> nr_rx_slots = v ; break ; case 1 : nmr -> nr_rx_slots = v ; break ; case 2 : nmr -> nr_tx_rings = nmr -> nr_rx_rings = v ; break ; case 3 : nmr -> nr_rx_rings = v ; break ; default : D ( " " , tok ) ; break ; } } D ( " " , nmr -> nr_tx_rings , nmr -> nr_tx_slots , nmr -> nr_rx_rings , nmr -> nr_rx_slots ) ; free ( w ) ; return ( nmr -> nr_tx_rings || nmr -> nr_tx_slots || nmr -> nr_rx_rings || nmr -> nr_rx_slots ) ? NM_OPEN_RING_CFG : 0 ; }
parse the vale configuration in conf and put it in nmr.
parse the vale configuration in conf and put it in nmr .