12 #include <sys/socket.h>
13 #include <netinet/in.h>
25 static struct protoent r;
27 struct protoent *getprotobyname(const char *name) {
32 static char buf[1024], proto[1024];
33 static char *nptr[Nname+1];
35 /* connect to server */
36 fd = open("/net/cs", O_RDWR);
38 h_errno = NO_RECOVERY;
42 /* construct the query, always expect a protocol# back */
43 snprintf(buf, sizeof buf, "!protocol=%s ipv4proto=*", name);
45 /* query the server */
46 if(write(fd, buf, strlen(buf)) < 0){
52 for(i = 0; i < sizeof(buf)-1; i += m){
53 m = read(fd, buf+i, sizeof(buf) - 1 - i);
68 if(strcmp(bp, "protocol") == 0){
73 } else if(strcmp(bp, "ipv4proto") == 0){
77 while(*p && *p != ' ')