143725Syokota/*
243725Syokota * Copyright (c) 1994, 1995, 1996
343725Syokota *	The Regents of the University of California.  All rights reserved.
443725Syokota *
543725Syokota * Redistribution and use in source and binary forms, with or without
643725Syokota * modification, are permitted provided that: (1) source code distributions
743725Syokota * retain the above copyright notice and this paragraph in its entirety, (2)
843725Syokota * distributions including binary code include the above copyright notice and
943725Syokota * this paragraph in its entirety in the documentation or other materials
1043725Syokota * provided with the distribution, and (3) all advertising materials mentioning
1143725Syokota * features or use of this software display the following acknowledgement:
1243725Syokota * ``This product includes software developed by the University of California,
1343725Syokota * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
1443725Syokota * the University nor the names of its contributors may be used to endorse
1543725Syokota * or promote products derived from this software without specific prior
1643725Syokota * written permission.
1743725Syokota * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
1843725Syokota * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
1943725Syokota * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
2043725Syokota *
2143725Syokota * Format and print NETBIOS packets.
2243725Syokota * Contributed by Brad Parker (brad@fcr.com).
2343725Syokota */
2443725Syokota
2543725Syokota#ifndef lint
2643725Syokotastatic const char rcsid[] _U_ =
2750476Speter    "@(#) $Header: /tcpdump/master/tcpdump/print-netbios.c,v 1.20 2003-11-16 09:36:29 guy Exp $";
2843725Syokota#endif
29216065Sdougb
3053200Sphantom#ifdef HAVE_CONFIG_H
3165013Ssheldonh#include "config.h"
3243725Syokota#endif
3343725Syokota
3465013Ssheldonh#include <tcpdump-stdinc.h>
3543725Syokota
3676175Sschweikh#include <stdlib.h>
3743725Syokota#include <stdio.h>
3843725Syokota#include <string.h>
3943725Syokota
4076175Sschweikh#include "interface.h"
4143725Syokota#include "addrtoname.h"
4243725Syokota#include "netbios.h"
4343725Syokota#include "extract.h"
4465013Ssheldonh
4562978Sdannyboy/*
4665009Ssheldonh * Print NETBIOS packets.
4765009Ssheldonh */
4865009Ssheldonhvoid
4965013Ssheldonhnetbios_print(struct p8022Hdr *nb, u_int length)
5076175Sschweikh{
5165009Ssheldonh	if (length < p8022Size) {
5265009Ssheldonh		(void)printf(" truncated-netbios %d", length);
5365009Ssheldonh		return;
5443725Syokota	}
5576175Sschweikh
5643725Syokota	if (nb->flags == UI) {
5743725Syokota	    (void)printf("802.1 UI ");
5843725Syokota	} else {
5962978Sdannyboy	    (void)printf("802.1 CONN ");
6057676Ssheldonh	}
6143844Syokota
6243725Syokota	if ((u_char *)(nb + 1) > snapend) {
6343844Syokota		printf(" [|netbios]");
6443844Syokota		return;
6555268Shoek	}
6643725Syokota
6743844Syokota/*
6843844Syokota	netbios_decode(nb, (u_char *)nb + p8022Size, length - p8022Size);
6943725Syokota*/
7043844Syokota}
7165009Ssheldonh
7265009Ssheldonh#ifdef never
7345628Sdes	(void)printf("%s.%d > ",
7445628Sdes		     ipxaddr_string(EXTRACT_32BITS(ipx->srcNet), ipx->srcNode),
7545628Sdes		     EXTRACT_16BITS(ipx->srcSkt));
7645628Sdes
77229994Seadler	(void)printf("%s.%d:",
78229994Seadler		     ipxaddr_string(EXTRACT_32BITS(ipx->dstNet), ipx->dstNode),
79229994Seadler		     EXTRACT_16BITS(ipx->dstSkt));
80229994Seadler
81229994Seadler	if ((u_char *)(ipx + 1) > snapend) {
82229994Seadler		printf(" [|ipx]");
83229994Seadler		return;
84229994Seadler	}
8543725Syokota
8643725Syokota	/* take length from ipx header */
8743725Syokota	length = EXTRACT_16BITS(&ipx->length);
8843725Syokota
8943725Syokota	ipx_decode(ipx, (u_char *)ipx + ipxSize, length - ipxSize);
9043725Syokota#endif
9143844Syokota
9243844Syokota