ether_sprintf.c revision 1.1
11.1Sdrochner/*	$NetBSD: ether_sprintf.c,v 1.1 2003/03/12 16:46:31 drochner Exp $	*/
21.1Sdrochner
31.1Sdrochner/*
41.1Sdrochner * Copyright (c) 1992 Regents of the University of California.
51.1Sdrochner * All rights reserved.
61.1Sdrochner *
71.1Sdrochner * This software was developed by the Computer Systems Engineering group
81.1Sdrochner * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
91.1Sdrochner * contributed to Berkeley.
101.1Sdrochner *
111.1Sdrochner * Redistribution and use in source and binary forms, with or without
121.1Sdrochner * modification, are permitted provided that the following conditions
131.1Sdrochner * are met:
141.1Sdrochner * 1. Redistributions of source code must retain the above copyright
151.1Sdrochner *    notice, this list of conditions and the following disclaimer.
161.1Sdrochner * 2. Redistributions in binary form must reproduce the above copyright
171.1Sdrochner *    notice, this list of conditions and the following disclaimer in the
181.1Sdrochner *    documentation and/or other materials provided with the distribution.
191.1Sdrochner * 3. All advertising materials mentioning features or use of this software
201.1Sdrochner *    must display the following acknowledgement:
211.1Sdrochner *	This product includes software developed by the University of
221.1Sdrochner *	California, Lawrence Berkeley Laboratory and its contributors.
231.1Sdrochner * 4. Neither the name of the University nor the names of its contributors
241.1Sdrochner *    may be used to endorse or promote products derived from this software
251.1Sdrochner *    without specific prior written permission.
261.1Sdrochner *
271.1Sdrochner * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
281.1Sdrochner * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
291.1Sdrochner * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
301.1Sdrochner * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
311.1Sdrochner * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
321.1Sdrochner * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
331.1Sdrochner * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
341.1Sdrochner * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
351.1Sdrochner * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
361.1Sdrochner * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
371.1Sdrochner * SUCH DAMAGE.
381.1Sdrochner *
391.1Sdrochner * @(#) Header: net.c,v 1.9 93/08/06 19:32:15 leres Exp  (LBL)
401.1Sdrochner */
411.1Sdrochner
421.1Sdrochner#include <sys/param.h>
431.1Sdrochner#include <sys/socket.h>
441.1Sdrochner#ifdef _STANDALONE
451.1Sdrochner#include <lib/libkern/libkern.h>
461.1Sdrochner#else
471.1Sdrochner#include <string.h>
481.1Sdrochner#endif
491.1Sdrochner
501.1Sdrochner#include <netinet/in.h>
511.1Sdrochner#include <netinet/in_systm.h>
521.1Sdrochner
531.1Sdrochner#include "stand.h"
541.1Sdrochner#include "net.h"
551.1Sdrochner
561.1Sdrochner/*
571.1Sdrochner * Convert Ethernet address to printable (loggable) representation.
581.1Sdrochner */
591.1Sdrochnerstatic char digits[] = "0123456789abcdef";
601.1Sdrochnerchar *
611.1Sdrochnerether_sprintf(ap)
621.1Sdrochner        u_char *ap;
631.1Sdrochner{
641.1Sdrochner	int i;
651.1Sdrochner	static char etherbuf[18];
661.1Sdrochner	char *cp = etherbuf;
671.1Sdrochner
681.1Sdrochner	for (i = 0; i < 6; i++) {
691.1Sdrochner		*cp++ = digits[*ap >> 4];
701.1Sdrochner		*cp++ = digits[*ap++ & 0xf];
711.1Sdrochner		*cp++ = ':';
721.1Sdrochner	}
731.1Sdrochner	*--cp = 0;
741.1Sdrochner	return (etherbuf);
751.1Sdrochner}
76