#include #include #include #include #include #include #include #include "dns.h" #include "socket.h" #include "buffer.h" #include "ip6.h" #include "str.h" #include "uint16.h" #include "str.h" #include "iopause.h" #include "fmt.h" #include "byte.h" #include "ndelay.h" #include "errmsg.h" #include #include static char seed[128]; char mc6ip[16]={0xff,2,0,0,0,0,0,0,0,0,0,0,'n','c','p','0'}; char mc4ip[4]={224,'n','c','p'}; char bcip[4]={0xff,0xff,0xff,0xff}; static char message[]="ncp-lowfat-1.2.2"; #if 0 long int socket_sendfile(int destfd,int sourcefd,long int maxcopy) { char buf[16*1024]; int len,written; long int done=0; while (maxcopy-done>0) { if (maxcopy-done>16*1024) len=read(sourcefd,buf,16*1024); else len=read(sourcefd,buf,maxcopy-done); len=read(sourcefd,buf,16*1024); if (len<0) return -1; if (len==0) return done; written=write(destfd,buf,len); if (written<0) return -1; if (written0) { if (s!=-1 && (pfd[0].revents&POLLIN)) { fd=socket_accept6(s,0,0,0); if (fd==-1) carp("accept"); else break; } if (s4!=-1 && (pfd[fl-1].revents&POLLIN)) { fd=socket_accept4(s4,0,0); if (fd==-1) carp("accept"); else break; } } } if (fds[0]!=-1) close(fds[0]); if (fds[1]!=-1) close(fds[1]); if (fds[2]!=-1) close(fds[2]); ndelay_off(fd); close(s); if (!*argv) { /* if command line is empty, send \0 and stdin */ char c=0; char buf[1500]; int len,written; if (write(fd,&c,1)!=1) diesys(111,"write failed"); do { len=read(0,buf,1500); if (len==-1) diesys(111,"read failed"); if (len==0) break; written=write(fd,buf,len); if (written==-1) diesys(111,"write failed"); if (writtenoutidx+16) { outidx+=16; byte_copy(ip,16,out.s+outidx); buf[fmt_ip6(buf,ip)]=0; carp("connecting to ",buf); close(s); continue; } diesys(111,"connection to ",*argv," failed"); } else break; } ndelay_off(s); if (read(s,buf,1)!=1) diesys(111,"read"); if (buf[0]==0) { /* stdin/stdout mode */ int len,written; do { len=read(s,buf,1500); if (len==-1) diesys(111,"read"); if (len==0) break; written=write(1,buf,len); if (written==-1) diesys(111,"write"); if (written\n" "This is free software; copy and use it as you like. No warranty.\n"); if (str_equal(argv0,"npush")) npush(argc,argv); else if (str_equal(argv0,"npoll")) npoll(argc,argv); else if (!*argv) ncpserver(argc,argv); else ncpclient(argc,argv); return 0; }