Beispiel #1
0
/* Display an HIPPI socket address. */
static char *
 pr_shippi(struct sockaddr *sap)
{
    static char buf[64];

    if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
	return (safe_strncpy(buf, _("[NONE SET]"), 64));
    return (pr_hippi(sap->sa_data));
}
Beispiel #2
0
/* Input an HIPPI address and convert to binary. */
static int in_hippi (char *bufp, struct sockaddr *sap)
{
    unsigned char *ptr;

    char c, *orig;

    int i, val;

    sap->sa_family = hippi_hwtype.type;
    ptr = sap->sa_data;

    i = 0;
    orig = bufp;
    while ((*bufp != '\0') && (i < HIPPI_ALEN))
    {
        val = 0;
        c = *bufp++;
        if (isdigit (c))
            val = c - '0';
        else if (c >= 'a' && c <= 'f')
            val = c - 'a' + 10;
        else if (c >= 'A' && c <= 'F')
            val = c - 'A' + 10;
        else
        {
#ifdef DEBUG
            fprintf (stderr, _("in_hippi(%s): invalid hippi address!\n"), orig);
#endif
            errno = EINVAL;
            return (-1);
        }
        val <<= 4;
        c = *bufp++;
        if (isdigit (c))
            val |= c - '0';
        else if (c >= 'a' && c <= 'f')
            val |= c - 'a' + 10;
        else if (c >= 'A' && c <= 'F')
            val |= c - 'A' + 10;
        else
        {
#ifdef DEBUG
            fprintf (stderr, _("in_hippi(%s): invalid hippi address!\n"), orig);
#endif
            errno = EINVAL;
            return (-1);
        }
        *ptr++ = (unsigned char) (val & 0377);
        i++;

        /* We might get a semicolon here - not required. */
        if (*bufp == ':')
        {
            if (i == HIPPI_ALEN)
            {
#ifdef DEBUG
                fprintf (stderr, _("in_hippi(%s): trailing : ignored!\n"), orig)
#endif
                    ;            /* nothing */
            }
            bufp++;
        }
    }

    /* That's it.  Any trailing junk? */
    if ((i == HIPPI_ALEN) && (*bufp != '\0'))
    {
#ifdef DEBUG
        fprintf (stderr, _("in_hippi(%s): trailing junk!\n"), orig);
        errno = EINVAL;
        return (-1);
#endif
    }
#ifdef DEBUG
    fprintf (stderr, "in_hippi(%s): %s\n", orig, pr_hippi (sap->sa_data));
#endif

    return (0);
}