sys/lib/libsa/ether_sprintf.c

http://www.minix3.org/ · C · 73 lines · 25 code · 6 blank · 42 comment · 1 complexity · 6c75ee10fe2e58924a3cda56c5082a4d MD5 · raw file

  1. /* $NetBSD: ether_sprintf.c,v 1.6 2007/11/24 13:20:55 isaki Exp $ */
  2. /*
  3. * Copyright (c) 1992 Regents of the University of California.
  4. * All rights reserved.
  5. *
  6. * This software was developed by the Computer Systems Engineering group
  7. * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
  8. * contributed to Berkeley.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in the
  17. * documentation and/or other materials provided with the distribution.
  18. * 3. All advertising materials mentioning features or use of this software
  19. * must display the following acknowledgement:
  20. * This product includes software developed by the University of
  21. * California, Lawrence Berkeley Laboratory and its contributors.
  22. * 4. Neither the name of the University nor the names of its contributors
  23. * may be used to endorse or promote products derived from this software
  24. * without specific prior written permission.
  25. *
  26. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  27. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  28. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  29. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  30. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  31. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  32. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  33. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  34. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  35. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  36. * SUCH DAMAGE.
  37. *
  38. * @(#) Header: net.c,v 1.9 93/08/06 19:32:15 leres Exp (LBL)
  39. */
  40. #include <sys/param.h>
  41. #include <sys/socket.h>
  42. #ifdef _STANDALONE
  43. #include <lib/libkern/libkern.h>
  44. #else
  45. #include <string.h>
  46. #endif
  47. #include <netinet/in.h>
  48. #include <netinet/in_systm.h>
  49. #include "stand.h"
  50. #include "net.h"
  51. /*
  52. * Convert Ethernet address to printable (loggable) representation.
  53. */
  54. char *
  55. ether_sprintf(const u_char *ap)
  56. {
  57. int i;
  58. static char etherbuf[18];
  59. char *cp = etherbuf;
  60. for (i = 0; i < 6; i++) {
  61. *cp++ = hexdigits[*ap >> 4];
  62. *cp++ = hexdigits[*ap++ & 0xf];
  63. *cp++ = ':';
  64. }
  65. *--cp = 0;
  66. return etherbuf;
  67. }