| 1 | #!/usr/bin/env python |
|---|
| 2 | # -*- coding: utf-8 -*- |
|---|
| 3 | # Copyright (C) 2009 Adriano Monteiro Marques |
|---|
| 4 | # |
|---|
| 5 | # Author: Francesco Piccinno <stack.box@gmail.com> |
|---|
| 6 | # |
|---|
| 7 | # This program is free software; you can redistribute it and/or modify |
|---|
| 8 | # it under the terms of the GNU General Public License as published by |
|---|
| 9 | # the Free Software Foundation; either version 2 of the License, or |
|---|
| 10 | # (at your option) any later version. |
|---|
| 11 | # |
|---|
| 12 | # This program is distributed in the hope that it will be useful, |
|---|
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 15 | # GNU General Public License for more details. |
|---|
| 16 | # |
|---|
| 17 | # You should have received a copy of the GNU General Public License |
|---|
| 18 | # along with this program; if not, write to the Free Software |
|---|
| 19 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 20 | |
|---|
| 21 | ############################################################################### |
|---|
| 22 | # Layers |
|---|
| 23 | ############################################################################### |
|---|
| 24 | |
|---|
| 25 | IFACE_LAYER = 1 |
|---|
| 26 | LINK_LAYER = 2 |
|---|
| 27 | NET_LAYER = 3 |
|---|
| 28 | PROTO_LAYER = 4 |
|---|
| 29 | |
|---|
| 30 | # Here goes dissectors |
|---|
| 31 | APP_LAYER = 5 |
|---|
| 32 | APP_LAYER_TCP = 6 |
|---|
| 33 | APP_LAYER_UDP = 7 |
|---|
| 34 | |
|---|
| 35 | ############################################################################### |
|---|
| 36 | # Layer types |
|---|
| 37 | ############################################################################### |
|---|
| 38 | |
|---|
| 39 | # IFACE_LAYER types |
|---|
| 40 | IL_TYPE_ETH = 0x01 # ethernet |
|---|
| 41 | IL_TYPE_TR = 0x06 # token ring |
|---|
| 42 | IL_TYPE_FDDI = 0x0a # fiber distributed data interface |
|---|
| 43 | IL_TYPE_RAWIP = 0x0c # raw ip dump file |
|---|
| 44 | IL_TYPE_WIFI = 0x69 # wireless |
|---|
| 45 | IL_TYPE_COOK = 0x71 # linux cooked |
|---|
| 46 | IL_TYPE_PRISM = 0x77 # prism2 header for wifi dumps |
|---|
| 47 | |
|---|
| 48 | # LINK_LAYER types |
|---|
| 49 | LL_TYPE_IP = 0x0800 |
|---|
| 50 | LL_TYPE_IP6 = 0x86DD |
|---|
| 51 | LL_TYPE_ARP = 0x0806 |
|---|
| 52 | LL_TYPE_PPP = 0x880B |
|---|
| 53 | LL_TYPE_VLAN = 0x8100 |
|---|
| 54 | |
|---|
| 55 | # NET_LAYER types |
|---|
| 56 | NL_TYPE_ICMP = 0x01 |
|---|
| 57 | NL_TYPE_ICMP6 = 0x3a |
|---|
| 58 | NL_TYPE_TCP = 0x06 |
|---|
| 59 | NL_TYPE_UDP = 0x11 |
|---|
| 60 | NL_TYPE_GRE = 0x2f |
|---|
| 61 | NL_TYPE_OSPF = 0x59 |
|---|
| 62 | NL_TYPE_VRRP = 0x70 |
|---|
| 63 | |
|---|
| 64 | # PROTO_LAYER types |
|---|
| 65 | PL_DEFAULT = 0x0000 |
|---|
| 66 | |
|---|
| 67 | ############################################################################### |
|---|
| 68 | # TCP headers flags |
|---|
| 69 | ############################################################################### |
|---|
| 70 | |
|---|
| 71 | TH_FIN = 0x01 |
|---|
| 72 | TH_SYN = 0x02 |
|---|
| 73 | TH_RST = 0x04 |
|---|
| 74 | TH_PSH = 0x08 |
|---|
| 75 | TH_ACK = 0x10 |
|---|
| 76 | TH_URG = 0x20 |
|---|
| 77 | |
|---|
| 78 | ############################################################################### |
|---|
| 79 | # ICMP types & codes |
|---|
| 80 | ############################################################################### |
|---|
| 81 | |
|---|
| 82 | ICMP_TYPE_ECHOREPLY = 0 |
|---|
| 83 | ICMP_TYPE_DEST_UNREACH = 3 |
|---|
| 84 | ICMP_TYPE_REDIRECT = 5 |
|---|
| 85 | ICMP_TYPE_ECHO = 8 |
|---|
| 86 | ICMP_TYPE_TIME_EXCEEDED = 11 |
|---|
| 87 | |
|---|
| 88 | ICMP_CODE_NET_UNREACH = 0 |
|---|
| 89 | ICMP_CODE_HOST_UNREACH = 1 |
|---|
| 90 | |
|---|
| 91 | ############################################################################### |
|---|
| 92 | # Injection stuff |
|---|
| 93 | ############################################################################### |
|---|
| 94 | |
|---|
| 95 | INJ_ERROR = -1 |
|---|
| 96 | INJ_SKIP_PACKET = 0 # Useless packet skip it |
|---|
| 97 | INJ_COLLECT_DATA = 1 # Data collection |
|---|
| 98 | INJ_COLLECT_STATS = 2 # Drop data collect only number of bytes |
|---|
| 99 | INJ_FORWARDED = 3 # Forwarded |
|---|
| 100 | INJ_FORWARD = 4 # Forward the packet as is |
|---|
| 101 | INJ_MODIFIED = 5 # Forward the packet but recompute checksums |
|---|
| 102 | |
|---|
| 103 | ############################################################################### |
|---|
| 104 | # Metapacket constants |
|---|
| 105 | ############################################################################### |
|---|
| 106 | |
|---|
| 107 | MPKT_IGNORE = 1 |
|---|
| 108 | MPKT_FORWARDABLE = 1 << 2 |
|---|
| 109 | MPKT_FORWARDED = 1 << 3 |
|---|
| 110 | MPKT_FROMIFACE = 1 << 4 |
|---|
| 111 | MPKT_FROMBRIDGE = 1 << 5 |
|---|
| 112 | |
|---|
| 113 | ############################################################################### |
|---|
| 114 | # Connection tracking constants |
|---|
| 115 | ############################################################################### |
|---|
| 116 | |
|---|
| 117 | CONN_UNDEFINED = -1 |
|---|
| 118 | CONN_JUST_ESTABLISHED = 0 |
|---|
| 119 | CONN_DATA = 1 |
|---|
| 120 | CONN_RESET = 2 |
|---|
| 121 | CONN_CLOSE = 3 |
|---|
| 122 | CONN_TIMED_OUT = 4 |
|---|