print-ipx.c (98527) | print-ipx.c (127675) |
---|---|
1/* 2 * Copyright (c) 1994, 1995, 1996 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that: (1) source code distributions 7 * retain the above copyright notice and this paragraph in its entirety, (2) 8 * distributions including binary code include the above copyright notice and --- 7 unchanged lines hidden (view full) --- 16 * written permission. 17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 * 21 * Format and print Novell IPX packets. 22 * Contributed by Brad Parker (brad@fcr.com). 23 * | 1/* 2 * Copyright (c) 1994, 1995, 1996 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that: (1) source code distributions 7 * retain the above copyright notice and this paragraph in its entirety, (2) 8 * distributions including binary code include the above copyright notice and --- 7 unchanged lines hidden (view full) --- 16 * written permission. 17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 * 21 * Format and print Novell IPX packets. 22 * Contributed by Brad Parker (brad@fcr.com). 23 * |
24 * $FreeBSD: head/contrib/tcpdump/print-ipx.c 98527 2002-06-21 00:49:02Z fenner $ | 24 * $FreeBSD: head/contrib/tcpdump/print-ipx.c 127675 2004-03-31 14:57:24Z bms $ |
25 */ 26 27#ifndef lint | 25 */ 26 27#ifndef lint |
28static const char rcsid[] = 29 "@(#) $Header: /tcpdump/master/tcpdump/print-ipx.c,v 1.32 2001/10/08 21:25:20 fenner Exp $"; | 28static const char rcsid[] _U_ = 29 "@(#) $Header: /tcpdump/master/tcpdump/print-ipx.c,v 1.34.2.2 2003/11/16 08:51:28 guy Exp $"; |
30#endif 31 32#ifdef HAVE_CONFIG_H 33#include "config.h" 34#endif 35 | 30#endif 31 32#ifdef HAVE_CONFIG_H 33#include "config.h" 34#endif 35 |
36#include <sys/param.h> 37#include <sys/time.h> 38#include <sys/socket.h> | 36#include <tcpdump-stdinc.h> |
39 | 37 |
40#include <netinet/in.h> 41 | |
42#include <stdlib.h> 43#include <stdio.h> 44#include <string.h> 45 46#include "interface.h" 47#include "addrtoname.h" 48#include "ipx.h" 49#include "extract.h" --- 8 unchanged lines hidden (view full) --- 58 * Print IPX datagram packets. 59 */ 60void 61ipx_print(const u_char *p, u_int length) 62{ 63 const struct ipxHdr *ipx = (const struct ipxHdr *)p; 64 65 TCHECK(ipx->srcSkt); | 38#include <stdlib.h> 39#include <stdio.h> 40#include <string.h> 41 42#include "interface.h" 43#include "addrtoname.h" 44#include "ipx.h" 45#include "extract.h" --- 8 unchanged lines hidden (view full) --- 54 * Print IPX datagram packets. 55 */ 56void 57ipx_print(const u_char *p, u_int length) 58{ 59 const struct ipxHdr *ipx = (const struct ipxHdr *)p; 60 61 TCHECK(ipx->srcSkt); |
66 (void)printf("%s.%x > ", | 62 (void)printf("%s.%04x > ", |
67 ipxaddr_string(EXTRACT_32BITS(ipx->srcNet), ipx->srcNode), 68 EXTRACT_16BITS(&ipx->srcSkt)); 69 | 63 ipxaddr_string(EXTRACT_32BITS(ipx->srcNet), ipx->srcNode), 64 EXTRACT_16BITS(&ipx->srcSkt)); 65 |
70 (void)printf("%s.%x:", | 66 (void)printf("%s.%04x:", |
71 ipxaddr_string(EXTRACT_32BITS(ipx->dstNet), ipx->dstNode), 72 EXTRACT_16BITS(&ipx->dstSkt)); 73 74 /* take length from ipx header */ 75 TCHECK(ipx->length); 76 length = EXTRACT_16BITS(&ipx->length); 77 78 ipx_decode(ipx, (u_char *)ipx + ipxSize, length - ipxSize); 79 return; 80trunc: 81 printf("[|ipx %d]", length); 82} 83 84static const char * 85ipxaddr_string(u_int32_t net, const u_char *node) 86{ 87 static char line[256]; 88 | 67 ipxaddr_string(EXTRACT_32BITS(ipx->dstNet), ipx->dstNode), 68 EXTRACT_16BITS(&ipx->dstSkt)); 69 70 /* take length from ipx header */ 71 TCHECK(ipx->length); 72 length = EXTRACT_16BITS(&ipx->length); 73 74 ipx_decode(ipx, (u_char *)ipx + ipxSize, length - ipxSize); 75 return; 76trunc: 77 printf("[|ipx %d]", length); 78} 79 80static const char * 81ipxaddr_string(u_int32_t net, const u_char *node) 82{ 83 static char line[256]; 84 |
89 snprintf(line, sizeof(line), "%x.%02x:%02x:%02x:%02x:%02x:%02x", | 85 snprintf(line, sizeof(line), "%08x.%02x:%02x:%02x:%02x:%02x:%02x", |
90 net, node[0], node[1], node[2], node[3], node[4], node[5]); 91 92 return line; 93} 94 95void 96ipx_decode(const struct ipxHdr *ipx, const u_char *datap, u_int length) 97{ --- 48 unchanged lines hidden (view full) --- 146 case 1: 147 case 3: 148 if (command == 1) 149 (void)printf("ipx-sap-req"); 150 else 151 (void)printf("ipx-sap-nearest-req"); 152 153 TCHECK(ipx[0]); | 86 net, node[0], node[1], node[2], node[3], node[4], node[5]); 87 88 return line; 89} 90 91void 92ipx_decode(const struct ipxHdr *ipx, const u_char *datap, u_int length) 93{ --- 48 unchanged lines hidden (view full) --- 142 case 1: 143 case 3: 144 if (command == 1) 145 (void)printf("ipx-sap-req"); 146 else 147 (void)printf("ipx-sap-nearest-req"); 148 149 TCHECK(ipx[0]); |
154 (void)printf(" %x", EXTRACT_16BITS(&ipx[0])); | 150 (void)printf(" %s", ipxsap_string(htons(EXTRACT_16BITS(&ipx[0])))); |
155 break; 156 157 case 2: 158 case 4: 159 if (command == 2) 160 (void)printf("ipx-sap-resp"); 161 else 162 (void)printf("ipx-sap-nearest-resp"); 163 164 for (i = 0; i < 8 && length > 0; i++) { 165 TCHECK2(ipx[25], 10); | 151 break; 152 153 case 2: 154 case 4: 155 if (command == 2) 156 (void)printf("ipx-sap-resp"); 157 else 158 (void)printf("ipx-sap-nearest-resp"); 159 160 for (i = 0; i < 8 && length > 0; i++) { 161 TCHECK2(ipx[25], 10); |
166 (void)printf(" %x '", EXTRACT_16BITS(&ipx[0])); | 162 (void)printf(" %s '", ipxsap_string(htons(EXTRACT_16BITS(&ipx[0])))); |
167 fn_print((u_char *)&ipx[1], (u_char *)&ipx[1] + 48); 168 printf("' addr %s", 169 ipxaddr_string(EXTRACT_32BITS(&ipx[25]), (u_char *)&ipx[27])); 170 ipx += 32; 171 length -= 64; 172 } 173 break; 174 default: --- 38 unchanged lines hidden (view full) --- 213 default: 214 (void)printf("ipx-rip-?%x", command); 215 break; 216 } 217 return; 218trunc: 219 printf("[|ipx %d]", length); 220} | 163 fn_print((u_char *)&ipx[1], (u_char *)&ipx[1] + 48); 164 printf("' addr %s", 165 ipxaddr_string(EXTRACT_32BITS(&ipx[25]), (u_char *)&ipx[27])); 166 ipx += 32; 167 length -= 64; 168 } 169 break; 170 default: --- 38 unchanged lines hidden (view full) --- 209 default: 210 (void)printf("ipx-rip-?%x", command); 211 break; 212 } 213 return; 214trunc: 215 printf("[|ipx %d]", length); 216} |
221 | |