Home | History | Annotate | Download | only in snoop
      1  0  stevel /*
      2  0  stevel  * CDDL HEADER START
      3  0  stevel  *
      4  0  stevel  * The contents of this file are subject to the terms of the
      5  0  stevel  * Common Development and Distribution License, Version 1.0 only
      6  0  stevel  * (the "License").  You may not use this file except in compliance
      7  0  stevel  * with the License.
      8  0  stevel  *
      9  0  stevel  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     10  0  stevel  * or http://www.opensolaris.org/os/licensing.
     11  0  stevel  * See the License for the specific language governing permissions
     12  0  stevel  * and limitations under the License.
     13  0  stevel  *
     14  0  stevel  * When distributing Covered Code, include this CDDL HEADER in each
     15  0  stevel  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     16  0  stevel  * If applicable, add the following below this CDDL HEADER, with the
     17  0  stevel  * fields enclosed by brackets "[]" replaced with your own identifying
     18  0  stevel  * information: Portions Copyright [yyyy] [name of copyright owner]
     19  0  stevel  *
     20  0  stevel  * CDDL HEADER END
     21  0  stevel  */
     22  0  stevel /*
     23  0  stevel  * Copyright (c) 2001 by Sun Microsystems, Inc.
     24  0  stevel  * All rights reserved.
     25  0  stevel  */
     26  0  stevel 
     27  0  stevel #pragma ident	"%Z%%M%	%I%	%E% SMI"
     28  0  stevel 
     29  0  stevel #include <stdio.h>
     30  0  stevel #include <sys/types.h>
     31  0  stevel 
     32  0  stevel #include <at.h>
     33  0  stevel #include <snoop.h>
     34  0  stevel 
     35  0  stevel static char *atp_ci(uint8_t);
     36  0  stevel 
     37  0  stevel static char *atp_trel[8] = {
     38  0  stevel 	"30s",
     39  0  stevel 	"1m",
     40  0  stevel 	"2m",
     41  0  stevel 	"4m",
     42  0  stevel 	"8m",
     43  0  stevel 	"(undef 5)",
     44  0  stevel 	"(undef 6)",
     45  0  stevel 	"(undef 7)"
     46  0  stevel };
     47  0  stevel 
     48  0  stevel void
     49  0  stevel interpret_atp(int flags, struct ddp_hdr *ddp, int len)
     50  0  stevel {
     51  0  stevel 	struct atp_hdr *atp = (struct atp_hdr *)ddp;
     52  0  stevel 	int atplen = len - (DDPHDR_SIZE + ATPHDR_SIZE);
     53  0  stevel 
     54  0  stevel 	if (flags & F_SUM) {
     55  0  stevel 		if (atplen < 0) {
     56  0  stevel 			(void) snprintf(get_sum_line(), MAXLINE,
     57  0  stevel 			    "ATP (short packet)");
     58  0  stevel 			return;
     59  0  stevel 		}
     60  0  stevel 		(void) snprintf(get_sum_line(), MAXLINE,
     61  0  stevel 		    "ATP (%s), TID=%d, L=%d",
     62  0  stevel 		    atp_ci(atp->atp_ctrl),
     63  0  stevel 		    get_short((uint8_t *)&atp->atp_tid),
     64  0  stevel 		    len);
     65  0  stevel 	}
     66  0  stevel 
     67  0  stevel 	if (flags & F_DTAIL) {
     68  0  stevel 		show_header("ATP:  ", "ATP Header", 8);
     69  0  stevel 		show_space();
     70  0  stevel 
     71  0  stevel 		if (atplen < 0) {
     72  0  stevel 			(void) snprintf(get_line(0, 0), get_line_remain(),
     73  0  stevel 			    "ATP (short packet)");
     74  0  stevel 			return;
     75  0  stevel 		}
     76  0  stevel 		(void) snprintf(get_line(0, 0), get_line_remain(),
     77  0  stevel 		    "Length = %d", len);
     78  0  stevel 		(void) snprintf(get_line(0, 0), get_line_remain(),
     79  0  stevel 		    "Ctrl = 0x%x (%s), bitmap/seq = 0x%x",
     80  0  stevel 		    atp->atp_ctrl,
     81  0  stevel 		    atp_ci(atp->atp_ctrl),
     82  0  stevel 		    atp->atp_seq);
     83  0  stevel 		(void) snprintf(get_line(0, 0), get_line_remain(),
     84  0  stevel 		    "TID = %d, user bytes 0x%x 0x%x 0x%x 0x%x",
     85  0  stevel 		    get_short((uint8_t *)&atp->atp_tid),
     86  0  stevel 		    atp->atp_user[0], atp->atp_user[1],
     87  0  stevel 		    atp->atp_user[2], atp->atp_user[3]);
     88  0  stevel 		show_space();
     89  0  stevel 	}
     90  0  stevel 
     91  0  stevel 	if (ddp->ddp_dest_sock == DDP_TYPE_ZIP ||
     92  0  stevel 	    ddp->ddp_src_sock == DDP_TYPE_ZIP)
     93  0  stevel 		interpret_atp_zip(flags, atp, atplen);
     94  0  stevel }
     95  0  stevel 
     96  0  stevel static char *
     97  0  stevel atp_ci(uint8_t ci)
     98  0  stevel {
     99  0  stevel 	static char buf[50];
    100  0  stevel 	char *p = buf;
    101  0  stevel 	char *to = NULL;
    102  0  stevel 	char *tail = &buf[sizeof (buf)];
    103  0  stevel 
    104  0  stevel 	switch (atp_fun(ci)) {
    105  0  stevel 	case ATP_TREQ:
    106  0  stevel 		p += snprintf(p, tail-p, "TReq");
    107  0  stevel 		to = atp_trel[atp_tmo(ci)];
    108  0  stevel 		break;
    109  0  stevel 	case ATP_TRESP:
    110  0  stevel 		p += snprintf(p, tail-p, "TResp");
    111  0  stevel 		break;
    112  0  stevel 	case ATP_TREL:
    113  0  stevel 		p += snprintf(p, tail-p, "TRel");
    114  0  stevel 		break;
    115  0  stevel 	}
    116  0  stevel 
    117  0  stevel 	p += snprintf(p, tail-p, ci & ATP_FLG_XO ? " XO" : " ALO");
    118  0  stevel 
    119  0  stevel 	if (ci & ATP_FLG_EOM)
    120  0  stevel 		p += snprintf(p, tail-p, " EOM");
    121  0  stevel 
    122  0  stevel 	if (ci & ATP_FLG_STS)
    123  0  stevel 		p += snprintf(p, tail-p, " STS");
    124  0  stevel 
    125  0  stevel 	if (to != NULL)
    126  0  stevel 		(void) snprintf(p, tail-p, " %s", to);
    127  0  stevel 	return (buf);
    128  0  stevel }
    129