11.7Sjakllsch/*	$NetBSD: ether_sprintf.c,v 1.7 2014/03/29 14:20:14 jakllsch 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.7Sjakllsch#include <net/if_ether.h>
511.1Sdrochner
521.1Sdrochner#include "stand.h"
531.1Sdrochner#include "net.h"
541.1Sdrochner
551.1Sdrochner/*
561.1Sdrochner * Convert Ethernet address to printable (loggable) representation.
571.1Sdrochner */
581.1Sdrochnerchar *
591.5Schristosether_sprintf(const u_char *ap)
601.1Sdrochner{
611.1Sdrochner	int i;
621.7Sjakllsch	static char etherbuf[3*ETHER_ADDR_LEN];
631.1Sdrochner	char *cp = etherbuf;
641.1Sdrochner
651.7Sjakllsch	for (i = 0; i < ETHER_ADDR_LEN; i++) {
661.3Schristos		*cp++ = hexdigits[*ap >> 4];
671.3Schristos		*cp++ = hexdigits[*ap++ & 0xf];
681.1Sdrochner		*cp++ = ':';
691.1Sdrochner	}
701.1Sdrochner	*--cp = 0;
711.6Sisaki	return etherbuf;
721.1Sdrochner}
73