6
#include <netatalk/at.h>
7
#include <netatalk/endian.h>
8
#include <atalk/util.h>
12
* Check whether "cp" is a valid ascii representation
13
* of an AppleTalk address and convert to a binary address.
14
* Examples of accepted forms are (in decimal, net of 4321,
22
* If hex is used, and the first digit is one of A-F, the leading
23
* 0x is redundant. Returns 1 if the address is valid, 0 if not.
25
* Unlike Internet addresses, AppleTalk addresses can have leading
26
* 0's. This means that we can't support octal addressing.
29
int atalk_aton( cp, addr )
33
u_int32_t val, base, n;
37
if ( *cp == '0' && ( *++cp == 'x' || *cp == 'X' )) {
40
if ( !isdigit( *cp ) && isxdigit( *cp )) {
45
while (( c = *cp ) != '\0') {
46
if ( isascii( c ) && isdigit( c )) {
47
val = (val * base) + (c - '0');
52
if ( base == 16 && isascii( c ) && isxdigit( c )) {
53
val = ( val << 4 ) + ( c + 10 - ( islower( c ) ? 'a' : 'A' ));
60
if ( c != '.' && c != '\0' ) {
81
if ( addr->s_net > 255 ) {
85
addr->s_net += addr->s_node;
113
addr->s_net = htons( addr->s_net );