source: asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/network/ether.c@ 337

Last change on this file since 337 was 337, checked in by coas-nagasima, 6 years ago

ASP3版ECNLを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-csrc;charset=UTF-8
File size: 1.1 KB
Line 
1#include <stdlib.h>
2#include <netinet/ether.h>
3#include <stdio.h>
4
5struct ether_addr *ether_aton_r (const char *x, struct ether_addr *p_a)
6{
7 struct ether_addr a;
8 char *y;
9 for (int ii = 0; ii < 6; ii++) {
10 unsigned long int n;
11 if (ii != 0) {
12 if (x[0] != ':') return 0; /* bad format */
13 else x++;
14 }
15 n = strtoul (x, &y, 16);
16 x = y;
17 if (n > 0xFF) return 0; /* bad byte */
18 a.ether_addr_octet[ii] = n;
19 }
20 if (x[0] != 0) return 0; /* bad format */
21 *p_a = a;
22 return p_a;
23}
24
25struct ether_addr *ether_aton (const char *x)
26{
27 static struct ether_addr a;
28 return ether_aton_r (x, &a);
29}
30
31char *ether_ntoa_r (const struct ether_addr *p_a, char *x) {
32 char *y;
33 y = x;
34 for (int ii = 0; ii < 6; ii++) {
35 x += sprintf (x, ii == 0 ? "%.2X" : ":%.2X", p_a->ether_addr_octet[ii]);
36 }
37 return y;
38}
39
40char *ether_ntoa (const struct ether_addr *p_a) {
41 static char x[18];
42 return ether_ntoa_r (p_a, x);
43}
44
45int ether_line(const char *l, struct ether_addr *e, char *hostname)
46{
47 return -1;
48}
49
50int ether_ntohost(char *hostname, const struct ether_addr *e)
51{
52 return -1;
53}
54
55int ether_hostton(const char *hostname, struct ether_addr *e)
56{
57 return -1;
58}
Note: See TracBrowser for help on using the repository browser.