summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/cidr.c14
-rw-r--r--src/bin/dragonturn.c2
-rw-r--r--src/bin/filemon.c40
-rw-r--r--src/bin/fontbuild.c1
-rw-r--r--src/bin/fontdump.c2
-rw-r--r--src/bin/great.c48
-rw-r--r--src/bin/ipgen.c3
-rw-r--r--src/bin/iplist2cidr.c2
-rw-r--r--src/bin/iprand.c4
-rw-r--r--src/bin/lineplot.c2
-rw-r--r--src/bin/rrd.c2
-rw-r--r--src/bin/tcpident.c1
-rw-r--r--src/bin/turn2line.c4
-rw-r--r--src/bin/urcdump.c12
14 files changed, 74 insertions, 63 deletions
diff --git a/src/bin/cidr.c b/src/bin/cidr.c
index fe44668..1cef7d4 100644
--- a/src/bin/cidr.c
+++ b/src/bin/cidr.c
@@ -1,4 +1,7 @@
#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <arpa/inet.h>
int main(int argc,char *argv[]) {
unsigned int cidr;
@@ -9,17 +12,16 @@ int main(int argc,char *argv[]) {
printf("example: cidr 192.168.0.1/24\n");
return 1;
}
- if(!strchr(argv[1],'/')) {
- cidr=32;
- net=argv[1];
- } else {
+ if(!strchr(argv[1],'/')) cidr=32;
+ else {
cidr=atoi(strchr(argv[1],'/')+1);
*strchr(argv[1],'/')=0;
- net=htonl(inet_addr(argv[1]));
}
+ net=htonl(inet_addr(argv[1]));
printf("%d.%d.%d.%d ",net>>24&255,net>>16&255,net>>8&255,net&255);
- mask=-1;
+ mask=~0;
mask>>=(32-cidr);
mask<<=(32-cidr);
printf("%d.%d.%d.%d\n",mask>>24&255,mask>>16&255,mask>>8&255,mask&255);
+ return 0;
}
diff --git a/src/bin/dragonturn.c b/src/bin/dragonturn.c
index a12bb97..958eeef 100644
--- a/src/bin/dragonturn.c
+++ b/src/bin/dragonturn.c
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <string.h>
+#include <stdlib.h>
int main(int argc,char *argv[]) {
int i,j;
char turns[1024]="R",append[1024],tmp[1024];
@@ -11,4 +12,5 @@ int main(int argc,char *argv[]) {
strcat(turns,tmp);
}
printf("F%s\n",turns);
+ return 0;
}
diff --git a/src/bin/filemon.c b/src/bin/filemon.c
index 2f0af24..ef7582b 100644
--- a/src/bin/filemon.c
+++ b/src/bin/filemon.c
@@ -10,27 +10,21 @@
#include <fcntl.h>
#include <err.h>
-int main(int argc, char *argv[]) {
- if(argc < 2) {
- printf("usage: filemon file [prog]");
- return 1;
- }
- monitor(argv[1],argv[2]);
-}
-
int monitor(char *file,char *handler) {
int fd, kq, nev;
struct kevent ev;
struct stat sb;
- char buffer[
+// char buffer[
static const struct timespec tout = { 1, 0 };
- if ((fd = open(file, O_RDONLY)) == -1) err(1, "Cannot open `%s'", argv[1]);
+ if ((fd = open(file, O_RDONLY)) == -1) err(1, "Cannot open `%s'", file);
fstat(fd,&sb);
if(S_ISDIR(sb.st_mode)) {
//read list of files from dir?
//rerun self on all files in that dir.
//system("filemon file/*"); //XD
- getdents(fd,,);
+ //getdents(fd,,); //I have code to do this in the MUD
+ printf("warning: this doesn't show changes of file in the dir.");
+ printf("warning: it just shows changes of the dir itself.");
}
if ((kq = kqueue()) == -1) err(1, "Cannot create kqueue");
EV_SET(&ev,
@@ -45,16 +39,16 @@ int monitor(char *file,char *handler) {
nev = kevent(kq, NULL, 0, &ev, 1, &tout);
if (nev == -1) err(1, "kevent");
if (nev == 0) continue;
- printf("nev:%x\n",nev);//probably fd that triggered event?
- printf("ev.ident:%x\n",ev.ident);
- printf("ev.filter:%x\n",ev.filter);
- printf("ev.flags:%x\n",ev.flags);
- printf("ev.fflags:%x\n",ev.fflags);
- printf("ev.data:%x\n",ev.data);
- printf("ev.udata:%x\n",ev.udata);
+ //printf("nev:%x\n",nev);//probably fd that triggered event?
+ //printf("ev.ident:%x\n",ev.ident);
+ //printf("ev.filter:%x\n",ev.filter);
+ //printf("ev.flags:%x\n",ev.flags);
+ //printf("ev.fflags:%x\n",ev.fflags);
+ //printf("ev.data:%x\n",ev.data);
+ //printf("ev.udata:%x\n",ev.udata);
if (ev.fflags & (NOTE_DELETE|NOTE_WRITE|NOTE_EXTEND|NOTE_ATTRIB|NOTE_LINK|NOTE_RENAME|NOTE_REVOKE)) {
printf("%s: ",file);
- if(argv[2]) system(handler);
+ if(handler) system(handler);
}
if (ev.fflags & NOTE_DELETE) {
printf("deleted ");
@@ -91,3 +85,11 @@ int monitor(char *file,char *handler) {
}
return 0;
}
+
+int main(int argc, char *argv[]) {
+ if(argc < 2) {
+ printf("usage: filemon file [prog]");
+ return 1;
+ }
+ return monitor(argv[1],argv[2]);
+}
diff --git a/src/bin/fontbuild.c b/src/bin/fontbuild.c
index b4a212a..09c0beb 100644
--- a/src/bin/fontbuild.c
+++ b/src/bin/fontbuild.c
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
+#include <unistd.h>
int main(int argc,char *argv[]) {
int i,j,k;
diff --git a/src/bin/fontdump.c b/src/bin/fontdump.c
index 1ed2b05..58702a8 100644
--- a/src/bin/fontdump.c
+++ b/src/bin/fontdump.c
@@ -1,5 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <ctype.h>
+#include <unistd.h>
int main(int argc,char *argv[]) {
int i,j,k;
diff --git a/src/bin/great.c b/src/bin/great.c
index 11976b8..9a554fc 100644
--- a/src/bin/great.c
+++ b/src/bin/great.c
@@ -9,68 +9,52 @@
#include <net/if.h>
#include <net/if_gre.h>
-#define PORT 1013
-
/*great = gre auto tunnel*/
-void dump(unsigned char *b,unsigned int t) {
- for(;t;b++,t--) printf("%02x ",*b);
-}
-
-/* TODO:
- args.
- password?
- clean out the extra shit.
- clean it up even more.
-
- arguments:
- interface
- listen-port
- listen-addr
- password?
-*/
int main(int argc,char *argv[]) {
struct sockaddr_in sa;
struct sockaddr_in from;
- char buf[512];
+ char in;
socklen_t sl=sizeof(struct sockaddr_in);
int so_link=socket(AF_LINK,SOCK_DGRAM,0);
- int so_unspec=socket(AF_UNSPEC,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));
- sa.sin_addr.s_addr=inet_addr("192.168.0.2");
- sa.sin_port=htons(PORT);
+ if(argc < 4) {
+ printf("usage: %s interface address port",argv[0]);
+ printf("example: %s gre0 192.168.0.2 1013",argv[0]);
+ return 1;
+ }
+ sa.sin_addr.s_addr=inet_addr(argv[2]);
+ sa.sin_port=htons(atoi(argv[3]));
sa.sin_family=PF_INET;
bind(so,(struct sockaddr *)&sa,sizeof(sa));
- recvfrom(so,buf,sizeof(buf),0,(struct sockaddr *)&from,&sl);
- connect(so,(struct sockaddr *)&from,sl);
+ recvfrom(so,&in,1,0,(struct sockaddr *)&from,&sl);
struct in_addr addr = {from.sin_addr.s_addr};
- printf("%s\n",inet_ntoa(addr));
+ 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));
memset(asdf,0,sizeof(struct ifreq));
- strcpy(asdf->ifr_name,"gre10");
+ strcpy(asdf->ifr_name,argv[1]);
printf("destroy: %d\n",ioctl(so_link,SIOCIFDESTROY,asdf));//destroy
memset(asdf,0,sizeof(struct ifreq));
- strcpy(asdf->ifr_name,"gre10");
+ 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,"gre10");
+ 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,"gre10");
+ strcpy(asdf->ifr_name,argv[1]);
asdf->ifr_value=so;
printf("gressock: %d\n",ioctl(so_inet,GRESSOCK,asdf));//set socket
-
- sleep(1);
- system("ifconfig gre10");//just so you can see what it looks like.
return 0;
}
diff --git a/src/bin/ipgen.c b/src/bin/ipgen.c
index 7aae99e..1818bf1 100644
--- a/src/bin/ipgen.c
+++ b/src/bin/ipgen.c
@@ -1,4 +1,5 @@
#include <stdio.h>
+#include <arpa/inet.h>
void print_ip(unsigned int i) {
printf("%d.%d.%d.%d\n",(i>>24)&255,(i>>16)&255,(i>>8)&255,i&255);
@@ -22,7 +23,7 @@ int main(int argc,char *argv[]) {
}
for(i=0;(mask>>i&1);inc<<=1,i++);
min=net&mask;
- max=net&mask|(~mask);
+ max=((net&mask)|(~mask));
if(argc > 3) {
printf("net: ");
print_ip(net);
diff --git a/src/bin/iplist2cidr.c b/src/bin/iplist2cidr.c
index b3cc62c..f909b62 100644
--- a/src/bin/iplist2cidr.c
+++ b/src/bin/iplist2cidr.c
@@ -1,5 +1,7 @@
#include <stdio.h>
#include <string.h>
+#include <arpa/inet.h>
+#include <stdlib.h>
struct net {
unsigned int ip;
diff --git a/src/bin/iprand.c b/src/bin/iprand.c
index e6b2f83..a0893a3 100644
--- a/src/bin/iprand.c
+++ b/src/bin/iprand.c
@@ -1,5 +1,8 @@
#include <stdio.h>
#include <time.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <arpa/inet.h>
int main(int argc,char *argv[]) {
srandom(time(0)+getpid());
@@ -14,4 +17,5 @@ int main(int argc,char *argv[]) {
ip |= net;
printf("%d.%d.%d.%d\n",ip>>24&255,ip>>16&255,ip>>8&255,ip&255);
}
+ return 0;
}
diff --git a/src/bin/lineplot.c b/src/bin/lineplot.c
index 781a85a..141f34d 100644
--- a/src/bin/lineplot.c
+++ b/src/bin/lineplot.c
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <string.h>
+#include <unistd.h>
#define WIDTH 39
#define HEIGHT 24
char buff[WIDTH*HEIGHT*4];
@@ -15,4 +16,5 @@ int main(int argc,char *argv[]) {
while(scanf("%d %d %d %d",&x1,&y1,&x2,&y2) == 4)
draw_line((x1+8)*2,(y1+8)*2,(x2+8)*2,(y2+8)*2);
for(y=0;y<HEIGHT*2;y++,write(1,"\n",1)) write(1,buff+(y*WIDTH*2),WIDTH*2);
+ return 0;
}
diff --git a/src/bin/rrd.c b/src/bin/rrd.c
index 067fede..9454fba 100644
--- a/src/bin/rrd.c
+++ b/src/bin/rrd.c
@@ -44,7 +44,7 @@ void print_sa6(struct sockaddr *sa) {
void p_rtentry(struct rt_msghdr *rtm) {
struct sockadrr *sa;
- sa = (struct sockaddr *)(rtm+1);
+ sa = (((struct sockaddr *)rtm)+1);
struct sockaddr *rti_info[RTAX_MAX];
get_rtaddrs(rtm->rtm_addrs, (struct sockaddr *)sa, rti_info);
diff --git a/src/bin/tcpident.c b/src/bin/tcpident.c
index 1af3bc1..eb15074 100644
--- a/src/bin/tcpident.c
+++ b/src/bin/tcpident.c
@@ -3,6 +3,7 @@
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/sysctl.h>
+#include <stdlib.h>
#include <netinet/in.h>
#include <netinet/ip_var.h>
diff --git a/src/bin/turn2line.c b/src/bin/turn2line.c
index a5de23c..78e4b33 100644
--- a/src/bin/turn2line.c
+++ b/src/bin/turn2line.c
@@ -1,6 +1,7 @@
#include <stdio.h>
+#include <stdlib.h>
int main(int argc,char *argv[]) {
- int in,x=0,dx,y=0,dy,h=0,dh=argc<2?-4:atoi(argv[1]);
+ int in,x=0,y=0,h=0,dh=argc<2?-4:atoi(argv[1]);
for(;(in=fgetc(stdin)) != -1;dh=-4) {
if(dh == -4) {
switch(in) { case'B':dh++;case'm':dh++;case'L':dh++;case'l':dh++;
@@ -13,4 +14,5 @@ int main(int argc,char *argv[]) {
y+=(signed char)"\x00\x01\x01\x01\x00\xff\xff\xff"[h%8];
printf("%d %d\n",x,y);
}
+ return 0;
}
diff --git a/src/bin/urcdump.c b/src/bin/urcdump.c
index 0fea8ed..f848384 100644
--- a/src/bin/urcdump.c
+++ b/src/bin/urcdump.c
@@ -1,6 +1,11 @@
+#include <string.h>
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <unistd.h>
#define BS 4096
@@ -9,8 +14,8 @@ int main(int argc,char *argv[]) {
struct sockaddr_in name;
//char *tmp;
int tmp;
- char chunk[BS];
- int off=0;
+ //char chunk[BS];
+ //int off=0;
char buf[BS];
int len=sizeof(struct sockaddr_in);
if(argc < 3) {
@@ -27,7 +32,7 @@ int main(int argc,char *argv[]) {
while((len=read(s,buf,BS-1)) > 0) {
for(tmp=0;tmp<len;tmp++) {
- if(isprint(*(buf+tmp))) {
+ if(isprint((short)*(buf+tmp))) {
write(1,(buf+tmp),1);
} else {
write(1,"%",1);
@@ -56,4 +61,5 @@ int main(int argc,char *argv[]) {
}
*/
}
+ return 0;
}