1*b9fc9a72Sderaadt /* $OpenBSD: print-netbios.c,v 1.10 2015/01/16 06:40:21 deraadt Exp $ */
2cf4e9b47Sho
384fb80dbSmickey /*
484fb80dbSmickey * Copyright (c) 1994, 1995, 1996
584fb80dbSmickey * The Regents of the University of California. All rights reserved.
684fb80dbSmickey *
784fb80dbSmickey * Redistribution and use in source and binary forms, with or without
884fb80dbSmickey * modification, are permitted provided that: (1) source code distributions
984fb80dbSmickey * retain the above copyright notice and this paragraph in its entirety, (2)
1084fb80dbSmickey * distributions including binary code include the above copyright notice and
1184fb80dbSmickey * this paragraph in its entirety in the documentation or other materials
1284fb80dbSmickey * provided with the distribution, and (3) all advertising materials mentioning
1384fb80dbSmickey * features or use of this software display the following acknowledgement:
1484fb80dbSmickey * ``This product includes software developed by the University of California,
1584fb80dbSmickey * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
1684fb80dbSmickey * the University nor the names of its contributors may be used to endorse
1784fb80dbSmickey * or promote products derived from this software without specific prior
1884fb80dbSmickey * written permission.
1984fb80dbSmickey * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
2084fb80dbSmickey * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
2184fb80dbSmickey * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22dc709136Sbitblt *
2384fb80dbSmickey * Format and print NETBIOS packets.
2484fb80dbSmickey * Contributed by Brad Parker (brad@fcr.com).
2584fb80dbSmickey */
2684fb80dbSmickey
2784fb80dbSmickey #include <sys/socket.h>
28dc709136Sbitblt
2984fb80dbSmickey #include <netinet/in.h>
3084fb80dbSmickey #include <netinet/ip.h>
3184fb80dbSmickey #include <netinet/ip_var.h>
3284fb80dbSmickey #include <netinet/udp.h>
3384fb80dbSmickey #include <netinet/udp_var.h>
3484fb80dbSmickey #include <netinet/tcp.h>
3584fb80dbSmickey
36dc709136Sbitblt #include <stdio.h>
37e7beb4a7Smillert #include <stdlib.h>
3884fb80dbSmickey #include <string.h>
3984fb80dbSmickey
4084fb80dbSmickey #include "interface.h"
4184fb80dbSmickey #include "addrtoname.h"
4284fb80dbSmickey #include "netbios.h"
4384fb80dbSmickey #include "extract.h"
4484fb80dbSmickey
4584fb80dbSmickey /*
4684fb80dbSmickey * Print NETBIOS packets.
4784fb80dbSmickey */
4884fb80dbSmickey void
netbios_print(struct p8022Hdr * nb,u_int length)49dc709136Sbitblt netbios_print(struct p8022Hdr *nb, u_int length)
5084fb80dbSmickey {
5184fb80dbSmickey if (length < p8022Size) {
525a3cb124Smoritz printf(" truncated-netbios %d", length);
5384fb80dbSmickey return;
5484fb80dbSmickey }
5584fb80dbSmickey
565a3cb124Smoritz TCHECK(*nb);
5784fb80dbSmickey
585a3cb124Smoritz if (nb->flags == UI)
595a3cb124Smoritz printf("802.1 UI ");
605a3cb124Smoritz else
615a3cb124Smoritz printf("802.1 CONN ");
6284fb80dbSmickey
635a3cb124Smoritz #if 0
6484fb80dbSmickey netbios_decode(nb, (u_char *)nb + p8022Size, length - p8022Size);
6584fb80dbSmickey #endif
6684fb80dbSmickey
675a3cb124Smoritz trunc:
685a3cb124Smoritz printf("[|netbios]");
695a3cb124Smoritz }
70