|
|
1.1 root 1: /*-
2: * Copyright (c) 1988, 1990 The Regents of the University of California.
3: * All rights reserved.
4: *
5: * Redistribution and use in source and binary forms, with or without
6: * modification, are permitted provided that the following conditions
7: * are met:
8: * 1. Redistributions of source code must retain the above copyright
9: * notice, this list of conditions and the following disclaimer.
10: * 2. Redistributions in binary form must reproduce the above copyright
11: * notice, this list of conditions and the following disclaimer in the
12: * documentation and/or other materials provided with the distribution.
13: * 3. All advertising materials mentioning features or use of this software
14: * must display the following acknowledgement:
15: * This product includes software developed by the University of
16: * California, Berkeley and its contributors.
17: * 4. Neither the name of the University nor the names of its contributors
18: * may be used to endorse or promote products derived from this software
19: * without specific prior written permission.
20: *
21: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31: * SUCH DAMAGE.
32: */
33:
34: #ifndef lint
35: char copyright[] =
36: "@(#) Copyright (c) 1988, 1990 The Regents of the University of California.\n\
37: All rights reserved.\n";
38: #endif /* not lint */
39:
40: #ifndef lint
41: static char sccsid[] = "@(#)Tesis.c 7.1 (Berkeley) 5/7/91";
42: #endif /* not lint */
43:
44: /* Modifications
45: * Copyright (c) 1990 Robert Hagens
46: */
47:
48: /*
49: * This is a test program to listen to esis packets.
50: */
51: #include <sys/param.h>
52: #include <sys/uio.h>
53: #include <sys/socket.h>
54: #include <sys/ioctl.h>
55: #include <net/route.h>
56: #include <net/if.h>
57: #define TCPT_NTIMERS 4
58: #include <netiso/iso.h>
59: #include <netiso/tp_param.h>
60: #include <netiso/tp_user.h>
61:
62: #include <stdio.h>
63: #include <errno.h>
64: #include <ctype.h>
65: #include <netdb.h>
66:
67:
68: #define dbprintf if(verbose)printf
69: #define try(a,b,c) {x = (a b); dbprintf("%s%s returns %d\n",c,"a",x);\
70: if(x<0) {perror("a"); myexit(0);}}
71:
72:
73: struct ifreq ifr;
74: short port = 3000;
75: struct sockaddr_iso faddr, laddr = { sizeof(laddr), AF_ISO };
76: struct sockaddr_iso *siso = &laddr;
77: char **xenvp;
78:
79: long size, count = 10, forkp, confp, echop, mynamep, verbose = 1, playtag = 0;
80: long records, intercept = 0, isode_mode;
81:
82: char buf[2048];
83: char your_it[] = "You're it!";
84:
85: char *Servername;
86:
87: main(argc, argv, envp)
88: int argc;
89: char *argv[];
90: char *envp[];
91: {
92: tisink();
93: }
94: #define BIG 2048
95: #define MIDLIN 512
96: char readbuf[BIG];
97: struct iovec iov[1] = {
98: readbuf,
99: sizeof readbuf,
100: };
101: char name[MIDLIN];
102: union {
103: struct {
104: struct cmsghdr cmhdr;
105: char cmdata[128 - sizeof(struct cmsghdr)];
106: } cm;
107: char data[128];
108: } cbuf;
109: #define control cbuf.data
110: struct msghdr msghdr = {
111: name, sizeof(name),
112: iov, sizeof(iov)/sizeof(iov[1]),
113: control, sizeof control,
114: 0 /* flags */
115: };
116:
117: tisink()
118: {
119: int x, s, pid, on = 1, loop = 0, n, fromlen, flags = 0;
120: extern int errno;
121:
122: try(socket, (AF_ISO, SOCK_DGRAM, ISOPROTO_ESIS),"");
123: s = x;
124:
125: for(;;) {
126: fromlen = sizeof(name);
127: try(recvfrom, (s, readbuf, sizeof(readbuf), flags,
128: name, &fromlen), "");
129: n = x;
130: dumpit("connection from:", name, fromlen);
131: dumpit("packet is:", readbuf, n);
132: }
133: }
134: answerback(flags, n, ns)
135: {
136: msghdr.msg_controllen = 0;
137: msghdr.msg_iovlen = 1;
138: iov->iov_len = n;
139: n = sendmsg(ns, &msghdr, flags);
140: dbprintf("echoed %d\n", n);
141: return n;
142: }
143:
144: dumpit(what, where, n)
145: char *what; unsigned short *where; int n;
146: {
147: unsigned short *s = where;
148: unsigned short *z = where + (n+1)/2;
149: int count = 0;
150: printf(what);
151: while(s < z) {
152: count++;
153: printf("%x ",*s++);
154: if ((count & 15) == 0)
155: putchar('\n');
156: }
157: if (count & 15)
158: putchar('\n');
159: fflush(stdout);
160: }
161: myexit(n)
162: {
163: fflush(stderr);
164: printf("got %d records\n", records);
165: fflush(stdout);
166: exit(n);
167: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.