diff --git a/Makefile.am b/Makefile.am index fd329f3..debf49b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -21,7 +21,6 @@ libtins_la_SOURCES=src/arp.cpp \ src/dhcpv6.cpp \ src/dns.cpp \ src/dns_record.cpp \ - src/dot11.cpp \ src/dot3.cpp \ src/dot1q.cpp \ src/eapol.cpp \ @@ -47,10 +46,19 @@ libtins_la_SOURCES=src/arp.cpp \ src/tcp.cpp \ src/tcp_stream.cpp \ src/udp.cpp \ - src/utils.cpp + src/utils.cpp \ + src/dot11/dot11_base.cpp \ + src/dot11/dot11_data.cpp \ + src/dot11/dot11_mgmt.cpp \ + src/dot11/dot11_beacon.cpp \ + src/dot11/dot11_assoc.cpp \ + src/dot11/dot11_auth.cpp \ + src/dot11/dot11_probe.cpp \ + src/dot11/dot11_control.cpp -libtins_includedir = $(includedir)/tins -libtins_include_HEADERS = include/internals.h \ +libtinsdir = $(includedir)/tins + +libtins_HEADERS = include/internals.h \ include/dhcpv6.h \ include/dot11.h \ include/dot1q.h \ @@ -102,3 +110,14 @@ libtins_include_HEADERS = include/internals.h \ include/stp.h \ include/exceptions.h \ include/config.h + +libtins_dot11_HEADERS = include/dot11/dot11_base.h \ + include/dot11/dot11_beacon.h \ + include/dot11/dot11_data.h \ + include/dot11/dot11_mgmt.h \ + include/dot11/dot11_assoc.h \ + include/dot11/dot11_auth.h \ + include/dot11/dot11_probe.h \ + include/dot11/dot11_control.h + +libtins_dot11dir = $(includedir)/tins/dot11/ diff --git a/Makefile.in b/Makefile.in index a150615..c779c3a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -55,11 +55,12 @@ build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = . -DIST_COMMON = README $(am__configure_deps) $(libtins_include_HEADERS) \ - $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ - $(srcdir)/libtins.pc.in $(top_srcdir)/configure \ - $(top_srcdir)/include/config.h.in AUTHORS INSTALL THANKS \ - config.guess config.sub depcomp install-sh ltmain.sh missing +DIST_COMMON = README $(am__configure_deps) $(libtins_HEADERS) \ + $(libtins_dot11_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(srcdir)/libtins.pc.in \ + $(top_srcdir)/configure $(top_srcdir)/include/config.h.in \ + AUTHORS COPYING INSTALL THANKS TODO config.guess config.sub \ + depcomp install-sh ltmain.sh missing ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cxx_compile_stdcxx_11.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ @@ -101,21 +102,25 @@ am__uninstall_files_from_dir = { \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pkgconfigdir)" \ - "$(DESTDIR)$(libtins_includedir)" + "$(DESTDIR)$(libtinsdir)" "$(DESTDIR)$(libtins_dot11dir)" LTLIBRARIES = $(lib_LTLIBRARIES) libtins_la_LIBADD = am__dirstamp = $(am__leading_dot)dirstamp am_libtins_la_OBJECTS = src/arp.lo src/bootp.lo \ src/handshake_capturer.lo src/stp.lo src/pppoe.lo \ src/crypto.lo src/dhcp.lo src/dhcpv6.lo src/dns.lo \ - src/dns_record.lo src/dot11.lo src/dot3.lo src/dot1q.lo \ - src/eapol.lo src/ethernetII.lo src/icmp.lo src/icmpv6.lo \ - src/internals.lo src/ip.lo src/ip_address.lo src/ipv6.lo \ - src/ipv6_address.lo src/llc.lo src/loopback.lo \ - src/network_interface.lo src/packet_sender.lo \ - src/packet_writer.lo src/pdu.lo src/radiotap.lo src/rawpdu.lo \ - src/rsn_information.lo src/sll.lo src/snap.lo src/sniffer.lo \ - src/tcp.lo src/tcp_stream.lo src/udp.lo src/utils.lo + src/dns_record.lo src/dot3.lo src/dot1q.lo src/eapol.lo \ + src/ethernetII.lo src/icmp.lo src/icmpv6.lo src/internals.lo \ + src/ip.lo src/ip_address.lo src/ipv6.lo src/ipv6_address.lo \ + src/llc.lo src/loopback.lo src/network_interface.lo \ + src/packet_sender.lo src/packet_writer.lo src/pdu.lo \ + src/radiotap.lo src/rawpdu.lo src/rsn_information.lo \ + src/sll.lo src/snap.lo src/sniffer.lo src/tcp.lo \ + src/tcp_stream.lo src/udp.lo src/utils.lo \ + src/dot11/dot11_base.lo src/dot11/dot11_data.lo \ + src/dot11/dot11_mgmt.lo src/dot11/dot11_beacon.lo \ + src/dot11/dot11_assoc.lo src/dot11/dot11_auth.lo \ + src/dot11/dot11_probe.lo src/dot11/dot11_control.lo libtins_la_OBJECTS = $(am_libtins_la_OBJECTS) libtins_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ @@ -141,7 +146,7 @@ am__can_run_installinfo = \ *) (install-info --version) >/dev/null 2>&1;; \ esac DATA = $(pkgconfig_DATA) -HEADERS = $(libtins_include_HEADERS) +HEADERS = $(libtins_HEADERS) $(libtins_dot11_HEADERS) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) @@ -304,7 +309,6 @@ libtins_la_SOURCES = src/arp.cpp \ src/dhcpv6.cpp \ src/dns.cpp \ src/dns_record.cpp \ - src/dot11.cpp \ src/dot3.cpp \ src/dot1q.cpp \ src/eapol.cpp \ @@ -330,10 +334,18 @@ libtins_la_SOURCES = src/arp.cpp \ src/tcp.cpp \ src/tcp_stream.cpp \ src/udp.cpp \ - src/utils.cpp + src/utils.cpp \ + src/dot11/dot11_base.cpp \ + src/dot11/dot11_data.cpp \ + src/dot11/dot11_mgmt.cpp \ + src/dot11/dot11_beacon.cpp \ + src/dot11/dot11_assoc.cpp \ + src/dot11/dot11_auth.cpp \ + src/dot11/dot11_probe.cpp \ + src/dot11/dot11_control.cpp -libtins_includedir = $(includedir)/tins -libtins_include_HEADERS = include/internals.h \ +libtinsdir = $(includedir)/tins +libtins_HEADERS = include/internals.h \ include/dhcpv6.h \ include/dot11.h \ include/dot1q.h \ @@ -386,6 +398,16 @@ libtins_include_HEADERS = include/internals.h \ include/exceptions.h \ include/config.h +libtins_dot11_HEADERS = include/dot11/dot11_base.h \ + include/dot11/dot11_beacon.h \ + include/dot11/dot11_data.h \ + include/dot11/dot11_mgmt.h \ + include/dot11/dot11_assoc.h \ + include/dot11/dot11_auth.h \ + include/dot11/dot11_probe.h \ + include/dot11/dot11_control.h + +libtins_dot11dir = $(includedir)/tins/dot11/ all: all-am .SUFFIXES: @@ -490,7 +512,6 @@ src/dhcp.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) src/dhcpv6.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) src/dns.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) src/dns_record.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) -src/dot11.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) src/dot3.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) src/dot1q.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) src/eapol.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) @@ -522,6 +543,28 @@ src/tcp.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) src/tcp_stream.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) src/udp.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) src/utils.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/dot11/$(am__dirstamp): + @$(MKDIR_P) src/dot11 + @: > src/dot11/$(am__dirstamp) +src/dot11/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) src/dot11/$(DEPDIR) + @: > src/dot11/$(DEPDIR)/$(am__dirstamp) +src/dot11/dot11_base.lo: src/dot11/$(am__dirstamp) \ + src/dot11/$(DEPDIR)/$(am__dirstamp) +src/dot11/dot11_data.lo: src/dot11/$(am__dirstamp) \ + src/dot11/$(DEPDIR)/$(am__dirstamp) +src/dot11/dot11_mgmt.lo: src/dot11/$(am__dirstamp) \ + src/dot11/$(DEPDIR)/$(am__dirstamp) +src/dot11/dot11_beacon.lo: src/dot11/$(am__dirstamp) \ + src/dot11/$(DEPDIR)/$(am__dirstamp) +src/dot11/dot11_assoc.lo: src/dot11/$(am__dirstamp) \ + src/dot11/$(DEPDIR)/$(am__dirstamp) +src/dot11/dot11_auth.lo: src/dot11/$(am__dirstamp) \ + src/dot11/$(DEPDIR)/$(am__dirstamp) +src/dot11/dot11_probe.lo: src/dot11/$(am__dirstamp) \ + src/dot11/$(DEPDIR)/$(am__dirstamp) +src/dot11/dot11_control.lo: src/dot11/$(am__dirstamp) \ + src/dot11/$(DEPDIR)/$(am__dirstamp) libtins.la: $(libtins_la_OBJECTS) $(libtins_la_DEPENDENCIES) $(EXTRA_libtins_la_DEPENDENCIES) $(libtins_la_LINK) -rpath $(libdir) $(libtins_la_OBJECTS) $(libtins_la_LIBADD) $(LIBS) @@ -541,8 +584,22 @@ mostlyclean-compile: -rm -f src/dns.lo -rm -f src/dns_record.$(OBJEXT) -rm -f src/dns_record.lo - -rm -f src/dot11.$(OBJEXT) - -rm -f src/dot11.lo + -rm -f src/dot11/dot11_assoc.$(OBJEXT) + -rm -f src/dot11/dot11_assoc.lo + -rm -f src/dot11/dot11_auth.$(OBJEXT) + -rm -f src/dot11/dot11_auth.lo + -rm -f src/dot11/dot11_base.$(OBJEXT) + -rm -f src/dot11/dot11_base.lo + -rm -f src/dot11/dot11_beacon.$(OBJEXT) + -rm -f src/dot11/dot11_beacon.lo + -rm -f src/dot11/dot11_control.$(OBJEXT) + -rm -f src/dot11/dot11_control.lo + -rm -f src/dot11/dot11_data.$(OBJEXT) + -rm -f src/dot11/dot11_data.lo + -rm -f src/dot11/dot11_mgmt.$(OBJEXT) + -rm -f src/dot11/dot11_mgmt.lo + -rm -f src/dot11/dot11_probe.$(OBJEXT) + -rm -f src/dot11/dot11_probe.lo -rm -f src/dot1q.$(OBJEXT) -rm -f src/dot1q.lo -rm -f src/dot3.$(OBJEXT) @@ -614,7 +671,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/dhcpv6.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/dns.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/dns_record.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/dot11.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/dot1q.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/dot3.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/eapol.Plo@am__quote@ @@ -645,6 +701,14 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/tcp_stream.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/udp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/utils.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/dot11/$(DEPDIR)/dot11_assoc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/dot11/$(DEPDIR)/dot11_auth.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/dot11/$(DEPDIR)/dot11_base.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/dot11/$(DEPDIR)/dot11_beacon.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/dot11/$(DEPDIR)/dot11_control.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/dot11/$(DEPDIR)/dot11_data.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/dot11/$(DEPDIR)/dot11_mgmt.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/dot11/$(DEPDIR)/dot11_probe.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @@ -676,6 +740,7 @@ mostlyclean-libtool: clean-libtool: -rm -rf .libs _libs -rm -rf src/.libs src/_libs + -rm -rf src/dot11/.libs src/dot11/_libs distclean-libtool: -rm -f libtool config.lt @@ -700,27 +765,48 @@ uninstall-pkgconfigDATA: @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir) -install-libtins_includeHEADERS: $(libtins_include_HEADERS) +install-libtinsHEADERS: $(libtins_HEADERS) @$(NORMAL_INSTALL) - @list='$(libtins_include_HEADERS)'; test -n "$(libtins_includedir)" || list=; \ + @list='$(libtins_HEADERS)'; test -n "$(libtinsdir)" || list=; \ if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(libtins_includedir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(libtins_includedir)" || exit 1; \ + echo " $(MKDIR_P) '$(DESTDIR)$(libtinsdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(libtinsdir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ - echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(libtins_includedir)'"; \ - $(INSTALL_HEADER) $$files "$(DESTDIR)$(libtins_includedir)" || exit $$?; \ + echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(libtinsdir)'"; \ + $(INSTALL_HEADER) $$files "$(DESTDIR)$(libtinsdir)" || exit $$?; \ done -uninstall-libtins_includeHEADERS: +uninstall-libtinsHEADERS: @$(NORMAL_UNINSTALL) - @list='$(libtins_include_HEADERS)'; test -n "$(libtins_includedir)" || list=; \ + @list='$(libtins_HEADERS)'; test -n "$(libtinsdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - dir='$(DESTDIR)$(libtins_includedir)'; $(am__uninstall_files_from_dir) + dir='$(DESTDIR)$(libtinsdir)'; $(am__uninstall_files_from_dir) +install-libtins_dot11HEADERS: $(libtins_dot11_HEADERS) + @$(NORMAL_INSTALL) + @list='$(libtins_dot11_HEADERS)'; test -n "$(libtins_dot11dir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(libtins_dot11dir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(libtins_dot11dir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(libtins_dot11dir)'"; \ + $(INSTALL_HEADER) $$files "$(DESTDIR)$(libtins_dot11dir)" || exit $$?; \ + done + +uninstall-libtins_dot11HEADERS: + @$(NORMAL_UNINSTALL) + @list='$(libtins_dot11_HEADERS)'; test -n "$(libtins_dot11dir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(libtins_dot11dir)'; $(am__uninstall_files_from_dir) ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ @@ -940,7 +1026,7 @@ check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) $(DATA) $(HEADERS) installdirs: - for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(libtins_includedir)"; do \ + for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(libtinsdir)" "$(DESTDIR)$(libtins_dot11dir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am @@ -971,6 +1057,8 @@ distclean-generic: -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) -rm -f src/$(DEPDIR)/$(am__dirstamp) -rm -f src/$(am__dirstamp) + -rm -f src/dot11/$(DEPDIR)/$(am__dirstamp) + -rm -f src/dot11/$(am__dirstamp) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @@ -982,7 +1070,7 @@ clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ distclean: distclean-am -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -rf src/$(DEPDIR) + -rm -rf src/$(DEPDIR) src/dot11/$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-hdr distclean-libtool distclean-tags @@ -999,7 +1087,8 @@ info: info-am info-am: -install-data-am: install-libtins_includeHEADERS install-pkgconfigDATA +install-data-am: install-libtinsHEADERS install-libtins_dot11HEADERS \ + install-pkgconfigDATA install-dvi: install-dvi-am @@ -1030,7 +1119,7 @@ installcheck-am: maintainer-clean: maintainer-clean-am -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache - -rm -rf src/$(DEPDIR) + -rm -rf src/$(DEPDIR) src/dot11/$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic @@ -1047,8 +1136,8 @@ ps: ps-am ps-am: -uninstall-am: uninstall-libLTLIBRARIES \ - uninstall-libtins_includeHEADERS uninstall-pkgconfigDATA +uninstall-am: uninstall-libLTLIBRARIES uninstall-libtinsHEADERS \ + uninstall-libtins_dot11HEADERS uninstall-pkgconfigDATA .MAKE: install-am install-strip @@ -1062,14 +1151,15 @@ uninstall-am: uninstall-libLTLIBRARIES \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am \ - install-libLTLIBRARIES install-libtins_includeHEADERS \ - install-man install-pdf install-pdf-am install-pkgconfigDATA \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - tags uninstall uninstall-am uninstall-libLTLIBRARIES \ - uninstall-libtins_includeHEADERS uninstall-pkgconfigDATA + install-libLTLIBRARIES install-libtinsHEADERS \ + install-libtins_dot11HEADERS install-man install-pdf \ + install-pdf-am install-pkgconfigDATA install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-libLTLIBRARIES uninstall-libtinsHEADERS \ + uninstall-libtins_dot11HEADERS uninstall-pkgconfigDATA # Tell versions [3.59,3.63) of GNU make to not export all variables. diff --git a/include/dot11.h b/include/dot11.h index 2ba0bdb..ac89a79 100644 --- a/include/dot11.h +++ b/include/dot11.h @@ -30,3575 +30,13 @@ #ifndef TINS_DOT_11 #define TINS_DOT_11 -#include -#include -#include -#include - -#include "macros.h" -#include "pdu.h" -#include "endianness.h" -#include "hw_address.h" -#include "small_uint.h" -#include "pdu_option.h" -#include "network_interface.h" -#include "cxxstd.h" - -namespace Tins { - class RSNInformation; - - /** - * \brief Class representing an 802.11 frame. - */ - class Dot11 : public PDU { - public: - typedef HWAddress<6> address_type; - - /** - * \brief This PDU's flag. - */ - static const PDU::PDUType pdu_flag = PDU::DOT11; - - /** - * \brief Broadcast hardware address. - */ - static const address_type BROADCAST; - - /** - * \brief Enum for the different types of 802.11 frames. - * - */ - enum Types { - MANAGEMENT = 0, - CONTROL = 1, - DATA = 2 - }; - - /** - * \brief Enum for the different types of tagged options. - */ - enum OptionTypes { - SSID, - SUPPORTED_RATES, - FH_SET, - DS_SET, - CF_SET, - TIM, - IBSS_SET, - COUNTRY, - HOPPING_PATTERN_PARAMS, - HOPPING_PATTERN_TABLE, - REQUEST_INFORMATION, - BSS_LOAD, - EDCA, - TSPEC, - TCLAS, - SCHEDULE, - CHALLENGE_TEXT, - POWER_CONSTRAINT = 32, - POWER_CAPABILITY, - TPC_REQUEST, - TPC_REPORT, - SUPPORTED_CHANNELS, - CHANNEL_SWITCH, - MEASUREMENT_REQUEST, - MEASUREMENT_REPORT, - QUIET, - IBSS_DFS, - ERP_INFORMATION, - TS_DELAY, - TCLAS_PROCESSING, - QOS_CAPABILITY = 46, - RSN = 48, - EXT_SUPPORTED_RATES = 50 - }; - - /** - * \brief Enum for the different subtypes of 802.11 management frames. - * - */ - enum ManagementSubtypes { - ASSOC_REQ = 0, - ASSOC_RESP = 1, - REASSOC_REQ = 2, - REASSOC_RESP = 3, - PROBE_REQ = 4, - PROBE_RESP = 5, - BEACON = 8, - ATIM = 9, - DISASSOC = 10, - AUTH = 11, - DEAUTH = 12 - }; - - /** - * \brief Enum for the different subtypes of 802.11 control frames. - * - */ - enum ControlSubtypes { - BLOCK_ACK_REQ = 8, - BLOCK_ACK = 9, - PS = 10, - RTS = 11, - CTS = 12, - ACK = 13, - CF_END = 14, - CF_END_ACK = 15 - }; - - /** - * \brief Enum fro the different subtypes of 802.11 data frames. - * - */ - enum DataSubtypes { - DATA_DATA = 0, - DATA_CF_ACK = 1, - DATA_CF_POLL = 2, - DATA_CF_ACK_POLL = 3, - DATA_NULL = 4, - CF_ACK = 5, - CF_POLL = 6, - CF_ACK_POLL = 7, - QOS_DATA_DATA = 8, - QOS_DATA_CF_ACK = 9, - QOS_DATA_CF_POLL = 10, - QOS_DATA_CF_ACK_POLL = 11, - QOS_DATA_NULL = 12 - }; - - /** - * \brief IEEE 802.11 options struct. - */ - typedef PDUOption option; - - /** - * \brief Constructor for creating an 802.11 PDU - * - * Constructor that builds an 802.11 PDU taking the interface index, - * destination's and source's MAC. - * - * \param dst_hw_addr The destination hardware address. - */ - Dot11(const address_type &dst_hw_addr = address_type()); - - /** - * \brief Constructs 802.11 PDU from a buffer and adds all - * identifiable PDUs found in the buffer as children of this one. - * - * If the next PDU is not recognized, then a RawPDU is used. - * - * If there is not enough size for a 802.11 header in the - * buffer, a malformed_packet exception is thrown. - * - * \param buffer The buffer from which this PDU will be constructed. - * \param total_sz The total size of the buffer. - */ - Dot11(const uint8_t *buffer, uint32_t total_sz); - - /** - * \brief Getter for the protocol version. - * - * \return uint8_t containing the protocol version. - */ - small_uint<2> protocol() const { return _header.control.protocol; } - - /** - * \brief Getter for the 802.11 frame's type. - * - * \return uint8_t containing the type of this 802.11 frame. - */ - small_uint<2> type() const { return _header.control.type; } - - /** - * \brief Getter for the 802.11 frame's subtype. - * - * \return uint8_t cotaining the subtype of this 802.11 frame. - */ - small_uint<4> subtype() const { return _header.control.subtype; } - - /** - * \brief Getter for the 802.11 frame's To-DS field. - * - * \return small_uint<1> containing the To-DS field. - */ - small_uint<1> to_ds() const { return _header.control.to_ds; } - - /** - * \brief Getter for the 802.11 frame's From-DS field. - * - * \return small_uint<1> containing the From-DS field. - */ - small_uint<1> from_ds() const { return _header.control.from_ds; } - - /** - * \brief Getter for the 802.11 frame's More-Frag field. - * - * \return small_uint<1> containing the More-Frag field. - */ - small_uint<1> more_frag() const { return _header.control.more_frag; } - - /** - * \brief Getter for the 802.11 frame's Retry field. - * - * \return small_uint<1> containing the Retry field. - */ - small_uint<1> retry() const { return _header.control.retry; } - - /** - * \brief Getter for the 802.11 frame's Power-Management field. - * - * \return small_uint<1> containing the Power-Management field. - */ - small_uint<1> power_mgmt() const { return _header.control.power_mgmt; } - - /** - * \brief Getter for the 802.11 frame's WEP field. - * - * \return small_uint<1> containing the WEP field. - */ - small_uint<1> wep() const { return _header.control.wep; } - - /** - * \brief Getter for the 802.11 frame's Order field. - * - * \return small_uint<1> containing the Order field. - */ - small_uint<1> order() const { return _header.control.order; } - - /** - * \brief Getter for the Duration-ID field. - * - * \return uint16_t containing the Duration-ID field. - */ - uint16_t duration_id() const { return Endian::le_to_host(_header.duration_id); } - - /** - * \brief Getter for the first address. - * - * \return address_type containing the first address. - */ - address_type addr1() const { return _header.addr1; } - - /** - * \brief Setter for the protocol version. - * - * \param new_proto The new protocol version. - */ - void protocol(small_uint<2> new_proto); - - /** - * \brief Setter for the 802.11 frame's type. - * - * \param new_type The new type of this 802.11 frame. - */ - void type(small_uint<2> new_type); - - /** - * \brief Setter for the 802.11 frame's subtype. - * - * \param new_subtype The new subtype of this 802.11 frame. - */ - void subtype(small_uint<4> new_subtype); - - /** - * \brief Setter for the 802.11 frame's To-DS field. - * - * \param new_value The new value of the To-DS field. - */ - void to_ds(small_uint<1> new_value); - - /** - * \brief Setter for the 802.11 frame's From-DS field. - * - * \param new_value The new value of the From-DS field. - */ - void from_ds(small_uint<1> new_value); - - /** - * \brief Setter for the 802.11 frame's More-Frag field. - * - * \param new_value The new value of the More-Frag field. - */ - void more_frag(small_uint<1> new_value); - - /** - * \brief Setter for the 802.11 frame's Retry field. - * - * \param new_value sThe new value of the Retry field. - */ - void retry(small_uint<1> new_value); - - /** - * \brief Setter for the 802.11 frame's Power-Management field. - * - * \param new_value The new value of the Power-Management field. - */ - void power_mgmt(small_uint<1> new_value); - - /** - * \brief Setter for the 802.11 frame's WEP field. - * - * \param new_value The new value of the WEP field. - */ - void wep(small_uint<1> new_value); - - /** - * \brief Setter for the 802.11 frame's Order field. - * - * \param new_value The new value of the Order field. - */ - void order(small_uint<1> new_value); - - /** - * \brief Setter for the Duration-ID field. - * - * \param new_duration_id The new value of the Duration-ID field. - */ - void duration_id(uint16_t new_duration_id); - - /** - * \brief Setter for the first address. - * - * \param new_addr1 The new first address. - */ - void addr1(const address_type &new_addr1); - - /* Virtual methods */ - /** - * \brief Returns the 802.11 frame's header length. - * - * \return An uint32_t with the header's size. - * \sa PDU::header_size() - */ - uint32_t header_size() const; - - #ifndef WIN32 - /** - * \sa PDU::send() - */ - void send(PacketSender &sender, const NetworkInterface &iface); - #endif // WIN32 - - /** - * \brief Adds a new option to this Dot11 PDU. - * \param opt The option to be added. - */ - void add_option(const option &opt); - - #if TINS_IS_CXX11 - /** - * \brief Adds a new option to this Dot11 PDU. - * - * The option is move-constructed - * - * \param opt The option to be added. - */ - void add_option(option &&opt) { - internal_add_option(opt); - _options.push_back(std::move(opt)); - } - #endif - - /** - * \brief Looks up a tagged option in the option list. - * - * The returned pointer must not be free'd. - * - * \param opt The option identifier. - * \return The option found, or 0 if no such option has been set. - */ - const option *search_option(OptionTypes opt) const; - - /** - * \brief Getter for the PDU's type. - * \sa PDU::pdu_type - */ - PDUType pdu_type() const { return pdu_flag; } - - /** - * \sa PDU::clone - */ - Dot11 *clone() const { - return new Dot11(*this); - } - - /** - * \brief Check wether this PDU matches the specified flag. - * \param flag The flag to match - * \sa PDU::matches_flag - */ - bool matches_flag(PDUType flag) const { - return flag == pdu_flag; - } - - /** - * \brief Allocates an Dot11 PDU from a buffer. - * - * This can be used somehow as a "virtual constructor". This - * method instantiates a subclass of Dot11 from the given buffer. - * The allocated class' type will be figured out from the - * information provided in the buffer. - * - * \param buffer The buffer from which to take the PDU data. - * \param total_sz The total size of the buffer. - * \return The allocated Dot11 PDU. - */ - static Dot11 *from_bytes(const uint8_t *buffer, uint32_t total_sz); - protected: - virtual uint32_t write_ext_header(uint8_t *buffer, uint32_t total_sz) { return 0; } - virtual uint32_t write_fixed_parameters(uint8_t *buffer, uint32_t total_sz) { return 0; } - void parse_tagged_parameters(const uint8_t *buffer, uint32_t total_sz); - void add_tagged_option(OptionTypes opt, uint8_t len, const uint8_t *val); - protected: - /** - * Struct that represents the 802.11 header - */ - TINS_BEGIN_PACK - struct ieee80211_header { - TINS_BEGIN_PACK - struct { - #if TINS_IS_LITTLE_ENDIAN - uint16_t protocol:2, - type:2, - subtype:4, - to_ds:1, - from_ds:1, - more_frag:1, - retry:1, - power_mgmt:1, - more_data:1, - wep:1, - order:1; - #elif TINS_IS_BIG_ENDIAN - uint16_t subtype:4, - type:2, - protocol:2, - order:1, - wep:1, - more_data:1, - power_mgmt:1, - retry:1, - more_frag:1, - from_ds:1, - to_ds:1; - #endif - } TINS_END_PACK control; - uint16_t duration_id; - uint8_t addr1[address_type::address_size]; - - } TINS_END_PACK; - private: - Dot11(const ieee80211_header *header_ptr); - - void internal_add_option(const option &opt); - void write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *parent); - - - ieee80211_header _header; - uint32_t _options_size; - std::list