Lines Matching refs:name
51 char *name;
136 for (alist = list; alist->name; alist++)
137 if (!memcmp(str, alist->name, len)) return alist->idx;
146 for (alist = list; alist->name; alist++)
147 if (!strcmp(str, alist->name)) return alist->idx;
156 for (alist = list; alist->name; alist++)
157 if (idx == alist->idx) return alist->name;
206 if (list[index]) free(list[index]->name);
209 list[index]->name = xstrdup(toybuf);
221 free(list[i]->name);
227 static void init_arglist(struct arglist **list,int value, char* name)
231 list[value]->name = xstrdup(name);
302 * return RPDB table name as per idx.
315 if (alist[idx] && alist[idx]->name) return alist[idx]->name;
323 static int idxfromRPDB(char *name, u_int8_t whichDB)
330 if (!alist[i] || !alist[i]->name) continue;
331 if (!strcmp(alist[i]->name, name)) return i;
333 i = strtol(name, &ptr, 0);
341 char *name = idx_to_string(idx, rtmtypes);
343 if (!name) snprintf(toybuf, RPDB_ENTRIES, "%u", idx);
344 else snprintf(toybuf, sizeof(toybuf), "%s", name);
348 static int rtmtype_str2idx(char *name)
350 int idx = string_to_idx(name, rtmtypes);
352 if (idx < 0) return atolx_range(name, 0, 255);
361 static int get_prefix(uint32_t *addr, uint8_t *af, char *name, int family)
363 if (family == AF_PACKET) error_exit("'%s' may be inet prefix", name);
364 if (!memcmp(name, "default", strlen(name))
365 || !memcmp(name, "all", strlen(name))
366 || !memcmp(name, "any", strlen(name))) {
370 if (strchr(name, ':')) {
373 if (inet_pton(AF_INET6, name, (void *)addr) != 1)
376 char *ptr = name;
399 char *name, uint8_t family)
407 plen = strtoul(name, &ptr, 0);
409 if (!ptr || ptr == name || *ptr || !plen || plen > *netmask) {
410 if (get_prefix(naddr, &naf, name, family)) return -1;
429 char *name, int family)
432 char *slash = strchr(name, '/');
435 if (get_prefix(addr, &af, name, family)) error_exit("Invalid prefix");
502 static uint32_t get_ifaceindex(char *name, int ext)
511 if (!strcmp(name, i->if_name)) {
516 if (index == -1 && ext) perror_exit("can't find device '%s'", name);
543 for (; p->name; p++) {
546 tmp = out ? xmprintf("%s,%s", out, p->name) : xmprintf("%s", p->name);
603 char *name, *dev, *type, *link, *addr;
607 name = dev = type = link = addr = NULL;
609 struct arglist objectlist[] = { {"type", 0}, {"name", 1}, {"link", 2},
617 else if (idx == 1) dev = name = *++argv;
620 else if (!dev) name = dev = *argv;
623 if (!name && !add)
636 request.info.ifi_index = get_ifaceindex(name, 1);
667 if (!name) {
673 name = toybuf;
675 len = strlen(name) + 1;
676 if (len < 2 || len > IFNAMSIZ) error_exit("Invalid device name.");
677 add_string_to_rtattr(&request.mhdr, sizeof(request), IFLA_IFNAME, name, len);
686 {"multicast", 3}, {"dynamic", 4}, {"name", 5}, {"txqueuelen", 6},
1277 char *tmp = NULL, *name = NULL;
1312 name = *argv;
1318 name = xstrdup(namefromRPDB(idx, RPDB_rtscopes));
1320 if ((scope = idxfromRPDB(name, RPDB_rtscopes)) < 0) {
1321 if (strcmp(name, "all"))
1322 error_exit("wrong scope '%s'", name);
1328 free(name);
2434 if ((rtype == SIOCCHGTUNNEL || rtype == SIOCDELTUNNEL) && *ptnl->name)
2435 xstrncpy(req.ifr_name, ptnl->name, IF_NAMESIZE);
2454 printf("%s: %s/ip", ptnl->name, ptnl->iph.protocol == IPPROTO_IPIP ? "ip" :
2514 if (*ptnl->name && strcmp(ptnl->name, iface)) continue;
2524 if ((ptnl->link && iptnl.link != ptnl->link) || (*ptnl->name &&
2525 strcmp(iptnl.name, ptnl->name)) || (ptnl->iph.daddr &&
2545 {"dsfield", 17}, {"name", 18}, {NULL, -1}
2553 xstrncpy(ptnl->name, *argv, IF_NAMESIZE);
2558 tnl_ioctl(ptnl->name, SIOCGETTUNNEL, &iptnl_old);
2645 if (!*++argv) error_exit("device name is missing");
2680 if (*ptnl->name) error_exit("invalid tunnel");
2682 if (!*++argv) error_exit("name is missing");
2683 xstrncpy(ptnl->name, *argv, IF_NAMESIZE);
2687 if (*ptnl->name) error_exit("invalid tunnel");
2688 xstrncpy(ptnl->name, *argv, IF_NAMESIZE);
2722 ret = tnl_ioctl(*iptnl.name ? iptnl.name : "tunl0", SIOCGETTUNNEL, &iptnl);
2724 ret = tnl_ioctl(*iptnl.name ? iptnl.name : "gre0", SIOCGETTUNNEL, &iptnl);
2726 ret = tnl_ioctl(*iptnl.name ? iptnl.name : "sit0", SIOCGETTUNNEL, &iptnl);
2761 return (tnl_ioctl(iptnl.name, rtype, &iptnl) < 0) ? 1 : 0;
2834 int idx, isip = !(toys.which->name[2]); //1 -> if only ip
2890 if ((idx = string_to_idx(toys.which->name, ip_objectlist)) == -1)