Annotation of embedaddon/hping2/getlhs.c, revision 1.1.1.1
1.1 misho 1: /*
2: * $smu-mark$
3: * $name: getlhs.c$
4: * $author: Salvatore Sanfilippo <antirez@invece.org>$
5: * $copyright: Copyright (C) 1999 by Salvatore Sanfilippo$
6: * $license: This software is under GPL version 2 of license$
7: * $date: Fri Nov 5 11:55:47 MET 1999$
8: * $rev: 8$
9: */
10:
11: /* $Id: getlhs.c,v 1.10 2003/07/25 12:11:24 njombart Exp $ */
12:
13: #include <string.h>
14:
15: #include "hping2.h"
16: #include "globals.h"
17:
18:
19: #if (!defined OSTYPE_LINUX) || (defined FORCE_LIBPCAP)
20: int get_linkhdr_size(char *ifname)
21: {
22: int dltype = pcap_datalink(pcapfp);
23:
24: if (opt_debug)
25: printf("DEBUG: dltype is %d\n", dltype);
26:
27: switch(dltype) {
28: case DLT_EN10MB:
29: case DLT_IEEE802:
30: linkhdr_size = 14;
31: break;
32: case DLT_SLIP:
33: case DLT_SLIP_BSDOS:
34: linkhdr_size = 16;
35: break;
36: case DLT_PPP:
37: case DLT_NULL:
38: #ifdef DLT_PPP_SERIAL
39: case DLT_PPP_SERIAL:
40: #endif
41: #ifdef DLT_LOOP
42: case DLT_LOOP:
43: #endif
44: linkhdr_size = 4;
45: break;
46: case DLT_PPP_BSDOS:
47: linkhdr_size = 24;
48: break;
49: case DLT_FDDI:
50: linkhdr_size = 13;
51: break;
52: case DLT_RAW:
53: linkhdr_size = 0;
54: break;
55: case DLT_IEEE802_11:
56: linkhdr_size = 14;
57: break;
58: case DLT_ATM_RFC1483:
59: #ifdef DLT_CIP
60: case DLT_CIP:
61: #endif
62: #ifdef DLT_ATM_CLIP
63: case DLT_ATM_CLIP:
64: #endif
65: linkhdr_size = 8;
66: break;
67: #ifdef DLT_C_HDLC
68: case DLT_C_HDLC:
69: linkhdr_size = 4;
70: break;
71: #endif
72: #ifdef DLT_LINUX_SLL
73: case DLT_LINUX_SLL:
74: #endif
75: #ifdef DLT_LANE8023
76: case DLT_LANE8023:
77: #endif
78: linkhdr_size = 16;
79: break;
80: default:
81: return -1;
82: break;
83: }
84: return 0;
85: }
86: #else /* Linux... */
87: int get_linkhdr_size(char *ifname)
88: {
89:
90: if ( strstr(ifname, "ppp") ) { /* also works for ippp (ISDN) */
91: linkhdr_size = PPPHDR_SIZE_LINUX;
92: return 0;
93: } else if ( strstr(ifname, "eth") ) {
94: linkhdr_size = ETHHDR_SIZE;
95: return 0;
96: } else if (strstr(ifname, "ets")) {
97: linkhdr_size = 0;
98: return 0;
99: } else if ( strstr(ifname, "lo") ) {
100: linkhdr_size = LOHDR_SIZE;
101: return 0;
102: } else if (strstr(ifname, "atm")) {
103: linkhdr_size = 0;
104: return 0;
105: } else if ( strstr(ifname, "wlan") ) {
106: linkhdr_size = WLANHDR_SIZE;
107: return 0;
108: }
109: else
110: return -1;
111: }
112: #endif /* (!defined OSTYPE_LINUX) || (defined FORCE_LIBPCAP) */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>