Generally use NULL instead of explicitly casting 0 to some pointer type (part2).
[dragonfly.git] / sys / netproto / atm / spans / spans_print.c
1 /*
2  *
3  * ===================================
4  * HARP  |  Host ATM Research Platform
5  * ===================================
6  *
7  *
8  * This Host ATM Research Platform ("HARP") file (the "Software") is
9  * made available by Network Computing Services, Inc. ("NetworkCS")
10  * "AS IS".  NetworkCS does not provide maintenance, improvements or
11  * support of any kind.
12  *
13  * NETWORKCS MAKES NO WARRANTIES OR REPRESENTATIONS, EXPRESS OR IMPLIED,
14  * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
15  * AND FITNESS FOR A PARTICULAR PURPOSE, AS TO ANY ELEMENT OF THE
16  * SOFTWARE OR ANY SUPPORT PROVIDED IN CONNECTION WITH THIS SOFTWARE.
17  * In no event shall NetworkCS be responsible for any damages, including
18  * but not limited to consequential damages, arising from or relating to
19  * any use of the Software or related support.
20  *
21  * Copyright 1994-1998 Network Computing Services, Inc.
22  *
23  * Copies of this Software may be made, however, the above copyright
24  * notice must be reproduced on all copies.
25  *
26  *      @(#) $FreeBSD: src/sys/netatm/spans/spans_print.c,v 1.6 1999/08/28 00:48:50 peter Exp $
27  *      @(#) $DragonFly: src/sys/netproto/atm/spans/spans_print.c,v 1.8 2006/12/22 23:57:54 swildner Exp $
28  */
29
30 /*
31  * SPANS Signalling Manager
32  * ---------------------------
33  *
34  * SPANS Print Routines.
35  *
36  */
37
38 #include <netproto/atm/kern_include.h>
39
40 #include "spans_xdr.h"
41 #include "spans_var.h"
42
43 /*
44  * If LONGPRINT is defined, every field of the SPANS message will be
45  * printed.  If not, a shorter summary (useful for debugging without
46  * swamping the console) is printed.
47  */
48 /* #define LONGPRINT */
49
50 /*
51  * Local functions
52  */
53 static void     spans_msgtype_str (spans_msgtype *, char *, int);
54 static void     spans_print_msgbody (spans_msgbody *);
55 static void     spans_result_str (spans_result *, char *, int);
56
57 #ifdef LONGPRINT
58
59 static void     inc_indent (void);
60 static void     dec_indent (void);
61 static void     spans_aal_str (spans_aal *, char *, int);
62 static void     spans_query_type_str (spans_query_type *, char *, int);
63 static void     spans_state_str (spans_query_type *, char *, int);
64 static void     spans_print_version (spans_version *);
65 static void     spans_print_vpvc (spans_vpvc *);
66 static void     spans_print_vpvc_pref (spans_vpvc_pref *);
67 static void     spans_print_addr (spans_addr *);
68 static void     spans_print_sap (spans_sap *);
69 static void     spans_print_atm_conn (spans_atm_conn *);
70 static void     spans_print_resrc (spans_resrc *);
71 static void     spans_print_aal (spans_aal *);
72 static void     spans_print_result (spans_result *);
73 static void     spans_print_msgtype (spans_msgtype *);
74 static void     spans_print_parm_stat_req (spans_parm_stat_req *);
75 static void     spans_print_parm_stat_ind (spans_parm_stat_ind *);
76 static void     spans_print_parm_stat_rsp (spans_parm_stat_rsp *);
77 static void     spans_print_parm_open_req (spans_parm_open_req *);
78 static void     spans_print_parm_open_ind (spans_parm_open_ind *);
79 static void     spans_print_parm_open_rsp (spans_parm_open_rsp *);
80 static void     spans_print_parm_open_cnf (spans_parm_open_cnf *);
81 static void     spans_print_parm_close_req (spans_parm_close_req *);
82 static void     spans_print_parm_close_ind (spans_parm_close_ind *);
83 static void     spans_print_parm_close_rsp (spans_parm_close_rsp *);
84 static void     spans_print_parm_close_cnf (spans_parm_close_cnf *);
85 static void     spans_print_parm_rclose_req (spans_parm_rclose_req *);
86 static void     spans_print_parm_rclose_ind (spans_parm_rclose_ind *);
87 static void     spans_print_parm_rclose_rsp (spans_parm_rclose_rsp *);
88 static void     spans_print_parm_rclose_cnf (spans_parm_rclose_cnf *);
89 static void     spans_print_parm_multi_req (spans_parm_multi_req *);
90 static void     spans_print_parm_multi_ind (spans_parm_multi_ind *);
91 static void     spans_print_parm_multi_rsp (spans_parm_multi_rsp *);
92 static void     spans_print_parm_multi_cnf (spans_parm_multi_cnf *);
93 static void     spans_print_parm_add_req (spans_parm_add_req *);
94 static void     spans_print_parm_add_ind (spans_parm_add_ind *);
95 static void     spans_print_parm_add_rsp (spans_parm_add_rsp *);
96 static void     spans_print_parm_add_cnf (spans_parm_add_cnf *);
97 static void     spans_print_parm_join_req (spans_parm_join_req *);
98 static void     spans_print_parm_join_cnf (spans_parm_join_cnf *);
99 static void     spans_print_parm_leave_req (spans_parm_leave_req *);
100 static void     spans_print_parm_leave_cnf (spans_parm_leave_cnf *);
101 static void     spans_print_parm_vcir_ind (spans_parm_vcir_ind *);
102 static void     spans_print_parm_query_req (spans_parm_query_req *);
103 static void     spans_print_parm_query_rsp (spans_parm_query_rsp *);
104
105
106 /*
107  * Local variables
108  */
109 #define MAX_INDENT      10
110 #define INIT_INDENT     &indent_str[MAX_INDENT]
111 static char *spans_indent;
112 static char indent_str[11] = "          ";
113
114 static void
115 inc_indent(void)
116 {
117         if (spans_indent != &indent_str[0]) {
118                 spans_indent--;
119         }
120 }
121
122 static void
123 dec_indent(void)
124 {
125         if (spans_indent != INIT_INDENT) {
126                 spans_indent++;
127         }
128 }
129
130 static void
131 spans_aal_str(spans_aal *objp, char *dest, int len)
132 {
133         static char     *aal_names[] = {
134                 "SPANS_AAL0",
135                 "SPANS_AAL1",
136                 "SPANS_AAL2",
137                 "SPANS_AAL3",
138                 "SPANS_AAL4",
139                 "SPANS_AAL5"
140         };
141
142         if (*objp < SPANS_AAL0 || *objp > SPANS_AAL5) {
143                 ksnprintf(dest, len, "Invalid (%d)", (int)*objp);
144         } else {
145                 ksnprintf(dest, len, "%s (%d)", aal_names[(int)*objp],
146                                 (int)*objp);
147         }
148 }
149
150 #endif 
151
152 static void
153 spans_result_str(spans_result *objp, char *dest, int len)
154 {
155         static char     *result_names[] = {
156                 "SPANS_OK",
157                 "SPANS_FAIL",
158                 "SPANS_NOVPVC",
159                 "SPANS_NORSC",
160                 "SPANS_BADDEST"
161         };
162
163         if (*objp < SPANS_OK || *objp > SPANS_BADDEST) {
164                 ksnprintf(dest, len, "Invalid (%d)", (int)*objp);
165         } else {
166                 ksnprintf(dest, len, "%s (%d)",
167                                 result_names[(int)*objp], (int)*objp);
168         }
169 }
170
171 static void
172 spans_msgtype_str(spans_msgtype *objp, char *dest, int len)
173 {
174         int     i;
175
176         static struct {
177                 spans_msgtype   type;
178                 char            *name;
179         } msgtype_names[] = {
180                 { SPANS_STAT_REQ,       "SPANS_STAT_REQ" },
181                 { SPANS_STAT_IND,       "SPANS_STAT_IND" },
182                 { SPANS_STAT_RSP,       "SPANS_STAT_RSP" },
183                 { SPANS_OPEN_REQ,       "SPANS_OPEN_REQ" },
184                 { SPANS_OPEN_IND,       "SPANS_OPEN_IND" },
185                 { SPANS_OPEN_RSP,       "SPANS_OPEN_RSP" },
186                 { SPANS_OPEN_CNF,       "SPANS_OPEN_CNF" },
187                 { SPANS_CLOSE_REQ,      "SPANS_CLOSE_REQ" },
188                 { SPANS_CLOSE_IND,      "SPANS_CLOSE_IND" },
189                 { SPANS_CLOSE_RSP,      "SPANS_CLOSE_RSP" },
190                 { SPANS_CLOSE_CNF,      "SPANS_CLOSE_CNF" },
191                 { SPANS_RCLOSE_REQ,     "SPANS_RCLOSE_REQ" },
192                 { SPANS_RCLOSE_IND,     "SPANS_RCLOSE_IND" },
193                 { SPANS_RCLOSE_RSP,     "SPANS_RCLOSE_RSP" },
194                 { SPANS_RCLOSE_CNF,     "SPANS_RCLOSE_CNF" },
195                 { SPANS_MULTI_REQ,      "SPANS_MULTI_REQ" },
196                 { SPANS_MULTI_IND,      "SPANS_MULTI_IND" },
197                 { SPANS_MULTI_RSP,      "SPANS_MULTI_RSP" },
198                 { SPANS_MULTI_CNF,      "SPANS_MULTI_CNF" },
199                 { SPANS_ADD_REQ,        "SPANS_ADD_REQ" },
200                 { SPANS_ADD_IND,        "SPANS_ADD_IND" },
201                 { SPANS_ADD_RSP,        "SPANS_ADD_RSP" },
202                 { SPANS_ADD_CNF,        "SPANS_ADD_CNF" },
203                 { SPANS_JOIN_REQ,       "SPANS_JOIN_REQ" },
204                 { SPANS_JOIN_CNF,       "SPANS_JOIN_CNF" },
205                 { SPANS_LEAVE_REQ,      "SPANS_LEAVE_REQ" },
206                 { SPANS_LEAVE_CNF,      "SPANS_LEAVE_CNF" },
207                 { SPANS_VCIR_IND,       "SPANS_VCIR_IND" },
208                 { SPANS_QUERY_REQ,      "SPANS_QUERY_REQ" },
209                 { SPANS_QUERY_RSP,      "SPANS_QUERY_RSP" },
210                 { 0,                    NULL }
211         };
212
213         /*
214          * Search the name table for the specified type
215          */
216         for (i=0; msgtype_names[i].name; i++) {
217                 if (*objp == msgtype_names[i].type) {
218                         ksnprintf(dest, len, "%s (%d)",
219                                         msgtype_names[i].name,
220                                         (int)*objp);
221                         return;
222                 }
223         }
224
225         /*
226          * Type was not found--return an error indicator
227          */
228         ksnprintf(dest, len, "Invalid (%d)", (int)*objp);
229 }
230
231 #ifdef LONGPRINT 
232
233 static void
234 spans_query_type_str(spans_query_type *objp, char *dest, int len)
235 {
236         static char     *query_names[] = {
237                 "SPANS_QUERY_NORMAL",
238                 "SPANS_QUERY_DEBUG",
239                 "SPANS_QUERY_END_TO_END"
240         };
241
242         if (*objp < SPANS_QUERY_NORMAL ||
243                         *objp > SPANS_QUERY_END_TO_END) {
244                 ksnprintf(dest, len, "Invalid (%d)", (int)*objp);
245         } else {
246                 ksnprintf(dest, len, "%s (%d)", query_names[(int)*objp],
247                                 (int)*objp);
248         }
249 }
250
251 static void
252 spans_state_str(spans_query_type *objp, char *dest, int len)
253 {
254         static char     *state_names[] = {
255                 "SPANS_CONN_OPEN",
256                 "SPANS_CONN_OPEN_PEND",
257                 "SPANS_CONN_CLOSE_PEND",
258                 "SPANS_CONN_CLOSED"
259         };
260
261         if (*objp < SPANS_CONN_OPEN || *objp > SPANS_CONN_CLOSED) {
262                 ksnprintf(dest, len, "Invalid (%d)", (int)*objp);
263         } else {
264                 ksnprintf(dest, len, "%s (%d)", state_names[(int)*objp],
265                                 (int)*objp);
266         }
267 }
268
269
270 static void
271 spans_print_version(spans_version *objp)
272 {
273         kprintf("%sspans_version        0x%x\n", spans_indent, *objp);
274 }
275
276 static void
277 spans_print_vpvc(spans_vpvc *objp)
278 {
279         kprintf("%sVP/VC                %d/%d\n", spans_indent,
280                         SPANS_EXTRACT_VPI(*objp),
281                         SPANS_EXTRACT_VCI(*objp));
282 }
283
284 static void
285 spans_print_vpvc_pref(spans_vpvc_pref *objp)
286 {
287         kprintf("%sspans_vpvc_pref\n", spans_indent);
288         inc_indent();
289         kprintf("%s%s\n", spans_indent,
290                         (objp->vpf_valid ? "Valid" : "Not valid"));
291         spans_print_vpvc(&objp->vpf_vpvc);
292         dec_indent();
293 }
294
295 static void
296 spans_print_addr(spans_addr *objp)
297 {
298         char    addr_str[80];
299
300         strncpy(addr_str, spans_addr_print(objp), sizeof(addr_str));
301         kprintf("%sspans_addr           %s\n", spans_indent, addr_str);
302 }
303
304 static void
305 spans_print_sap(spans_sap *objp)
306 {
307         kprintf("%sSAP                  %d\n", spans_indent, *objp);
308 }
309
310 static void
311 spans_print_atm_conn(spans_atm_conn *objp)
312 {
313         kprintf("%sspans_atm_conn\n", spans_indent);
314         inc_indent();
315         spans_print_addr(&objp->con_dst);
316         spans_print_addr(&objp->con_src);
317         spans_print_sap(&objp->con_dsap);
318         spans_print_sap(&objp->con_ssap);
319         dec_indent();
320 }
321
322 static void
323 spans_print_resrc(spans_resrc *objp)
324 {
325         kprintf("%sspans_resrc\n", spans_indent);
326         inc_indent();
327         kprintf("%srsc_peak             %d\n", spans_indent, objp->rsc_peak);
328         kprintf("%srsc_mean             %d\n", spans_indent, objp->rsc_mean);
329         kprintf("%srsc_burst            %d\n", spans_indent, objp->rsc_burst);
330         dec_indent();
331 }
332
333 static void
334 spans_print_aal(spans_aal *objp)
335 {
336         char            aal_str[80];
337
338         spans_aal_str(objp, aal_str, sizeof(aal_str));
339         kprintf("%sspans_aal            %s\n", spans_indent, aal_str);
340 }
341
342 static void
343 spans_print_result(spans_result *objp)
344 {
345         char            result_str[80];
346
347         spans_result_str(objp, result_str, sizeof(result_str));
348         kprintf("%sspans_result         %s\n", spans_indent, result_str);
349 }
350
351 static void
352 spans_print_msgtype(spans_msgtype *objp)
353 {
354         char            msgtype_str[80];
355
356         spans_msgtype_str(objp, msgtype_str, sizeof(msgtype_str));
357         kprintf("%sspans_msgtype        %s\n", spans_indent, msgtype_str);
358 }
359
360 static void
361 spans_print_parm_stat_req(spans_parm_stat_req *objp)
362 {
363         kprintf("%sspans_parm_stat_req\n", spans_indent);
364         inc_indent();
365         kprintf("%sstreq_es_epoch       %d\n", spans_indent,
366                         objp->streq_es_epoch);
367         dec_indent();
368 }
369
370 static void
371 spans_print_parm_stat_ind(spans_parm_stat_ind *objp)
372 {
373         kprintf("%sspans_parm_stat_ind\n", spans_indent);
374         inc_indent();
375         kprintf("%sstind_sw_epoch       %d\n", spans_indent,
376                         objp->stind_sw_epoch);
377         spans_print_addr(&objp->stind_es_addr);
378         spans_print_addr(&objp->stind_sw_addr);
379         dec_indent();
380 }
381
382 static void
383 spans_print_parm_stat_rsp(spans_parm_stat_rsp *objp)
384 {
385         kprintf("%sspans_parm_stat_rsp\n", spans_indent);
386         inc_indent();
387         kprintf("%sstrsp_es_epoch       %d\n", spans_indent,
388                         objp->strsp_es_epoch);
389         spans_print_addr(&objp->strsp_es_addr);
390         dec_indent();
391 }
392
393 static void
394 spans_print_parm_open_req(spans_parm_open_req *objp)
395 {
396         kprintf("%sspans_parm_open_req\n", spans_indent);
397         inc_indent();
398         spans_print_atm_conn(&objp->opreq_conn);
399         spans_print_aal(&objp->opreq_aal);
400         spans_print_resrc(&objp->opreq_desrsrc);
401         spans_print_resrc(&objp->opreq_minrsrc);
402         spans_print_vpvc_pref(&objp->opreq_vpvc);
403         dec_indent();
404 }
405
406 static void
407 spans_print_parm_open_ind(spans_parm_open_ind *objp)
408 {
409         kprintf("%sspans_parm_open_ind\n", spans_indent);
410         inc_indent();
411         spans_print_atm_conn(&objp->opind_conn);
412         spans_print_aal(&objp->opind_aal);
413         spans_print_resrc(&objp->opind_desrsrc);
414         spans_print_resrc(&objp->opind_minrsrc);
415         spans_print_vpvc_pref(&objp->opind_vpvc);
416         dec_indent();
417 }
418
419 static void
420 spans_print_parm_open_rsp(spans_parm_open_rsp *objp)
421 {
422         kprintf("%sspans_parm_open_rsp\n", spans_indent);
423         inc_indent();
424         spans_print_atm_conn(&objp->oprsp_conn);
425         spans_print_result(&objp->oprsp_result);
426         spans_print_resrc(&objp->oprsp_rsrc);
427         spans_print_vpvc(&objp->oprsp_vpvc);
428         dec_indent();
429 }
430
431 static void
432 spans_print_parm_open_cnf(spans_parm_open_cnf *objp)
433 {
434         kprintf("%sspans_parm_open_cnf\n", spans_indent);
435         inc_indent();
436         spans_print_atm_conn(&objp->opcnf_conn);
437         spans_print_result(&objp->opcnf_result);
438         spans_print_resrc(&objp->opcnf_rsrc);
439         spans_print_vpvc(&objp->opcnf_vpvc);
440         dec_indent();
441 }
442
443 static void
444 spans_print_parm_close_req(spans_parm_close_req *objp)
445 {
446         kprintf("%sspans_parm_close_req\n", spans_indent);
447         inc_indent();
448         spans_print_atm_conn(&objp->clreq_conn);
449         dec_indent();
450 }
451
452 static void
453 spans_print_parm_close_ind(spans_parm_close_ind *objp)
454 {
455         kprintf("%sspans_parm_close_ind\n", spans_indent);
456         inc_indent();
457         spans_print_atm_conn(&objp->clind_conn);
458         dec_indent();
459 }
460
461 static void
462 spans_print_parm_close_rsp(spans_parm_close_rsp *objp)
463 {
464         kprintf("%sspans_parm_close_rsp\n", spans_indent);
465         inc_indent();
466         spans_print_atm_conn(&objp->clrsp_conn);
467         spans_print_result(&objp->clrsp_result);
468         dec_indent();
469 }
470
471 static void
472 spans_print_parm_close_cnf(spans_parm_close_cnf *objp)
473 {
474         kprintf("%sspans_parm_close_cnf\n", spans_indent);
475         inc_indent();
476         spans_print_atm_conn(&objp->clcnf_conn);
477         spans_print_result(&objp->clcnf_result);
478         dec_indent();
479 }
480
481 static void
482 spans_print_parm_rclose_req(spans_parm_rclose_req *objp)
483 {
484         kprintf("%sspans_parm_rclose_req\n", spans_indent);
485         inc_indent();
486         spans_print_atm_conn(&objp->rcreq_conn);
487         dec_indent();
488 }
489
490 static void
491 spans_print_parm_rclose_ind(spans_parm_rclose_ind *objp)
492 {
493         kprintf("%sspans_parm_rclose_ind\n", spans_indent);
494         inc_indent();
495         spans_print_atm_conn(&objp->rcind_conn);
496         dec_indent();
497 }
498
499 static void
500 spans_print_parm_rclose_rsp(spans_parm_rclose_rsp *objp)
501 {
502         kprintf("%sspans_parm_rclose_rsp\n", spans_indent);
503         inc_indent();
504         spans_print_atm_conn(&objp->rcrsp_conn);
505         spans_print_result(&objp->rcrsp_result);
506         dec_indent();
507 }
508
509 static void
510 spans_print_parm_rclose_cnf(spans_parm_rclose_cnf *objp)
511 {
512         kprintf("%sspans_parm_rclose_cnf\n", spans_indent);
513         inc_indent();
514         spans_print_atm_conn(&objp->rccnf_conn);
515         spans_print_result(&objp->rccnf_result);
516         dec_indent();
517 }
518
519 static void
520 spans_print_parm_multi_req(spans_parm_multi_req *objp)
521 {
522         kprintf("%sspans_parm_multi_req\n", spans_indent);
523         inc_indent();
524         spans_print_atm_conn(&objp->mureq_conn);
525         spans_print_aal(&objp->mureq_aal);
526         spans_print_resrc(&objp->mureq_desrsrc);
527         spans_print_resrc(&objp->mureq_minrsrc);
528         spans_print_vpvc(&objp->mureq_vpvc);
529         dec_indent();
530 }
531
532 static void
533 spans_print_parm_multi_ind(spans_parm_multi_ind *objp)
534 {
535         kprintf("%sspans_parm_multi_ind\n", spans_indent);
536         inc_indent();
537         spans_print_atm_conn(&objp->muind_conn);
538         spans_print_aal(&objp->muind_aal);
539         spans_print_resrc(&objp->muind_desrsrc);
540         spans_print_resrc(&objp->muind_minrsrc);
541         spans_print_vpvc(&objp->muind_vpvc);
542         dec_indent();
543 }
544
545 static void
546 spans_print_parm_multi_rsp(spans_parm_multi_rsp *objp)
547 {
548         kprintf("%sspans_parm_multi_rsp\n", spans_indent);
549         inc_indent();
550         spans_print_atm_conn(&objp->mursp_conn);
551         spans_print_result(&objp->mursp_result);
552         spans_print_resrc(&objp->mursp_rsrc);
553         spans_print_vpvc(&objp->mursp_vpvc);
554         dec_indent();
555 }
556
557 static void
558 spans_print_parm_multi_cnf(spans_parm_multi_cnf *objp)
559 {
560         kprintf("%sspans_parm_multi_cnf\n", spans_indent);
561         inc_indent();
562         spans_print_atm_conn(&objp->mucnf_conn);
563         spans_print_result(&objp->mucnf_result);
564         spans_print_resrc(&objp->mucnf_rsrc);
565         spans_print_vpvc(&objp->mucnf_vpvc);
566         dec_indent();
567 }
568
569 static void
570 spans_print_parm_add_req(spans_parm_add_req *objp)
571 {
572         kprintf("%sspans_parm_add_req\n", spans_indent);
573         inc_indent();
574         spans_print_atm_conn(&objp->adreq_desconn);
575         spans_print_atm_conn(&objp->adreq_xstconn);
576         dec_indent();
577 }
578
579 static void
580 spans_print_parm_add_ind(spans_parm_add_ind *objp)
581 {
582         kprintf("%sspans_parm_add_ind\n", spans_indent);
583         inc_indent();
584         spans_print_atm_conn(&objp->adind_desconn);
585         spans_print_atm_conn(&objp->adind_xstconn);
586         dec_indent();
587 }
588
589 static void
590 spans_print_parm_add_rsp(spans_parm_add_rsp *objp)
591 {
592         kprintf("%sspans_parm_add_rsp\n", spans_indent);
593         inc_indent();
594         spans_print_atm_conn(&objp->adrsp_conn);
595         spans_print_result(&objp->adrsp_result);
596         spans_print_resrc(&objp->adrsp_rsrc);
597         dec_indent();
598 }
599
600 static void
601 spans_print_parm_add_cnf(spans_parm_add_cnf *objp)
602 {
603         kprintf("%sspans_parm_add_cnf\n", spans_indent);
604         inc_indent();
605         spans_print_atm_conn(&objp->adcnf_conn);
606         spans_print_result(&objp->adcnf_result);
607         spans_print_resrc(&objp->adcnf_rsrc);
608         dec_indent();
609 }
610
611 static void
612 spans_print_parm_join_req(spans_parm_join_req *objp)
613 {
614         kprintf("%sspans_parm_join_req\n", spans_indent);
615         inc_indent();
616         spans_print_addr(&objp->jnreq_addr);
617         dec_indent();
618 }
619
620 static void
621 spans_print_parm_join_cnf(spans_parm_join_cnf *objp)
622 {
623         kprintf("%sspans_print_parm_join_cnf\n", spans_indent);
624         inc_indent();
625         spans_print_addr(&objp->jncnf_addr);
626         spans_print_result(&objp->jncnf_result);
627         dec_indent();
628 }
629
630 static void
631 spans_print_parm_leave_req(spans_parm_leave_req *objp)
632 {
633         kprintf("%sspans_print_parm_leave_req\n", spans_indent);
634         inc_indent();
635         spans_print_addr(&objp->lvreq_addr);
636         dec_indent();
637 }
638
639 static void
640 spans_print_parm_leave_cnf(spans_parm_leave_cnf *objp)
641 {
642         kprintf("%sspans_parm_leave_cnf\n", spans_indent);
643         inc_indent();
644         spans_print_addr(&objp->lvcnf_addr);
645         spans_print_result(&objp->lvcnf_result);
646         dec_indent();
647 }
648
649 static void
650 spans_print_parm_vcir_ind(spans_parm_vcir_ind *objp)
651 {
652         kprintf("%sspans_parm_vcir_ind\n", spans_indent);
653         inc_indent();
654         kprintf("%svrind_min            %d\n", spans_indent, objp->vrind_min);
655         kprintf("%svrind_max            %d\n", spans_indent, objp->vrind_max);
656         dec_indent();
657 }
658
659 static void
660 spans_print_parm_query_req(spans_parm_query_req *objp)
661 {
662         char query_type_str[80];
663
664         kprintf("%sspans_parm_query_req\n", spans_indent);
665         inc_indent();
666         spans_print_atm_conn(&objp->qyreq_conn);
667         spans_query_type_str(&objp->qyreq_type,
668                 query_type_str, sizeof(query_type_str));
669         kprintf("%sqyreq_type           %s\n", spans_indent, query_type_str);
670         dec_indent();
671 }
672
673 static void
674 spans_print_parm_query_rsp(spans_parm_query_rsp *objp)
675 {
676         char query_type_str[80], state_type_str[80];
677
678         kprintf("%sspans_parm_query_rsp\n", spans_indent);
679         inc_indent();
680         spans_print_atm_conn(&objp->qyrsp_conn);
681         spans_query_type_str(&objp->qyrsp_type,
682                 query_type_str, sizeof(query_type_str));
683         kprintf("%sqyrsp_type           %s\n", spans_indent, query_type_str);
684         spans_state_str(&objp->qyrsp_state,
685                 state_type_str, sizeof(state_type_str));
686         kprintf("%sqyrsp_state          %s\n", spans_indent, state_type_str);
687         kprintf("%sqyrsp_data           0x%x\n", spans_indent,
688                         objp->qyrsp_data);
689         dec_indent();
690 }
691
692 static void
693 spans_print_msgbody(spans_msgbody *objp)
694 {
695         kprintf("%sspans_msgbody\n", spans_indent);
696         inc_indent();
697         spans_print_msgtype(&objp->mb_type);
698         switch (objp->mb_type) {
699         case SPANS_STAT_REQ:
700                 spans_print_parm_stat_req(&objp->spans_msgbody_u.mb_stat_req);
701                 break;
702         case SPANS_STAT_IND:
703                 spans_print_parm_stat_ind(&objp->spans_msgbody_u.mb_stat_ind);
704                 break;
705         case SPANS_STAT_RSP:
706                 spans_print_parm_stat_rsp(&objp->spans_msgbody_u.mb_stat_rsp);
707                 break;
708         case SPANS_OPEN_REQ:
709                 spans_print_parm_open_req(&objp->spans_msgbody_u.mb_open_req);
710                 break;
711         case SPANS_OPEN_IND:
712                 spans_print_parm_open_ind(&objp->spans_msgbody_u.mb_open_ind);
713                 break;
714         case SPANS_OPEN_RSP:
715                 spans_print_parm_open_rsp(&objp->spans_msgbody_u.mb_open_rsp);
716                 break;
717         case SPANS_OPEN_CNF:
718                 spans_print_parm_open_cnf(&objp->spans_msgbody_u.mb_open_cnf);
719                 break;
720         case SPANS_CLOSE_REQ:
721                 spans_print_parm_close_req(&objp->spans_msgbody_u.mb_close_req);
722                 break;
723         case SPANS_CLOSE_IND:
724                 spans_print_parm_close_ind(&objp->spans_msgbody_u.mb_close_ind);
725                 break;
726         case SPANS_CLOSE_RSP:
727                 spans_print_parm_close_rsp(&objp->spans_msgbody_u.mb_close_rsp);
728                 break;
729         case SPANS_CLOSE_CNF:
730                 spans_print_parm_close_cnf(&objp->spans_msgbody_u.mb_close_cnf);
731                 break;
732         case SPANS_RCLOSE_REQ:
733                 spans_print_parm_rclose_req(&objp->spans_msgbody_u.mb_rclose_req);
734                 break;
735         case SPANS_RCLOSE_IND:
736                 spans_print_parm_rclose_ind(&objp->spans_msgbody_u.mb_rclose_ind);
737                 break;
738         case SPANS_RCLOSE_RSP:
739                 spans_print_parm_rclose_rsp(&objp->spans_msgbody_u.mb_rclose_rsp);
740                 break;
741         case SPANS_RCLOSE_CNF:
742                 spans_print_parm_rclose_cnf(&objp->spans_msgbody_u.mb_rclose_cnf);
743                 break;
744         case SPANS_MULTI_REQ:
745                 spans_print_parm_multi_req(&objp->spans_msgbody_u.mb_multi_req);
746                 break;
747         case SPANS_MULTI_IND:
748                 spans_print_parm_multi_ind(&objp->spans_msgbody_u.mb_multi_ind);
749                 break;
750         case SPANS_MULTI_RSP:
751                 spans_print_parm_multi_rsp(&objp->spans_msgbody_u.mb_multi_rsp);
752                 break;
753         case SPANS_MULTI_CNF:
754                 spans_print_parm_multi_cnf(&objp->spans_msgbody_u.mb_multi_cnf);
755                 break;
756         case SPANS_ADD_REQ:
757                 spans_print_parm_add_req(&objp->spans_msgbody_u.mb_add_req);
758                 break;
759         case SPANS_ADD_IND:
760                 spans_print_parm_add_ind(&objp->spans_msgbody_u.mb_add_ind);
761                 break;
762         case SPANS_ADD_RSP:
763                 spans_print_parm_add_rsp(&objp->spans_msgbody_u.mb_add_rsp);
764                 break;
765         case SPANS_ADD_CNF:
766                 spans_print_parm_add_cnf(&objp->spans_msgbody_u.mb_add_cnf);
767                 break;
768         case SPANS_JOIN_REQ:
769                 spans_print_parm_join_req(&objp->spans_msgbody_u.mb_join_req);
770                 break;
771         case SPANS_JOIN_CNF:
772                 spans_print_parm_join_cnf(&objp->spans_msgbody_u.mb_join_cnf);
773                 break;
774         case SPANS_LEAVE_REQ:
775                 spans_print_parm_leave_req(&objp->spans_msgbody_u.mb_leave_req);
776                 break;
777         case SPANS_LEAVE_CNF:
778                 spans_print_parm_leave_cnf(&objp->spans_msgbody_u.mb_leave_cnf);
779                 break;
780         case SPANS_VCIR_IND:
781                 spans_print_parm_vcir_ind(&objp->spans_msgbody_u.mb_vcir_ind);
782                 break;
783         case SPANS_QUERY_REQ:
784                 spans_print_parm_query_req(&objp->spans_msgbody_u.mb_query_req);
785                 break;
786         case SPANS_QUERY_RSP:
787                 spans_print_parm_query_rsp(&objp->spans_msgbody_u.mb_query_rsp);
788                 break;
789         }
790         dec_indent();
791 }
792
793 void
794 spans_print_msg(spans_msg *objp)
795 {
796         spans_indent = INIT_INDENT;
797         kprintf("%sspans_msg\n", spans_indent);
798         inc_indent();
799         spans_print_version(&objp->sm_vers);
800         spans_print_msgbody(&objp->sm_body);
801         dec_indent();
802 }
803
804 #else   /* ifdef LONGPRINT */
805
806 static void
807 spans_print_msgbody(spans_msgbody *objp)
808 {
809         char    daddr[80], msgtype_str[80], result_str[80], saddr[80];
810         spans_parm_stat_req     *streq_p;
811         spans_parm_stat_ind     *stind_p;
812         spans_parm_stat_rsp     *strsp_p;
813         spans_parm_open_req     *opreq_p;
814         spans_parm_open_ind     *opind_p;
815         spans_parm_open_rsp     *oprsp_p;
816         spans_parm_open_cnf     *opcnf_p;
817         spans_parm_close_req    *clreq_p;
818         spans_parm_close_ind    *clind_p;
819         spans_parm_close_rsp    *clrsp_p;
820         spans_parm_close_cnf    *clcnf_p;
821         spans_parm_rclose_req   *rcreq_p;
822         spans_parm_rclose_ind   *rcind_p;
823         spans_parm_rclose_rsp   *rcrsp_p;
824         spans_parm_rclose_cnf   *rccnf_p;
825
826         spans_msgtype_str(&objp->mb_type, msgtype_str, sizeof(msgtype_str));
827         kprintf("%s: ", msgtype_str);
828         switch (objp->mb_type) {
829         case SPANS_STAT_REQ:
830                 streq_p = &objp->spans_msgbody_u.mb_stat_req;
831                 kprintf("es_epoch=0x%lx", streq_p->streq_es_epoch);
832                 break;
833         case SPANS_STAT_IND:
834                 stind_p = &objp->spans_msgbody_u.mb_stat_ind;
835                 strncpy(daddr, spans_addr_print(&stind_p->stind_es_addr),
836                                 sizeof(daddr));
837                 strncpy(saddr, spans_addr_print(&stind_p->stind_sw_addr),
838                                 sizeof(saddr));
839                 kprintf("sw_epoch=0x%lx, es_addr=%s, sw_addr=0x%s",
840                                 stind_p->stind_sw_epoch,
841                                 daddr, saddr);
842                 break;
843         case SPANS_STAT_RSP:
844                 strsp_p = &objp->spans_msgbody_u.mb_stat_rsp;
845                 strncpy(daddr, spans_addr_print(&strsp_p->strsp_es_addr),
846                                 sizeof(daddr));
847                 kprintf("es_epoch=0x%lx, es_addr=%s",
848                                 strsp_p->strsp_es_epoch, daddr);
849                 break;
850         case SPANS_OPEN_REQ:
851                 opreq_p = &objp->spans_msgbody_u.mb_open_req;
852                 strncpy(daddr, spans_addr_print(&opreq_p->opreq_conn.con_dst),
853                                 sizeof(daddr));
854                 strncpy(saddr, spans_addr_print(&opreq_p->opreq_conn.con_src),
855                                 sizeof(saddr));
856                 kprintf("daddr=%s, saddr=%s, dsap=%d, ssap=%d, aal=%d",
857                                 daddr, saddr,
858                                 opreq_p->opreq_conn.con_dsap,
859                                 opreq_p->opreq_conn.con_ssap,
860                                 opreq_p->opreq_aal);
861                 if (opreq_p->opreq_vpvc.vpf_valid)
862                         kprintf(", vp.vc=%d.%d",
863                                         SPANS_EXTRACT_VPI(opreq_p->opreq_vpvc.vpf_vpvc),
864                                         SPANS_EXTRACT_VCI(opreq_p->opreq_vpvc.vpf_vpvc));
865                 break;
866         case SPANS_OPEN_IND:
867                 opind_p = &objp->spans_msgbody_u.mb_open_ind;
868                 strncpy(daddr, spans_addr_print(&opind_p->opind_conn.con_dst),
869                                 sizeof(daddr));
870                 strncpy(saddr, spans_addr_print(&opind_p->opind_conn.con_src),
871                                 sizeof(saddr));
872                 kprintf("daddr=%s, saddr=%s, dsap=%d, ssap=%d, aal=%d",
873                                 daddr, saddr,
874                                 opind_p->opind_conn.con_dsap,
875                                 opind_p->opind_conn.con_ssap,
876                                 opind_p->opind_aal);
877                 if (opind_p->opind_vpvc.vpf_valid)
878                         kprintf(", vp.vc=%d.%d",
879                                         SPANS_EXTRACT_VPI(opind_p->opind_vpvc.vpf_vpvc),
880                                         SPANS_EXTRACT_VCI(opind_p->opind_vpvc.vpf_vpvc));
881                 break;
882         case SPANS_OPEN_RSP:
883                 oprsp_p = &objp->spans_msgbody_u.mb_open_rsp;
884                 strncpy(daddr, spans_addr_print(&oprsp_p->oprsp_conn.con_dst),
885                                 sizeof(daddr));
886                 strncpy(saddr, spans_addr_print(&oprsp_p->oprsp_conn.con_src),
887                                 sizeof(saddr));
888                 spans_result_str(&oprsp_p->oprsp_result, result_str,
889                         sizeof(result_str));
890                 kprintf("result=%s, daddr=%s, saddr=%s, dsap=%d, ssap=%d, vp.vc=%d.%d",
891                                 result_str, daddr, saddr,
892                                 oprsp_p->oprsp_conn.con_dsap,
893                                 oprsp_p->oprsp_conn.con_ssap,
894                                 SPANS_EXTRACT_VPI(oprsp_p->oprsp_vpvc),
895                                 SPANS_EXTRACT_VCI(oprsp_p->oprsp_vpvc));
896                 break;
897         case SPANS_OPEN_CNF:
898                 opcnf_p = &objp->spans_msgbody_u.mb_open_cnf;
899                 strncpy(daddr, spans_addr_print(&opcnf_p->opcnf_conn.con_dst),
900                                 sizeof(daddr));
901                 strncpy(saddr, spans_addr_print(&opcnf_p->opcnf_conn.con_src),
902                                 sizeof(saddr));
903                 spans_result_str(&opcnf_p->opcnf_result, result_str,
904                         sizeof(result_str));
905                 kprintf("result=%s, daddr=%s, saddr=%s, dsap=%d, ssap=%d, vp.vc=%d.%d",
906                                 result_str, daddr, saddr,
907                                 opcnf_p->opcnf_conn.con_dsap,
908                                 opcnf_p->opcnf_conn.con_ssap,
909                                 SPANS_EXTRACT_VPI(opcnf_p->opcnf_vpvc),
910                                 SPANS_EXTRACT_VCI(opcnf_p->opcnf_vpvc));
911                 break;
912         case SPANS_CLOSE_REQ:
913                 clreq_p = &objp->spans_msgbody_u.mb_close_req;
914                 strncpy(daddr, spans_addr_print(&clreq_p->clreq_conn.con_dst),
915                                 sizeof(daddr));
916                 strncpy(saddr, spans_addr_print(&clreq_p->clreq_conn.con_src),
917                                 sizeof(saddr));
918                 kprintf("daddr=%s, saddr=%s, dsap=%d, ssap=%d",
919                                 daddr, saddr,
920                                 clreq_p->clreq_conn.con_dsap,
921                                 clreq_p->clreq_conn.con_ssap);
922                 break;
923         case SPANS_CLOSE_IND:
924                 clind_p = &objp->spans_msgbody_u.mb_close_ind;
925                 strncpy(daddr, spans_addr_print(&clind_p->clind_conn.con_dst),
926                                 sizeof(daddr));
927                 strncpy(saddr, spans_addr_print(&clind_p->clind_conn.con_src),
928                                 sizeof(saddr));
929                 kprintf("daddr=%s, saddr=%s, dsap=%d, ssap=%d",
930                                 daddr, saddr,
931                                 clind_p->clind_conn.con_dsap,
932                                 clind_p->clind_conn.con_ssap);
933                 break;
934         case SPANS_CLOSE_RSP:
935                 clrsp_p = &objp->spans_msgbody_u.mb_close_rsp;
936                 strncpy(daddr, spans_addr_print(&clrsp_p->clrsp_conn.con_dst),
937                                 sizeof(daddr));
938                 strncpy(saddr, spans_addr_print(&clrsp_p->clrsp_conn.con_src),
939                                 sizeof(saddr));
940                 spans_result_str(&clrsp_p->clrsp_result, result_str,
941                         sizeof(result_str));
942                 kprintf("result=%s, daddr=%s, saddr=%s, dsap=%d, ssap=%d",
943                                 result_str, daddr, saddr,
944                                 clrsp_p->clrsp_conn.con_dsap,
945                                 clrsp_p->clrsp_conn.con_ssap);
946                 break;
947         case SPANS_CLOSE_CNF:
948                 clcnf_p = &objp->spans_msgbody_u.mb_close_cnf;
949                 strncpy(daddr, spans_addr_print(&clcnf_p->clcnf_conn.con_dst),
950                                 sizeof(daddr));
951                 strncpy(saddr, spans_addr_print(&clcnf_p->clcnf_conn.con_src),
952                                 sizeof(saddr));
953                 spans_result_str(&clcnf_p->clcnf_result, result_str,
954                         sizeof(result_str));
955                 kprintf("result=%s, daddr=%s, saddr=%s, dsap=%d, ssap=%d",
956                                 result_str, daddr, saddr,
957                                 clcnf_p->clcnf_conn.con_dsap,
958                                 clcnf_p->clcnf_conn.con_ssap);
959                 break;
960         case SPANS_RCLOSE_REQ:
961                 rcreq_p = &objp->spans_msgbody_u.mb_rclose_req;
962                 strncpy(daddr, spans_addr_print(&rcreq_p->rcreq_conn.con_dst),
963                                 sizeof(daddr));
964                 strncpy(saddr, spans_addr_print(&rcreq_p->rcreq_conn.con_src),
965                                 sizeof(saddr));
966                 kprintf("daddr=%s, saddr=%s, dsap=%d, ssap=%d",
967                                 daddr, saddr,
968                                 rcreq_p->rcreq_conn.con_dsap,
969                                 rcreq_p->rcreq_conn.con_ssap);
970                 break;
971         case SPANS_RCLOSE_IND:
972                 rcind_p = &objp->spans_msgbody_u.mb_rclose_ind;
973                 strncpy(daddr, spans_addr_print(&rcind_p->rcind_conn.con_dst),
974                                 sizeof(daddr));
975                 strncpy(saddr, spans_addr_print(&rcind_p->rcind_conn.con_src),
976                                 sizeof(saddr));
977                 kprintf("daddr=%s, saddr=%s, dsap=%d, ssap=%d",
978                                 daddr, saddr,
979                                 rcind_p->rcind_conn.con_dsap,
980                                 rcind_p->rcind_conn.con_ssap);
981                 break;
982         case SPANS_RCLOSE_RSP:
983                 rcrsp_p = &objp->spans_msgbody_u.mb_rclose_rsp;
984                 strncpy(daddr, spans_addr_print(&rcrsp_p->rcrsp_conn.con_dst),
985                                 sizeof(daddr));
986                 strncpy(saddr, spans_addr_print(&rcrsp_p->rcrsp_conn.con_src),
987                                 sizeof(saddr));
988                 spans_result_str(&rcrsp_p->rcrsp_result, result_str,
989                         sizeof(result_str));
990                 kprintf("result=%s, daddr=%s, saddr=%s, dsap=%d, ssap=%d",
991                                 result_str, daddr, saddr,
992                                 rcrsp_p->rcrsp_conn.con_dsap,
993                                 rcrsp_p->rcrsp_conn.con_ssap);
994                 break;
995         case SPANS_RCLOSE_CNF:
996                 rccnf_p = &objp->spans_msgbody_u.mb_rclose_cnf;
997                 strncpy(daddr, spans_addr_print(&rccnf_p->rccnf_conn.con_dst),
998                                 sizeof(daddr));
999                 strncpy(saddr, spans_addr_print(&rccnf_p->rccnf_conn.con_src),
1000                                 sizeof(saddr));
1001                 spans_result_str(&rccnf_p->rccnf_result, result_str,
1002                         sizeof(result_str));
1003                 kprintf("result=%s, daddr=%s, saddr=%s, dsap=%d, ssap=%d",
1004                                 result_str, daddr, saddr,
1005                                 rccnf_p->rccnf_conn.con_dsap,
1006                                 rccnf_p->rccnf_conn.con_ssap);
1007                 break;
1008         default:
1009                 break;
1010         }
1011         kprintf("\n");
1012 }
1013
1014 void
1015 spans_print_msg(spans_msg *objp)
1016 {
1017 #ifdef LONGPRINT
1018         spans_indent = INIT_INDENT;
1019 #endif
1020         spans_print_msgbody(&objp->sm_body);
1021 }
1022
1023 #endif  /* ifdef LONGPRINT */