int ip4cidr(const char *s, ip4addr_t *ap, char **np) { int bits = ip4prefix(s, ap, (char**)&s); if (bits < 0) /* error */ return eret(np, s); else if (*s == '/') /* probably /bits */ return ip4mbits(s + 1, np); else if (bits == 8) /* disallow bare numbers */ return eret(np, s); else return cret(bits, np, s); }
int ip4range(const char *s, ip4addr_t *ap, ip4addr_t *bp, char **np) { int bits = ip4prefix(s, ap, (char**)&s); if (bits < 0) return eret(np, s); else if (*s == '-') { /* a-z */ int bbits = ip4prefix(s + 1, bp, (char**)&s); if (bbits < 0) return eret(np, s); if (bbits == 8) { /* treat 127.0.0.1-2 as 127.0.0.1-127.0.0.2 */ *bp = (*bp >> (bits - 8)) | (*ap & ip4mask(bits - 8)); bbits = bits; }
static int ip4mbits(const char *s, char **np) { /* helper routine for ip4cidr() and ip4range() */ int bits; if (!digit(*s)) return eret(np, s - 1); bits = d2n(*s++); while(digit(*s)) if ((bits = bits * 10 + d2n(*s++)) > 32) return eret(np, s - 1); /*if (!bits) return eret(np, s - 1); allow /0 mask too */ return cret(bits, np, s); }
void __dead2 drop_el(aapcs64_params *args, unsigned long spsr, unsigned long entrypoint) { write_spsr(spsr); write_elr(entrypoint); eret(args->arg0, args->arg1, args->arg2, args->arg3, args->arg4, args->arg5, args->arg6, args->arg7); }