-rw-r--r-- | libopie2/opienet/onetwork.cpp | 12 | ||||
-rw-r--r-- | libopie2/opienet/opcap.cpp | 23 |
2 files changed, 18 insertions, 17 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index 171a2bc..591681c 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp | |||
@@ -789,105 +789,105 @@ void OWirelessNetworkInterface::setNickName( const QString& nickname ) | |||
789 | 789 | ||
790 | 790 | ||
791 | QString OWirelessNetworkInterface::nickName() const | 791 | QString OWirelessNetworkInterface::nickName() const |
792 | { | 792 | { |
793 | char str[IW_ESSID_MAX_SIZE]; | 793 | char str[IW_ESSID_MAX_SIZE]; |
794 | _iwr.u.data.pointer = &str[0]; | 794 | _iwr.u.data.pointer = &str[0]; |
795 | _iwr.u.data.length = IW_ESSID_MAX_SIZE; | 795 | _iwr.u.data.length = IW_ESSID_MAX_SIZE; |
796 | if ( !wioctl( SIOCGIWNICKN ) ) | 796 | if ( !wioctl( SIOCGIWNICKN ) ) |
797 | { | 797 | { |
798 | return "<unknown>"; | 798 | return "<unknown>"; |
799 | } | 799 | } |
800 | else | 800 | else |
801 | { | 801 | { |
802 | str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string | 802 | str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string |
803 | return str; | 803 | return str; |
804 | } | 804 | } |
805 | } | 805 | } |
806 | 806 | ||
807 | 807 | ||
808 | void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... ) | 808 | void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... ) |
809 | { | 809 | { |
810 | OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) ); | 810 | OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) ); |
811 | if ( !priv ) | 811 | if ( !priv ) |
812 | { | 812 | { |
813 | owarn << "OWirelessNetworkInterface::setPrivate(): interface '" << name() | 813 | owarn << "OWirelessNetworkInterface::setPrivate(): interface '" << name() |
814 | << "' does not support private ioctl '" << call << "'" << oendl; | 814 | << "' does not support private ioctl '" << call << "'" << oendl; |
815 | return; | 815 | return; |
816 | } | 816 | } |
817 | if ( priv->numberSetArgs() != numargs ) | 817 | if ( priv->numberSetArgs() != numargs ) |
818 | { | 818 | { |
819 | owarn << "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '" | 819 | owarn << "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '" |
820 | << call << "' expects " << priv->numberSetArgs() << ", but got " << numargs << oendl; | 820 | << call << "' expects " << priv->numberSetArgs() << ", but got " << numargs << oendl; |
821 | return; | 821 | return; |
822 | } | 822 | } |
823 | 823 | ||
824 | odebug << "OWirelessNetworkInterface::setPrivate(): about to call '" << call << "' on interface '" << name() << "'" << oendl; | 824 | odebug << "OWirelessNetworkInterface::setPrivate(): about to call '" << call << "' on interface '" << name() << "'" << oendl; |
825 | memset( &_iwr, 0, sizeof _iwr ); | 825 | memset( &_iwr, 0, sizeof _iwr ); |
826 | va_list argp; | 826 | va_list argp; |
827 | va_start( argp, numargs ); | 827 | va_start( argp, numargs ); |
828 | for ( int i = 0; i < numargs; ++i ) | 828 | for ( int i = 0; i < numargs; ++i ) |
829 | { | 829 | { |
830 | priv->setParameter( i, va_arg( argp, int ) ); | 830 | priv->setParameter( i, va_arg( argp, int ) ); |
831 | } | 831 | } |
832 | va_end( argp ); | 832 | va_end( argp ); |
833 | priv->invoke(); | 833 | priv->invoke(); |
834 | } | 834 | } |
835 | 835 | ||
836 | 836 | ||
837 | void OWirelessNetworkInterface::getPrivate( const QString& call ) | 837 | void OWirelessNetworkInterface::getPrivate( const QString& ) |
838 | { | 838 | { |
839 | oerr << "OWirelessNetworkInterface::getPrivate() is not implemented yet." << oendl; | 839 | oerr << "OWirelessNetworkInterface::getPrivate() is not implemented yet." << oendl; |
840 | } | 840 | } |
841 | 841 | ||
842 | 842 | ||
843 | bool OWirelessNetworkInterface::hasPrivate( const QString& call ) | 843 | bool OWirelessNetworkInterface::hasPrivate( const QString& call ) |
844 | { | 844 | { |
845 | return child( (const char*) call ); | 845 | return child( call.local8Bit() ); |
846 | } | 846 | } |
847 | 847 | ||
848 | 848 | ||
849 | QString OWirelessNetworkInterface::SSID() const | 849 | QString OWirelessNetworkInterface::SSID() const |
850 | { | 850 | { |
851 | char str[IW_ESSID_MAX_SIZE]; | 851 | char str[IW_ESSID_MAX_SIZE]; |
852 | _iwr.u.essid.pointer = &str[0]; | 852 | _iwr.u.essid.pointer = &str[0]; |
853 | _iwr.u.essid.length = IW_ESSID_MAX_SIZE; | 853 | _iwr.u.essid.length = IW_ESSID_MAX_SIZE; |
854 | if ( !wioctl( SIOCGIWESSID ) ) | 854 | if ( !wioctl( SIOCGIWESSID ) ) |
855 | { | 855 | { |
856 | return "<unknown>"; | 856 | return "<unknown>"; |
857 | } | 857 | } |
858 | else | 858 | else |
859 | { | 859 | { |
860 | return str; | 860 | return str; |
861 | } | 861 | } |
862 | } | 862 | } |
863 | 863 | ||
864 | 864 | ||
865 | void OWirelessNetworkInterface::setSSID( const QString& ssid ) | 865 | void OWirelessNetworkInterface::setSSID( const QString& ssid ) |
866 | { | 866 | { |
867 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); | 867 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); |
868 | _iwr.u.essid.length = ssid.length(); | 868 | _iwr.u.essid.length = ssid.length(); |
869 | wioctl( SIOCSIWESSID ); | 869 | wioctl( SIOCSIWESSID ); |
870 | } | 870 | } |
871 | 871 | ||
872 | 872 | ||
873 | OStationList* OWirelessNetworkInterface::scanNetwork() | 873 | OStationList* OWirelessNetworkInterface::scanNetwork() |
874 | { | 874 | { |
875 | _iwr.u.param.flags = IW_SCAN_DEFAULT; | 875 | _iwr.u.param.flags = IW_SCAN_DEFAULT; |
876 | _iwr.u.param.value = 0; | 876 | _iwr.u.param.value = 0; |
877 | if ( !wioctl( SIOCSIWSCAN ) ) | 877 | if ( !wioctl( SIOCSIWSCAN ) ) |
878 | { | 878 | { |
879 | return 0; | 879 | return 0; |
880 | } | 880 | } |
881 | 881 | ||
882 | OStationList* stations = new OStationList(); | 882 | OStationList* stations = new OStationList(); |
883 | 883 | ||
884 | int timeout = 1000000; | 884 | int timeout = 1000000; |
885 | 885 | ||
886 | odebug << "ONetworkInterface::scanNetwork() - scan started." << oendl; | 886 | odebug << "ONetworkInterface::scanNetwork() - scan started." << oendl; |
887 | 887 | ||
888 | bool results = false; | 888 | bool results = false; |
889 | struct timeval tv; | 889 | struct timeval tv; |
890 | tv.tv_sec = 0; | 890 | tv.tv_sec = 0; |
891 | tv.tv_usec = 250000; // initial timeout ~ 250ms | 891 | tv.tv_usec = 250000; // initial timeout ~ 250ms |
892 | char buffer[IW_SCAN_MAX_DATA]; | 892 | char buffer[IW_SCAN_MAX_DATA]; |
893 | 893 | ||
@@ -967,177 +967,177 @@ OStationList* OWirelessNetworkInterface::scanNetwork() | |||
967 | } | 967 | } |
968 | case SIOCGIWESSID: | 968 | case SIOCGIWESSID: |
969 | { | 969 | { |
970 | odebug << "SIOCGIWESSID" << oendl; | 970 | odebug << "SIOCGIWESSID" << oendl; |
971 | stations->last()->ssid = static_cast<const char*>( we->u.essid.pointer ); | 971 | stations->last()->ssid = static_cast<const char*>( we->u.essid.pointer ); |
972 | break; | 972 | break; |
973 | } | 973 | } |
974 | case SIOCGIWSENS: odebug << "SIOCGIWSENS" << oendl; break; | 974 | case SIOCGIWSENS: odebug << "SIOCGIWSENS" << oendl; break; |
975 | case SIOCGIWENCODE: odebug << "SIOCGIWENCODE" << oendl; break; | 975 | case SIOCGIWENCODE: odebug << "SIOCGIWENCODE" << oendl; break; |
976 | case IWEVTXDROP: odebug << "IWEVTXDROP" << oendl; break; /* Packet dropped to excessive retry */ | 976 | case IWEVTXDROP: odebug << "IWEVTXDROP" << oendl; break; /* Packet dropped to excessive retry */ |
977 | case IWEVQUAL: odebug << "IWEVQUAL" << oendl; break; /* Quality part of statistics (scan) */ | 977 | case IWEVQUAL: odebug << "IWEVQUAL" << oendl; break; /* Quality part of statistics (scan) */ |
978 | case IWEVCUSTOM: odebug << "IWEVCUSTOM" << oendl; break; /* Driver specific ascii string */ | 978 | case IWEVCUSTOM: odebug << "IWEVCUSTOM" << oendl; break; /* Driver specific ascii string */ |
979 | case IWEVREGISTERED: odebug << "IWEVREGISTERED" << oendl; break; /* Discovered a new node (AP mode) */ | 979 | case IWEVREGISTERED: odebug << "IWEVREGISTERED" << oendl; break; /* Discovered a new node (AP mode) */ |
980 | case IWEVEXPIRED: odebug << "IWEVEXPIRED" << oendl; break; /* Expired a node (AP mode) */ | 980 | case IWEVEXPIRED: odebug << "IWEVEXPIRED" << oendl; break; /* Expired a node (AP mode) */ |
981 | default: odebug << "unhandled event" << oendl; | 981 | default: odebug << "unhandled event" << oendl; |
982 | } | 982 | } |
983 | 983 | ||
984 | offset += we->len; | 984 | offset += we->len; |
985 | we = (struct iw_event*) &buffer[offset]; | 985 | we = (struct iw_event*) &buffer[offset]; |
986 | } | 986 | } |
987 | return stations; | 987 | return stations; |
988 | 988 | ||
989 | return stations; | 989 | return stations; |
990 | 990 | ||
991 | } | 991 | } |
992 | else | 992 | else |
993 | { | 993 | { |
994 | odebug << " - no results (timeout) :(" << oendl; | 994 | odebug << " - no results (timeout) :(" << oendl; |
995 | return stations; | 995 | return stations; |
996 | } | 996 | } |
997 | } | 997 | } |
998 | 998 | ||
999 | 999 | ||
1000 | int OWirelessNetworkInterface::signalStrength() const | 1000 | int OWirelessNetworkInterface::signalStrength() const |
1001 | { | 1001 | { |
1002 | iw_statistics stat; | 1002 | iw_statistics stat; |
1003 | ::memset( &stat, 0, sizeof stat ); | 1003 | ::memset( &stat, 0, sizeof stat ); |
1004 | _iwr.u.data.pointer = (char*) &stat; | 1004 | _iwr.u.data.pointer = (char*) &stat; |
1005 | _iwr.u.data.flags = 0; | 1005 | _iwr.u.data.flags = 0; |
1006 | _iwr.u.data.length = sizeof stat; | 1006 | _iwr.u.data.length = sizeof stat; |
1007 | 1007 | ||
1008 | if ( !wioctl( SIOCGIWSTATS ) ) | 1008 | if ( !wioctl( SIOCGIWSTATS ) ) |
1009 | { | 1009 | { |
1010 | return -1; | 1010 | return -1; |
1011 | } | 1011 | } |
1012 | 1012 | ||
1013 | int max = _range.max_qual.qual; | 1013 | int max = _range.max_qual.qual; |
1014 | int cur = stat.qual.qual; | 1014 | int cur = stat.qual.qual; |
1015 | int lev = stat.qual.level; //FIXME: Do something with them? | 1015 | // int lev = stat.qual.level; //FIXME: Do something with them? |
1016 | int noi = stat.qual.noise; //FIXME: Do something with them? | 1016 | // int noi = stat.qual.noise; //FIXME: Do something with them? |
1017 | 1017 | ||
1018 | 1018 | ||
1019 | return max != 0 ? cur*100/max: -1; | 1019 | return max != 0 ? cur*100/max: -1; |
1020 | } | 1020 | } |
1021 | 1021 | ||
1022 | 1022 | ||
1023 | bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const | 1023 | bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const |
1024 | { | 1024 | { |
1025 | #ifndef NODEBUG | 1025 | #ifndef NODEBUG |
1026 | int result = ::ioctl( _sfd, call, &iwreq ); | 1026 | int result = ::ioctl( _sfd, call, &iwreq ); |
1027 | 1027 | ||
1028 | if ( result == -1 ) | 1028 | if ( result == -1 ) |
1029 | odebug << "ONetworkInterface::wioctl (" << name() << ") call '" | 1029 | odebug << "ONetworkInterface::wioctl (" << name() << ") call '" |
1030 | << debugmapper->map( call ) << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl; | 1030 | << debugmapper->map( call ) << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl; |
1031 | else | 1031 | else |
1032 | odebug << "ONetworkInterface::wioctl (" << name() << ") call '" | 1032 | odebug << "ONetworkInterface::wioctl (" << name() << ") call '" |
1033 | << debugmapper->map( call ) << "' - Status: Ok." << oendl; | 1033 | << debugmapper->map( call ) << "' - Status: Ok." << oendl; |
1034 | 1034 | ||
1035 | return ( result != -1 ); | 1035 | return ( result != -1 ); |
1036 | #else | 1036 | #else |
1037 | return ::ioctl( _sfd, call, &iwreq ) != -1; | 1037 | return ::ioctl( _sfd, call, &iwreq ) != -1; |
1038 | #endif | 1038 | #endif |
1039 | } | 1039 | } |
1040 | 1040 | ||
1041 | 1041 | ||
1042 | bool OWirelessNetworkInterface::wioctl( int call ) const | 1042 | bool OWirelessNetworkInterface::wioctl( int call ) const |
1043 | { | 1043 | { |
1044 | strcpy( _iwr.ifr_name, name() ); | 1044 | strcpy( _iwr.ifr_name, name() ); |
1045 | return wioctl( call, _iwr ); | 1045 | return wioctl( call, _iwr ); |
1046 | } | 1046 | } |
1047 | 1047 | ||
1048 | 1048 | ||
1049 | /*====================================================================================== | 1049 | /*====================================================================================== |
1050 | * OMonitoringInterface | 1050 | * OMonitoringInterface |
1051 | *======================================================================================*/ | 1051 | *======================================================================================*/ |
1052 | 1052 | ||
1053 | OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) | 1053 | OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
1054 | :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader ) | 1054 | :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader ) |
1055 | { | 1055 | { |
1056 | } | 1056 | } |
1057 | 1057 | ||
1058 | 1058 | ||
1059 | OMonitoringInterface::~OMonitoringInterface() | 1059 | OMonitoringInterface::~OMonitoringInterface() |
1060 | { | 1060 | { |
1061 | } | 1061 | } |
1062 | 1062 | ||
1063 | 1063 | ||
1064 | void OMonitoringInterface::setChannel( int c ) | 1064 | void OMonitoringInterface::setChannel( int c ) |
1065 | { | 1065 | { |
1066 | // use standard WE channel switching protocol | 1066 | // use standard WE channel switching protocol |
1067 | memset( &_if->_iwr, 0, sizeof( struct iwreq ) ); | 1067 | memset( &_if->_iwr, 0, sizeof( struct iwreq ) ); |
1068 | _if->_iwr.u.freq.m = c; | 1068 | _if->_iwr.u.freq.m = c; |
1069 | _if->_iwr.u.freq.e = 0; | 1069 | _if->_iwr.u.freq.e = 0; |
1070 | _if->wioctl( SIOCSIWFREQ ); | 1070 | _if->wioctl( SIOCSIWFREQ ); |
1071 | } | 1071 | } |
1072 | 1072 | ||
1073 | 1073 | ||
1074 | void OMonitoringInterface::setEnabled( bool b ) | 1074 | void OMonitoringInterface::setEnabled( bool ) |
1075 | { | 1075 | { |
1076 | } | 1076 | } |
1077 | 1077 | ||
1078 | 1078 | ||
1079 | /*====================================================================================== | 1079 | /*====================================================================================== |
1080 | * OCiscoMonitoringInterface | 1080 | * OCiscoMonitoringInterface |
1081 | *======================================================================================*/ | 1081 | *======================================================================================*/ |
1082 | 1082 | ||
1083 | OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) | 1083 | OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
1084 | :OMonitoringInterface( iface, prismHeader ) | 1084 | :OMonitoringInterface( iface, prismHeader ) |
1085 | { | 1085 | { |
1086 | iface->setMonitoring( this ); | 1086 | iface->setMonitoring( this ); |
1087 | } | 1087 | } |
1088 | 1088 | ||
1089 | 1089 | ||
1090 | OCiscoMonitoringInterface::~OCiscoMonitoringInterface() | 1090 | OCiscoMonitoringInterface::~OCiscoMonitoringInterface() |
1091 | { | 1091 | { |
1092 | } | 1092 | } |
1093 | 1093 | ||
1094 | 1094 | ||
1095 | void OCiscoMonitoringInterface::setEnabled( bool b ) | 1095 | void OCiscoMonitoringInterface::setEnabled( bool /*b*/ ) |
1096 | { | 1096 | { |
1097 | QString fname; | 1097 | QString fname; |
1098 | fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() ); | 1098 | fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() ); |
1099 | QFile f( fname ); | 1099 | QFile f( fname ); |
1100 | if ( !f.exists() ) return; | 1100 | if ( !f.exists() ) return; |
1101 | 1101 | ||
1102 | if ( f.open( IO_WriteOnly ) ) | 1102 | if ( f.open( IO_WriteOnly ) ) |
1103 | { | 1103 | { |
1104 | QTextStream s( &f ); | 1104 | QTextStream s( &f ); |
1105 | s << "Mode: r"; | 1105 | s << "Mode: r"; |
1106 | s << "Mode: y"; | 1106 | s << "Mode: y"; |
1107 | s << "XmitPower: 1"; | 1107 | s << "XmitPower: 1"; |
1108 | } | 1108 | } |
1109 | 1109 | ||
1110 | // flushing and closing will be done automatically when f goes out of scope | 1110 | // flushing and closing will be done automatically when f goes out of scope |
1111 | } | 1111 | } |
1112 | 1112 | ||
1113 | 1113 | ||
1114 | QString OCiscoMonitoringInterface::name() const | 1114 | QString OCiscoMonitoringInterface::name() const |
1115 | { | 1115 | { |
1116 | return "cisco"; | 1116 | return "cisco"; |
1117 | } | 1117 | } |
1118 | 1118 | ||
1119 | 1119 | ||
1120 | void OCiscoMonitoringInterface::setChannel( int ) | 1120 | void OCiscoMonitoringInterface::setChannel( int ) |
1121 | { | 1121 | { |
1122 | // cisco devices automatically switch channels when in monitor mode | 1122 | // cisco devices automatically switch channels when in monitor mode |
1123 | } | 1123 | } |
1124 | 1124 | ||
1125 | 1125 | ||
1126 | /*====================================================================================== | 1126 | /*====================================================================================== |
1127 | * OWlanNGMonitoringInterface | 1127 | * OWlanNGMonitoringInterface |
1128 | *======================================================================================*/ | 1128 | *======================================================================================*/ |
1129 | 1129 | ||
1130 | 1130 | ||
1131 | OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) | 1131 | OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
1132 | :OMonitoringInterface( iface, prismHeader ) | 1132 | :OMonitoringInterface( iface, prismHeader ) |
1133 | { | 1133 | { |
1134 | iface->setMonitoring( this ); | 1134 | iface->setMonitoring( this ); |
1135 | } | 1135 | } |
1136 | 1136 | ||
1137 | 1137 | ||
1138 | OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface() | 1138 | OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface() |
1139 | { | 1139 | { |
1140 | } | 1140 | } |
1141 | 1141 | ||
1142 | 1142 | ||
1143 | void OWlanNGMonitoringInterface::setEnabled( bool b ) | 1143 | void OWlanNGMonitoringInterface::setEnabled( bool b ) |
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp index 03e4502..25ac09b 100644 --- a/libopie2/opienet/opcap.cpp +++ b/libopie2/opienet/opcap.cpp | |||
@@ -145,96 +145,97 @@ QString OPacket::_dumpStructure( QObjectList* l ) const | |||
145 | 145 | ||
146 | QString OPacket::dump( int bpl ) const | 146 | QString OPacket::dump( int bpl ) const |
147 | { | 147 | { |
148 | static int index = 0; | 148 | static int index = 0; |
149 | index++; | 149 | index++; |
150 | int len = _hdr.caplen; | 150 | int len = _hdr.caplen; |
151 | QString str( "000:" ); | 151 | QString str( "000:" ); |
152 | QString tmp; | 152 | QString tmp; |
153 | QString bytes; | 153 | QString bytes; |
154 | QString chars; | 154 | QString chars; |
155 | 155 | ||
156 | for ( int i = 0; i < len; ++i ) | 156 | for ( int i = 0; i < len; ++i ) |
157 | { | 157 | { |
158 | tmp.sprintf( "%02X ", _data[i] ); bytes.append( tmp ); | 158 | tmp.sprintf( "%02X ", _data[i] ); bytes.append( tmp ); |
159 | if ( (_data[i] > 31) && (_data[i]<128) ) chars.append( _data[i] ); | 159 | if ( (_data[i] > 31) && (_data[i]<128) ) chars.append( _data[i] ); |
160 | else chars.append( '.' ); | 160 | else chars.append( '.' ); |
161 | 161 | ||
162 | if ( !((i+1) % bpl) ) | 162 | if ( !((i+1) % bpl) ) |
163 | { | 163 | { |
164 | str.append( bytes ); | 164 | str.append( bytes ); |
165 | str.append( ' ' ); | 165 | str.append( ' ' ); |
166 | str.append( chars ); | 166 | str.append( chars ); |
167 | str.append( '\n' ); | 167 | str.append( '\n' ); |
168 | tmp.sprintf( "%03X:", i+1 ); str.append( tmp ); | 168 | tmp.sprintf( "%03X:", i+1 ); str.append( tmp ); |
169 | bytes = ""; | 169 | bytes = ""; |
170 | chars = ""; | 170 | chars = ""; |
171 | } | 171 | } |
172 | 172 | ||
173 | } | 173 | } |
174 | if ( (len % bpl) ) | 174 | if ( (len % bpl) ) |
175 | { | 175 | { |
176 | str.append( bytes.leftJustify( 1 + 3*bpl ) ); | 176 | str.append( bytes.leftJustify( 1 + 3*bpl ) ); |
177 | str.append( chars ); | 177 | str.append( chars ); |
178 | } | 178 | } |
179 | str.append( '\n' ); | 179 | str.append( '\n' ); |
180 | return str; | 180 | return str; |
181 | } | 181 | } |
182 | 182 | ||
183 | 183 | ||
184 | int OPacket::len() const | 184 | int OPacket::len() const |
185 | { | 185 | { |
186 | return _hdr.len; | 186 | return _hdr.len; |
187 | } | 187 | } |
188 | 188 | ||
189 | 189 | ||
190 | QTextStream& operator<<( QTextStream& s, const OPacket& p ) | 190 | QTextStream& operator<<( QTextStream& s, const OPacket& p ) |
191 | { | 191 | { |
192 | s << p.dumpStructure(); | 192 | s << p.dumpStructure(); |
193 | return s; | ||
193 | } | 194 | } |
194 | 195 | ||
195 | 196 | ||
196 | /*====================================================================================== | 197 | /*====================================================================================== |
197 | * OEthernetPacket | 198 | * OEthernetPacket |
198 | *======================================================================================*/ | 199 | *======================================================================================*/ |
199 | 200 | ||
200 | OEthernetPacket::OEthernetPacket( const unsigned char* end, const struct ether_header* data, QObject* parent ) | 201 | OEthernetPacket::OEthernetPacket( const unsigned char* end, const struct ether_header* data, QObject* parent ) |
201 | :QObject( parent, "Ethernet" ), _ether( data ) | 202 | :QObject( parent, "Ethernet" ), _ether( data ) |
202 | { | 203 | { |
203 | 204 | ||
204 | odebug << "Source = " << sourceAddress().toString() << oendl; | 205 | odebug << "Source = " << sourceAddress().toString() << oendl; |
205 | odebug << "Destination = " << destinationAddress().toString() << oendl; | 206 | odebug << "Destination = " << destinationAddress().toString() << oendl; |
206 | 207 | ||
207 | if ( sourceAddress() == OMacAddress::broadcast ) | 208 | if ( sourceAddress() == OMacAddress::broadcast ) |
208 | odebug << "Source is broadcast address" << oendl; | 209 | odebug << "Source is broadcast address" << oendl; |
209 | if ( destinationAddress() == OMacAddress::broadcast ) | 210 | if ( destinationAddress() == OMacAddress::broadcast ) |
210 | odebug << "Destination is broadcast address" << oendl; | 211 | odebug << "Destination is broadcast address" << oendl; |
211 | 212 | ||
212 | switch ( type() ) | 213 | switch ( type() ) |
213 | { | 214 | { |
214 | case ETHERTYPE_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break; | 215 | case ETHERTYPE_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break; |
215 | case ETHERTYPE_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break; | 216 | case ETHERTYPE_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break; |
216 | case ETHERTYPE_REVARP: { odebug << "OPacket::OPacket(): Received Ethernet Packet : Type = RARP" << oendl; break; } | 217 | case ETHERTYPE_REVARP: { odebug << "OPacket::OPacket(): Received Ethernet Packet : Type = RARP" << oendl; break; } |
217 | default: odebug << "OPacket::OPacket(): Received Ethernet Packet : Type = UNKNOWN" << oendl; | 218 | default: odebug << "OPacket::OPacket(): Received Ethernet Packet : Type = UNKNOWN" << oendl; |
218 | } | 219 | } |
219 | 220 | ||
220 | } | 221 | } |
221 | 222 | ||
222 | 223 | ||
223 | OEthernetPacket::~OEthernetPacket() | 224 | OEthernetPacket::~OEthernetPacket() |
224 | { | 225 | { |
225 | } | 226 | } |
226 | 227 | ||
227 | 228 | ||
228 | OMacAddress OEthernetPacket::sourceAddress() const | 229 | OMacAddress OEthernetPacket::sourceAddress() const |
229 | { | 230 | { |
230 | return OMacAddress( _ether->ether_shost ); | 231 | return OMacAddress( _ether->ether_shost ); |
231 | } | 232 | } |
232 | 233 | ||
233 | 234 | ||
234 | OMacAddress OEthernetPacket::destinationAddress() const | 235 | OMacAddress OEthernetPacket::destinationAddress() const |
235 | { | 236 | { |
236 | return OMacAddress( _ether->ether_dhost ); | 237 | return OMacAddress( _ether->ether_dhost ); |
237 | } | 238 | } |
238 | 239 | ||
239 | int OEthernetPacket::type() const | 240 | int OEthernetPacket::type() const |
240 | { | 241 | { |
@@ -282,97 +283,97 @@ QHostAddress OIPPacket::toIPAddress() const | |||
282 | 283 | ||
283 | 284 | ||
284 | int OIPPacket::tos() const | 285 | int OIPPacket::tos() const |
285 | { | 286 | { |
286 | return _iphdr->tos; | 287 | return _iphdr->tos; |
287 | } | 288 | } |
288 | 289 | ||
289 | 290 | ||
290 | int OIPPacket::len() const | 291 | int OIPPacket::len() const |
291 | { | 292 | { |
292 | return EXTRACT_16BITS( &_iphdr->tot_len ); | 293 | return EXTRACT_16BITS( &_iphdr->tot_len ); |
293 | } | 294 | } |
294 | 295 | ||
295 | 296 | ||
296 | int OIPPacket::id() const | 297 | int OIPPacket::id() const |
297 | { | 298 | { |
298 | return EXTRACT_16BITS( &_iphdr->id ); | 299 | return EXTRACT_16BITS( &_iphdr->id ); |
299 | } | 300 | } |
300 | 301 | ||
301 | 302 | ||
302 | int OIPPacket::offset() const | 303 | int OIPPacket::offset() const |
303 | { | 304 | { |
304 | return EXTRACT_16BITS( &_iphdr->frag_off ); | 305 | return EXTRACT_16BITS( &_iphdr->frag_off ); |
305 | } | 306 | } |
306 | 307 | ||
307 | 308 | ||
308 | int OIPPacket::ttl() const | 309 | int OIPPacket::ttl() const |
309 | { | 310 | { |
310 | return _iphdr->ttl; | 311 | return _iphdr->ttl; |
311 | } | 312 | } |
312 | 313 | ||
313 | 314 | ||
314 | int OIPPacket::protocol() const | 315 | int OIPPacket::protocol() const |
315 | { | 316 | { |
316 | return _iphdr->protocol; | 317 | return _iphdr->protocol; |
317 | } | 318 | } |
318 | 319 | ||
319 | 320 | ||
320 | int OIPPacket::checksum() const | 321 | int OIPPacket::checksum() const |
321 | { | 322 | { |
322 | return EXTRACT_16BITS( &_iphdr->check ); | 323 | return EXTRACT_16BITS( &_iphdr->check ); |
323 | } | 324 | } |
324 | 325 | ||
325 | /*====================================================================================== | 326 | /*====================================================================================== |
326 | * OARPPacket | 327 | * OARPPacket |
327 | *======================================================================================*/ | 328 | *======================================================================================*/ |
328 | 329 | ||
329 | 330 | ||
330 | OARPPacket::OARPPacket( const unsigned char* end, const struct myarphdr* data, QObject* parent ) | 331 | OARPPacket::OARPPacket( const unsigned char* /*end*/, const struct myarphdr* data, QObject* parent ) |
331 | :QObject( parent, "ARP" ), _arphdr( data ) | 332 | :QObject( parent, "ARP" ), _arphdr( data ) |
332 | { | 333 | { |
333 | odebug << "OARPPacket::OARPPacket(): decoding ARP header..." << oendl; | 334 | odebug << "OARPPacket::OARPPacket(): decoding ARP header..." << oendl; |
334 | odebug << "ARP type seems to be " << EXTRACT_16BITS( &_arphdr->ar_op ) << " = " << type() << oendl; | 335 | odebug << "ARP type seems to be " << EXTRACT_16BITS( &_arphdr->ar_op ) << " = " << type() << oendl; |
335 | odebug << "Sender: MAC " << senderMacAddress().toString() << " = IP " << senderIPV4Address().toString() << oendl; | 336 | odebug << "Sender: MAC " << senderMacAddress().toString() << " = IP " << senderIPV4Address().toString() << oendl; |
336 | odebug << "Target: MAC " << targetMacAddress().toString() << " = IP " << targetIPV4Address().toString() << oendl; | 337 | odebug << "Target: MAC " << targetMacAddress().toString() << " = IP " << targetIPV4Address().toString() << oendl; |
337 | } | 338 | } |
338 | 339 | ||
339 | 340 | ||
340 | OARPPacket::~OARPPacket() | 341 | OARPPacket::~OARPPacket() |
341 | { | 342 | { |
342 | } | 343 | } |
343 | 344 | ||
344 | 345 | ||
345 | QString OARPPacket::type() const | 346 | QString OARPPacket::type() const |
346 | { | 347 | { |
347 | switch ( EXTRACT_16BITS( &_arphdr->ar_op ) ) | 348 | switch ( EXTRACT_16BITS( &_arphdr->ar_op ) ) |
348 | { | 349 | { |
349 | case 1: return "REQUEST"; | 350 | case 1: return "REQUEST"; |
350 | case 2: return "REPLY"; | 351 | case 2: return "REPLY"; |
351 | case 3: return "RREQUEST"; | 352 | case 3: return "RREQUEST"; |
352 | case 4: return "RREPLY"; | 353 | case 4: return "RREPLY"; |
353 | case 8: return "InREQUEST"; | 354 | case 8: return "InREQUEST"; |
354 | case 9: return "InREPLY"; | 355 | case 9: return "InREPLY"; |
355 | case 10: return "NAK"; | 356 | case 10: return "NAK"; |
356 | default: owarn << "OARPPacket::type(): invalid ARP type!" << oendl; return "<unknown>"; | 357 | default: owarn << "OARPPacket::type(): invalid ARP type!" << oendl; return "<unknown>"; |
357 | } | 358 | } |
358 | } | 359 | } |
359 | 360 | ||
360 | 361 | ||
361 | QHostAddress OARPPacket::senderIPV4Address() const | 362 | QHostAddress OARPPacket::senderIPV4Address() const |
362 | { | 363 | { |
363 | return EXTRACT_32BITS( &_arphdr->ar_sip ); | 364 | return EXTRACT_32BITS( &_arphdr->ar_sip ); |
364 | } | 365 | } |
365 | 366 | ||
366 | 367 | ||
367 | QHostAddress OARPPacket::targetIPV4Address() const | 368 | QHostAddress OARPPacket::targetIPV4Address() const |
368 | { | 369 | { |
369 | return EXTRACT_32BITS( &_arphdr->ar_tip ); | 370 | return EXTRACT_32BITS( &_arphdr->ar_tip ); |
370 | } | 371 | } |
371 | 372 | ||
372 | 373 | ||
373 | OMacAddress OARPPacket::senderMacAddress() const | 374 | OMacAddress OARPPacket::senderMacAddress() const |
374 | { | 375 | { |
375 | return OMacAddress( _arphdr->ar_sha ); | 376 | return OMacAddress( _arphdr->ar_sha ); |
376 | } | 377 | } |
377 | 378 | ||
378 | 379 | ||
@@ -502,97 +503,97 @@ QString ODHCPPacket::type() const | |||
502 | case 1: return "DISCOVER"; | 503 | case 1: return "DISCOVER"; |
503 | case 2: return "OFFER"; | 504 | case 2: return "OFFER"; |
504 | case 3: return "REQUEST"; | 505 | case 3: return "REQUEST"; |
505 | case 4: return "DECLINE"; | 506 | case 4: return "DECLINE"; |
506 | case 5: return "ACK"; | 507 | case 5: return "ACK"; |
507 | case 6: return "NAK"; | 508 | case 6: return "NAK"; |
508 | case 7: return "RELEASE"; | 509 | case 7: return "RELEASE"; |
509 | case 8: return "INFORM"; | 510 | case 8: return "INFORM"; |
510 | default: owarn << "ODHCPPacket::type(): invalid DHCP type " << _dhcphdr->op << oendl; return "<unknown>"; | 511 | default: owarn << "ODHCPPacket::type(): invalid DHCP type " << _dhcphdr->op << oendl; return "<unknown>"; |
511 | } | 512 | } |
512 | } | 513 | } |
513 | 514 | ||
514 | 515 | ||
515 | QHostAddress ODHCPPacket::clientAddress() const | 516 | QHostAddress ODHCPPacket::clientAddress() const |
516 | { | 517 | { |
517 | return EXTRACT_32BITS( &_dhcphdr->ciaddr ); | 518 | return EXTRACT_32BITS( &_dhcphdr->ciaddr ); |
518 | } | 519 | } |
519 | 520 | ||
520 | 521 | ||
521 | QHostAddress ODHCPPacket::yourAddress() const | 522 | QHostAddress ODHCPPacket::yourAddress() const |
522 | { | 523 | { |
523 | return EXTRACT_32BITS( &_dhcphdr->yiaddr ); | 524 | return EXTRACT_32BITS( &_dhcphdr->yiaddr ); |
524 | } | 525 | } |
525 | 526 | ||
526 | 527 | ||
527 | QHostAddress ODHCPPacket::serverAddress() const | 528 | QHostAddress ODHCPPacket::serverAddress() const |
528 | { | 529 | { |
529 | return EXTRACT_32BITS( &_dhcphdr->siaddr ); | 530 | return EXTRACT_32BITS( &_dhcphdr->siaddr ); |
530 | } | 531 | } |
531 | 532 | ||
532 | 533 | ||
533 | QHostAddress ODHCPPacket::relayAddress() const | 534 | QHostAddress ODHCPPacket::relayAddress() const |
534 | { | 535 | { |
535 | return EXTRACT_32BITS( &_dhcphdr->giaddr ); | 536 | return EXTRACT_32BITS( &_dhcphdr->giaddr ); |
536 | } | 537 | } |
537 | 538 | ||
538 | 539 | ||
539 | OMacAddress ODHCPPacket::clientMacAddress() const | 540 | OMacAddress ODHCPPacket::clientMacAddress() const |
540 | { | 541 | { |
541 | return OMacAddress( _dhcphdr->chaddr ); | 542 | return OMacAddress( _dhcphdr->chaddr ); |
542 | } | 543 | } |
543 | 544 | ||
544 | 545 | ||
545 | /*====================================================================================== | 546 | /*====================================================================================== |
546 | * OTCPPacket | 547 | * OTCPPacket |
547 | *======================================================================================*/ | 548 | *======================================================================================*/ |
548 | 549 | ||
549 | 550 | ||
550 | OTCPPacket::OTCPPacket( const unsigned char* end, const struct tcphdr* data, QObject* parent ) | 551 | OTCPPacket::OTCPPacket( const unsigned char* /*end*/, const struct tcphdr* data, QObject* parent ) |
551 | :QObject( parent, "TCP" ), _tcphdr( data ) | 552 | :QObject( parent, "TCP" ), _tcphdr( data ) |
552 | 553 | ||
553 | { | 554 | { |
554 | odebug << "OTCPPacket::OTCPPacket(): decoding TCP header..." << oendl; | 555 | odebug << "OTCPPacket::OTCPPacket(): decoding TCP header..." << oendl; |
555 | } | 556 | } |
556 | 557 | ||
557 | 558 | ||
558 | OTCPPacket::~OTCPPacket() | 559 | OTCPPacket::~OTCPPacket() |
559 | { | 560 | { |
560 | } | 561 | } |
561 | 562 | ||
562 | 563 | ||
563 | int OTCPPacket::fromPort() const | 564 | int OTCPPacket::fromPort() const |
564 | { | 565 | { |
565 | return EXTRACT_16BITS( &_tcphdr->source ); | 566 | return EXTRACT_16BITS( &_tcphdr->source ); |
566 | } | 567 | } |
567 | 568 | ||
568 | 569 | ||
569 | int OTCPPacket::toPort() const | 570 | int OTCPPacket::toPort() const |
570 | { | 571 | { |
571 | return EXTRACT_16BITS( &_tcphdr->dest ); | 572 | return EXTRACT_16BITS( &_tcphdr->dest ); |
572 | } | 573 | } |
573 | 574 | ||
574 | 575 | ||
575 | int OTCPPacket::seq() const | 576 | int OTCPPacket::seq() const |
576 | { | 577 | { |
577 | return EXTRACT_16BITS( &_tcphdr->seq ); | 578 | return EXTRACT_16BITS( &_tcphdr->seq ); |
578 | } | 579 | } |
579 | 580 | ||
580 | 581 | ||
581 | int OTCPPacket::ack() const | 582 | int OTCPPacket::ack() const |
582 | { | 583 | { |
583 | return EXTRACT_16BITS( &_tcphdr->ack_seq ); | 584 | return EXTRACT_16BITS( &_tcphdr->ack_seq ); |
584 | } | 585 | } |
585 | 586 | ||
586 | 587 | ||
587 | int OTCPPacket::window() const | 588 | int OTCPPacket::window() const |
588 | { | 589 | { |
589 | return EXTRACT_16BITS( &_tcphdr->window ); | 590 | return EXTRACT_16BITS( &_tcphdr->window ); |
590 | } | 591 | } |
591 | 592 | ||
592 | 593 | ||
593 | int OTCPPacket::checksum() const | 594 | int OTCPPacket::checksum() const |
594 | { | 595 | { |
595 | return EXTRACT_16BITS( &_tcphdr->check ); | 596 | return EXTRACT_16BITS( &_tcphdr->check ); |
596 | } | 597 | } |
597 | 598 | ||
598 | /*====================================================================================== | 599 | /*====================================================================================== |
@@ -789,295 +790,295 @@ QString OWaveLanManagementPacket::managementType() const | |||
789 | 790 | ||
790 | 791 | ||
791 | int OWaveLanManagementPacket::beaconInterval() const | 792 | int OWaveLanManagementPacket::beaconInterval() const |
792 | { | 793 | { |
793 | return EXTRACT_LE_16BITS( &_body->beacon_interval ); | 794 | return EXTRACT_LE_16BITS( &_body->beacon_interval ); |
794 | } | 795 | } |
795 | 796 | ||
796 | 797 | ||
797 | int OWaveLanManagementPacket::capabilities() const | 798 | int OWaveLanManagementPacket::capabilities() const |
798 | { | 799 | { |
799 | return EXTRACT_LE_16BITS( &_body->capability_info ); | 800 | return EXTRACT_LE_16BITS( &_body->capability_info ); |
800 | } | 801 | } |
801 | 802 | ||
802 | 803 | ||
803 | bool OWaveLanManagementPacket::canESS() const | 804 | bool OWaveLanManagementPacket::canESS() const |
804 | { | 805 | { |
805 | return CAPABILITY_ESS( EXTRACT_LE_16BITS( &_body->capability_info ) ); | 806 | return CAPABILITY_ESS( EXTRACT_LE_16BITS( &_body->capability_info ) ); |
806 | } | 807 | } |
807 | 808 | ||
808 | 809 | ||
809 | bool OWaveLanManagementPacket::canIBSS() const | 810 | bool OWaveLanManagementPacket::canIBSS() const |
810 | { | 811 | { |
811 | return CAPABILITY_IBSS( EXTRACT_LE_16BITS( &_body->capability_info ) ); | 812 | return CAPABILITY_IBSS( EXTRACT_LE_16BITS( &_body->capability_info ) ); |
812 | } | 813 | } |
813 | 814 | ||
814 | 815 | ||
815 | bool OWaveLanManagementPacket::canCFP() const | 816 | bool OWaveLanManagementPacket::canCFP() const |
816 | { | 817 | { |
817 | return CAPABILITY_CFP( EXTRACT_LE_16BITS( &_body->capability_info ) ); | 818 | return CAPABILITY_CFP( EXTRACT_LE_16BITS( &_body->capability_info ) ); |
818 | } | 819 | } |
819 | 820 | ||
820 | 821 | ||
821 | bool OWaveLanManagementPacket::canCFP_REQ() const | 822 | bool OWaveLanManagementPacket::canCFP_REQ() const |
822 | { | 823 | { |
823 | return CAPABILITY_CFP_REQ( EXTRACT_LE_16BITS( &_body->capability_info ) ); | 824 | return CAPABILITY_CFP_REQ( EXTRACT_LE_16BITS( &_body->capability_info ) ); |
824 | } | 825 | } |
825 | 826 | ||
826 | 827 | ||
827 | bool OWaveLanManagementPacket::canPrivacy() const | 828 | bool OWaveLanManagementPacket::canPrivacy() const |
828 | { | 829 | { |
829 | return CAPABILITY_PRIVACY( EXTRACT_LE_16BITS( &_body->capability_info ) ); | 830 | return CAPABILITY_PRIVACY( EXTRACT_LE_16BITS( &_body->capability_info ) ); |
830 | } | 831 | } |
831 | 832 | ||
832 | 833 | ||
833 | /*====================================================================================== | 834 | /*====================================================================================== |
834 | * OWaveLanManagementSSID | 835 | * OWaveLanManagementSSID |
835 | *======================================================================================*/ | 836 | *======================================================================================*/ |
836 | 837 | ||
837 | OWaveLanManagementSSID::OWaveLanManagementSSID( const unsigned char* end, const struct ssid_t* data, QObject* parent ) | 838 | OWaveLanManagementSSID::OWaveLanManagementSSID( const unsigned char* /*end*/, const struct ssid_t* data, QObject* parent ) |
838 | :QObject( parent, "802.11 SSID" ), _data( data ) | 839 | :QObject( parent, "802.11 SSID" ), _data( data ) |
839 | { | 840 | { |
840 | odebug << "OWaveLanManagementSSID()" << oendl; | 841 | odebug << "OWaveLanManagementSSID()" << oendl; |
841 | } | 842 | } |
842 | 843 | ||
843 | 844 | ||
844 | OWaveLanManagementSSID::~OWaveLanManagementSSID() | 845 | OWaveLanManagementSSID::~OWaveLanManagementSSID() |
845 | { | 846 | { |
846 | } | 847 | } |
847 | 848 | ||
848 | 849 | ||
849 | QString OWaveLanManagementSSID::ID( bool decloak ) const | 850 | QString OWaveLanManagementSSID::ID( bool decloak ) const |
850 | { | 851 | { |
851 | int length = _data->length; | 852 | int length = _data->length; |
852 | if ( length > 32 ) length = 32; | 853 | if ( length > 32 ) length = 32; |
853 | char essid[length+1]; | 854 | char essid[length+1]; |
854 | memcpy( &essid, &_data->ssid, length ); | 855 | memcpy( &essid, &_data->ssid, length ); |
855 | essid[length] = 0x0; | 856 | essid[length] = 0x0; |
856 | if ( !decloak || length < 2 || essid[0] != '\0' ) return essid; | 857 | if ( !decloak || length < 2 || essid[0] != '\0' ) return essid; |
857 | odebug << "OWaveLanManagementSSID:ID(): SSID is cloaked - decloaking..." << oendl; | 858 | odebug << "OWaveLanManagementSSID:ID(): SSID is cloaked - decloaking..." << oendl; |
858 | 859 | ||
859 | QString decloakedID; | 860 | QString decloakedID; |
860 | for ( int i = 1; i < length; ++i ) | 861 | for ( int i = 1; i < length; ++i ) |
861 | { | 862 | { |
862 | if ( essid[i] >= 32 && essid[i] <= 126 ) decloakedID.append( essid[i] ); | 863 | if ( essid[i] >= 32 && essid[i] <= 126 ) decloakedID.append( essid[i] ); |
863 | else decloakedID.append( '.' ); | 864 | else decloakedID.append( '.' ); |
864 | } | 865 | } |
865 | return decloakedID; | 866 | return decloakedID; |
866 | } | 867 | } |
867 | 868 | ||
868 | 869 | ||
869 | /*====================================================================================== | 870 | /*====================================================================================== |
870 | * OWaveLanManagementRates | 871 | * OWaveLanManagementRates |
871 | *======================================================================================*/ | 872 | *======================================================================================*/ |
872 | 873 | ||
873 | OWaveLanManagementRates::OWaveLanManagementRates( const unsigned char* end, const struct rates_t* data, QObject* parent ) | 874 | OWaveLanManagementRates::OWaveLanManagementRates( const unsigned char* /*end*/, const struct rates_t* data, QObject* parent ) |
874 | :QObject( parent, "802.11 Rates" ), _data( data ) | 875 | :QObject( parent, "802.11 Rates" ), _data( data ) |
875 | { | 876 | { |
876 | odebug << "OWaveLanManagementRates()" << oendl; | 877 | odebug << "OWaveLanManagementRates()" << oendl; |
877 | } | 878 | } |
878 | 879 | ||
879 | 880 | ||
880 | OWaveLanManagementRates::~OWaveLanManagementRates() | 881 | OWaveLanManagementRates::~OWaveLanManagementRates() |
881 | { | 882 | { |
882 | } | 883 | } |
883 | 884 | ||
884 | /*====================================================================================== | 885 | /*====================================================================================== |
885 | * OWaveLanManagementCF | 886 | * OWaveLanManagementCF |
886 | *======================================================================================*/ | 887 | *======================================================================================*/ |
887 | 888 | ||
888 | OWaveLanManagementCF::OWaveLanManagementCF( const unsigned char* end, const struct cf_t* data, QObject* parent ) | 889 | OWaveLanManagementCF::OWaveLanManagementCF( const unsigned char* /*end*/, const struct cf_t* data, QObject* parent ) |
889 | :QObject( parent, "802.11 CF" ), _data( data ) | 890 | :QObject( parent, "802.11 CF" ), _data( data ) |
890 | { | 891 | { |
891 | odebug << "OWaveLanManagementCF()" << oendl; | 892 | odebug << "OWaveLanManagementCF()" << oendl; |
892 | } | 893 | } |
893 | 894 | ||
894 | 895 | ||
895 | OWaveLanManagementCF::~OWaveLanManagementCF() | 896 | OWaveLanManagementCF::~OWaveLanManagementCF() |
896 | { | 897 | { |
897 | } | 898 | } |
898 | 899 | ||
899 | /*====================================================================================== | 900 | /*====================================================================================== |
900 | * OWaveLanManagementFH | 901 | * OWaveLanManagementFH |
901 | *======================================================================================*/ | 902 | *======================================================================================*/ |
902 | 903 | ||
903 | OWaveLanManagementFH::OWaveLanManagementFH( const unsigned char* end, const struct fh_t* data, QObject* parent ) | 904 | OWaveLanManagementFH::OWaveLanManagementFH( const unsigned char* /*end*/, const struct fh_t* data, QObject* parent ) |
904 | :QObject( parent, "802.11 FH" ), _data( data ) | 905 | :QObject( parent, "802.11 FH" ), _data( data ) |
905 | { | 906 | { |
906 | odebug << "OWaveLanManagementFH()" << oendl; | 907 | odebug << "OWaveLanManagementFH()" << oendl; |
907 | } | 908 | } |
908 | 909 | ||
909 | 910 | ||
910 | OWaveLanManagementFH::~OWaveLanManagementFH() | 911 | OWaveLanManagementFH::~OWaveLanManagementFH() |
911 | { | 912 | { |
912 | } | 913 | } |
913 | 914 | ||
914 | /*====================================================================================== | 915 | /*====================================================================================== |
915 | * OWaveLanManagementDS | 916 | * OWaveLanManagementDS |
916 | *======================================================================================*/ | 917 | *======================================================================================*/ |
917 | 918 | ||
918 | OWaveLanManagementDS::OWaveLanManagementDS( const unsigned char* end, const struct ds_t* data, QObject* parent ) | 919 | OWaveLanManagementDS::OWaveLanManagementDS( const unsigned char* /*end*/, const struct ds_t* data, QObject* parent ) |
919 | :QObject( parent, "802.11 DS" ), _data( data ) | 920 | :QObject( parent, "802.11 DS" ), _data( data ) |
920 | { | 921 | { |
921 | odebug << "OWaveLanManagementDS()" << oendl; | 922 | odebug << "OWaveLanManagementDS()" << oendl; |
922 | } | 923 | } |
923 | 924 | ||
924 | 925 | ||
925 | OWaveLanManagementDS::~OWaveLanManagementDS() | 926 | OWaveLanManagementDS::~OWaveLanManagementDS() |
926 | { | 927 | { |
927 | } | 928 | } |
928 | 929 | ||
929 | 930 | ||
930 | int OWaveLanManagementDS::channel() const | 931 | int OWaveLanManagementDS::channel() const |
931 | { | 932 | { |
932 | return _data->channel; | 933 | return _data->channel; |
933 | } | 934 | } |
934 | 935 | ||
935 | /*====================================================================================== | 936 | /*====================================================================================== |
936 | * OWaveLanManagementTim | 937 | * OWaveLanManagementTim |
937 | *======================================================================================*/ | 938 | *======================================================================================*/ |
938 | 939 | ||
939 | OWaveLanManagementTim::OWaveLanManagementTim( const unsigned char* end, const struct tim_t* data, QObject* parent ) | 940 | OWaveLanManagementTim::OWaveLanManagementTim( const unsigned char* /*end*/, const struct tim_t* data, QObject* parent ) |
940 | :QObject( parent, "802.11 Tim" ), _data( data ) | 941 | :QObject( parent, "802.11 Tim" ), _data( data ) |
941 | { | 942 | { |
942 | odebug << "OWaveLanManagementTim()" << oendl; | 943 | odebug << "OWaveLanManagementTim()" << oendl; |
943 | } | 944 | } |
944 | 945 | ||
945 | 946 | ||
946 | OWaveLanManagementTim::~OWaveLanManagementTim() | 947 | OWaveLanManagementTim::~OWaveLanManagementTim() |
947 | { | 948 | { |
948 | } | 949 | } |
949 | 950 | ||
950 | /*====================================================================================== | 951 | /*====================================================================================== |
951 | * OWaveLanManagementIBSS | 952 | * OWaveLanManagementIBSS |
952 | *======================================================================================*/ | 953 | *======================================================================================*/ |
953 | 954 | ||
954 | OWaveLanManagementIBSS::OWaveLanManagementIBSS( const unsigned char* end, const struct ibss_t* data, QObject* parent ) | 955 | OWaveLanManagementIBSS::OWaveLanManagementIBSS( const unsigned char* /*end*/, const struct ibss_t* data, QObject* parent ) |
955 | :QObject( parent, "802.11 IBSS" ), _data( data ) | 956 | :QObject( parent, "802.11 IBSS" ), _data( data ) |
956 | { | 957 | { |
957 | odebug << "OWaveLanManagementIBSS()" << oendl; | 958 | odebug << "OWaveLanManagementIBSS()" << oendl; |
958 | } | 959 | } |
959 | 960 | ||
960 | 961 | ||
961 | OWaveLanManagementIBSS::~OWaveLanManagementIBSS() | 962 | OWaveLanManagementIBSS::~OWaveLanManagementIBSS() |
962 | { | 963 | { |
963 | } | 964 | } |
964 | 965 | ||
965 | /*====================================================================================== | 966 | /*====================================================================================== |
966 | * OWaveLanManagementChallenge | 967 | * OWaveLanManagementChallenge |
967 | *======================================================================================*/ | 968 | *======================================================================================*/ |
968 | 969 | ||
969 | OWaveLanManagementChallenge::OWaveLanManagementChallenge( const unsigned char* end, const struct challenge_t* data, QObject* parent ) | 970 | OWaveLanManagementChallenge::OWaveLanManagementChallenge( const unsigned char* /*end*/, const struct challenge_t* data, QObject* parent ) |
970 | :QObject( parent, "802.11 Challenge" ), _data( data ) | 971 | :QObject( parent, "802.11 Challenge" ), _data( data ) |
971 | { | 972 | { |
972 | odebug << "OWaveLanManagementChallenge()" << oendl; | 973 | odebug << "OWaveLanManagementChallenge()" << oendl; |
973 | } | 974 | } |
974 | 975 | ||
975 | 976 | ||
976 | OWaveLanManagementChallenge::~OWaveLanManagementChallenge() | 977 | OWaveLanManagementChallenge::~OWaveLanManagementChallenge() |
977 | { | 978 | { |
978 | } | 979 | } |
979 | 980 | ||
980 | /*====================================================================================== | 981 | /*====================================================================================== |
981 | * OWaveLanDataPacket | 982 | * OWaveLanDataPacket |
982 | *======================================================================================*/ | 983 | *======================================================================================*/ |
983 | 984 | ||
984 | OWaveLanDataPacket::OWaveLanDataPacket( const unsigned char* end, const struct ieee_802_11_data_header* data, OWaveLanPacket* parent ) | 985 | OWaveLanDataPacket::OWaveLanDataPacket( const unsigned char* end, const struct ieee_802_11_data_header* data, OWaveLanPacket* parent ) |
985 | :QObject( parent, "802.11 Data" ), _header( data ) | 986 | :QObject( parent, "802.11 Data" ), _header( data ) |
986 | { | 987 | { |
987 | odebug << "OWaveLanDataPacket::OWaveLanDataPacket(): decoding frame..." << oendl; | 988 | odebug << "OWaveLanDataPacket::OWaveLanDataPacket(): decoding frame..." << oendl; |
988 | 989 | ||
989 | const unsigned char* payload = (const unsigned char*) data + sizeof( struct ieee_802_11_data_header ); | 990 | const unsigned char* payload = (const unsigned char*) data + sizeof( struct ieee_802_11_data_header ); |
990 | 991 | ||
991 | #warning The next line works for most cases, but can not be correct generally! | 992 | #warning The next line works for most cases, but can not be correct generally! |
992 | if (!( ( (OWaveLanPacket*) this->parent())->duration() )) payload -= 6; // compensation for missing last address | 993 | if (!( ( (OWaveLanPacket*) this->parent())->duration() )) payload -= 6; // compensation for missing last address |
993 | 994 | ||
994 | new OLLCPacket( end, (const struct ieee_802_11_802_2_header*) payload, this ); | 995 | new OLLCPacket( end, (const struct ieee_802_11_802_2_header*) payload, this ); |
995 | } | 996 | } |
996 | 997 | ||
997 | 998 | ||
998 | OWaveLanDataPacket::~OWaveLanDataPacket() | 999 | OWaveLanDataPacket::~OWaveLanDataPacket() |
999 | { | 1000 | { |
1000 | } | 1001 | } |
1001 | 1002 | ||
1002 | 1003 | ||
1003 | /*====================================================================================== | 1004 | /*====================================================================================== |
1004 | * OLLCPacket | 1005 | * OLLCPacket |
1005 | *======================================================================================*/ | 1006 | *======================================================================================*/ |
1006 | 1007 | ||
1007 | OLLCPacket::OLLCPacket( const unsigned char* end, const struct ieee_802_11_802_2_header* data, QObject* parent ) | 1008 | OLLCPacket::OLLCPacket( const unsigned char* end, const struct ieee_802_11_802_2_header* data, QObject* parent ) |
1008 | :QObject( parent, "802.11 LLC" ), _header( data ) | 1009 | :QObject( parent, "802.11 LLC" ), _header( data ) |
1009 | { | 1010 | { |
1010 | odebug << "OLLCPacket::OLLCPacket(): decoding frame..." << oendl; | 1011 | odebug << "OLLCPacket::OLLCPacket(): decoding frame..." << oendl; |
1011 | 1012 | ||
1012 | if ( !(_header->oui[0] || _header->oui[1] || _header->oui[2]) ) | 1013 | if ( !(_header->oui[0] || _header->oui[1] || _header->oui[2]) ) |
1013 | { | 1014 | { |
1014 | owarn << "OLLCPacket::OLLCPacket(): contains an encapsulated Ethernet frame (type = " << EXTRACT_16BITS( &_header->type ) << ")" << oendl; | 1015 | owarn << "OLLCPacket::OLLCPacket(): contains an encapsulated Ethernet frame (type = " << EXTRACT_16BITS( &_header->type ) << ")" << oendl; |
1015 | 1016 | ||
1016 | switch ( EXTRACT_16BITS( &_header->type ) ) // defined in linux/if_ether.h | 1017 | switch ( EXTRACT_16BITS( &_header->type ) ) // defined in linux/if_ether.h |
1017 | { | 1018 | { |
1018 | case ETH_P_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break; | 1019 | case ETH_P_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break; |
1019 | case ETH_P_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break; | 1020 | case ETH_P_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break; |
1020 | default: owarn << "OLLCPacket::OLLCPacket(): Unknown Encapsulation type = " << EXTRACT_16BITS( &_header->type ) << oendl; | 1021 | default: owarn << "OLLCPacket::OLLCPacket(): Unknown Encapsulation type = " << EXTRACT_16BITS( &_header->type ) << oendl; |
1021 | } | 1022 | } |
1022 | } | 1023 | } |
1023 | } | 1024 | } |
1024 | 1025 | ||
1025 | 1026 | ||
1026 | OLLCPacket::~OLLCPacket() | 1027 | OLLCPacket::~OLLCPacket() |
1027 | { | 1028 | { |
1028 | } | 1029 | } |
1029 | 1030 | ||
1030 | 1031 | ||
1031 | /*====================================================================================== | 1032 | /*====================================================================================== |
1032 | * OWaveLanControlPacket | 1033 | * OWaveLanControlPacket |
1033 | *======================================================================================*/ | 1034 | *======================================================================================*/ |
1034 | 1035 | ||
1035 | OWaveLanControlPacket::OWaveLanControlPacket( const unsigned char* end, const struct ieee_802_11_control_header* data, OWaveLanPacket* parent ) | 1036 | OWaveLanControlPacket::OWaveLanControlPacket( const unsigned char* /*end*/, const struct ieee_802_11_control_header* data, OWaveLanPacket* parent ) |
1036 | :QObject( parent, "802.11 Control" ), _header( data ) | 1037 | :QObject( parent, "802.11 Control" ), _header( data ) |
1037 | { | 1038 | { |
1038 | odebug << "OWaveLanControlPacket::OWaveLanDataControl(): decoding frame..." << oendl; | 1039 | odebug << "OWaveLanControlPacket::OWaveLanDataControl(): decoding frame..." << oendl; |
1039 | odebug << "Detected subtype is " << controlType() << oendl; | 1040 | odebug << "Detected subtype is " << controlType() << oendl; |
1040 | } | 1041 | } |
1041 | 1042 | ||
1042 | 1043 | ||
1043 | OWaveLanControlPacket::~OWaveLanControlPacket() | 1044 | OWaveLanControlPacket::~OWaveLanControlPacket() |
1044 | { | 1045 | { |
1045 | } | 1046 | } |
1046 | 1047 | ||
1047 | 1048 | ||
1048 | QString OWaveLanControlPacket::controlType() const | 1049 | QString OWaveLanControlPacket::controlType() const |
1049 | { | 1050 | { |
1050 | switch ( FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) ) | 1051 | switch ( FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) ) |
1051 | { | 1052 | { |
1052 | case CTRL_PS_POLL: return "PowerSavePoll"; break; | 1053 | case CTRL_PS_POLL: return "PowerSavePoll"; break; |
1053 | case CTRL_RTS: return "RequestToSend"; break; | 1054 | case CTRL_RTS: return "RequestToSend"; break; |
1054 | case CTRL_CTS: return "ClearToSend"; break; | 1055 | case CTRL_CTS: return "ClearToSend"; break; |
1055 | case CTRL_ACK: return "Acknowledge"; break; | 1056 | case CTRL_ACK: return "Acknowledge"; break; |
1056 | case CTRL_CF_END: return "ContentionFreeEnd"; break; | 1057 | case CTRL_CF_END: return "ContentionFreeEnd"; break; |
1057 | case CTRL_END_ACK: return "AcknowledgeEnd"; break; | 1058 | case CTRL_END_ACK: return "AcknowledgeEnd"; break; |
1058 | default: | 1059 | default: |
1059 | owarn << "OWaveLanControlPacket::managementType(): unhandled subtype " << FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) << oendl; | 1060 | owarn << "OWaveLanControlPacket::managementType(): unhandled subtype " << FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) << oendl; |
1060 | return "Unknown"; | 1061 | return "Unknown"; |
1061 | } | 1062 | } |
1062 | } | 1063 | } |
1063 | 1064 | ||
1064 | 1065 | ||
1065 | /*====================================================================================== | 1066 | /*====================================================================================== |
1066 | * OPacketCapturer | 1067 | * OPacketCapturer |
1067 | *======================================================================================*/ | 1068 | *======================================================================================*/ |
1068 | 1069 | ||
1069 | OPacketCapturer::OPacketCapturer( QObject* parent, const char* name ) | 1070 | OPacketCapturer::OPacketCapturer( QObject* parent, const char* name ) |
1070 | :QObject( parent, name ), _name( QString::null ), _open( false ), _pch( 0 ), _pcd( 0 ), _sn( 0 ), _autodelete( true ) | 1071 | :QObject( parent, name ), _name( QString::null ), _open( false ), _pch( 0 ), _pcd( 0 ), _sn( 0 ), _autodelete( true ) |
1071 | { | 1072 | { |
1072 | } | 1073 | } |
1073 | 1074 | ||
1074 | 1075 | ||
1075 | OPacketCapturer::~OPacketCapturer() | 1076 | OPacketCapturer::~OPacketCapturer() |
1076 | { | 1077 | { |
1077 | if ( _open ) | 1078 | if ( _open ) |
1078 | { | 1079 | { |
1079 | odebug << "OPacketCapturer::~OPacketCapturer(): pcap still open, autoclosing." << oendl; | 1080 | odebug << "OPacketCapturer::~OPacketCapturer(): pcap still open, autoclosing." << oendl; |
1080 | close(); | 1081 | close(); |
1081 | } | 1082 | } |
1082 | } | 1083 | } |
1083 | 1084 | ||