Exemple #1
0
static int
parse_addresses(const char *addrstr, struct in6_addr *addrp)
{
    char *buffer, *cp, *next;
    unsigned int i;

    buffer = strdup(addrstr);
    if (!buffer) xtables_error(OTHER_PROBLEM, "strdup failed");

    for (cp=buffer, i=0; cp && i<IP6T_RT_HOPS; cp=next,i++)
    {
        next=strchr(cp, ',');
        if (next) *next++='\0';
        memcpy(&(addrp[i]), numeric_to_addr(cp), sizeof(struct in6_addr));
#if DEBUG
        printf("addr str: %s\n", cp);
        printf("addr ip6: %s\n", addr_to_numeric((numeric_to_addr(cp))));
        printf("addr [%d]: %s\n", i, addr_to_numeric(&(addrp[i])));
#endif
    }
    if (cp) xtables_error(PARAMETER_PROBLEM, "too many addresses specified");

    free(buffer);

#if DEBUG
    printf("addr nr: %d\n", i);
#endif

    return i;
}
Exemple #2
0
static void print_entry(char *prefix, const struct ip6t_policy_elem *e,
                        int numeric)
{
	if (e->match.reqid) {
		PRINT_INVERT(e->invert.reqid);
		printf("%sreqid %u ", prefix, e->reqid);
	}
	if (e->match.spi) {
		PRINT_INVERT(e->invert.spi);
		printf("%sspi 0x%x ", prefix, e->spi);
	}
	if (e->match.proto) {
		PRINT_INVERT(e->invert.proto);
		print_proto(prefix, e->proto, numeric);
	}
	if (e->match.mode) {
		PRINT_INVERT(e->invert.mode);
		print_mode(prefix, e->mode, numeric);
	}
	if (e->match.daddr) {
		PRINT_INVERT(e->invert.daddr);
		printf("%stunnel-dst %s%s ", prefix,
		       addr_to_numeric((struct in6_addr *)&e->daddr),
		       mask_to_numeric((struct in6_addr *)&e->dmask));
	}
	if (e->match.saddr) {
		PRINT_INVERT(e->invert.saddr);
		printf("%stunnel-src %s%s ", prefix,
		       addr_to_numeric((struct in6_addr *)&e->saddr),
		       mask_to_numeric((struct in6_addr *)&e->smask));
	}
}
Exemple #3
0
static void
print_addresses(unsigned int addrnr, struct in6_addr *addrp)
{
    unsigned int i;

    for(i=0; i<addrnr; i++) {
        printf("%s%c", addr_to_numeric(&(addrp[i])), (i!=addrnr-1)?',':' ');
    }
}
static void
print_addresses(unsigned int addrnr, struct in6_addr *addrp)
{
	unsigned int i;

	for(i=0; i<addrnr; i++){
		printf("%c%s", (i==0)?' ':',', addr_to_numeric(&(addrp[i])));
	}
}
Exemple #5
0
static char *
mask_to_numeric(const struct in6_addr *addrp)
{
        static char buf[50+2];
        int l = ipv6_prefix_length(addrp);
        if (l == -1) {
		strcpy(buf, "/");
		strcat(buf, addr_to_numeric(addrp));
		return buf;
	}
	sprintf(buf, "/%d", l);
	return buf;
}