Exemple #1
0
static int blacklist_parse_parameters(char *str, range_action action,
                      int msgtrigger)
{
    unsigned int from_cssid, to_cssid, from_ssid, to_ssid, from, to;
    int rc, totalrc;
    char *parm;
    range_action ra;

    totalrc = 0;

    while ((parm = strsep(&str, ","))) {
        rc = 0;
        ra = action;
        if (*parm == '!') {
            if (ra == add)
                ra = free;
            else
                ra = add;
            parm++;
        }
        if (strcmp(parm, "all") == 0) {
            from_cssid = 0;
            from_ssid = 0;
            from = 0;
            to_cssid = __MAX_CSSID;
            to_ssid = __MAX_SSID;
            to = __MAX_SUBCHANNEL;
        } else {
            rc = parse_busid(strsep(&parm, "-"), &from_cssid,
                     &from_ssid, &from, msgtrigger);
            if (!rc) {
                if (parm != NULL)
                    rc = parse_busid(parm, &to_cssid,
                             &to_ssid, &to,
                             msgtrigger);
                else {
                    to_cssid = from_cssid;
                    to_ssid = from_ssid;
                    to = from;
                }
            }
        }
        if (!rc) {
            rc = blacklist_range(ra, from_ssid, to_ssid, from, to,
                         msgtrigger);
            if (rc)
                totalrc = 1;
        } else
            totalrc = 1;
    }

    return totalrc;
}
static inline int
blacklist_parse_parameters (char *str, range_action action)
{
	unsigned int from, to, from_id0, to_id0, from_id1, to_id1;

	while (*str != 0 && *str != '\n') {
		range_action ra = action;
		while(*str == ',')
			str++;
		if (*str == '!') {
			ra = !action;
			++str;
		}

		/*
		 * Since we have to parse the proc commands and the
		 * kernel arguments we have to check four cases
		 */
		if (strncmp(str,"all,",4) == 0 || strcmp(str,"all") == 0 ||
		    strncmp(str,"all\n",4) == 0 || strncmp(str,"all ",4) == 0) {
			from = 0;
			to = __MAX_SUBCHANNELS;
			str += 3;
		} else {
			int rc;

			rc = blacklist_busid(&str, &from_id0,
					     &from_id1, &from);
			if (rc)
				continue;
			to = from;
			to_id0 = from_id0;
			to_id1 = from_id1;
			if (*str == '-') {
				str++;
				rc = blacklist_busid(&str, &to_id0,
						     &to_id1, &to);
				if (rc)
					continue;
			}
			if (*str == '-') {
				printk(KERN_WARNING "invalid cio_ignore "
					"parameter '%s'\n",
					strsep(&str, ",\n"));
				continue;
			}
			if ((from_id0 != to_id0) || (from_id1 != to_id1)) {
				printk(KERN_WARNING "invalid cio_ignore range "
					"%x.%x.%04x-%x.%x.%04x\n",
					from_id0, from_id1, from,
					to_id0, to_id1, to);
				continue;
			}
		}
		/* FIXME: ignoring id0 and id1 here. */
		pr_debug("blacklist_setup: adding range "
			 "from 0.0.%04x to 0.0.%04x\n", from, to);
		blacklist_range (ra, from, to);
	}
	return 1;
}