1*0a6a1f1dSLionel Sambuc /* $NetBSD: ether_sprintf.c,v 1.7 2014/03/29 14:20:14 jakllsch Exp $ */
258a2b000SEvgeniy Ivanov
358a2b000SEvgeniy Ivanov /*
458a2b000SEvgeniy Ivanov * Copyright (c) 1992 Regents of the University of California.
558a2b000SEvgeniy Ivanov * All rights reserved.
658a2b000SEvgeniy Ivanov *
758a2b000SEvgeniy Ivanov * This software was developed by the Computer Systems Engineering group
858a2b000SEvgeniy Ivanov * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
958a2b000SEvgeniy Ivanov * contributed to Berkeley.
1058a2b000SEvgeniy Ivanov *
1158a2b000SEvgeniy Ivanov * Redistribution and use in source and binary forms, with or without
1258a2b000SEvgeniy Ivanov * modification, are permitted provided that the following conditions
1358a2b000SEvgeniy Ivanov * are met:
1458a2b000SEvgeniy Ivanov * 1. Redistributions of source code must retain the above copyright
1558a2b000SEvgeniy Ivanov * notice, this list of conditions and the following disclaimer.
1658a2b000SEvgeniy Ivanov * 2. Redistributions in binary form must reproduce the above copyright
1758a2b000SEvgeniy Ivanov * notice, this list of conditions and the following disclaimer in the
1858a2b000SEvgeniy Ivanov * documentation and/or other materials provided with the distribution.
1958a2b000SEvgeniy Ivanov * 3. All advertising materials mentioning features or use of this software
2058a2b000SEvgeniy Ivanov * must display the following acknowledgement:
2158a2b000SEvgeniy Ivanov * This product includes software developed by the University of
2258a2b000SEvgeniy Ivanov * California, Lawrence Berkeley Laboratory and its contributors.
2358a2b000SEvgeniy Ivanov * 4. Neither the name of the University nor the names of its contributors
2458a2b000SEvgeniy Ivanov * may be used to endorse or promote products derived from this software
2558a2b000SEvgeniy Ivanov * without specific prior written permission.
2658a2b000SEvgeniy Ivanov *
2758a2b000SEvgeniy Ivanov * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2858a2b000SEvgeniy Ivanov * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2958a2b000SEvgeniy Ivanov * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3058a2b000SEvgeniy Ivanov * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
3158a2b000SEvgeniy Ivanov * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3258a2b000SEvgeniy Ivanov * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3358a2b000SEvgeniy Ivanov * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3458a2b000SEvgeniy Ivanov * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3558a2b000SEvgeniy Ivanov * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3658a2b000SEvgeniy Ivanov * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3758a2b000SEvgeniy Ivanov * SUCH DAMAGE.
3858a2b000SEvgeniy Ivanov *
3958a2b000SEvgeniy Ivanov * @(#) Header: net.c,v 1.9 93/08/06 19:32:15 leres Exp (LBL)
4058a2b000SEvgeniy Ivanov */
4158a2b000SEvgeniy Ivanov
4258a2b000SEvgeniy Ivanov #include <sys/param.h>
4358a2b000SEvgeniy Ivanov #include <sys/socket.h>
4458a2b000SEvgeniy Ivanov #ifdef _STANDALONE
4558a2b000SEvgeniy Ivanov #include <lib/libkern/libkern.h>
4658a2b000SEvgeniy Ivanov #else
4758a2b000SEvgeniy Ivanov #include <string.h>
4858a2b000SEvgeniy Ivanov #endif
4958a2b000SEvgeniy Ivanov
50*0a6a1f1dSLionel Sambuc #include <net/if_ether.h>
5158a2b000SEvgeniy Ivanov
5258a2b000SEvgeniy Ivanov #include "stand.h"
5358a2b000SEvgeniy Ivanov #include "net.h"
5458a2b000SEvgeniy Ivanov
5558a2b000SEvgeniy Ivanov /*
5658a2b000SEvgeniy Ivanov * Convert Ethernet address to printable (loggable) representation.
5758a2b000SEvgeniy Ivanov */
5858a2b000SEvgeniy Ivanov char *
ether_sprintf(const u_char * ap)5958a2b000SEvgeniy Ivanov ether_sprintf(const u_char *ap)
6058a2b000SEvgeniy Ivanov {
6158a2b000SEvgeniy Ivanov int i;
62*0a6a1f1dSLionel Sambuc static char etherbuf[3*ETHER_ADDR_LEN];
6358a2b000SEvgeniy Ivanov char *cp = etherbuf;
6458a2b000SEvgeniy Ivanov
65*0a6a1f1dSLionel Sambuc for (i = 0; i < ETHER_ADDR_LEN; i++) {
6658a2b000SEvgeniy Ivanov *cp++ = hexdigits[*ap >> 4];
6758a2b000SEvgeniy Ivanov *cp++ = hexdigits[*ap++ & 0xf];
6858a2b000SEvgeniy Ivanov *cp++ = ':';
6958a2b000SEvgeniy Ivanov }
7058a2b000SEvgeniy Ivanov *--cp = 0;
7158a2b000SEvgeniy Ivanov return etherbuf;
7258a2b000SEvgeniy Ivanov }
73