|
|
1.1 root 1: /*
2: * Generic dialer routine. Usage:
3: * dialer mount-pt [unit]
4: */
5: #include <stdio.h>
6: #include <ipc.h>
7: #include <sys/filio.h>
8: #include <libc.h>
9:
10: /* export */
11: char *av0;
12: int debug;
13:
14: /* cheap foiegn imports */
15: extern void dodialout(), dodialin();
16:
17: usage(name)
18: char *name;
19: {
20: fprintf(stderr, "usage: %s [-m mount-pt]\n", name);
21: exit(1);
22: }
23:
24: main(ac, av)
25: int ac;
26: char *av[];
27: {
28: char *mtpt="tcp", *cp;
29: int ai;
30:
31: av0 = av[0];
32: chdir("/cs");
33: for (ai=1; ai<ac; ai++) {
34: if (av[ai][0] == '-')
35: for (cp= &av[ai][1]; *cp; cp++) {
36: switch(*cp) {
37: case 'd':
38: debug = 1;
39: break;
40: case 'm':
41: if (ai+1>=ac || *cp!='m')
42: usage(av0);
43: mtpt = av[++ai];
44: break;
45: default:
46: usage(av0);
47: }
48: }
49: else
50: usage(av[0]);
51: }
52: if (!debug)
53: detach(mtpt);
54:
55: tcpconfig();
56:
57: /* create dialer and listener */
58: switch (fork()) {
59: case -1:
60: perror(av0);
61: exit(1);
62: case 0:
63: for(;;)
64: dodialout(mtpt);
65: break;
66: default:
67: for(;;)
68: dodialin(mtpt, "seymour cray", "");
69: break;
70: }
71: }
72:
73: #define IPDEVFORTCP "/dev/iptcp"
74: tcpconfig()
75: {
76: int fd;
77: extern int tcp_ld;
78:
79: fd = open(IPDEVFORTCP, 2);
80: if(fd < 0)
81: return -1;
82: if(ioctl(fd, FIOPUSHLD, &tcp_ld) < 0) {
83: close(fd);
84: return -1;
85: }
86: logevent("tcp active\n");
87: return 0;
88: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.