diff options
Diffstat (limited to 'src/bin')
-rw-r--r-- | src/bin/great.c | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/src/bin/great.c b/src/bin/great.c index 9a554fc..f3bae17 100644 --- a/src/bin/great.c +++ b/src/bin/great.c @@ -16,14 +16,13 @@ int main(int argc,char *argv[]) { struct sockaddr_in from; char in; socklen_t sl=sizeof(struct sockaddr_in); - int so_link=socket(AF_LINK,SOCK_DGRAM,0); int so_inet=socket(AF_INET,SOCK_DGRAM,0); int so=socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP); memset(&sa,0,(size_t)sizeof(struct sockaddr_in)); memset(&from,0,(size_t)sizeof(struct sockaddr_in)); if(argc < 4) { - printf("usage: %s interface address port",argv[0]); - printf("example: %s gre0 192.168.0.2 1013",argv[0]); + printf("usage: %s interface address port\n",argv[0]); + printf("example: %s gre0 192.168.0.2 1013\n",argv[0]); return 1; } sa.sin_addr.s_addr=inet_addr(argv[2]); @@ -35,26 +34,14 @@ int main(int argc,char *argv[]) { printf("setting remote end to %s:%d\n",inet_ntoa(addr),ntohs(from.sin_port)); connect(so,(struct sockaddr *)&from,sl); -//name this stuff better and test if it needs to be refilled each time. - struct ifreq *asdf; - asdf=malloc(sizeof(struct ifreq)); + struct ifreq *data; + data=malloc(sizeof(struct ifreq)); - memset(asdf,0,sizeof(struct ifreq)); - strcpy(asdf->ifr_name,argv[1]); - printf("destroy: %d\n",ioctl(so_link,SIOCIFDESTROY,asdf));//destroy + memset(data,0,sizeof(struct ifreq)); + strcpy(data->ifr_name,argv[1]); + data->ifr_value=so; + printf("gressock: %d\n",ioctl(so_inet,GRESSOCK,data));//set socket - memset(asdf,0,sizeof(struct ifreq)); - strcpy(asdf->ifr_name,argv[1]); - printf("create: %d\n",ioctl(so_link,SIOCIFCREATE,asdf));//create - - memset(asdf,0,sizeof(struct ifreq)); - strcpy(asdf->ifr_name,argv[1]); - asdf->ifr_flags=IPPROTO_UDP; - printf("proto: %d\n",ioctl(so_link,GRESPROTO,asdf));//link0 link2 - - memset(asdf,0,sizeof(struct ifreq)); - strcpy(asdf->ifr_name,argv[1]); - asdf->ifr_value=so; - printf("gressock: %d\n",ioctl(so_inet,GRESSOCK,asdf));//set socket + free(data); return 0; } |