summaryrefslogtreecommitdiff
path: root/libopie2/opienet
Side-by-side diff
Diffstat (limited to 'libopie2/opienet') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opienet/dhcp.h200
-rw-r--r--libopie2/opienet/opcap.cpp79
-rw-r--r--libopie2/opienet/opcap.h28
-rw-r--r--libopie2/opienet/opienet.pro4
4 files changed, 309 insertions, 2 deletions
diff --git a/libopie2/opienet/dhcp.h b/libopie2/opienet/dhcp.h
new file mode 100644
index 0000000..3f2f775
--- a/dev/null
+++ b/libopie2/opienet/dhcp.h
@@ -0,0 +1,200 @@
+/* dhcp.h
+
+ Protocol structures... */
+
+/*
+ * Copyright (c) 1995-2001 The Internet Software Consortium.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of The Internet Software Consortium nor the names
+ * of its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
+ * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This software has been written for the Internet Software Consortium
+ * by Ted Lemon in cooperation with Vixie Enterprises. To learn more
+ * about the Internet Software Consortium, see ``http://www.isc.org''.
+ * To learn more about Vixie Enterprises, see ``http://www.vix.com''.
+ */
+
+#ifndef DHCP_H
+#define DHCP_H
+
+#define DHCP_UDP_OVERHEAD (14 + /* Ethernet header */ \
+ 20 + /* IP header */ \
+ 8) /* UDP header */
+#define DHCP_SNAME_LEN 64
+#define DHCP_FILE_LEN 128
+#define DHCP_FIXED_NON_UDP 236
+#define DHCP_FIXED_LEN (DHCP_FIXED_NON_UDP + DHCP_UDP_OVERHEAD)
+ /* Everything but options. */
+#define DHCP_MTU_MAX 1500
+#define DHCP_OPTION_LEN (DHCP_MTU_MAX - DHCP_FIXED_LEN)
+
+#define BOOTP_MIN_LEN 300
+#define DHCP_MIN_LEN 548
+
+struct dhcp_packet {
+ u_int8_t op; /* 0: Message opcode/type */
+ u_int8_t htype; /* 1: Hardware addr type (net/if_types.h) */
+ u_int8_t hlen; /* 2: Hardware addr length */
+ u_int8_t hops; /* 3: Number of relay agent hops from client */
+ u_int32_t xid; /* 4: Transaction ID */
+ u_int16_t secs; /* 8: Seconds since client started looking */
+ u_int16_t flags; /* 10: Flag bits */
+ struct in_addr ciaddr; /* 12: Client IP address (if already in use) */
+ struct in_addr yiaddr; /* 16: Client IP address */
+ struct in_addr siaddr; /* 18: IP address of next server to talk to */
+ struct in_addr giaddr; /* 20: DHCP relay agent IP address */
+ unsigned char chaddr [16]; /* 24: Client hardware address */
+ char sname [DHCP_SNAME_LEN]; /* 40: Server name */
+ char file [DHCP_FILE_LEN]; /* 104: Boot filename */
+ unsigned char options [DHCP_OPTION_LEN];
+ /* 212: Optional parameters
+ (actual length dependent on MTU). */
+};
+
+/* BOOTP (rfc951) message types */
+#define BOOTREQUEST 1
+#define BOOTREPLY 2
+
+/* Possible values for flags field... */
+#define BOOTP_BROADCAST 32768L
+
+/* Possible values for hardware type (htype) field... */
+#define HTYPE_ETHER 1 /* Ethernet 10Mbps */
+#define HTYPE_IEEE802 6 /* IEEE 802.2 Token Ring... */
+#define HTYPE_FDDI 8 /* FDDI... */
+
+/* Magic cookie validating dhcp options field (and bootp vendor
+ extensions field). */
+#define DHCP_OPTIONS_COOKIE "\143\202\123\143"
+
+/* DHCP Option codes: */
+
+#define DHO_PAD 0
+#define DHO_SUBNET_MASK 1
+#define DHO_TIME_OFFSET 2
+#define DHO_ROUTERS 3
+#define DHO_TIME_SERVERS 4
+#define DHO_NAME_SERVERS 5
+#define DHO_DOMAIN_NAME_SERVERS 6
+#define DHO_LOG_SERVERS 7
+#define DHO_COOKIE_SERVERS 8
+#define DHO_LPR_SERVERS 9
+#define DHO_IMPRESS_SERVERS 10
+#define DHO_RESOURCE_LOCATION_SERVERS 11
+#define DHO_HOST_NAME 12
+#define DHO_BOOT_SIZE 13
+#define DHO_MERIT_DUMP 14
+#define DHO_DOMAIN_NAME 15
+#define DHO_SWAP_SERVER 16
+#define DHO_ROOT_PATH 17
+#define DHO_EXTENSIONS_PATH 18
+#define DHO_IP_FORWARDING 19
+#define DHO_NON_LOCAL_SOURCE_ROUTING 20
+#define DHO_POLICY_FILTER 21
+#define DHO_MAX_DGRAM_REASSEMBLY 22
+#define DHO_DEFAULT_IP_TTL 23
+#define DHO_PATH_MTU_AGING_TIMEOUT 24
+#define DHO_PATH_MTU_PLATEAU_TABLE 25
+#define DHO_INTERFACE_MTU 26
+#define DHO_ALL_SUBNETS_LOCAL 27
+#define DHO_BROADCAST_ADDRESS 28
+#define DHO_PERFORM_MASK_DISCOVERY 29
+#define DHO_MASK_SUPPLIER 30
+#define DHO_ROUTER_DISCOVERY 31
+#define DHO_ROUTER_SOLICITATION_ADDRESS 32
+#define DHO_STATIC_ROUTES 33
+#define DHO_TRAILER_ENCAPSULATION 34
+#define DHO_ARP_CACHE_TIMEOUT 35
+#define DHO_IEEE802_3_ENCAPSULATION 36
+#define DHO_DEFAULT_TCP_TTL 37
+#define DHO_TCP_KEEPALIVE_INTERVAL 38
+#define DHO_TCP_KEEPALIVE_GARBAGE 39
+#define DHO_NIS_DOMAIN 40
+#define DHO_NIS_SERVERS 41
+#define DHO_NTP_SERVERS 42
+#define DHO_VENDOR_ENCAPSULATED_OPTIONS 43
+#define DHO_NETBIOS_NAME_SERVERS 44
+#define DHO_NETBIOS_DD_SERVER 45
+#define DHO_NETBIOS_NODE_TYPE 46
+#define DHO_NETBIOS_SCOPE 47
+#define DHO_FONT_SERVERS 48
+#define DHO_X_DISPLAY_MANAGER 49
+#define DHO_DHCP_REQUESTED_ADDRESS 50
+#define DHO_DHCP_LEASE_TIME 51
+#define DHO_DHCP_OPTION_OVERLOAD 52
+#define DHO_DHCP_MESSAGE_TYPE 53
+#define DHO_DHCP_SERVER_IDENTIFIER 54
+#define DHO_DHCP_PARAMETER_REQUEST_LIST 55
+#define DHO_DHCP_MESSAGE 56
+#define DHO_DHCP_MAX_MESSAGE_SIZE 57
+#define DHO_DHCP_RENEWAL_TIME 58
+#define DHO_DHCP_REBINDING_TIME 59
+#define DHO_VENDOR_CLASS_IDENTIFIER 60
+#define DHO_DHCP_CLIENT_IDENTIFIER 61
+#define DHO_NWIP_DOMAIN_NAME 62
+#define DHO_NWIP_SUBOPTIONS 63
+#define DHO_USER_CLASS 77
+#define DHO_FQDN 81
+#define DHO_DHCP_AGENT_OPTIONS 82
+#define DHO_SUBNET_SELECTION 118 /* RFC3011! */
+/* The DHO_AUTHENTICATE option is not a standard yet, so I've
+ allocated an option out of the "local" option space for it on a
+ temporary basis. Once an option code number is assigned, I will
+ immediately and shamelessly break this, so don't count on it
+ continuing to work. */
+#define DHO_AUTHENTICATE 210
+
+#define DHO_END 255
+
+/* DHCP message types. */
+#define DHCPDISCOVER 1
+#define DHCPOFFER 2
+#define DHCPREQUEST 3
+#define DHCPDECLINE 4
+#define DHCPACK 5
+#define DHCPNAK 6
+#define DHCPRELEASE 7
+#define DHCPINFORM 8
+
+/* Relay Agent Information option subtypes: */
+#define RAI_CIRCUIT_ID 1
+#define RAI_REMOTE_ID 2
+#define RAI_AGENT_ID 3
+
+/* FQDN suboptions: */
+#define FQDN_NO_CLIENT_UPDATE 1
+#define FQDN_SERVER_UPDATE 2
+#define FQDN_ENCODED 3
+#define FQDN_RCODE1 4
+#define FQDN_RCODE2 5
+#define FQDN_HOSTNAME 6
+#define FQDN_DOMAINNAME 7
+#define FQDN_FQDN 8
+#define FQDN_SUBOPTION_COUNT 8
+
+#endif \ No newline at end of file
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp
index 1de7124..cc8ce7f 100644
--- a/libopie2/opienet/opcap.cpp
+++ b/libopie2/opienet/opcap.cpp
@@ -347,46 +347,125 @@ OMacAddress OARPPacket::targetMacAddress() const
/*======================================================================================
* OUDPPacket
*======================================================================================*/
OUDPPacket::OUDPPacket( const unsigned char* end, const struct udphdr* data, QObject* parent )
:QObject( parent, "UDP" ), _udphdr( data )
{
qDebug( "OUDPPacket::OUDPPacket(): decoding UDP header..." );
}
+
OUDPPacket::~OUDPPacket()
{
}
+int OUDPPacket::fromPort() const
+{
+ return _udphdr->source;
+}
+
+
+int OUDPPacket::toPort() const
+{
+ return _udphdr->dest;
+}
+
+
+int OUDPPacket::length() const
+{
+ return _udphdr->len;
+}
+
+
+int OUDPPacket::checksum() const
+{
+ return _udphdr->check;
+}
+
+
+/*======================================================================================
+ * ODHCPPacket
+ *======================================================================================*/
+
+
+ODHCPPacket::ODHCPPacket( const unsigned char* end, const struct dhcp_packet* data, QObject* parent )
+ :QObject( parent, "DHCP" ), _dhcphdr( data )
+
+{
+ qDebug( "ODHCPPacket::ODHCPPacket(): decoding DHCP information..." );
+}
+
+
+ODHCPPacket::~ODHCPPacket()
+{
+}
+
+
/*======================================================================================
* OTCPPacket
*======================================================================================*/
OTCPPacket::OTCPPacket( const unsigned char* end, const struct tcphdr* data, QObject* parent )
:QObject( parent, "TCP" ), _tcphdr( data )
{
qDebug( "OTCPPacket::OTCPPacket(): decoding TCP header..." );
}
+
OTCPPacket::~OTCPPacket()
{
}
+int OTCPPacket::fromPort() const
+{
+ return _tcphdr->source;
+}
+
+
+int OTCPPacket::toPort() const
+{
+ return _tcphdr->dest;
+}
+
+
+int OTCPPacket::seq() const
+{
+ return _tcphdr->seq;
+}
+
+
+int OTCPPacket::ack() const
+{
+ return _tcphdr->ack_seq;
+}
+
+
+int OTCPPacket::window() const
+{
+ return _tcphdr->window;
+}
+
+
+int OTCPPacket::checksum() const
+{
+ return _tcphdr->check;
+}
+
/*======================================================================================
* OPrismHeaderPacket
*======================================================================================*/
OPrismHeaderPacket::OPrismHeaderPacket( const unsigned char* end, const struct prism_hdr* data, QObject* parent )
:QObject( parent, "Prism" ), _header( data )
{
qDebug( "OPrismHeaderPacket::OPrismHeaderPacket(): decoding PRISM header..." );
qDebug( "Signal Strength = %d", data->signal.data );
diff --git a/libopie2/opienet/opcap.h b/libopie2/opienet/opcap.h
index 9119972..0c9e7da 100644
--- a/libopie2/opienet/opcap.h
+++ b/libopie2/opienet/opcap.h
@@ -46,25 +46,28 @@ extern "C" // work around a bpf/pcap conflict in recent headers
#include <time.h>
/* QT */
#include <qevent.h>
#include <qfile.h>
#include <qhostaddress.h>
#include <qobject.h>
#include <qstring.h>
#include <qmap.h>
/* OPIE */
#include <opie2/onetutils.h>
+
+/* Custom Network Includes */
#include "802_11_user.h"
+#include "dhcp.h"
/* TYPEDEFS */
typedef struct timeval timevalstruct;
typedef struct pcap_pkthdr packetheaderstruct;
/* FORWARDS */
class OPacketCapturer;
class QSocketNotifier;
/*======================================================================================
* OPacket - A frame on the wire
*======================================================================================*/
@@ -468,58 +471,81 @@ class OARPPacket : public QObject
*======================================================================================*/
class OUDPPacket : public QObject
{
Q_OBJECT
public:
OUDPPacket( const unsigned char*, const struct udphdr*, QObject* parent = 0 );
virtual ~OUDPPacket();
int fromPort() const;
int toPort() const;
+ int length() const;
+ int checksum() const;
private:
const struct udphdr* _udphdr;
};
/*======================================================================================
+ * ODHCPPacket
+ *======================================================================================*/
+
+class ODHCPPacket : public QObject
+{
+ Q_OBJECT
+
+ public:
+ ODHCPPacket( const unsigned char*, const struct dhcp_packet*, QObject* parent = 0 );
+ virtual ~ODHCPPacket();
+
+ private:
+ const struct dhcp_packet* _dhcphdr;
+};
+
+/*======================================================================================
* OTCPPacket
*======================================================================================*/
class OTCPPacket : public QObject
{
Q_OBJECT
public:
OTCPPacket( const unsigned char*, const struct tcphdr*, QObject* parent = 0 );
virtual ~OTCPPacket();
int fromPort() const;
int toPort() const;
+ int seq() const;
+ int ack() const;
+ int window() const;
+ int checksum() const;
private:
const struct tcphdr* _tcphdr;
};
/*======================================================================================
* OPacketCapturer
*======================================================================================*/
/**
* @brief A class based wrapper for network packet capturing.
*
* This class is the base of a high-level interface to the well known packet capturing
- * library libpcap. ...
+ * library libpcap.
+ * @see http://tcpdump.org
*/
class OPacketCapturer : public QObject
{
Q_OBJECT
public:
/**
* Constructor.
*/
OPacketCapturer( QObject* parent = 0, const char* name = 0 );
/**
* Destructor.
diff --git a/libopie2/opienet/opienet.pro b/libopie2/opienet/opienet.pro
index 93389db..7a7adde 100644
--- a/libopie2/opienet/opienet.pro
+++ b/libopie2/opienet/opienet.pro
@@ -1,16 +1,18 @@
TEMPLATE = lib
CONFIG += qt warn_on debug
DESTDIR = $(OPIEDIR)/lib
-HEADERS = omanufacturerdb.cpp \
+HEADERS = 802_11_user.h \
+ dhcp.h \
+ omanufacturerdb.cpp \
onetutils.cpp \
onetwork.h \
opcap.h
SOURCES = omanufacturerdb.cpp \
onetutils.cpp \
onetwork.cpp \
opcap.cpp
INTERFACES =
TARGET = opienet2
VERSION = 1.8.1
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include