|
|
1.1 root 1: /* tsapmgmt.c - management info reporting routines */
2:
3: #ifndef lint
4: static char *rcsid = "$Header: /f/osi/tsap/RCS/tsapmgmt.c,v 7.2 90/06/12 02:19:52 mrose Exp $";
5: #endif
6:
7: /*
8: * $Header: /f/osi/tsap/RCS/tsapmgmt.c,v 7.2 90/06/12 02:19:52 mrose Exp $
9: *
10: *
11: * $Log: tsapmgmt.c,v $
12: * Revision 7.2 90/06/12 02:19:52 mrose
13: * typo
14: *
15: * Revision 7.1 90/03/23 17:31:45 mrose
16: * 8
17: *
18: * Revision 7.0 89/11/23 22:30:53 mrose
19: * Release 6.0
20: *
21: */
22:
23: /*
24: * NOTICE
25: *
26: * Acquisition, use, and distribution of this module and related
27: * materials are subject to the restrictions of a license agreement.
28: * Consult the Preface in the User's Manual for the full terms of
29: * this agreement.
30: *
31: */
32:
33:
34: /* LINTLIBRARY */
35:
36: #include <stdio.h>
37: #include <varargs.h>
38: #include "tpkt.h"
39: #include "mpkt.h"
40:
41:
42: #ifdef MGMT
43: #include "internet.h"
44:
45: #define LOCALTHLD 128 /* local threshold for reporting (bytes) */
46:
47: /* */
48:
49: static long pid = OK;
50: static int ManSoc;
51: static struct MReport TsapInfo;
52: static struct qbuf data;
53:
54: /* */
55:
56: /* VARARGS2 */
57:
58: int TManGen (va_alist)
59: va_dcl
60: {
61: int a,
62: result;
63: struct TSAPaddr *b;
64: unsigned int type;
65: register struct tsapblk *tb;
66: va_list ap;
67:
68: va_start (ap);
69:
70: type = va_arg (ap, unsigned int);
71: tb = va_arg (ap, struct tsapblk *);
72: a = 0, b = NULLTA;
73: switch (type) {
74: case USERDT:
75: case USERDR:
76: a = va_arg (ap, int);
77: break;
78:
79: case STARTLISTEN:
80: case ENDLISTEN:
81: b = va_arg (ap, struct TSAPaddr *);
82: break;
83:
84: default:
85: break;
86: }
87:
88: result = TManGenAux (type, tb, a, b);
89:
90: va_end (ap);
91:
92: return result;
93: }
94:
95: /* */
96:
97: #define SendMReport() write_udp_socket (ManSoc, &data)
98:
99:
100: static int TManGenAux (type, tb, a, b)
101: unsigned int type;
102: struct tsapblk * tb;
103: int a;
104: struct TSAPaddr *b;
105: {
106: if (pid == NOTOK)
107: return NOTOK;
108:
109: if (pid == OK && ManInit () == NOTOK)
110: return (pid = NOTOK);
111:
112: switch (TsapInfo.type = type) {
113: case USERDT:
114: tb -> tb_pdus++;
115: if ((tb -> tb_bytes += a) < LOCALTHLD)
116: break;
117: TsapInfo.cid = tb -> tb_fd;
118: TsapInfo.u.gp.a = tb -> tb_bytes;
119: TsapInfo.u.gp.b = tb -> tb_pdus;
120: tb -> tb_bytes = 0;
121: break;
122:
123: case USERDR:
124: tb -> tb_pdur++;
125: if ((tb -> tb_byter += a) < LOCALTHLD)
126: return OK;
127: TsapInfo.cid = tb -> tb_fd;
128: TsapInfo.u.gp.a = tb -> tb_byter;
129: TsapInfo.u.gp.b = tb -> tb_pdur;
130: tb -> tb_byter = 0;
131: break;
132:
133: case OPREQIN:
134: case OPREQOUT:
135: TsapInfo.cid = tb -> tb_fd;
136: bcopy (tb -> tb_responding.ta_selector,
137: TsapInfo.u.taddr.tsel,
138: TsapInfo.u.taddr.tsel_len =
139: tb -> tb_responding.ta_selectlen);
140: /* struct copy */
141: TsapInfo.u.taddr.nsap = tb -> tb_responding.ta_addr;
142: if (SendMReport () == NOTOK)
143: return NOTOK;
144:
145: TsapInfo.type = SOURCEADDR;
146: bcopy (tb -> tb_initiating.ta_selector,
147: TsapInfo.u.taddr.tsel,
148: TsapInfo.u.taddr.tsel_len =
149: tb -> tb_initiating.ta_selectlen);
150: /* struct copy */
151: TsapInfo.u.taddr.nsap = tb -> tb_initiating.ta_addr;
152: break;
153:
154: case DISCREQ:
155: TsapInfo.cid = tb -> tb_fd;
156: TsapInfo.u.gp.a = tb -> tb_bytes;
157: TsapInfo.u.gp.b = tb -> tb_byter;
158: TsapInfo.u.gp.c = tb -> tb_pdus;
159: TsapInfo.u.gp.d = tb -> tb_pdur;
160: break;
161:
162: case PROTERR:
163: case CONGEST:
164: case CONFIGBAD:
165: case OPREQINBAD:
166: case OPREQOUTBAD:
167: TsapInfo.cid = tb -> tb_fd;
168: break;
169:
170: case STARTLISTEN:
171: case ENDLISTEN:
172: bcopy (b -> ta_selector,
173: TsapInfo.u.taddr.tsel,
174: TsapInfo.u.taddr.tsel_len = b -> ta_selectlen);
175: TsapInfo.u.taddr.nsap = b -> ta_addrs[0]; /* struct copy */
176: break;
177:
178: default:
179: return NOTOK;
180: }
181: return SendMReport ();
182: }
183:
184: /* */
185:
186: static int ManInit () {
187: struct sockaddr_in sin;
188: register struct sockaddr_in *sock = &sin;
189: register struct servent *sp;
190: register struct hostent *hp;
191:
192: if ((sp = getservbyname ("manager", "udp")) == NULL
193: || (hp = gethostbyname ("localhost")) == NULL)
194: return NOTOK;
195:
196: bzero((char *) sock, sizeof *sock);
197: sock -> sin_family = hp -> h_addrtype;
198: inaddr_copy (hp, sock);
199: if ((ManSoc = start_udp_client (sock, 0, SO_DONTROUTE, 0)) == NOTOK)
200: return NOTOK;
201:
202: sock -> sin_port = sp -> s_port;
203: if (join_udp_server (ManSoc, sock) == NOTOK)
204: return NOTOK;
205:
206: TsapInfo.id = pid = getpid();
207: data.qb_data = (char *) &TsapInfo;
208: data.qb_len = sizeof TsapInfo;
209:
210: return OK;
211: }
212:
213: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.