/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 2000-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* Phong Vo <kpv@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
#include "ivlib.h"
#include <ip6.h>
/*
* convert string to address or prefix
*/
int
{
int c;
int i;
int n;
int r;
r = -1;
i = 0;
do
{
n = 0;
while ((c = *s++) >= '0' && c <= '9')
n = n * 10 + (c - '0');
if (n > 0xff)
goto done;
addr[i++] = n;
if (bits)
{
if (c == '/')
{
n = 0;
while ((c = *s++) >= '0' && c <= '9')
n = n * 10 + (c - '0');
c = (n + 7) / 8;
if (i > c)
i = c;
}
else
n = i * 8;
*bits = n;
}
addr[i++] = 0;
r = 0;
done:
if (e)
*e = (char*)(s - 1);
return r;
}