summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-11-08 20:39:38 (UTC)
committer mickeyl <mickeyl>2003-11-08 20:39:38 (UTC)
commiteb26b0413c269b898a24deb30d5602ac0c142a56 (patch) (side-by-side diff)
tree4e9b24ce6a9e8811eb9e62d8537b452921d4564d
parent33d86bb19d4e21b95504ba3b16789d08b4820313 (diff)
downloadopie-eb26b0413c269b898a24deb30d5602ac0c142a56.zip
opie-eb26b0413c269b898a24deb30d5602ac0c142a56.tar.gz
opie-eb26b0413c269b898a24deb30d5602ac0c142a56.tar.bz2
refactor the debug mapper and make it more secure
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/odebugmapper.cpp213
-rw-r--r--libopie2/opienet/odebugmapper.h26
-rw-r--r--libopie2/opienet/oioctlmap.cpp366
-rw-r--r--libopie2/opienet/oioctlmap.h17
-rw-r--r--libopie2/opienet/onetutils.cpp15
-rw-r--r--libopie2/opienet/onetutils.h18
-rw-r--r--libopie2/opienet/onetwork.cpp20
-rw-r--r--libopie2/opienet/opienet.pro4
-rwxr-xr-xlibopie2/tools/regen.py52
9 files changed, 311 insertions, 420 deletions
diff --git a/libopie2/opienet/odebugmapper.cpp b/libopie2/opienet/odebugmapper.cpp
new file mode 100644
index 0000000..d62b3ba
--- a/dev/null
+++ b/libopie2/opienet/odebugmapper.cpp
@@ -0,0 +1,213 @@
+
+/*
+ * debug value mapper - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de>
+ */
+
+#include "odebugmapper.h"
+
+DebugMapper::DebugMapper()
+{
+ qDebug( "DebugMapper::DebugMapper()" );
+
+
+ _map.insert( 0x8902, new QString("SIOCSPGRP") );
+ _map.insert( 0x8904, new QString("SIOCGPGRP") );
+ _map.insert( 0x8905, new QString("SIOCATMARK") );
+ _map.insert( 0x8906, new QString("SIOCGSTAMP") );
+ _map.insert( 0x890B, new QString("SIOCADDRT") );
+ _map.insert( 0x890C, new QString("SIOCDELRT") );
+ _map.insert( 0x890D, new QString("SIOCRTMSG") );
+ _map.insert( 0x8910, new QString("SIOCGIFNAME") );
+ _map.insert( 0x8911, new QString("SIOCSIFLINK") );
+ _map.insert( 0x8912, new QString("SIOCGIFCONF") );
+ _map.insert( 0x8913, new QString("SIOCGIFFLAGS") );
+ _map.insert( 0x8914, new QString("SIOCSIFFLAGS") );
+ _map.insert( 0x8915, new QString("SIOCGIFADDR") );
+ _map.insert( 0x8916, new QString("SIOCSIFADDR") );
+ _map.insert( 0x8917, new QString("SIOCGIFDSTADDR") );
+ _map.insert( 0x8918, new QString("SIOCSIFDSTADDR") );
+ _map.insert( 0x8919, new QString("SIOCGIFBRDADDR") );
+ _map.insert( 0x891a, new QString("SIOCSIFBRDADDR") );
+ _map.insert( 0x891b, new QString("SIOCGIFNETMASK") );
+ _map.insert( 0x891c, new QString("SIOCSIFNETMASK") );
+ _map.insert( 0x891d, new QString("SIOCGIFMETRIC") );
+ _map.insert( 0x891e, new QString("SIOCSIFMETRIC") );
+ _map.insert( 0x891f, new QString("SIOCGIFMEM") );
+ _map.insert( 0x8920, new QString("SIOCSIFMEM") );
+ _map.insert( 0x8921, new QString("SIOCGIFMTU") );
+ _map.insert( 0x8922, new QString("SIOCSIFMTU") );
+ _map.insert( 0x8923, new QString("SIOCSIFNAME") );
+ _map.insert( 0x8924, new QString("SIOCSIFHWADDR") );
+ _map.insert( 0x8925, new QString("SIOCGIFENCAP") );
+ _map.insert( 0x8926, new QString("SIOCSIFENCAP") );
+ _map.insert( 0x8927, new QString("SIOCGIFHWADDR") );
+ _map.insert( 0x8929, new QString("SIOCGIFSLAVE") );
+ _map.insert( 0x8930, new QString("SIOCSIFSLAVE") );
+ _map.insert( 0x8931, new QString("SIOCADDMULTI") );
+ _map.insert( 0x8932, new QString("SIOCDELMULTI") );
+ _map.insert( 0x8933, new QString("SIOCGIFINDEX") );
+ _map.insert( 0x8934, new QString("SIOCSIFPFLAGS") );
+ _map.insert( 0x8935, new QString("SIOCGIFPFLAGS") );
+ _map.insert( 0x8936, new QString("SIOCDIFADDR") );
+ _map.insert( 0x8937, new QString("SIOCSIFHWBROADCAST") );
+ _map.insert( 0x8938, new QString("SIOCGIFCOUNT") );
+ _map.insert( 0x8940, new QString("SIOCGIFBR") );
+ _map.insert( 0x8941, new QString("SIOCSIFBR") );
+ _map.insert( 0x8942, new QString("SIOCGIFTXQLEN") );
+ _map.insert( 0x8943, new QString("SIOCSIFTXQLEN") );
+ _map.insert( 0x8953, new QString("SIOCDARP") );
+ _map.insert( 0x8954, new QString("SIOCGARP") );
+ _map.insert( 0x8955, new QString("SIOCSARP") );
+ _map.insert( 0x8960, new QString("SIOCDRARP") );
+ _map.insert( 0x8961, new QString("SIOCGRARP") );
+ _map.insert( 0x8962, new QString("SIOCSRARP") );
+ _map.insert( 0x8970, new QString("SIOCGIFMAP") );
+ _map.insert( 0x8971, new QString("SIOCSIFMAP") );
+ _map.insert( 0x8980, new QString("SIOCADDDLCI") );
+ _map.insert( 0x8981, new QString("SIOCDELDLCI") );
+ _map.insert( 0x89F0, new QString("SIOCDEVPRIVATE") );
+ _map.insert( 0x89E0, new QString("SIOCPROTOPRIVATE") );
+ _map.insert( 0x1fff, new QString("SIOCPARM_MASK") );
+ _map.insert( 0x00000000, new QString("SIOC_VOID") );
+ _map.insert( 0x20000000, new QString("SIOC_OUT") );
+ _map.insert( 0x40000000, new QString("SIOC_IN") );
+ _map.insert( 0x8B00, new QString("SIOCSIWCOMMIT") );
+ _map.insert( 0x8B01, new QString("SIOCGIWNAME") );
+ _map.insert( 0x8B02, new QString("SIOCSIWNWID") );
+ _map.insert( 0x8B03, new QString("SIOCGIWNWID") );
+ _map.insert( 0x8B04, new QString("SIOCSIWFREQ") );
+ _map.insert( 0x8B05, new QString("SIOCGIWFREQ") );
+ _map.insert( 0x8B06, new QString("SIOCSIWMODE") );
+ _map.insert( 0x8B07, new QString("SIOCGIWMODE") );
+ _map.insert( 0x8B08, new QString("SIOCSIWSENS") );
+ _map.insert( 0x8B09, new QString("SIOCGIWSENS") );
+ _map.insert( 0x8B0A, new QString("SIOCSIWRANGE") );
+ _map.insert( 0x8B0B, new QString("SIOCGIWRANGE") );
+ _map.insert( 0x8B0C, new QString("SIOCSIWPRIV") );
+ _map.insert( 0x8B0D, new QString("SIOCGIWPRIV") );
+ _map.insert( 0x8B0E, new QString("SIOCSIWSTATS") );
+ _map.insert( 0x8B0F, new QString("SIOCGIWSTATS") );
+ _map.insert( 0x8B10, new QString("SIOCSIWSPY") );
+ _map.insert( 0x8B11, new QString("SIOCGIWSPY") );
+ _map.insert( 0x8B14, new QString("SIOCSIWAP") );
+ _map.insert( 0x8B15, new QString("SIOCGIWAP") );
+ _map.insert( 0x8B17, new QString("SIOCGIWAPLIST") );
+ _map.insert( 0x8B18, new QString("SIOCSIWSCAN") );
+ _map.insert( 0x8B19, new QString("SIOCGIWSCAN") );
+ _map.insert( 0x8B1A, new QString("SIOCSIWESSID") );
+ _map.insert( 0x8B1B, new QString("SIOCGIWESSID") );
+ _map.insert( 0x8B1C, new QString("SIOCSIWNICKN") );
+ _map.insert( 0x8B1D, new QString("SIOCGIWNICKN") );
+ _map.insert( 0x8B20, new QString("SIOCSIWRATE") );
+ _map.insert( 0x8B21, new QString("SIOCGIWRATE") );
+ _map.insert( 0x8B22, new QString("SIOCSIWRTS") );
+ _map.insert( 0x8B23, new QString("SIOCGIWRTS") );
+ _map.insert( 0x8B24, new QString("SIOCSIWFRAG") );
+ _map.insert( 0x8B25, new QString("SIOCGIWFRAG") );
+ _map.insert( 0x8B26, new QString("SIOCSIWTXPOW") );
+ _map.insert( 0x8B27, new QString("SIOCGIWTXPOW") );
+ _map.insert( 0x8B28, new QString("SIOCSIWRETRY") );
+ _map.insert( 0x8B29, new QString("SIOCGIWRETRY") );
+ _map.insert( 0x8B2A, new QString("SIOCSIWENCODE") );
+ _map.insert( 0x8B2B, new QString("SIOCGIWENCODE") );
+ _map.insert( 0x8B2C, new QString("SIOCSIWPOWER") );
+ _map.insert( 0x8B2D, new QString("SIOCGIWPOWER") );
+ _map.insert( 0x8BE0, new QString("SIOCIWFIRSTPRIV") );
+ _map.insert( 0x8BFF, new QString("SIOCIWLASTPRIV") );
+ _map.insert( 0x8B00, new QString("SIOCIWFIRST") );
+ _map.insert( 0x5000, new QString("SIOCGBPQETHPARAM") );
+ _map.insert( 0x5001, new QString("SIOCSBPQETHPARAM") );
+ _map.insert( 0x890B, new QString("SIOCADDRT") );
+ _map.insert( 0x890C, new QString("SIOCDELRT") );
+ _map.insert( 0x890D, new QString("SIOCRTMSG") );
+ _map.insert( 0x8910, new QString("SIOCGIFNAME") );
+ _map.insert( 0x8911, new QString("SIOCSIFLINK") );
+ _map.insert( 0x8912, new QString("SIOCGIFCONF") );
+ _map.insert( 0x8913, new QString("SIOCGIFFLAGS") );
+ _map.insert( 0x8914, new QString("SIOCSIFFLAGS") );
+ _map.insert( 0x8915, new QString("SIOCGIFADDR") );
+ _map.insert( 0x8916, new QString("SIOCSIFADDR") );
+ _map.insert( 0x8917, new QString("SIOCGIFDSTADDR") );
+ _map.insert( 0x8918, new QString("SIOCSIFDSTADDR") );
+ _map.insert( 0x8919, new QString("SIOCGIFBRDADDR") );
+ _map.insert( 0x891a, new QString("SIOCSIFBRDADDR") );
+ _map.insert( 0x891b, new QString("SIOCGIFNETMASK") );
+ _map.insert( 0x891c, new QString("SIOCSIFNETMASK") );
+ _map.insert( 0x891d, new QString("SIOCGIFMETRIC") );
+ _map.insert( 0x891e, new QString("SIOCSIFMETRIC") );
+ _map.insert( 0x891f, new QString("SIOCGIFMEM") );
+ _map.insert( 0x8920, new QString("SIOCSIFMEM") );
+ _map.insert( 0x8921, new QString("SIOCGIFMTU") );
+ _map.insert( 0x8922, new QString("SIOCSIFMTU") );
+ _map.insert( 0x8923, new QString("SIOCSIFNAME") );
+ _map.insert( 0x8924, new QString("SIOCSIFHWADDR") );
+ _map.insert( 0x8925, new QString("SIOCGIFENCAP") );
+ _map.insert( 0x8926, new QString("SIOCSIFENCAP") );
+ _map.insert( 0x8927, new QString("SIOCGIFHWADDR") );
+ _map.insert( 0x8929, new QString("SIOCGIFSLAVE") );
+ _map.insert( 0x8930, new QString("SIOCSIFSLAVE") );
+ _map.insert( 0x8931, new QString("SIOCADDMULTI") );
+ _map.insert( 0x8932, new QString("SIOCDELMULTI") );
+ _map.insert( 0x8933, new QString("SIOCGIFINDEX") );
+ _map.insert( 0x8934, new QString("SIOCSIFPFLAGS") );
+ _map.insert( 0x8935, new QString("SIOCGIFPFLAGS") );
+ _map.insert( 0x8936, new QString("SIOCDIFADDR") );
+ _map.insert( 0x8937, new QString("SIOCSIFHWBROADCAST") );
+ _map.insert( 0x8938, new QString("SIOCGIFCOUNT") );
+ _map.insert( 0x8940, new QString("SIOCGIFBR") );
+ _map.insert( 0x8941, new QString("SIOCSIFBR") );
+ _map.insert( 0x8942, new QString("SIOCGIFTXQLEN") );
+ _map.insert( 0x8943, new QString("SIOCSIFTXQLEN") );
+ _map.insert( 0x8944, new QString("SIOCGIFDIVERT") );
+ _map.insert( 0x8945, new QString("SIOCSIFDIVERT") );
+ _map.insert( 0x8946, new QString("SIOCETHTOOL") );
+ _map.insert( 0x8947, new QString("SIOCGMIIPHY") );
+ _map.insert( 0x8948, new QString("SIOCGMIIREG") );
+ _map.insert( 0x8949, new QString("SIOCSMIIREG") );
+ _map.insert( 0x894A, new QString("SIOCWANDEV") );
+ _map.insert( 0x8953, new QString("SIOCDARP") );
+ _map.insert( 0x8954, new QString("SIOCGARP") );
+ _map.insert( 0x8955, new QString("SIOCSARP") );
+ _map.insert( 0x8960, new QString("SIOCDRARP") );
+ _map.insert( 0x8961, new QString("SIOCGRARP") );
+ _map.insert( 0x8962, new QString("SIOCSRARP") );
+ _map.insert( 0x8970, new QString("SIOCGIFMAP") );
+ _map.insert( 0x8971, new QString("SIOCSIFMAP") );
+ _map.insert( 0x8980, new QString("SIOCADDDLCI") );
+ _map.insert( 0x8981, new QString("SIOCDELDLCI") );
+ _map.insert( 0x8982, new QString("SIOCGIFVLAN") );
+ _map.insert( 0x8983, new QString("SIOCSIFVLAN") );
+ _map.insert( 0x8990, new QString("SIOCBONDENSLAVE") );
+ _map.insert( 0x8991, new QString("SIOCBONDRELEASE") );
+ _map.insert( 0x8992, new QString("SIOCBONDSETHWADDR") );
+ _map.insert( 0x8993, new QString("SIOCBONDSLAVEINFOQUERY") );
+ _map.insert( 0x8994, new QString("SIOCBONDINFOQUERY") );
+ _map.insert( 0x8995, new QString("SIOCBONDCHANGEACTIVE") );
+ _map.insert( 0x89F0, new QString("SIOCDEVPRIVATE") );
+ _map.insert( 0x89E0, new QString("SIOCPROTOPRIVATE") );
+
+};
+
+
+DebugMapper::~DebugMapper()
+{
+ qDebug( "DebugMapper::~DebugMapper()" );
+}
+
+
+const QString& DebugMapper::map( int value ) const
+{
+ QString* result = _map[ value ];
+
+ if ( !result )
+ {
+ qDebug( "DebugMapper::map() - value not found." );
+ return QString::null;
+ }
+ else
+ {
+ return *result;
+ }
+}
+
+
diff --git a/libopie2/opienet/odebugmapper.h b/libopie2/opienet/odebugmapper.h
new file mode 100644
index 0000000..66b331d
--- a/dev/null
+++ b/libopie2/opienet/odebugmapper.h
@@ -0,0 +1,26 @@
+
+/*
+ * debug value mapper - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de>
+ */
+
+#ifndef DEBUGMAPPER_H
+#define DEBUGMAPPER_H
+
+#include <qstring.h>
+#include <qintdict.h>
+
+typedef QIntDict<QString> IntStringMap;
+
+class DebugMapper
+{
+ public:
+ DebugMapper();
+ ~DebugMapper();
+
+ const QString& map( int value ) const;
+ private:
+ IntStringMap _map;
+};
+
+#endif
+
diff --git a/libopie2/opienet/oioctlmap.cpp b/libopie2/opienet/oioctlmap.cpp
deleted file mode 100644
index 4a67eb6..0000000
--- a/libopie2/opienet/oioctlmap.cpp
+++ b/dev/null
@@ -1,366 +0,0 @@
-
-/*
- * ioctl table - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de>
- */
-
-#include "oioctlmap.h"
-
-IntStringMap* constructIoctlMap()
-{
- IntStringMap* map = new IntStringMap();
-
-
- qDebug( "adding 0x8902 = SIOCSPGRP" );
- map->insert( 0x8902, new QString("SIOCSPGRP") );
- qDebug( "adding 0x8904 = SIOCGPGRP" );
- map->insert( 0x8904, new QString("SIOCGPGRP") );
- qDebug( "adding 0x8905 = SIOCATMARK" );
- map->insert( 0x8905, new QString("SIOCATMARK") );
- qDebug( "adding 0x8906 = SIOCGSTAMP" );
- map->insert( 0x8906, new QString("SIOCGSTAMP") );
- qDebug( "adding 0x890B = SIOCADDRT" );
- map->insert( 0x890B, new QString("SIOCADDRT") );
- qDebug( "adding 0x890C = SIOCDELRT" );
- map->insert( 0x890C, new QString("SIOCDELRT") );
- qDebug( "adding 0x890D = SIOCRTMSG" );
- map->insert( 0x890D, new QString("SIOCRTMSG") );
- qDebug( "adding 0x8910 = SIOCGIFNAME" );
- map->insert( 0x8910, new QString("SIOCGIFNAME") );
- qDebug( "adding 0x8911 = SIOCSIFLINK" );
- map->insert( 0x8911, new QString("SIOCSIFLINK") );
- qDebug( "adding 0x8912 = SIOCGIFCONF" );
- map->insert( 0x8912, new QString("SIOCGIFCONF") );
- qDebug( "adding 0x8913 = SIOCGIFFLAGS" );
- map->insert( 0x8913, new QString("SIOCGIFFLAGS") );
- qDebug( "adding 0x8914 = SIOCSIFFLAGS" );
- map->insert( 0x8914, new QString("SIOCSIFFLAGS") );
- qDebug( "adding 0x8915 = SIOCGIFADDR" );
- map->insert( 0x8915, new QString("SIOCGIFADDR") );
- qDebug( "adding 0x8916 = SIOCSIFADDR" );
- map->insert( 0x8916, new QString("SIOCSIFADDR") );
- qDebug( "adding 0x8917 = SIOCGIFDSTADDR" );
- map->insert( 0x8917, new QString("SIOCGIFDSTADDR") );
- qDebug( "adding 0x8918 = SIOCSIFDSTADDR" );
- map->insert( 0x8918, new QString("SIOCSIFDSTADDR") );
- qDebug( "adding 0x8919 = SIOCGIFBRDADDR" );
- map->insert( 0x8919, new QString("SIOCGIFBRDADDR") );
- qDebug( "adding 0x891a = SIOCSIFBRDADDR" );
- map->insert( 0x891a, new QString("SIOCSIFBRDADDR") );
- qDebug( "adding 0x891b = SIOCGIFNETMASK" );
- map->insert( 0x891b, new QString("SIOCGIFNETMASK") );
- qDebug( "adding 0x891c = SIOCSIFNETMASK" );
- map->insert( 0x891c, new QString("SIOCSIFNETMASK") );
- qDebug( "adding 0x891d = SIOCGIFMETRIC" );
- map->insert( 0x891d, new QString("SIOCGIFMETRIC") );
- qDebug( "adding 0x891e = SIOCSIFMETRIC" );
- map->insert( 0x891e, new QString("SIOCSIFMETRIC") );
- qDebug( "adding 0x891f = SIOCGIFMEM" );
- map->insert( 0x891f, new QString("SIOCGIFMEM") );
- qDebug( "adding 0x8920 = SIOCSIFMEM" );
- map->insert( 0x8920, new QString("SIOCSIFMEM") );
- qDebug( "adding 0x8921 = SIOCGIFMTU" );
- map->insert( 0x8921, new QString("SIOCGIFMTU") );
- qDebug( "adding 0x8922 = SIOCSIFMTU" );
- map->insert( 0x8922, new QString("SIOCSIFMTU") );
- qDebug( "adding 0x8923 = SIOCSIFNAME" );
- map->insert( 0x8923, new QString("SIOCSIFNAME") );
- qDebug( "adding 0x8924 = SIOCSIFHWADDR" );
- map->insert( 0x8924, new QString("SIOCSIFHWADDR") );
- qDebug( "adding 0x8925 = SIOCGIFENCAP" );
- map->insert( 0x8925, new QString("SIOCGIFENCAP") );
- qDebug( "adding 0x8926 = SIOCSIFENCAP" );
- map->insert( 0x8926, new QString("SIOCSIFENCAP") );
- qDebug( "adding 0x8927 = SIOCGIFHWADDR" );
- map->insert( 0x8927, new QString("SIOCGIFHWADDR") );
- qDebug( "adding 0x8929 = SIOCGIFSLAVE" );
- map->insert( 0x8929, new QString("SIOCGIFSLAVE") );
- qDebug( "adding 0x8930 = SIOCSIFSLAVE" );
- map->insert( 0x8930, new QString("SIOCSIFSLAVE") );
- qDebug( "adding 0x8931 = SIOCADDMULTI" );
- map->insert( 0x8931, new QString("SIOCADDMULTI") );
- qDebug( "adding 0x8932 = SIOCDELMULTI" );
- map->insert( 0x8932, new QString("SIOCDELMULTI") );
- qDebug( "adding 0x8933 = SIOCGIFINDEX" );
- map->insert( 0x8933, new QString("SIOCGIFINDEX") );
- qDebug( "adding 0x8934 = SIOCSIFPFLAGS" );
- map->insert( 0x8934, new QString("SIOCSIFPFLAGS") );
- qDebug( "adding 0x8935 = SIOCGIFPFLAGS" );
- map->insert( 0x8935, new QString("SIOCGIFPFLAGS") );
- qDebug( "adding 0x8936 = SIOCDIFADDR" );
- map->insert( 0x8936, new QString("SIOCDIFADDR") );
- qDebug( "adding 0x8937 = SIOCSIFHWBROADCAST" );
- map->insert( 0x8937, new QString("SIOCSIFHWBROADCAST") );
- qDebug( "adding 0x8938 = SIOCGIFCOUNT" );
- map->insert( 0x8938, new QString("SIOCGIFCOUNT") );
- qDebug( "adding 0x8940 = SIOCGIFBR" );
- map->insert( 0x8940, new QString("SIOCGIFBR") );
- qDebug( "adding 0x8941 = SIOCSIFBR" );
- map->insert( 0x8941, new QString("SIOCSIFBR") );
- qDebug( "adding 0x8942 = SIOCGIFTXQLEN" );
- map->insert( 0x8942, new QString("SIOCGIFTXQLEN") );
- qDebug( "adding 0x8943 = SIOCSIFTXQLEN" );
- map->insert( 0x8943, new QString("SIOCSIFTXQLEN") );
- qDebug( "adding 0x8953 = SIOCDARP" );
- map->insert( 0x8953, new QString("SIOCDARP") );
- qDebug( "adding 0x8954 = SIOCGARP" );
- map->insert( 0x8954, new QString("SIOCGARP") );
- qDebug( "adding 0x8955 = SIOCSARP" );
- map->insert( 0x8955, new QString("SIOCSARP") );
- qDebug( "adding 0x8960 = SIOCDRARP" );
- map->insert( 0x8960, new QString("SIOCDRARP") );
- qDebug( "adding 0x8961 = SIOCGRARP" );
- map->insert( 0x8961, new QString("SIOCGRARP") );
- qDebug( "adding 0x8962 = SIOCSRARP" );
- map->insert( 0x8962, new QString("SIOCSRARP") );
- qDebug( "adding 0x8970 = SIOCGIFMAP" );
- map->insert( 0x8970, new QString("SIOCGIFMAP") );
- qDebug( "adding 0x8971 = SIOCSIFMAP" );
- map->insert( 0x8971, new QString("SIOCSIFMAP") );
- qDebug( "adding 0x8980 = SIOCADDDLCI" );
- map->insert( 0x8980, new QString("SIOCADDDLCI") );
- qDebug( "adding 0x8981 = SIOCDELDLCI" );
- map->insert( 0x8981, new QString("SIOCDELDLCI") );
- qDebug( "adding 0x89F0 = SIOCDEVPRIVATE" );
- map->insert( 0x89F0, new QString("SIOCDEVPRIVATE") );
- qDebug( "adding 0x89E0 = SIOCPROTOPRIVATE" );
- map->insert( 0x89E0, new QString("SIOCPROTOPRIVATE") );
- qDebug( "adding 0x1fff = SIOCPARM_MASK" );
- map->insert( 0x1fff, new QString("SIOCPARM_MASK") );
- qDebug( "adding 0x00000000 = SIOC_VOID" );
- map->insert( 0x00000000, new QString("SIOC_VOID") );
- qDebug( "adding 0x20000000 = SIOC_OUT" );
- map->insert( 0x20000000, new QString("SIOC_OUT") );
- qDebug( "adding 0x40000000 = SIOC_IN" );
- map->insert( 0x40000000, new QString("SIOC_IN") );
- qDebug( "adding 0x8B00 = SIOCSIWCOMMIT" );
- map->insert( 0x8B00, new QString("SIOCSIWCOMMIT") );
- qDebug( "adding 0x8B01 = SIOCGIWNAME" );
- map->insert( 0x8B01, new QString("SIOCGIWNAME") );
- qDebug( "adding 0x8B02 = SIOCSIWNWID" );
- map->insert( 0x8B02, new QString("SIOCSIWNWID") );
- qDebug( "adding 0x8B03 = SIOCGIWNWID" );
- map->insert( 0x8B03, new QString("SIOCGIWNWID") );
- qDebug( "adding 0x8B04 = SIOCSIWFREQ" );
- map->insert( 0x8B04, new QString("SIOCSIWFREQ") );
- qDebug( "adding 0x8B05 = SIOCGIWFREQ" );
- map->insert( 0x8B05, new QString("SIOCGIWFREQ") );
- qDebug( "adding 0x8B06 = SIOCSIWMODE" );
- map->insert( 0x8B06, new QString("SIOCSIWMODE") );
- qDebug( "adding 0x8B07 = SIOCGIWMODE" );
- map->insert( 0x8B07, new QString("SIOCGIWMODE") );
- qDebug( "adding 0x8B08 = SIOCSIWSENS" );
- map->insert( 0x8B08, new QString("SIOCSIWSENS") );
- qDebug( "adding 0x8B09 = SIOCGIWSENS" );
- map->insert( 0x8B09, new QString("SIOCGIWSENS") );
- qDebug( "adding 0x8B0A = SIOCSIWRANGE" );
- map->insert( 0x8B0A, new QString("SIOCSIWRANGE") );
- qDebug( "adding 0x8B0B = SIOCGIWRANGE" );
- map->insert( 0x8B0B, new QString("SIOCGIWRANGE") );
- qDebug( "adding 0x8B0C = SIOCSIWPRIV" );
- map->insert( 0x8B0C, new QString("SIOCSIWPRIV") );
- qDebug( "adding 0x8B0D = SIOCGIWPRIV" );
- map->insert( 0x8B0D, new QString("SIOCGIWPRIV") );
- qDebug( "adding 0x8B0E = SIOCSIWSTATS" );
- map->insert( 0x8B0E, new QString("SIOCSIWSTATS") );
- qDebug( "adding 0x8B0F = SIOCGIWSTATS" );
- map->insert( 0x8B0F, new QString("SIOCGIWSTATS") );
- qDebug( "adding 0x8B10 = SIOCSIWSPY" );
- map->insert( 0x8B10, new QString("SIOCSIWSPY") );
- qDebug( "adding 0x8B11 = SIOCGIWSPY" );
- map->insert( 0x8B11, new QString("SIOCGIWSPY") );
- qDebug( "adding 0x8B14 = SIOCSIWAP" );
- map->insert( 0x8B14, new QString("SIOCSIWAP") );
- qDebug( "adding 0x8B15 = SIOCGIWAP" );
- map->insert( 0x8B15, new QString("SIOCGIWAP") );
- qDebug( "adding 0x8B17 = SIOCGIWAPLIST" );
- map->insert( 0x8B17, new QString("SIOCGIWAPLIST") );
- qDebug( "adding 0x8B18 = SIOCSIWSCAN" );
- map->insert( 0x8B18, new QString("SIOCSIWSCAN") );
- qDebug( "adding 0x8B19 = SIOCGIWSCAN" );
- map->insert( 0x8B19, new QString("SIOCGIWSCAN") );
- qDebug( "adding 0x8B1A = SIOCSIWESSID" );
- map->insert( 0x8B1A, new QString("SIOCSIWESSID") );
- qDebug( "adding 0x8B1B = SIOCGIWESSID" );
- map->insert( 0x8B1B, new QString("SIOCGIWESSID") );
- qDebug( "adding 0x8B1C = SIOCSIWNICKN" );
- map->insert( 0x8B1C, new QString("SIOCSIWNICKN") );
- qDebug( "adding 0x8B1D = SIOCGIWNICKN" );
- map->insert( 0x8B1D, new QString("SIOCGIWNICKN") );
- qDebug( "adding 0x8B20 = SIOCSIWRATE" );
- map->insert( 0x8B20, new QString("SIOCSIWRATE") );
- qDebug( "adding 0x8B21 = SIOCGIWRATE" );
- map->insert( 0x8B21, new QString("SIOCGIWRATE") );
- qDebug( "adding 0x8B22 = SIOCSIWRTS" );
- map->insert( 0x8B22, new QString("SIOCSIWRTS") );
- qDebug( "adding 0x8B23 = SIOCGIWRTS" );
- map->insert( 0x8B23, new QString("SIOCGIWRTS") );
- qDebug( "adding 0x8B24 = SIOCSIWFRAG" );
- map->insert( 0x8B24, new QString("SIOCSIWFRAG") );
- qDebug( "adding 0x8B25 = SIOCGIWFRAG" );
- map->insert( 0x8B25, new QString("SIOCGIWFRAG") );
- qDebug( "adding 0x8B26 = SIOCSIWTXPOW" );
- map->insert( 0x8B26, new QString("SIOCSIWTXPOW") );
- qDebug( "adding 0x8B27 = SIOCGIWTXPOW" );
- map->insert( 0x8B27, new QString("SIOCGIWTXPOW") );
- qDebug( "adding 0x8B28 = SIOCSIWRETRY" );
- map->insert( 0x8B28, new QString("SIOCSIWRETRY") );
- qDebug( "adding 0x8B29 = SIOCGIWRETRY" );
- map->insert( 0x8B29, new QString("SIOCGIWRETRY") );
- qDebug( "adding 0x8B2A = SIOCSIWENCODE" );
- map->insert( 0x8B2A, new QString("SIOCSIWENCODE") );
- qDebug( "adding 0x8B2B = SIOCGIWENCODE" );
- map->insert( 0x8B2B, new QString("SIOCGIWENCODE") );
- qDebug( "adding 0x8B2C = SIOCSIWPOWER" );
- map->insert( 0x8B2C, new QString("SIOCSIWPOWER") );
- qDebug( "adding 0x8B2D = SIOCGIWPOWER" );
- map->insert( 0x8B2D, new QString("SIOCGIWPOWER") );
- qDebug( "adding 0x8BE0 = SIOCIWFIRSTPRIV" );
- map->insert( 0x8BE0, new QString("SIOCIWFIRSTPRIV") );
- qDebug( "adding 0x8BFF = SIOCIWLASTPRIV" );
- map->insert( 0x8BFF, new QString("SIOCIWLASTPRIV") );
- qDebug( "adding 0x8B00 = SIOCIWFIRST" );
- map->insert( 0x8B00, new QString("SIOCIWFIRST") );
- qDebug( "adding 0x5000 = SIOCGBPQETHPARAM" );
- map->insert( 0x5000, new QString("SIOCGBPQETHPARAM") );
- qDebug( "adding 0x5001 = SIOCSBPQETHPARAM" );
- map->insert( 0x5001, new QString("SIOCSBPQETHPARAM") );
- qDebug( "adding 0x890B = SIOCADDRT" );
- map->insert( 0x890B, new QString("SIOCADDRT") );
- qDebug( "adding 0x890C = SIOCDELRT" );
- map->insert( 0x890C, new QString("SIOCDELRT") );
- qDebug( "adding 0x890D = SIOCRTMSG" );
- map->insert( 0x890D, new QString("SIOCRTMSG") );
- qDebug( "adding 0x8910 = SIOCGIFNAME" );
- map->insert( 0x8910, new QString("SIOCGIFNAME") );
- qDebug( "adding 0x8911 = SIOCSIFLINK" );
- map->insert( 0x8911, new QString("SIOCSIFLINK") );
- qDebug( "adding 0x8912 = SIOCGIFCONF" );
- map->insert( 0x8912, new QString("SIOCGIFCONF") );
- qDebug( "adding 0x8913 = SIOCGIFFLAGS" );
- map->insert( 0x8913, new QString("SIOCGIFFLAGS") );
- qDebug( "adding 0x8914 = SIOCSIFFLAGS" );
- map->insert( 0x8914, new QString("SIOCSIFFLAGS") );
- qDebug( "adding 0x8915 = SIOCGIFADDR" );
- map->insert( 0x8915, new QString("SIOCGIFADDR") );
- qDebug( "adding 0x8916 = SIOCSIFADDR" );
- map->insert( 0x8916, new QString("SIOCSIFADDR") );
- qDebug( "adding 0x8917 = SIOCGIFDSTADDR" );
- map->insert( 0x8917, new QString("SIOCGIFDSTADDR") );
- qDebug( "adding 0x8918 = SIOCSIFDSTADDR" );
- map->insert( 0x8918, new QString("SIOCSIFDSTADDR") );
- qDebug( "adding 0x8919 = SIOCGIFBRDADDR" );
- map->insert( 0x8919, new QString("SIOCGIFBRDADDR") );
- qDebug( "adding 0x891a = SIOCSIFBRDADDR" );
- map->insert( 0x891a, new QString("SIOCSIFBRDADDR") );
- qDebug( "adding 0x891b = SIOCGIFNETMASK" );
- map->insert( 0x891b, new QString("SIOCGIFNETMASK") );
- qDebug( "adding 0x891c = SIOCSIFNETMASK" );
- map->insert( 0x891c, new QString("SIOCSIFNETMASK") );
- qDebug( "adding 0x891d = SIOCGIFMETRIC" );
- map->insert( 0x891d, new QString("SIOCGIFMETRIC") );
- qDebug( "adding 0x891e = SIOCSIFMETRIC" );
- map->insert( 0x891e, new QString("SIOCSIFMETRIC") );
- qDebug( "adding 0x891f = SIOCGIFMEM" );
- map->insert( 0x891f, new QString("SIOCGIFMEM") );
- qDebug( "adding 0x8920 = SIOCSIFMEM" );
- map->insert( 0x8920, new QString("SIOCSIFMEM") );
- qDebug( "adding 0x8921 = SIOCGIFMTU" );
- map->insert( 0x8921, new QString("SIOCGIFMTU") );
- qDebug( "adding 0x8922 = SIOCSIFMTU" );
- map->insert( 0x8922, new QString("SIOCSIFMTU") );
- qDebug( "adding 0x8923 = SIOCSIFNAME" );
- map->insert( 0x8923, new QString("SIOCSIFNAME") );
- qDebug( "adding 0x8924 = SIOCSIFHWADDR" );
- map->insert( 0x8924, new QString("SIOCSIFHWADDR") );
- qDebug( "adding 0x8925 = SIOCGIFENCAP" );
- map->insert( 0x8925, new QString("SIOCGIFENCAP") );
- qDebug( "adding 0x8926 = SIOCSIFENCAP" );
- map->insert( 0x8926, new QString("SIOCSIFENCAP") );
- qDebug( "adding 0x8927 = SIOCGIFHWADDR" );
- map->insert( 0x8927, new QString("SIOCGIFHWADDR") );
- qDebug( "adding 0x8929 = SIOCGIFSLAVE" );
- map->insert( 0x8929, new QString("SIOCGIFSLAVE") );
- qDebug( "adding 0x8930 = SIOCSIFSLAVE" );
- map->insert( 0x8930, new QString("SIOCSIFSLAVE") );
- qDebug( "adding 0x8931 = SIOCADDMULTI" );
- map->insert( 0x8931, new QString("SIOCADDMULTI") );
- qDebug( "adding 0x8932 = SIOCDELMULTI" );
- map->insert( 0x8932, new QString("SIOCDELMULTI") );
- qDebug( "adding 0x8933 = SIOCGIFINDEX" );
- map->insert( 0x8933, new QString("SIOCGIFINDEX") );
- qDebug( "adding 0x8934 = SIOCSIFPFLAGS" );
- map->insert( 0x8934, new QString("SIOCSIFPFLAGS") );
- qDebug( "adding 0x8935 = SIOCGIFPFLAGS" );
- map->insert( 0x8935, new QString("SIOCGIFPFLAGS") );
- qDebug( "adding 0x8936 = SIOCDIFADDR" );
- map->insert( 0x8936, new QString("SIOCDIFADDR") );
- qDebug( "adding 0x8937 = SIOCSIFHWBROADCAST" );
- map->insert( 0x8937, new QString("SIOCSIFHWBROADCAST") );
- qDebug( "adding 0x8938 = SIOCGIFCOUNT" );
- map->insert( 0x8938, new QString("SIOCGIFCOUNT") );
- qDebug( "adding 0x8940 = SIOCGIFBR" );
- map->insert( 0x8940, new QString("SIOCGIFBR") );
- qDebug( "adding 0x8941 = SIOCSIFBR" );
- map->insert( 0x8941, new QString("SIOCSIFBR") );
- qDebug( "adding 0x8942 = SIOCGIFTXQLEN" );
- map->insert( 0x8942, new QString("SIOCGIFTXQLEN") );
- qDebug( "adding 0x8943 = SIOCSIFTXQLEN" );
- map->insert( 0x8943, new QString("SIOCSIFTXQLEN") );
- qDebug( "adding 0x8944 = SIOCGIFDIVERT" );
- map->insert( 0x8944, new QString("SIOCGIFDIVERT") );
- qDebug( "adding 0x8945 = SIOCSIFDIVERT" );
- map->insert( 0x8945, new QString("SIOCSIFDIVERT") );
- qDebug( "adding 0x8946 = SIOCETHTOOL" );
- map->insert( 0x8946, new QString("SIOCETHTOOL") );
- qDebug( "adding 0x8947 = SIOCGMIIPHY" );
- map->insert( 0x8947, new QString("SIOCGMIIPHY") );
- qDebug( "adding 0x8948 = SIOCGMIIREG" );
- map->insert( 0x8948, new QString("SIOCGMIIREG") );
- qDebug( "adding 0x8949 = SIOCSMIIREG" );
- map->insert( 0x8949, new QString("SIOCSMIIREG") );
- qDebug( "adding 0x894A = SIOCWANDEV" );
- map->insert( 0x894A, new QString("SIOCWANDEV") );
- qDebug( "adding 0x8953 = SIOCDARP" );
- map->insert( 0x8953, new QString("SIOCDARP") );
- qDebug( "adding 0x8954 = SIOCGARP" );
- map->insert( 0x8954, new QString("SIOCGARP") );
- qDebug( "adding 0x8955 = SIOCSARP" );
- map->insert( 0x8955, new QString("SIOCSARP") );
- qDebug( "adding 0x8960 = SIOCDRARP" );
- map->insert( 0x8960, new QString("SIOCDRARP") );
- qDebug( "adding 0x8961 = SIOCGRARP" );
- map->insert( 0x8961, new QString("SIOCGRARP") );
- qDebug( "adding 0x8962 = SIOCSRARP" );
- map->insert( 0x8962, new QString("SIOCSRARP") );
- qDebug( "adding 0x8970 = SIOCGIFMAP" );
- map->insert( 0x8970, new QString("SIOCGIFMAP") );
- qDebug( "adding 0x8971 = SIOCSIFMAP" );
- map->insert( 0x8971, new QString("SIOCSIFMAP") );
- qDebug( "adding 0x8980 = SIOCADDDLCI" );
- map->insert( 0x8980, new QString("SIOCADDDLCI") );
- qDebug( "adding 0x8981 = SIOCDELDLCI" );
- map->insert( 0x8981, new QString("SIOCDELDLCI") );
- qDebug( "adding 0x8982 = SIOCGIFVLAN" );
- map->insert( 0x8982, new QString("SIOCGIFVLAN") );
- qDebug( "adding 0x8983 = SIOCSIFVLAN" );
- map->insert( 0x8983, new QString("SIOCSIFVLAN") );
- qDebug( "adding 0x8990 = SIOCBONDENSLAVE" );
- map->insert( 0x8990, new QString("SIOCBONDENSLAVE") );
- qDebug( "adding 0x8991 = SIOCBONDRELEASE" );
- map->insert( 0x8991, new QString("SIOCBONDRELEASE") );
- qDebug( "adding 0x8992 = SIOCBONDSETHWADDR" );
- map->insert( 0x8992, new QString("SIOCBONDSETHWADDR") );
- qDebug( "adding 0x8993 = SIOCBONDSLAVEINFOQUERY" );
- map->insert( 0x8993, new QString("SIOCBONDSLAVEINFOQUERY") );
- qDebug( "adding 0x8994 = SIOCBONDINFOQUERY" );
- map->insert( 0x8994, new QString("SIOCBONDINFOQUERY") );
- qDebug( "adding 0x8995 = SIOCBONDCHANGEACTIVE" );
- map->insert( 0x8995, new QString("SIOCBONDCHANGEACTIVE") );
- qDebug( "adding 0x89F0 = SIOCDEVPRIVATE" );
- map->insert( 0x89F0, new QString("SIOCDEVPRIVATE") );
- qDebug( "adding 0x89E0 = SIOCPROTOPRIVATE" );
- map->insert( 0x89E0, new QString("SIOCPROTOPRIVATE") );
-
- return map;
-};
-
diff --git a/libopie2/opienet/oioctlmap.h b/libopie2/opienet/oioctlmap.h
deleted file mode 100644
index 1cd89a3..0000000
--- a/libopie2/opienet/oioctlmap.h
+++ b/dev/null
@@ -1,17 +0,0 @@
-
-/*
- * ioctl table - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de>
- */
-
-#ifndef IOCTLMAP_H
-#define IOCTLMAP_H
-
-#include <qstring.h>
-#include <qintdict.h>
-
-typedef QIntDict<QString> IntStringMap;
-
-IntStringMap* constructIoctlMap();
-
-#endif
-
diff --git a/libopie2/opienet/onetutils.cpp b/libopie2/opienet/onetutils.cpp
index ce147c5..e3eb327 100644
--- a/libopie2/opienet/onetutils.cpp
+++ b/libopie2/opienet/onetutils.cpp
@@ -1,243 +1,232 @@
/*
                This file is part of the Opie Project
              (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <opie2/onetutils.h>
#include <opie2/onetwork.h>
#include <opie2/omanufacturerdb.h>
#include <net/if.h>
-#include <cassert>
-#include <cstdio>
-using namespace std;
-
-#define IW_PRIV_TYPE_MASK 0x7000
-#define IW_PRIV_TYPE_NONE 0x0000
-#define IW_PRIV_TYPE_BYTE 0x1000
-#define IW_PRIV_TYPE_CHAR 0x2000
-#define IW_PRIV_TYPE_INT 0x4000
-#define IW_PRIV_TYPE_FLOAT 0x5000
-#define IW_PRIV_TYPE_ADDR 0x6000
-#define IW_PRIV_SIZE_FIXED 0x0800
-#define IW_PRIV_SIZE_MASK 0x07FF
+#include <assert.h>
+#include <stdio.h>
/*======================================================================================
* OMacAddress
*======================================================================================*/
// static initializer for broadcast and unknown MAC Adresses
const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast );
const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 };
const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown );
//TODO: Incorporate Ethernet Manufacturer database here! (inline or so)
OMacAddress::OMacAddress()
{
memcpy( _bytes, __unknown, 6 );
}
OMacAddress::OMacAddress( unsigned char* p )
{
memcpy( _bytes, p, 6 );
}
OMacAddress::OMacAddress( const unsigned char* p )
{
memcpy( _bytes, p, 6 );
}
OMacAddress::OMacAddress( struct ifreq& ifr )
{
memcpy( _bytes, ifr.ifr_hwaddr.sa_data, 6 );
}
OMacAddress::~OMacAddress()
{
}
//#ifdef QT_NO_DEBUG
//inline
//#endif
const unsigned char* OMacAddress::native() const
{
return (const unsigned char*) &_bytes;
}
OMacAddress OMacAddress::fromString( const QString& str )
{
QString addr( str );
unsigned char buf[6];
bool ok = true;
int index = 14;
for ( int i = 5; i >= 0; --i )
{
buf[i] = addr.right( 2 ).toUShort( &ok, 16 );
if ( !ok ) return OMacAddress::unknown;
addr.truncate( index );
index -= 3;
}
return (const unsigned char*) &buf;
}
QString OMacAddress::toString( bool substitute ) const
{
QString manu;
manu.sprintf( "%.2X:%.2X:%.2X", _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff );
QString serial;
serial.sprintf( ":%.2X:%.2X:%.2X", _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff );
if ( !substitute ) return manu+serial;
// fallback - if no vendor is found, just use the number
QString textmanu = OManufacturerDB::instance()->lookup( manu );
return textmanu.isNull() ? manu+serial : textmanu+serial;
}
QString OMacAddress::manufacturer() const
{
return OManufacturerDB::instance()->lookupExt( toString() );
}
bool operator==( const OMacAddress &m1, const OMacAddress &m2 )
{
return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0;
}
/*======================================================================================
* OHostAddress
*======================================================================================*/
/*======================================================================================
* OPrivateIOCTL
*======================================================================================*/
OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs )
:QObject( parent, name ), _ioctl( cmd ), _getargs( getargs ), _setargs( setargs )
{
}
OPrivateIOCTL::~OPrivateIOCTL()
{
}
int OPrivateIOCTL::numberGetArgs() const
{
return _getargs & IW_PRIV_SIZE_MASK;
}
int OPrivateIOCTL::typeGetArgs() const
{
return _getargs & IW_PRIV_TYPE_MASK >> 12;
}
int OPrivateIOCTL::numberSetArgs() const
{
return _setargs & IW_PRIV_SIZE_MASK;
}
int OPrivateIOCTL::typeSetArgs() const
{
return _setargs & IW_PRIV_TYPE_MASK >> 12;
}
void OPrivateIOCTL::invoke() const
{
( (OWirelessNetworkInterface*) parent() )->wioctl( _ioctl );
}
void OPrivateIOCTL::setParameter( int num, u_int32_t value )
{
u_int32_t* arglist = (u_int32_t*) &( (OWirelessNetworkInterface*) parent() )->_iwr.u.name;
arglist[num] = value;
}
/*======================================================================================
* assorted functions
*======================================================================================*/
void dumpBytes( const unsigned char* data, int num )
{
printf( "Dumping %d bytes @ %0x", num, data );
printf( "-------------------------------------------\n" );
for ( int i = 0; i < num; ++i )
{
printf( "%02x ", data[i] );
if ( !((i+1) % 32) ) printf( "\n" );
}
printf( "\n\n" );
}
int stringToMode( const QString& mode )
{
if ( mode == "auto" ) return IW_MODE_AUTO;
else if ( mode == "adhoc" ) return IW_MODE_ADHOC;
else if ( mode == "managed" ) return IW_MODE_INFRA;
else if ( mode == "master" ) return IW_MODE_MASTER;
else if ( mode == "repeater" ) return IW_MODE_REPEAT;
else if ( mode == "secondary" ) return IW_MODE_SECOND;
else if ( mode == "monitor" ) return IW_MODE_MONITOR;
else assert( 0 );
}
QString modeToString( int mode )
{
switch ( mode )
{
case IW_MODE_AUTO: return "auto";
case IW_MODE_ADHOC: return "adhoc";
case IW_MODE_INFRA: return "managed";
case IW_MODE_MASTER: return "master";
case IW_MODE_REPEAT: return "repeater";
case IW_MODE_SECOND: return "second";
case IW_MODE_MONITOR: return "monitor";
default: assert( 0 );
}
}
diff --git a/libopie2/opienet/onetutils.h b/libopie2/opienet/onetutils.h
index 541c5ab..bddfab9 100644
--- a/libopie2/opienet/onetutils.h
+++ b/libopie2/opienet/onetutils.h
@@ -1,163 +1,181 @@
/*
                This file is part of the Opie Project
              (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef ONETUTILS_H
#define ONETUTILS_H
#include <qdict.h>
#include <qmap.h>
#include <qstring.h>
#include <qhostaddress.h>
#include <qobject.h>
#include <sys/types.h>
struct ifreq;
class OWirelessNetworkInterface;
/*======================================================================================
* OMacAddress
*======================================================================================*/
class OMacAddress
{
public:
// QString c'tor? -zecke
OMacAddress();
OMacAddress( unsigned char* );
OMacAddress( const unsigned char* );
OMacAddress( struct ifreq& );
~OMacAddress();
QString manufacturer() const;
QString toString( bool substitute = false ) const;
const unsigned char* native() const;
// no c'tor but this one why not make it a c'tor. it could also replace the others or is this the problem?
static OMacAddress fromString( const QString& );
public:
static const OMacAddress& broadcast; // ff:ff:ff:ff:ff:ff
static const OMacAddress& unknown; // 44:44:44:44:44:44
private:
unsigned char _bytes[6];
friend bool operator==( const OMacAddress &m1, const OMacAddress &m2 );
};
bool operator==( const OMacAddress &m1, const OMacAddress &m2 );
/*======================================================================================
* OHostAddress
*======================================================================================*/
class OHostAddress : public QHostAddress
{
/*public:
OHostAddress();
~OHostAddress();
*/
};
/*======================================================================================
* OPrivateIOCTL
*======================================================================================*/
class OPrivateIOCTL : public QObject
{
public:
OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs );
~OPrivateIOCTL();
int numberGetArgs() const;
int typeGetArgs() const;
int numberSetArgs() const;
int typeSetArgs() const;
// FIXME return int? as ::ioctl does? -zecke
void invoke() const;
void setParameter( int, u_int32_t );
private:
u_int32_t _ioctl;
u_int16_t _getargs;
u_int16_t _setargs;
};
/*======================================================================================
* Miscellaneous
*======================================================================================*/
void dumpBytes( const unsigned char* data, int num );
QString modeToString( int );
int stringToMode( const QString& );
+#define IW_PRIV_TYPE_MASK 0x7000
+#define IW_PRIV_TYPE_NONE 0x0000
+#define IW_PRIV_TYPE_BYTE 0x1000
+#define IW_PRIV_TYPE_CHAR 0x2000
+#define IW_PRIV_TYPE_INT 0x4000
+#define IW_PRIV_TYPE_FLOAT 0x5000
+#define IW_PRIV_TYPE_ADDR 0x6000
+#define IW_PRIV_SIZE_FIXED 0x0800
+#define IW_PRIV_SIZE_MASK 0x07FF
+
+#ifndef ARPHRD_IEEE80211
+#define ARPHRD_IEEE80211 801
+#endif
+#ifndef ARPHRD_IEEE80211_PRISM
+#define ARPHRD_IEEE80211_PRISM 802
+#endif
+
+
/* Network to host order macros */
#ifdef LBL_ALIGN
#define EXTRACT_16BITS(p) \
((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \
(u_int16_t)*((const u_int8_t *)(p) + 1)))
#define EXTRACT_32BITS(p) \
((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \
(u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \
(u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \
(u_int32_t)*((const u_int8_t *)(p) + 3)))
#else
#define EXTRACT_16BITS(p) \
((u_int16_t)ntohs(*(const u_int16_t *)(p)))
#define EXTRACT_32BITS(p) \
((u_int32_t)ntohl(*(const u_int32_t *)(p)))
#endif
#define EXTRACT_24BITS(p) \
((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \
(u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \
(u_int32_t)*((const u_int8_t *)(p) + 2)))
/* Little endian protocol host order macros */
#define EXTRACT_LE_8BITS(p) (*(p))
#define EXTRACT_LE_16BITS(p) \
((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \
(u_int16_t)*((const u_int8_t *)(p) + 0)))
#define EXTRACT_LE_32BITS(p) \
((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 3) << 24 | \
(u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \
(u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \
(u_int32_t)*((const u_int8_t *)(p) + 0)))
#endif // ONETUTILS_H
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index c329e9a..95c813f 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -1,1192 +1,1190 @@
/*
                This file is part of the Opie Project
              Copyright (C) 2003 by the Wellenreiter team:
Martin J. Muench <mjm@remote-exploit.org>
Max Moser <mmo@remote-exploit.org
Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/* OPIE */
#include <opie2/onetwork.h>
#include <opie2/ostation.h>
/* QT */
#include <qfile.h>
#include <qtextstream.h>
/* UNIX */
#include <assert.h>
#include <arpa/inet.h>
-#include <cerrno>
-#include <cstring>
-#include <cstdlib>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
#include <math.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#include <linux/sockios.h>
#include <net/if_arp.h>
#include <stdarg.h>
-using namespace std;
-
#ifndef NODEBUG
-#include <opie2/oioctlmap.h>
-IntStringMap* _ioctlmap = constructIoctlMap();
+#include <opie2/odebugmapper.h>
+DebugMapper* debugmapper = new DebugMapper();
#endif
/*======================================================================================
* ONetwork
*======================================================================================*/
ONetwork* ONetwork::_instance = 0;
ONetwork::ONetwork()
{
qDebug( "ONetwork::ONetwork()" );
qDebug( "ONetwork: This code has been compiled against Wireless Extensions V%d", WIRELESS_EXT );
synchronize();
}
void ONetwork::synchronize()
{
// gather available interfaces by inspecting /proc/net/dev
//FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices
//FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices
//FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev
_interfaces.clear();
QString str;
QFile f( "/proc/net/dev" );
bool hasFile = f.open( IO_ReadOnly );
if ( !hasFile )
{
qDebug( "ONetwork: /proc/net/dev not existing. No network devices available" );
return;
}
QTextStream s( &f );
s.readLine();
s.readLine();
while ( !s.atEnd() )
{
s >> str;
str.truncate( str.find( ':' ) );
qDebug( "ONetwork: found interface '%s'", (const char*) str );
ONetworkInterface* iface;
if ( isWirelessInterface( str ) )
{
iface = new OWirelessNetworkInterface( this, (const char*) str );
qDebug( "ONetwork: interface '%s' has Wireless Extensions", (const char*) str );
}
else
{
iface = new ONetworkInterface( this, (const char*) str );
}
_interfaces.insert( str, iface );
s.readLine();
}
}
short ONetwork::wirelessExtensionVersion()
{
return WIRELESS_EXT;
}
int ONetwork::count() const
{
return _interfaces.count();
}
ONetworkInterface* ONetwork::interface( const QString& iface ) const
{
return _interfaces[iface];
}
ONetwork* ONetwork::instance()
{
if ( !_instance ) _instance = new ONetwork();
return _instance;
}
ONetwork::InterfaceIterator ONetwork::iterator() const
{
return ONetwork::InterfaceIterator( _interfaces );
}
bool ONetwork::isWirelessInterface( const char* name ) const
{
int sfd = socket( AF_INET, SOCK_STREAM, 0 );
struct iwreq iwr;
memset( &iwr, 0, sizeof( struct iwreq ) );
strcpy( (char*) &iwr.ifr_name, name );
int result = ::ioctl( sfd, SIOCGIWNAME, &iwr );
return result != -1;
}
/*======================================================================================
* ONetworkInterface
*======================================================================================*/
ONetworkInterface::ONetworkInterface( QObject* parent, const char* name )
:QObject( parent, name ),
_sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 )
{
qDebug( "ONetworkInterface::ONetworkInterface()" );
init();
}
struct ifreq& ONetworkInterface::ifr() const
{
return _ifr;
}
void ONetworkInterface::init()
{
qDebug( "ONetworkInterface::init()" );
memset( &_ifr, 0, sizeof( struct ifreq ) );
if ( _sfd == -1 )
{
qDebug( "ONetworkInterface::init(): Warning - can't get socket for device '%s'", name() );
return;
}
}
bool ONetworkInterface::ioctl( int call, struct ifreq& ifreq ) const
{
#ifndef NODEBUG
int result = ::ioctl( _sfd, call, &ifreq );
if ( result == -1 )
- qDebug( "ONetworkInterface::ioctl (%s) call %s (0x%04X) - Status: Failed: %d (%s)", name(), (const char*) *(*_ioctlmap)[call], call, result, strerror( errno ) );
+ qDebug( "ONetworkInterface::ioctl (%s) call %s (0x%04X) - Status: Failed: %d (%s)", name(), (const char*) debugmapper->map( call ), call, result, strerror( errno ) );
else
- qDebug( "ONetworkInterface::ioctl (%s) call %s (0x%04X) - Status: Ok.", name(), (const char*) *(*_ioctlmap)[call], call );
+ qDebug( "ONetworkInterface::ioctl (%s) call %s (0x%04X) - Status: Ok.", name(), (const char*) debugmapper->map( call ), call );
return ( result != -1 );
#else
return ::ioctl( _sfd, call, &ifreq ) != -1;
#endif
}
bool ONetworkInterface::ioctl( int call ) const
{
strcpy( _ifr.ifr_name, name() );
return ioctl( call, _ifr );
}
bool ONetworkInterface::isLoopback() const
{
ioctl( SIOCGIFFLAGS );
return _ifr.ifr_flags & IFF_LOOPBACK;
}
bool ONetworkInterface::setUp( bool b )
{
ioctl( SIOCGIFFLAGS );
if ( b ) _ifr.ifr_flags |= IFF_UP;
else _ifr.ifr_flags &= (~IFF_UP);
return ioctl( SIOCSIFFLAGS );
}
bool ONetworkInterface::isUp() const
{
ioctl( SIOCGIFFLAGS );
return _ifr.ifr_flags & IFF_UP;
}
void ONetworkInterface::setIPV4Address( const QHostAddress& addr )
{
struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr;
sa->sin_family = AF_INET;
sa->sin_port = 0;
sa->sin_addr.s_addr = htonl( addr.ip4Addr() );
ioctl( SIOCSIFADDR );
}
QString ONetworkInterface::ipV4Address() const
{
if ( ioctl( SIOCGIFADDR ) )
{
struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr;
//FIXME: Use QHostAddress here
return QString( inet_ntoa( sa->sin_addr ) );
}
else
return "<unknown>";
}
void ONetworkInterface::setMacAddress( const OMacAddress& addr )
{
_ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER;
memcpy( &_ifr.ifr_hwaddr.sa_data, addr.native(), 6 );
ioctl( SIOCSIFHWADDR );
}
OMacAddress ONetworkInterface::macAddress() const
{
if ( ioctl( SIOCGIFHWADDR ) )
{
return OMacAddress( _ifr );
}
else
{
return OMacAddress::unknown;
}
}
void ONetworkInterface::setIPV4Netmask( const QHostAddress& addr )
{
struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr;
sa->sin_family = AF_INET;
sa->sin_port = 0;
sa->sin_addr.s_addr = htonl( addr.ip4Addr() );
ioctl( SIOCSIFNETMASK );
}
QString ONetworkInterface::ipV4Netmask() const
{
if ( ioctl( SIOCGIFNETMASK ) )
{
struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr;
//FIXME: Use QHostAddress here
return QString( inet_ntoa( sa->sin_addr ) );
}
else
return "<unknown>";
}
int ONetworkInterface::dataLinkType() const
{
if ( ioctl( SIOCGIFHWADDR ) )
{
return _ifr.ifr_hwaddr.sa_family;
}
else
{
return -1;
}
}
void ONetworkInterface::setMonitoring( OMonitoringInterface* m )
{
_mon = m;
qDebug( "ONetwork::setMonitoring(): Installed monitoring driver '%s' on interface '%s'", (const char*) m->name(), name() );
}
OMonitoringInterface* ONetworkInterface::monitoring() const
{
return _mon;
}
ONetworkInterface::~ONetworkInterface()
{
qDebug( "ONetworkInterface::~ONetworkInterface()" );
if ( _sfd != -1 ) ::close( _sfd );
}
bool ONetworkInterface::setPromiscuousMode( bool b )
{
ioctl( SIOCGIFFLAGS );
if ( b ) _ifr.ifr_flags |= IFF_PROMISC;
else _ifr.ifr_flags &= (~IFF_PROMISC);
return ioctl( SIOCSIFFLAGS );
}
bool ONetworkInterface::promiscuousMode() const
{
ioctl( SIOCGIFFLAGS );
return _ifr.ifr_flags & IFF_PROMISC;
}
bool ONetworkInterface::isWireless() const
{
return ioctl( SIOCGIWNAME );
}
/*======================================================================================
* OChannelHopper
*======================================================================================*/
OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface )
:QObject( 0, "Mickey's funky hopper" ),
_iface( iface ), _interval( 0 ), _tid( 0 )
{
int _maxChannel = iface->channels()+1;
// generate fancy hopping sequence honoring the device capabilities
if ( _maxChannel >= 1 ) _channels.append( 1 );
if ( _maxChannel >= 7 ) _channels.append( 7 );
if ( _maxChannel >= 13 ) _channels.append( 13 );
if ( _maxChannel >= 2 ) _channels.append( 2 );
if ( _maxChannel >= 8 ) _channels.append( 8 );
if ( _maxChannel >= 3 ) _channels.append( 3 );
if ( _maxChannel >= 14 ) _channels.append( 14 );
if ( _maxChannel >= 9 ) _channels.append( 9 );
if ( _maxChannel >= 4 ) _channels.append( 4 );
if ( _maxChannel >= 10 ) _channels.append( 10 );
if ( _maxChannel >= 5 ) _channels.append( 5 );
if ( _maxChannel >= 11 ) _channels.append( 11 );
if ( _maxChannel >= 6 ) _channels.append( 6 );
if ( _maxChannel >= 12 ) _channels.append( 12 );
_channel = _channels.begin();
}
OChannelHopper::~OChannelHopper()
{
}
bool OChannelHopper::isActive() const
{
return _tid;
}
int OChannelHopper::channel() const
{
return *_channel;
}
void OChannelHopper::timerEvent( QTimerEvent* )
{
_iface->setChannel( *_channel );
emit( hopped( *_channel ) );
qDebug( "OChannelHopper::timerEvent(): set channel %d on interface '%s'",
*_channel, (const char*) _iface->name() );
if ( ++_channel == _channels.end() ) _channel = _channels.begin();
}
void OChannelHopper::setInterval( int interval )
{
if ( interval == _interval )
return;
if ( _interval )
killTimer( _tid );
_tid = 0;
_interval = interval;
if ( _interval )
{
_tid = startTimer( interval );
}
}
int OChannelHopper::interval() const
{
return _interval;
}
/*======================================================================================
* OWirelessNetworkInterface
*======================================================================================*/
OWirelessNetworkInterface::OWirelessNetworkInterface( QObject* parent, const char* name )
:ONetworkInterface( parent, name ), _hopper( 0 )
{
qDebug( "OWirelessNetworkInterface::OWirelessNetworkInterface()" );
init();
}
OWirelessNetworkInterface::~OWirelessNetworkInterface()
{
}
struct iwreq& OWirelessNetworkInterface::iwr() const
{
return _iwr;
}
void OWirelessNetworkInterface::init()
{
qDebug( "OWirelessNetworkInterface::init()" );
memset( &_iwr, 0, sizeof( struct iwreq ) );
buildInformation();
buildPrivateList();
dumpInformation();
}
bool OWirelessNetworkInterface::isAssociated() const
{
//FIXME: handle different modes
return !(associatedAP() == OMacAddress::unknown);
}
OMacAddress OWirelessNetworkInterface::associatedAP() const
{
if ( ioctl( SIOCGIWAP ) )
return (const unsigned char*) &_ifr.ifr_hwaddr.sa_data[0];
else
return OMacAddress::unknown;
}
void OWirelessNetworkInterface::buildInformation()
{
//ML: If you listen carefully enough, you can hear lots of WLAN drivers suck
//ML: The HostAP drivers need more than sizeof struct_iw range to complete
//ML: SIOCGIWRANGE otherwise they fail with "Invalid Argument Length".
//ML: The Wlan-NG drivers on the otherside fail (segfault!) if you allocate
//ML: _too much_ space. This is damn shitty crap *sigh*
//ML: We allocate a large memory region in RAM and check whether the
//ML: driver pollutes this extra space. The complaint will be made on stdout,
//ML: so please forward this...
struct iwreq wrq;
int len = sizeof( struct iw_range )*2;
char *buffer = (char*) malloc( len );
//FIXME: Validate if we actually got the memory block
memset( buffer, 0, len );
memcpy( wrq.ifr_name, name(), IFNAMSIZ);
wrq.u.data.pointer = (caddr_t) buffer;
wrq.u.data.length = sizeof( struct iw_range );
wrq.u.data.flags = 0;
if ( ::ioctl( _sfd, SIOCGIWRANGE, &wrq ) == -1 )
{
qDebug( "OWirelessNetworkInterface::buildInformation(): SIOCGIWRANGE failed (%s) - using default values.", strerror( errno ) );
_channels.insert( 2412, 1 ); // 2.412 GHz
_channels.insert( 2417, 2 ); // 2.417 GHz
_channels.insert( 2422, 3 ); // 2.422 GHz
_channels.insert( 2427, 4 ); // 2.427 GHz
_channels.insert( 2432, 5 ); // 2.432 GHz
_channels.insert( 2437, 6 ); // 2.437 GHz
_channels.insert( 2442, 7 ); // 2.442 GHz
_channels.insert( 2447, 8 ); // 2.447 GHz
_channels.insert( 2452, 9 ); // 2.452 GHz
_channels.insert( 2457, 10 ); // 2.457 GHz
_channels.insert( 2462, 11 ); // 2.462 GHz
memset( &_range, 0, sizeof( struct iw_range ) );
}
else
{
// <check if the driver overwrites stuff>
int max = 0;
for ( int r = sizeof( struct iw_range ); r < len; r++ )
if (buffer[r] != 0)
max = r;
if (max > 0)
{
qWarning( "OWirelessNetworkInterface::buildInformation(): Driver for wireless interface '%s' sucks!\n"
"It overwrote the buffer end with at least %i bytes!\n", name(), max - sizeof( struct iw_range ) );
}
// </check if the driver overwrites stuff>
struct iw_range range;
memcpy( &range, buffer, sizeof range );
qDebug( "OWirelessNetworkInterface::buildInformation(): Interface %s reported to have %d channels.", name(), range.num_frequency );
for ( int i = 0; i < range.num_frequency; ++i )
{
int freq = (int) ( double( range.freq[i].m ) * pow( 10.0, range.freq[i].e ) / 1000000.0 );
_channels.insert( freq, i+1 );
}
}
memcpy( &_range, buffer, sizeof( struct iw_range ) );
qDebug( "OWirelessNetworkInterface::buildInformation(): Information block constructed." );
free(buffer);
}
void OWirelessNetworkInterface::buildPrivateList()
{
qDebug( "OWirelessNetworkInterface::buildPrivateList()" );
struct iw_priv_args priv[IW_MAX_PRIV_DEF];
_iwr.u.data.pointer = (char*) &priv;
_iwr.u.data.length = IW_MAX_PRIV_DEF; // length in terms of number of (sizeof iw_priv_args), not (sizeof iw_priv_args) itself
_iwr.u.data.flags = 0;
if ( !wioctl( SIOCGIWPRIV ) )
{
qDebug( "OWirelessNetworkInterface::buildPrivateList(): SIOCGIWPRIV failed (%s) - can't get private ioctl information.", strerror( errno ) );
return;
}
for ( int i = 0; i < _iwr.u.data.length; ++i )
{
new OPrivateIOCTL( this, priv[i].name, priv[i].cmd, priv[i].get_args, priv[i].set_args );
}
qDebug( "OWirelessNetworkInterface::buildPrivateList(): Private IOCTL list constructed." );
}
void OWirelessNetworkInterface::dumpInformation() const
{
qDebug( "OWirelessNetworkInterface::() -------------- dumping information block ----------------" );
qDebug( " - driver's idea of maximum throughput is %d bps = %d byte/s = %d Kb/s = %f.2 Mb/s", _range.throughput, _range.throughput / 8, _range.throughput / 8 / 1024, float( _range.throughput ) / 8.0 / 1024.0 / 1024.0 );
qDebug( " - driver for '%s' has been compiled against WE V%d (source=V%d)", name(), _range.we_version_compiled, _range.we_version_source );
qDebug( "OWirelessNetworkInterface::() ---------------------------------------------------------" );
}
int OWirelessNetworkInterface::channel() const
{
//FIXME: When monitoring enabled, then use it
//FIXME: to gather the current RF channel
//FIXME: Until then, get active channel from hopper.
if ( _hopper && _hopper->isActive() )
return _hopper->channel();
if ( !wioctl( SIOCGIWFREQ ) )
{
return -1;
}
else
{
return _channels[ static_cast<int>(double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000) ];
}
}
void OWirelessNetworkInterface::setChannel( int c ) const
{
if ( !c )
{
qWarning( "OWirelessNetworkInterface::setChannel( 0 ) called - fix your application!" );
return;
}
if ( !_mon )
{
memset( &_iwr, 0, sizeof( struct iwreq ) );
_iwr.u.freq.m = c;
_iwr.u.freq.e = 0;
wioctl( SIOCSIWFREQ );
}
else
{
_mon->setChannel( c );
}
}
double OWirelessNetworkInterface::frequency() const
{
if ( !wioctl( SIOCGIWFREQ ) )
{
return -1.0;
}
else
{
return double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000000.0;
}
}
int OWirelessNetworkInterface::channels() const
{
return _channels.count();
}
void OWirelessNetworkInterface::setChannelHopping( int interval )
{
if ( !_hopper ) _hopper = new OChannelHopper( this );
_hopper->setInterval( interval );
//FIXME: When and by whom will the channel hopper be deleted?
//TODO: rely on QObject hierarchy
}
int OWirelessNetworkInterface::channelHopping() const
{
return _hopper->interval();
}
OChannelHopper* OWirelessNetworkInterface::channelHopper() const
{
return _hopper;
}
void OWirelessNetworkInterface::commit() const
{
wioctl( SIOCSIWCOMMIT );
}
void OWirelessNetworkInterface::setMode( const QString& newMode )
{
#ifdef FINALIZE
QString currentMode = mode();
if ( currentMode == newMode ) return;
#endif
qDebug( "OWirelessNetworkInterface::setMode(): trying to set mode '%s' (%d)", (const char*) newMode, stringToMode( newMode ) );
_iwr.u.mode = stringToMode( newMode );
if ( _iwr.u.mode != IW_MODE_MONITOR )
{
// IWR.U.MODE WIRD DURCH ABFRAGE DES MODE HIER PLATTGEMACHT!!!!!!!!!!!!!!!!!!!!! DEPP!
_iwr.u.mode = stringToMode( newMode );
wioctl( SIOCSIWMODE );
// special iwpriv fallback for monitor mode (check if we're really out of monitor mode now)
if ( mode() == "monitor" )
{
qDebug( "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not sufficient - trying fallback to iwpriv..." );
if ( _mon )
_mon->setEnabled( false );
else
qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" );
}
}
else // special iwpriv fallback for monitor mode
{
if ( wioctl( SIOCSIWMODE ) )
{
qDebug( "OWirelessNetworkInterface::setMode(): IW_MODE_MONITOR ok" );
}
else
{
qDebug( "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not working - trying fallback to iwpriv..." );
if ( _mon )
_mon->setEnabled( true );
else
qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" );
}
}
}
QString OWirelessNetworkInterface::mode() const
{
memset( &_iwr, 0, sizeof( struct iwreq ) );
if ( !wioctl( SIOCGIWMODE ) )
{
return "<unknown>";
}
qDebug( "DEBUG: WE's idea of current mode seems to be '%s'", (const char*) modeToString( _iwr.u.mode ) );
// legacy compatible monitor mode check
if ( dataLinkType() == ARPHRD_IEEE80211 || dataLinkType() == 802 )
{
return "monitor";
}
else
{
return modeToString( _iwr.u.mode );
}
}
void OWirelessNetworkInterface::setNickName( const QString& nickname )
{
_iwr.u.essid.pointer = const_cast<char*>( (const char*) nickname );
_iwr.u.essid.length = nickname.length();
wioctl( SIOCSIWNICKN );
}
QString OWirelessNetworkInterface::nickName() const
{
char str[IW_ESSID_MAX_SIZE];
_iwr.u.data.pointer = &str[0];
_iwr.u.data.length = IW_ESSID_MAX_SIZE;
if ( !wioctl( SIOCGIWNICKN ) )
{
return "<unknown>";
}
else
{
str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string
return str;
}
}
void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... )
{
OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) );
if ( !priv )
{
qDebug( "OWirelessNetworkInterface::setPrivate(): interface '%s' does not support private ioctl '%s'", name(), (const char*) call );
return;
}
if ( priv->numberSetArgs() != numargs )
{
qDebug( "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '%s' expects %d arguments, but got %d", (const char*) call, priv->numberSetArgs(), numargs );
return;
}
qDebug( "OWirelessNetworkInterface::setPrivate(): about to call '%s' on interface '%s'", (const char*) call, name() );
memset( &_iwr, 0, sizeof _iwr );
va_list argp;
va_start( argp, numargs );
for ( int i = 0; i < numargs; ++i )
{
priv->setParameter( i, va_arg( argp, int ) );
}
va_end( argp );
priv->invoke();
}
void OWirelessNetworkInterface::getPrivate( const QString& call )
{
qWarning( "OWirelessNetworkInterface::getPrivate() is not implemented yet." );
}
bool OWirelessNetworkInterface::hasPrivate( const QString& call )
{
return child( (const char*) call );
}
QString OWirelessNetworkInterface::SSID() const
{
char str[IW_ESSID_MAX_SIZE];
_iwr.u.essid.pointer = &str[0];
_iwr.u.essid.length = IW_ESSID_MAX_SIZE;
if ( !wioctl( SIOCGIWESSID ) )
{
return "<unknown>";
}
else
{
return str;
}
}
void OWirelessNetworkInterface::setSSID( const QString& ssid )
{
_iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid );
_iwr.u.essid.length = ssid.length();
wioctl( SIOCSIWESSID );
}
OStationList* OWirelessNetworkInterface::scanNetwork()
{
_iwr.u.param.flags = IW_SCAN_DEFAULT;
_iwr.u.param.value = 0;
if ( !wioctl( SIOCSIWSCAN ) )
{
return 0;
}
OStationList* stations = new OStationList();
int timeout = 1000000;
qDebug( "ONetworkInterface::scanNetwork() - scan started." );
bool results = false;
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = 250000; // initial timeout ~ 250ms
char buffer[IW_SCAN_MAX_DATA];
while ( !results && timeout > 0 )
{
timeout -= tv.tv_usec;
select( 0, 0, 0, 0, &tv );
_iwr.u.data.pointer = &buffer[0];
_iwr.u.data.flags = 0;
_iwr.u.data.length = sizeof buffer;
if ( wioctl( SIOCGIWSCAN ) )
{
results = true;
continue;
}
else if ( errno == EAGAIN)
{
qDebug( "ONetworkInterface::scanNetwork() - scan in progress..." );
#if 0
if ( qApp )
{
qApp->processEvents( 100 );
continue;
}
#endif
tv.tv_sec = 0;
tv.tv_usec = 100000;
continue;
}
}
qDebug( "ONetworkInterface::scanNetwork() - scan finished." );
if ( results )
{
qDebug( " - result length = %d", _iwr.u.data.length );
if ( !_iwr.u.data.length )
{
qDebug( " - no results (empty neighbourhood)" );
return stations;
}
qDebug( " - results are in!" );
dumpBytes( (const unsigned char*) &buffer[0], _iwr.u.data.length );
// parse results
int offset = 0;
struct iw_event* we = (struct iw_event*) &buffer[0];
while ( offset < _iwr.u.data.length )
{
//const char* cmd = *(*_ioctlmap)[we->cmd];
//if ( !cmd ) cmd = "<unknown>";
qDebug( "reading next event... cmd=%d, len=%d", we->cmd, we->len );
switch (we->cmd)
{
case SIOCGIWAP:
{
qDebug( "SIOCGIWAP" );
stations->append( new OStation() );
stations->last()->macAddress = (const unsigned char*) &we->u.ap_addr.sa_data[0];
break;
}
case SIOCGIWMODE:
{
qDebug( "SIOCGIWMODE" );
stations->last()->type = modeToString( we->u.mode );
break;
}
case SIOCGIWFREQ:
{
qDebug( "SIOCGIWFREQ" );
stations->last()->channel = _channels[ static_cast<int>(double( we->u.freq.m ) * pow( 10.0, we->u.freq.e ) / 1000000) ];
break;
}
case SIOCGIWESSID:
{
qDebug( "SIOCGIWESSID" );
stations->last()->ssid = we->u.essid.pointer;
break;
}
case SIOCGIWSENS: qDebug( "SIOCGIWSENS" ); break;
case SIOCGIWENCODE: qDebug( "SIOCGIWENCODE" ); break;
case IWEVTXDROP: qDebug( "IWEVTXDROP" ); break; /* Packet dropped to excessive retry */
case IWEVQUAL: qDebug( "IWEVQUAL" ); break; /* Quality part of statistics (scan) */
case IWEVCUSTOM: qDebug( "IWEVCUSTOM" ); break; /* Driver specific ascii string */
case IWEVREGISTERED: qDebug( "IWEVREGISTERED" ); break; /* Discovered a new node (AP mode) */
case IWEVEXPIRED: qDebug( "IWEVEXPIRED" ); break; /* Expired a node (AP mode) */
default: qDebug( "unhandled event" );
}
offset += we->len;
we = (struct iw_event*) &buffer[offset];
}
return stations;
}
else
{
qDebug( " - no results (timeout) :(" );
return stations;
}
}
bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const
{
#ifndef NODEBUG
int result = ::ioctl( _sfd, call, &iwreq );
if ( result == -1 )
- qDebug( "ONetworkInterface::wioctl (%s) call %s (0x%04X) - Status: Failed: %d (%s)", name(), (const char*) *(*_ioctlmap)[call], call, result, strerror( errno ) );
+ qDebug( "ONetworkInterface::wioctl (%s) call %s (0x%04X) - Status: Failed: %d (%s)", name(), (const char*) debugmapper->map( call ), call, result, strerror( errno ) );
else
- qDebug( "ONetworkInterface::wioctl (%s) call %s (0x%04X) - Status: Ok.", name(), (const char*) *(*_ioctlmap)[call], call );
+ qDebug( "ONetworkInterface::wioctl (%s) call %s (0x%04X) - Status: Ok.", name(), (const char*) debugmapper->map( call ), call );
return ( result != -1 );
#else
return ::ioctl( _sfd, call, &iwreq ) != -1;
#endif
}
bool OWirelessNetworkInterface::wioctl( int call ) const
{
strcpy( _iwr.ifr_name, name() );
return wioctl( call, _iwr );
}
/*======================================================================================
* OMonitoringInterface
*======================================================================================*/
OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
:_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader )
{
}
OMonitoringInterface::~OMonitoringInterface()
{
}
void OMonitoringInterface::setChannel( int c )
{
// use standard WE channel switching protocol
memset( &_if->_iwr, 0, sizeof( struct iwreq ) );
_if->_iwr.u.freq.m = c;
_if->_iwr.u.freq.e = 0;
_if->wioctl( SIOCSIWFREQ );
}
void OMonitoringInterface::setEnabled( bool b )
{
}
/*======================================================================================
* OCiscoMonitoringInterface
*======================================================================================*/
OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
:OMonitoringInterface( iface, prismHeader )
{
iface->setMonitoring( this );
}
OCiscoMonitoringInterface::~OCiscoMonitoringInterface()
{
}
void OCiscoMonitoringInterface::setEnabled( bool b )
{
QString fname;
fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() );
QFile f( fname );
if ( !f.exists() ) return;
if ( f.open( IO_WriteOnly ) )
{
QTextStream s( &f );
s << "Mode: r";
s << "Mode: y";
s << "XmitPower: 1";
}
// flushing and closing will be done automatically when f goes out of scope
}
QString OCiscoMonitoringInterface::name() const
{
return "cisco";
}
void OCiscoMonitoringInterface::setChannel( int )
{
// cisco devices automatically switch channels when in monitor mode
}
/*======================================================================================
* OWlanNGMonitoringInterface
*======================================================================================*/
OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
:OMonitoringInterface( iface, prismHeader )
{
iface->setMonitoring( this );
}
OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface()
{
}
void OWlanNGMonitoringInterface::setEnabled( bool b )
{
//FIXME: do nothing if its already in the same mode
QString enable = b ? "true" : "false";
QString prism = _prismHeader ? "true" : "false";
QString cmd;
cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s",
(const char*) _if->name(), 1, (const char*) enable, (const char*) prism );
system( cmd );
}
QString OWlanNGMonitoringInterface::name() const
{
return "wlan-ng";
}
void OWlanNGMonitoringInterface::setChannel( int c )
{
//NOTE: Older wlan-ng drivers automatically hopped channels while lnxreq_wlansniff=true. Newer ones don't.
QString enable = "true"; //_if->monitorMode() ? "true" : "false";
QString prism = _prismHeader ? "true" : "false";
QString cmd;
cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s",
(const char*) _if->name(), c, (const char*) enable, (const char*) prism );
system( cmd );
}
/*======================================================================================
* OHostAPMonitoringInterface
*======================================================================================*/
OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
:OMonitoringInterface( iface, prismHeader )
{
iface->setMonitoring( this );
}
OHostAPMonitoringInterface::~OHostAPMonitoringInterface()
{
}
void OHostAPMonitoringInterface::setEnabled( bool b )
{
int monitorCode = _prismHeader ? 1 : 2;
if ( b )
{
_if->setPrivate( "monitor", 1, monitorCode );
}
else
{
_if->setPrivate( "monitor", 1, 0 );
}
}
QString OHostAPMonitoringInterface::name() const
{
return "hostap";
}
/*======================================================================================
* OOrinocoNetworkInterface
*======================================================================================*/
OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
:OMonitoringInterface( iface, prismHeader )
{
iface->setMonitoring( this );
}
OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface()
{
}
void OOrinocoMonitoringInterface::setChannel( int c )
{
int monitorCode = _prismHeader ? 1 : 2;
_if->setPrivate( "monitor", 2, monitorCode, c );
}
void OOrinocoMonitoringInterface::setEnabled( bool b )
{
// IW_MODE_MONITOR was introduced in Wireless Extensions Version 15
// Wireless Extensions < Version 15 need iwpriv commandos for monitoring
// However, as of recent orinoco drivers, IW_MODE_MONITOR is still not supported
if ( b )
{
setChannel( 1 );
}
else
{
_if->setPrivate( "monitor", 2, 0, 0 );
}
}
QString OOrinocoMonitoringInterface::name() const
{
return "orinoco";
}
diff --git a/libopie2/opienet/opienet.pro b/libopie2/opienet/opienet.pro
index d966462..386c2db 100644
--- a/libopie2/opienet/opienet.pro
+++ b/libopie2/opienet/opienet.pro
@@ -1,34 +1,34 @@
TEMPLATE = lib
CONFIG += qt warn_on debug
DESTDIR = $(OPIEDIR)/lib
HEADERS = 802_11_user.h \
dhcp.h \
udp_ports.h \
wireless.h \
- oioctlmap.h \
+ odebugmapper.h \
omanufacturerdb.h \
onetutils.h \
onetwork.h \
opcap.h \
ostation.h
-SOURCES = oioctlmap.cpp \
+SOURCES = odebugmapper.cpp \
omanufacturerdb.cpp \
onetutils.cpp \
onetwork.cpp \
opcap.cpp \
ostation.cpp
INTERFACES =
TARGET = opienet2
VERSION = 1.8.1
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lpcap
!contains( platform, x11 ) {
include ( $(OPIEDIR)/include.pro )
}
contains( platform, x11 ) {
LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib
}
diff --git a/libopie2/tools/regen.py b/libopie2/tools/regen.py
index 2f7f418..9ad5352 100755
--- a/libopie2/tools/regen.py
+++ b/libopie2/tools/regen.py
@@ -1,64 +1,94 @@
#!/usr/bin/env python
#
# regenerate ioctl_table.h
#
import sys
import os
result = os.popen( 'find /usr/include -name "*.h" |xargs grep -h SIOC|grep 0x' ).readlines()
try:
tablehfile = file( sys.argv[1]+".h", "w" )
except:
tablehfile = sys.stdout
try:
tablecfile = file( sys.argv[1]+".cpp", "w" )
except:
tablecfile = sys.stdout
print >>tablehfile,"""
/*
- * ioctl table - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de>
+ * debug value mapper - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de>
*/
-#ifndef IOCTLMAP_H
-#define IOCTLMAP_H
+#ifndef DEBUGMAPPER_H
+#define DEBUGMAPPER_H
#include <qstring.h>
#include <qintdict.h>
typedef QIntDict<QString> IntStringMap;
-IntStringMap* constructIoctlMap();
+class DebugMapper
+{
+ public:
+ DebugMapper();
+ ~DebugMapper();
+
+ const QString& map( int value ) const;
+ private:
+ IntStringMap _map;
+};
#endif
"""
print >>tablecfile,"""
/*
- * ioctl table - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de>
+ * debug value mapper - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de>
*/
#include "%s"
-IntStringMap* constructIoctlMap()
+DebugMapper::DebugMapper()
{
-\tIntStringMap* map = new IntStringMap();
+ qDebug( "DebugMapper::DebugMapper()" );
""" % (tablehfile.name)
for line in result:
l = line.split()
if not l[0].startswith( "#define" ) or not l[2].startswith( "0x" ):
print >>sys.stderr, "can't parse line: %s" % l
continue
- #print >>tablecfile, "\tqDebug( \"adding %s = %s\" );" % ( l[2], l[1] )
- print >>tablecfile, "\tmap->insert( %s, new QString(\"%s\") );" % ( l[2], l[1] )
+ print >>tablecfile, " _map.insert( %s, new QString(\"%s\") );" % ( l[2], l[1] )
print >>tablecfile,"""
-\treturn map;
};
-""" \ No newline at end of file
+
+
+DebugMapper::~DebugMapper()
+{
+ qDebug( "DebugMapper::~DebugMapper()" );
+}
+
+
+const QString& DebugMapper::map( int value ) const
+{
+ QString* result = _map[ value ];
+
+ if ( !result )
+ {
+ qDebug( "DebugMapper::map() - value not found." );
+ return QString::null;
+ }
+ else
+ {
+ return *result;
+ }
+}
+
+"""