fix auto-quoting screwup
[unix-history] / usr / src / sys / tests / netiso / Tesis.c
CommitLineData
a529adbe
KB
1/*-
2 * Copyright (c) 1988, 1990 The Regents of the University of California.
c57dfcf9
KS
3 * All rights reserved.
4 *
5 * %sccs.include.redist.c%
6 */
a529adbe
KB
7
8#ifndef lint
9char copyright[] =
10"@(#) Copyright (c) 1988, 1990 The Regents of the University of California.\n\
11 All rights reserved.\n";
12#endif /* not lint */
13
14#ifndef lint
15static char sccsid[] = "@(#)Tesis.c 7.1 (Berkeley) %G%";
16#endif /* not lint */
17
c57dfcf9
KS
18/* Modifications
19 * Copyright (c) 1990 Robert Hagens
20 */
c57dfcf9
KS
21
22/*
23 * This is a test program to listen to esis packets.
24 */
25#include <sys/param.h>
26#include <sys/uio.h>
27#include <sys/socket.h>
28#include <sys/ioctl.h>
29#include <net/route.h>
30#include <net/if.h>
31#define TCPT_NTIMERS 4
32#include <netiso/iso.h>
33#include <netiso/tp_param.h>
34#include <netiso/tp_user.h>
35
36#include <stdio.h>
37#include <errno.h>
38#include <ctype.h>
39#include <netdb.h>
40
41
42#define dbprintf if(verbose)printf
43#define try(a,b,c) {x = (a b); dbprintf("%s%s returns %d\n",c,"a",x);\
44 if(x<0) {perror("a"); myexit(0);}}
45
46
47struct ifreq ifr;
48short port = 3000;
49struct sockaddr_iso faddr, laddr = { sizeof(laddr), AF_ISO };
50struct sockaddr_iso *siso = &laddr;
51char **xenvp;
52
53long size, count = 10, forkp, confp, echop, mynamep, verbose = 1, playtag = 0;
54long records, intercept = 0, isode_mode;
55
56char buf[2048];
57char your_it[] = "You're it!";
58
59char *Servername;
60
61main(argc, argv, envp)
62int argc;
63char *argv[];
64char *envp[];
65{
66 tisink();
67}
68#define BIG 2048
69#define MIDLIN 512
70char readbuf[BIG];
71struct iovec iov[1] = {
72 readbuf,
73 sizeof readbuf,
74};
75char name[MIDLIN];
76union {
77 struct {
78 struct cmsghdr cmhdr;
79 char cmdata[128 - sizeof(struct cmsghdr)];
80 } cm;
81 char data[128];
82} cbuf;
83#define control cbuf.data
84struct msghdr msghdr = {
85 name, sizeof(name),
86 iov, sizeof(iov)/sizeof(iov[1]),
87 control, sizeof control,
88 0 /* flags */
89};
90
91tisink()
92{
93 int x, s, pid, on = 1, loop = 0, n, fromlen, flags = 0;
94 extern int errno;
95
96 try(socket, (AF_ISO, SOCK_DGRAM, ISOPROTO_ESIS),"");
97 s = x;
98
99 for(;;) {
100 fromlen = sizeof(name);
101 try(recvfrom, (s, readbuf, sizeof(readbuf), flags,
102 name, &fromlen), "");
103 n = x;
104 dumpit("connection from:", name, fromlen);
105 dumpit("packet is:", readbuf, n);
106 }
107}
108answerback(flags, n, ns)
109{
110 msghdr.msg_controllen = 0;
111 msghdr.msg_iovlen = 1;
112 iov->iov_len = n;
113 n = sendmsg(ns, &msghdr, flags);
114 dbprintf("echoed %d\n", n);
115 return n;
116}
117
118dumpit(what, where, n)
119char *what; unsigned short *where; int n;
120{
121 unsigned short *s = where;
122 unsigned short *z = where + (n+1)/2;
123 int count = 0;
124 printf(what);
125 while(s < z) {
126 count++;
127 printf("%x ",*s++);
128 if ((count & 15) == 0)
129 putchar('\n');
130 }
131 if (count & 15)
132 putchar('\n');
133 fflush(stdout);
134}
135myexit(n)
136{
137 fflush(stderr);
138 printf("got %d records\n", records);
139 fflush(stdout);
140 exit(n);
141}