xref: /plan9/sys/src/ape/lib/bsd/_sock_ipattr.c (revision 781103c4074deb8af160e8a0da2742ba6b29dc2b)
1 /* posix */
2 #include <sys/types.h>
3 #include <unistd.h>
4 #include <ctype.h>
5 
6 /* bsd extensions */
7 #include <sys/uio.h>
8 #include <sys/socket.h>
9 #include <netinet/in.h>
10 
11 #include "priv.h"
12 
13 /*
14  *  return ndb attribute type of an ip name
15  */
16 int
_sock_ipattr(char * name)17 _sock_ipattr(char *name)
18 {
19 	char *p;
20 	int dot = 0;
21 	int alpha = 0;
22 
23 	for(p = name; *p; p++){
24 		if(isdigit(*p)){
25 			;
26 		}else if(isalpha(*p) || *p == '-')
27 			alpha = 1;
28 		else if(*p == '.')
29 			dot = 1;
30 		else
31 			return Tsys;
32 	}
33 
34 	if(alpha){
35 		if(dot)
36 			return Tdom;
37 		else
38 			return Tsys;
39 	}
40 
41 	if(dot)
42 		return Tip;
43 	else
44 		return Tsys;
45 }
46