2 * lib/ash.c This file contains an implementation of the Ash
3 * support functions for the NET-2 base distribution.
4 * $Id: ash.c,v 1.11 1999/09/27 11:00:45 philip Exp $
9 #if HAVE_HWASH || HAVE_AFASH
11 #include <sys/types.h>
12 #include <sys/socket.h>
13 #include <net/if_arp.h>
20 #include "net-support.h"
21 #include "pathnames.h"
27 static unsigned char hamming
[16] =
29 0x15, 0x02, 0x49, 0x5e, 0x64, 0x73, 0x38, 0x2f,
30 0xd0, 0xc7, 0x8c, 0x9b, 0xa1, 0xb6, 0xfd, 0xea
33 /* Display an Ash address in readable format. */
35 pr_ash(unsigned char *ptr
)
37 static char buff
[128];
43 while (ptr
[i
] != 0xc9 && ptr
[i
] != 0xff && (i
< ASH_ALEN
))
44 sprintf(p
++, "%1x", ptr
[i
++]);
54 #warning "No definition of ARPHRD_ASH in <net/if_arp.h>, using private value 517"
55 #define ARPHRD_ASH 517
58 struct hwtype ash_hwtype
;
61 in_ash(char *bufp
, struct sockaddr
*sap
)
66 sap
->sa_family
= ash_hwtype
.type
;
69 while (bufp
&& i
< ASH_ALEN
) {
71 int hop
= strtol(bufp
, &next
, 16);
72 ptr
[i
++] = hamming
[hop
];
81 fprintf(stderr
, _("Malformed Ash address"));
82 memset(ptr
, 0xc9, ASH_ALEN
);
93 struct hwtype ash_hwtype
=
95 "ash", NULL
, ARPHRD_ASH
, ASH_ALEN
,
100 #endif /* HAVE_HWASH */
104 /* Display an Ash socket address. */
106 pr_sash(struct sockaddr
*sap
, int numeric
)
110 if (sap
->sa_family
!= AF_ASH
)
111 return safe_strncpy(buf
, "[NONE SET]", 64);
112 return pr_ash(sap
->sa_data
);
115 struct aftype ash_aftype
=
117 "ash", NULL
, AF_ASH
, 0,
118 pr_ash
, pr_sash
, NULL
, NULL
,
124 #endif /* HAVE_AFASH */
126 #endif /* HAVE_AFASH || HAVE_HWASH */