├── DISTFILES ├── LICENSE ├── Makefile ├── README ├── click-packages.spec ├── dhcp ├── .cvsignore ├── .gitignore ├── Makefile.in ├── conf │ ├── client.click │ ├── client_tun.click │ ├── dhclient │ ├── dhcpd.conf │ ├── dhcpd_kscript │ ├── server.click │ ├── server_tun.click │ └── test.click ├── configure ├── configure.ac ├── doc │ ├── .cvsignore │ ├── .gitignore │ ├── Makefile │ ├── dhcp.ltx │ ├── dhcp_client_first_iter.pdf │ ├── dhcp_client_first_iter.sxd │ ├── final_client.pdf │ ├── final_client.sxd │ ├── final_server.pdf │ ├── final_server.sxd │ ├── initial_server.pdf │ └── initial_server.sxd ├── package │ ├── .cvsignore │ ├── .gitignore │ ├── Makefile.in │ ├── checkdhcpmsg.cc │ ├── checkdhcpmsg.hh │ ├── dhcp_common.hh │ ├── dhcpclassifier.cc │ ├── dhcpclassifier.hh │ ├── dhcpclient.cc │ ├── dhcpclient.hh │ ├── dhcpicmpencap.cc │ ├── dhcpicmpencap.hh │ ├── dhcpoptionutil.cc │ ├── dhcpoptionutil.hh │ ├── dhcpserverack.cc │ ├── dhcpserverack.hh │ ├── dhcpserveroffer.cc │ ├── dhcpserveroffer.hh │ ├── dhcpserverrelease.cc │ ├── dhcpserverrelease.hh │ ├── leasehash.cc │ ├── leasehash.hh │ ├── leasepool.cc │ ├── leasepool.hh │ ├── leasetable.cc │ └── leasetable.hh └── test │ └── t01.testie ├── iias ├── .cvsignore ├── .gitignore ├── Makefile.in ├── conf │ ├── egress.click │ ├── ingress.click │ └── router.click ├── configure ├── configure.ac ├── gre │ ├── .cvsignore │ ├── .gitignore │ ├── Makefile.in │ ├── checkgreheader.cc │ ├── checkgreheader.hh │ ├── gre.h │ ├── greencap.cc │ ├── greencap.hh │ ├── stripgreheader.cc │ └── stripgreheader.hh └── ppp │ ├── .cvsignore │ ├── .gitignore │ ├── Makefile.in │ ├── ipcp.cc │ ├── ipcp.hh │ ├── lcp.cc │ ├── lcp.hh │ ├── ppp_defs.h │ ├── pppcontrolprotocol.cc │ ├── pppcontrolprotocol.hh │ ├── pppencap.cc │ ├── pppencap.hh │ ├── pptpdefs.h │ ├── pptpserver.cc │ └── pptpserver.hh ├── ip6_natpt ├── .cvsignore ├── .gitignore ├── Makefile.in ├── README.NATPT ├── conf │ ├── gt64_dns-userlevel-debian.click │ ├── gt64_dns_ftp-kernellevel-debian.click │ ├── gt64_dns_ftp-userlevel-debian.click │ └── gt64_ftp-userlevel_debian.click ├── configure ├── configure.ac ├── include │ ├── click │ │ └── dnsmessage.hh │ └── clicknet │ │ └── rfc1035.h └── package │ ├── .cvsignore │ ├── .gitignore │ ├── Makefile.in │ ├── dnsalg.cc │ ├── dnsalg.hh │ ├── dnsmessage.cc │ ├── ftpportmapper6.cc │ ├── ftpportmapper6.hh │ ├── tcpaddresstranslator.cc │ └── tcpaddresstranslator.hh ├── models ├── .cvsignore ├── .gitignore ├── Makefile.in ├── README ├── config.h.in ├── configure ├── configure.ac ├── double_arrow.png ├── double_arrow_small.png ├── examples │ ├── sample.dump │ └── sample.xml ├── package │ ├── .cvsignore │ ├── .gitignore │ ├── Makefile.in │ ├── calculatecapacity.cc │ ├── calculatecapacity.hh │ ├── calculateflows.cc │ ├── calculateflows.hh │ ├── inferipaddrcolors.cc │ ├── inferipaddrcolors.hh │ ├── ipaddrcolorpaint.cc │ ├── ipaddrcolorpaint.hh │ ├── ipaddrcolors.cc │ ├── ipaddrcolors.hh │ ├── multiq.cc │ ├── multiq.hh │ ├── tcpcollector.cc │ ├── tcpcollector.hh │ ├── tcpmystery.cc │ ├── tcpmystery.hh │ ├── tcpscoreboard.cc │ ├── tcpscoreboard.hh │ ├── testipaddrcolors.cc │ └── testipaddrcolors.hh ├── scripts │ └── lossxml.sh └── tcpscape ├── multicast ├── .cvsignore ├── .gitignore ├── Makefile.in ├── configure ├── configure.ac ├── debug.hh ├── fixpimsource.cc ├── fixpimsource.hh ├── igmp.cc ├── igmp.hh ├── ip4_liburn.click ├── ipmulticasttable.cc ├── ipmulticasttable.hh ├── mcastetherencap.cc ├── mcastetherencap.hh ├── multicast.mp ├── pim.cc ├── pim.hh ├── pimcontrol.cc ├── pimcontrol.hh ├── pimforwardingtable.cc ├── pimforwardingtable.hh └── protocoldefinitions.hh ├── multicast6 ├── .cvsignore ├── .gitignore ├── Makefile.in ├── configure ├── configure.ac ├── debug.hh ├── fixip6src.cc ├── fixip6src.hh ├── icmp6checksum.cc ├── icmp6checksum.hh ├── ip6_liburn.click ├── ip6fixpimsource.cc ├── ip6fixpimsource.hh ├── ip6mcastetherencap.cc ├── ip6mcastetherencap.hh ├── ip6multicasttable.cc ├── ip6multicasttable.hh ├── ip6pim.cc ├── ip6pim.hh ├── ip6pimcontrol.cc ├── ip6pimcontrol.hh ├── ip6pimforwardingtable.cc ├── ip6pimforwardingtable.hh ├── ip6protocoldefinitions.hh ├── mld.cc └── mld.hh ├── netflow ├── .cvsignore ├── .gitignore ├── Makefile.in ├── configure ├── configure.ac ├── ipfixtypes.hh ├── mkipfixtypes │ ├── .cvsignore │ ├── .gitignore │ ├── Makefile.in │ ├── cisco.xml │ ├── ietf.xml │ ├── ipfixtypes.py │ └── schema.xml ├── netflowdata.cc ├── netflowdata.hh ├── netflowexport.cc ├── netflowexport.hh ├── netflowpacket.cc ├── netflowpacket.hh ├── netflowprint.cc ├── netflowprint.hh ├── netflowtemplate.cc ├── netflowtemplate.hh ├── netflowtemplatecache.cc └── netflowtemplatecache.hh ├── roofnet ├── .cvsignore ├── .gitignore ├── Makefile.in ├── analysis │ ├── counterrors.cc │ ├── counterrors.hh │ ├── countfecbytes.cc │ ├── countfecbytes.hh │ ├── countfragbytes.cc │ ├── countfragbytes.hh │ ├── errorthreshold.cc │ ├── errorthreshold.hh │ ├── locationhistogram.cc │ ├── locationhistogram.hh │ ├── printpower.cc │ ├── printpower.hh │ ├── printrate.cc │ ├── printrate.hh │ ├── printseq.cc │ ├── printseq.hh │ ├── wificounter.cc │ └── wificounter.hh ├── configure ├── configure.ac ├── copyrxstats.cc ├── copyrxstats.hh ├── dhcp │ ├── dhcpserver.cc │ ├── dhcpserver.hh │ ├── snoopdhcpreplies.cc │ └── snoopdhcpreplies.hh ├── frag │ ├── checkfragment.cc │ ├── checkfragment.hh │ ├── defragment.cc │ ├── defragment.hh │ ├── frag.hh │ ├── fragment.cc │ ├── fragment.hh │ ├── fragmentack.cc │ ├── fragmentack.hh │ ├── fragmentdecap.cc │ ├── fragmentdecap.hh │ ├── fragmentdupefilter.cc │ ├── fragmentdupefilter.hh │ ├── fragmentencap.cc │ ├── fragmentencap.hh │ ├── fragmentresender.cc │ ├── fragmentresender.hh │ ├── printfragment.cc │ └── printfragment.hh ├── linkfailuredetection.cc ├── linkfailuredetection.hh ├── setwifiextraflag.cc ├── setwifiextraflag.hh ├── sr │ ├── checksrheader.cc │ ├── checksrheader.hh │ ├── counterflood.cc │ ├── counterflood.hh │ ├── dupefilter.cc │ ├── dupefilter.hh │ ├── ettmetric.cc │ ├── ettmetric.hh │ ├── ettstat.cc │ ├── ettstat.hh │ ├── floodtracker.cc │ ├── floodtracker.hh │ ├── gatewayselector.cc │ ├── gatewayselector.hh │ ├── ipaddresscounter.cc │ ├── ipaddresscounter.hh │ ├── linkmetric.hh │ ├── localbroadcast.cc │ ├── localbroadcast.hh │ ├── metricflood.cc │ ├── metricflood.hh │ ├── pflood.cc │ ├── pflood.hh │ ├── printsr.cc │ ├── printsr.hh │ ├── setgateway.cc │ ├── setgateway.hh │ ├── setsourceroute.cc │ ├── setsourceroute.hh │ ├── setsrchecksum.cc │ ├── setsrchecksum.hh │ ├── setsrflag.cc │ ├── setsrflag.hh │ ├── sr1gatewayresponder.cc │ ├── sr1gatewayresponder.hh │ ├── srdestcache.cc │ ├── srdestcache.hh │ ├── srforwarder.cc │ ├── srforwarder.hh │ ├── srlog.cc │ ├── srlog.hh │ ├── srpacket.hh │ ├── srquerier.cc │ ├── srquerier.hh │ ├── srqueryforwarder.cc │ ├── srqueryforwarder.hh │ ├── srqueryresponder.cc │ ├── srqueryresponder.hh │ ├── stripsrheader.cc │ ├── stripsrheader.hh │ ├── txcountmetric.cc │ └── txcountmetric.hh ├── sr2 │ ├── sr2checkheader.cc │ ├── sr2checkheader.hh │ ├── sr2destcache.cc │ ├── sr2destcache.hh │ ├── sr2ettmetric.cc │ ├── sr2ettmetric.hh │ ├── sr2ettstat.cc │ ├── sr2ettstat.hh │ ├── sr2forwarder.cc │ ├── sr2forwarder.hh │ ├── sr2gatewayresponder.cc │ ├── sr2gatewayresponder.hh │ ├── sr2gatewayselector.cc │ ├── sr2gatewayselector.hh │ ├── sr2linkmetric.hh │ ├── sr2localbroadcast.cc │ ├── sr2localbroadcast.hh │ ├── sr2metricflood.cc │ ├── sr2metricflood.hh │ ├── sr2packet.hh │ ├── sr2print.cc │ ├── sr2print.hh │ ├── sr2querier.cc │ ├── sr2querier.hh │ ├── sr2queryforwarder.cc │ ├── sr2queryforwarder.hh │ ├── sr2queryresponder.cc │ ├── sr2queryresponder.hh │ ├── sr2setchecksum.cc │ ├── sr2setchecksum.hh │ ├── sr2setgateway.cc │ ├── sr2setgateway.hh │ ├── sr2setsourceroute.cc │ ├── sr2setsourceroute.hh │ ├── sr2stripheader.cc │ ├── sr2stripheader.hh │ ├── sr2txcountmetric.cc │ └── sr2txcountmetric.hh ├── txfeedbackstats.cc ├── txfeedbackstats.hh ├── txflog.cc ├── txflog.hh ├── txstat.cc └── txstat.hh ├── security ├── .cvsignore ├── .gitignore ├── Makefile.in ├── configure.ac ├── map_trw.cc ├── map_trw.hh ├── map_trw_example.click ├── rc5.cc ├── rc5.hh ├── trw_packet_utils.cc └── trw_packet_utils.hh ├── snmp ├── .cvsignore ├── .gitignore ├── Makefile.in ├── README ├── conf │ └── test-trap.click ├── configure ├── configure.ac ├── snmpbasics.cc ├── snmpbasics.hh ├── snmpber.cc ├── snmpber.hh ├── snmpoidinfo.cc ├── snmpoidinfo.hh ├── snmpoidtree.cc ├── snmpoidtree.hh ├── snmptrapsource.cc ├── snmptrapsource.hh ├── snmpvarinfo.cc └── snmpvarinfo.hh └── unibo_qos ├── .cvsignore ├── .gitignore ├── Makefile.in ├── configure ├── configure.ac └── package ├── .cvsignore ├── .gitignore ├── Makefile.in ├── checkaveragelength.cc ├── checkaveragelength.hh ├── getssrc.cc ├── getssrc.hh ├── packet_anno.hh ├── rtpclassifier.cc ├── rtpclassifier.hh ├── splitfirst.cc └── splitfirst.hh /LICENSE: -------------------------------------------------------------------------------- 1 | Portions of this software are subject to the license below. The relevant 2 | source files are clearly marked; they refer to this file using the phrase 3 | "the Click LICENSE file". This license is an MIT license, plus a clause 4 | (taken from the W3C license) requiring prior written permission to use our 5 | names in publicity. The AUTHORS file lists the people who have contributed 6 | to this software. 7 | 8 | =========================================================================== 9 | 10 | (c) 1999-2009 Massachusetts Institute of Technology 11 | (c) 2000-2009 Mazu Networks, Inc. 12 | (c) 2001-2009 International Computer Science Institute 13 | (c) 2004-2009 Regents of the University of California 14 | 15 | Permission is hereby granted, free of charge, to any person obtaining a 16 | copy of this software and associated documentation files (the "Software"), 17 | to deal in the Software without restriction, including without limitation 18 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 19 | and/or sell copies of the Software, and to permit persons to whom the 20 | Software is furnished to do so, subject to the following conditions: 21 | 22 | The above copyright notice and this permission notice shall be included in 23 | all copies or substantial portions of the Software. 24 | 25 | The name and trademarks of copyright holders may NOT be used in advertising 26 | or publicity pertaining to the Software without specific, written prior 27 | permission. Title to copyright in this Software and any associated 28 | documentation will at all times remain with copyright holders. 29 | 30 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 35 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 36 | DEALINGS IN THE SOFTWARE. 37 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Warning: this file must be usable by regular make 2 | # (unlike the Makefiles in subdirectories). 3 | 4 | SHELL = /bin/sh 5 | 6 | 7 | PACKAGE = click-packages 8 | VERSION = 2.0.1 9 | 10 | srcdir = . 11 | 12 | 13 | CLICKDIR = $(HOME)/click 14 | SUBDIRS = dhcp iias models multicast netflow roofnet security snmp unibo_qos 15 | IP6_SUBDIRS = ip6_natpt multicast6 16 | 17 | distdir = $(PACKAGE)-$(VERSION) 18 | 19 | all install clean distclean: 20 | for d in $(SUBDIRS); do { cd $$d; $(MAKE) $@ || exit 1; cd ..; }; done 21 | if click-buildtool provides ip6; then for d in $(IP6_SUBDIRS); do { cd $$d; $(MAKE) $@ || exit 1; cd ..; }; done; fi 22 | 23 | recheck: 24 | for d in $(SUBDIRS) $(IP6_SUBDIRS); do { cd $$d; ./config.status --recheck; ./config.status; cd ..; }; done 25 | 26 | dist: distdir 27 | tar czf $(distdir).tar.gz $(distdir) 28 | -rm -rf $(distdir) 29 | distdir: 30 | for d in $(SUBDIRS); do { cd $$d; autoconf; cd ..; }; done 31 | cp $(CLICKDIR)/LICENSE . 32 | -rm -rf $(distdir) 33 | mkdir $(distdir) 34 | chmod 777 $(distdir) 35 | for file in `cat $(srcdir)/DISTFILES | grep .`; do \ 36 | if expr "$$file" : '.*:$$' >/dev/null 2>&1; then \ 37 | d=`echo $$file | sed 's/:$$//;s/^\.\///'`; \ 38 | elif test -d "$(srcdir)/$$d/$$file"; then \ 39 | mkdir $(distdir)/$$d/$$file; \ 40 | chmod 777 $(distdir)/$$d/$$file; \ 41 | else \ 42 | for f in `cd $(srcdir)/$$d && echo $$file`; do \ 43 | test -f "$(distdir)/$$d/$$f" \ 44 | || ln $(srcdir)/$$d/$$f $(distdir)/$$d/$$f 2> /dev/null \ 45 | || cp -p $(srcdir)/$$d/$$f $(distdir)/$$d/$$f \ 46 | || echo "Could not copy $$d/$$f!" 1>&2; \ 47 | done; fi; \ 48 | done 49 | 50 | 51 | .PHONY: all always elemlist elemlists \ 52 | bsdmodule exopc linuxmodule ns tools userlevel \ 53 | clean distclean dist distdir recheck \ 54 | install install-doc install-man install-local install-include install-local-include \ 55 | uninstall uninstall-local uninstall-local-include 56 | -------------------------------------------------------------------------------- /click-packages.spec: -------------------------------------------------------------------------------- 1 | %define name click-packages 2 | %define version 1.4.2 3 | %define release 1 4 | %define packages ip6_natpt models iias 5 | 6 | Summary: Click modular router packages 7 | Name: %{name} 8 | Version: %{version} 9 | Release: %{release} 10 | Source0: %{name}-%{version}.tar.gz 11 | License: Various 12 | Group: System/Networking 13 | BuildRoot: %{_tmppath}/%{name}-buildroot 14 | Prefix: %{_prefix} 15 | Requires: click 16 | 17 | %description 18 | This source release consists of several independent "packages" for 19 | the Click modular software router. You will need to compile and run 20 | Click 1.4 before compiling these packages. 21 | 22 | These packages were written by independent developers and are 23 | distributed COMPLETELY WITHOUT WARRANTY. In particular, the main Click 24 | developers ARE NOT RESPONSIBLE for these packages. Send mail concerning 25 | these packages to the individual package developers, with a cc: to the 26 | Click mailing list . 27 | 28 | %prep 29 | %setup -q 30 | 31 | %build 32 | for i in %{packages} ; do ( 33 | cd $i 34 | autoconf 35 | %configure --with-click=%{_prefix} 36 | make 37 | ) done 38 | 39 | %install 40 | rm -rf $RPM_BUILD_ROOT 41 | for i in %{packages} ; do ( 42 | cd $i 43 | %makeinstall 44 | ) done 45 | 46 | %clean 47 | rm -rf $RPM_BUILD_ROOT 48 | 49 | %files 50 | %defattr(-,root,root) 51 | %doc LICENSE README 52 | %{_datadir}/click 53 | %{_mandir} 54 | %{_libdir} 55 | 56 | %changelog 57 | * Tue Apr 20 2004 Mark Huang 58 | - initial version 59 | 60 | # end of file 61 | -------------------------------------------------------------------------------- /dhcp/.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile autom4te* 2 | config.log config.status config.h 3 | -------------------------------------------------------------------------------- /dhcp/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | autom4te* 3 | config.log 4 | config.status 5 | config.h 6 | -------------------------------------------------------------------------------- /dhcp/Makefile.in: -------------------------------------------------------------------------------- 1 | SHELL = @SHELL@ 2 | 3 | 4 | # THESE VARIABLES MAY CHANGE BETWEEN PACKAGES 5 | 6 | # Set 'package' to the name of your package. 7 | package := @CLICKPACKAGENAME@ 8 | 9 | # Set these variables appropriately. 10 | top_builddir := . 11 | subdir := . 12 | 13 | # Require Click prefix settings. 14 | # Generally, you will provide a '--with-click=CLICKPREFIX' option, and set: 15 | clickbuild_prefix := @clickbuild_prefix@ 16 | include @clickbuild_datadir@/config.mk 17 | include @clickbuild_datadir@/pkg-config.mk 18 | 19 | srcdir = @srcdir@ 20 | top_srcdir = @top_srcdir@ 21 | AUTOCONF = $(CLICKAUTOCONF) 22 | ACLOCAL = : 23 | 24 | TARGETS = package 25 | 26 | all: Makefile $(TARGETS) 27 | 28 | package: Makefile 29 | @cd package && $(MAKE) all 30 | 31 | elemlist: Makefile 32 | @cd package && $(MAKE) elemlist 33 | 34 | install: Makefile 35 | @for d in $(TARGETS); do (cd $$d && $(MAKE) install) || exit 1; done 36 | 37 | install-man: 38 | @cd package && $(MAKE) install-man 39 | 40 | $(srcdir)/configure: $(srcdir)/configure.ac 41 | cd $(srcdir) && $(ACLOCAL) && $(AUTOCONF) 42 | config.status: $(srcdir)/configure 43 | $(SHELL) $(srcdir)/configure @ac_configure_args@ 44 | Makefile: config.status $(srcdir)/Makefile.in 45 | cd $(top_builddir) && \ 46 | CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status 47 | 48 | clean: 49 | @-for d in $(TARGETS); do (cd $$d && $(MAKE) clean); done 50 | 51 | distclean: 52 | @-for d in $(TARGETS); do (cd $$d && $(MAKE) distclean); done 53 | -rm -f Makefile config.status config.cache config.log config.h 54 | 55 | .PHONY: all package elemlist clean distclean \ 56 | install install-doc install-man install-include 57 | -------------------------------------------------------------------------------- /dhcp/conf/client.click: -------------------------------------------------------------------------------- 1 | require(dhcp) 2 | 3 | AddressInfo(myeth 00:13:02:99:76:12); 4 | //52:54:00:e5:33:17); 5 | 6 | in :: FromDevice(eth0, PROMISC true) 7 | -> inc :: Classifier(12/0806 20/0001, // ARP queries 8 | 12/0806 20/0002, // ARP replies 9 | 12/0800, -); 10 | 11 | inc[0] -> Discard; 12 | inc[3] -> Discard; 13 | 14 | inc[2] -> Strip(14) 15 | -> CheckIPHeader 16 | -> IPPrint("in ") 17 | -> ipc :: IPClassifier(udp && dst port bootpc, icmp echo-reply) 18 | -> client :: DHCPClient(myeth, LEASE_CALL release.run) 19 | -> udpbcast :: UDPIPEncap(0.0.0.0, bootpc, 255.255.255.255, bootps) 20 | -> eencap :: EtherEncap(0x0800, myeth, ff:ff:ff:ff:ff:ff) 21 | -> IPPrint(out) 22 | -> q :: Queue 23 | -> ToDevice(eth0); 24 | 25 | client[1] -> udpucast :: UDPIPEncap(0.0.0.0, bootpc, 255.255.255.255, bootps) 26 | -> eencap; 27 | 28 | ipc[1] -> ping :: ICMPPingSource(0.0.0.0, 0.0.0.0, ACTIVE false) 29 | -> IPPrint(png) 30 | -> arpq :: ARPQuerier(0.0.0.0, myeth) 31 | -> q; 32 | inc[1] -> [1] arpq; 33 | 34 | release :: Script(TYPE PASSIVE, 35 | print $args, 36 | write ping.active $1, 37 | goto end $(not $1), 38 | write udpucast.src $2, 39 | write udpucast.dst $3, 40 | write ping.src $2, 41 | write ping.dst $3, 42 | write arpq.ipaddr $2); 43 | -------------------------------------------------------------------------------- /dhcp/conf/client_tun.click: -------------------------------------------------------------------------------- 1 | require(dhcp) 2 | 3 | tun :: KernelTun(2.0.0.1/8); 4 | tunq :: IPEncap(4, 2.0.0.2, 1.0.0.2)->Queue->tun; 5 | udp_encap::UDPIPEncap(255.255.255.255, 68, 255.255.255.255, 67); 6 | eth_encap::EtherEncap(0x0800, 1:2:3:4:5:6, ff:ff:ff:ff:ff:ff); 7 | 8 | client::DHCPClient(1:2:3:4:5:6, LEASE_CALL newlease.run); 9 | 10 | tun -> IPPrint() 11 | -> StripIPHeader 12 | -> Strip(14) 13 | -> Align(4, 0) 14 | -> CheckIPHeader(CHECKSUM true) 15 | -> CheckUDPHeader 16 | -> CheckDHCPMsg(reply) 17 | -> [0]client; 18 | 19 | client[0] -> Print() 20 | -> udp_encap 21 | -> eth_encap 22 | -> tunq; 23 | 24 | client[1] -> udp_encap1::UDPIPEncap( 192.168.10.10 , 68, 192.168.10.9, 67 ) 25 | -> eth_encap -> tunq; 26 | 27 | newlease :: Script(TYPE PASSIVE, 28 | goto end $(not $1), 29 | write udp_encap1.src $2, 30 | write udp_encap1.dst $3, 31 | write udp_encap.src $2, 32 | write udp_encap.dst $3) 33 | -------------------------------------------------------------------------------- /dhcp/conf/dhclient: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | my $IP_FILE = "client_ip.txt"; 3 | my $LEASE_FILE = "client.lease"; 4 | open(IP_FH , "<$IP_FILE"); 5 | open(LEASE_FH, ">$LEASE_FILE"); 6 | 7 | my $CURR_IP_ADDR = ; 8 | 9 | while(1) 10 | { 11 | open(IP_FH , $IP_FILE); 12 | my $tmp_ip = ; 13 | chomp($tmp_ip); 14 | chomp($CURR_IP_ADDR); 15 | 16 | if($tmp_ip eq $CURR_IP_ADDR) 17 | { 18 | # do nothing 19 | print "good\n"; 20 | } 21 | else 22 | { 23 | print "file changed!\n"; 24 | $CURR_IP_ADDR = $tmp_ip; 25 | system("ifconfig eth0 inet $CURR_IP_ADDR"); 26 | print LEASE_FH $CURR_IP_ADDR; 27 | } 28 | 29 | sleep(2); 30 | } 31 | #main 32 | -------------------------------------------------------------------------------- /dhcp/conf/dhcpd.conf: -------------------------------------------------------------------------------- 1 | subnet 192.168.10.0 netmask 255.255.255.0{ 2 | option routers 192.168.10.1 3 | option subnet-mask 255.255.255.0 4 | range dynamic-bootp 192.168.10.128 192.168.10.254 5 | default-lease-time 30 6 | max-lease-time 60 7 | } -------------------------------------------------------------------------------- /dhcp/conf/dhcpd_kscript: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | # This script is for running dhcpd as a kernel module. 4 | 5 | my $LEASES_FILE = "dhcpd.leases"; 6 | my $CONF_FILE = "dhcpd.conf"; 7 | my $CLICK_HOME ="/home/dafreak/click"; 8 | 9 | #open( LEASES_INPUT_FH, "<$LEASES_FILE" ); 10 | #open( CONF_INPUT_FH, "<$CONF_FILE" ); 11 | 12 | # bootstrap the server 13 | system("$CLICK_HOME/sbin/click-install server.click"); 14 | print STDOUT "cating LEASES_FILE\n"; 15 | system("cat $LEASES_FILE"); 16 | print STDOUT "cating CONF_FILE\n"; 17 | system("cat $CONF_FILE"); 18 | 19 | system("cat $LEASES_FILE > /click/server/dhcpd_leases"); 20 | system("cat $CONF_FILE > /click/server/dhcpd_conf"); 21 | 22 | #clena up !! 23 | sub catch_c { 24 | print STDOUT "cleanup\n"; 25 | system("$CLICK_HOME/sbin/click-uninstall"); 26 | exit(0); 27 | } 28 | $SIG{INT} = \&catch_c; 29 | 30 | # saving the leases 31 | open( LEASES_FH, ">$LEASES_FILE"); 32 | while(1) 33 | { 34 | system("cat /click/server/read_leases > $LEASES_FILE"); 35 | sleep(10); 36 | } 37 | 38 | -------------------------------------------------------------------------------- /dhcp/conf/server.click: -------------------------------------------------------------------------------- 1 | require(dhcp) 2 | 3 | udp_encap::UDPIPEncap( 192.168.10.10, 67, 255.255.255.255, 68 ); 4 | eth_encap::EtherEncap( 0x0800, 52:54:00:E5:33:17 , ff:ff:ff:ff:ff:ff); 5 | 6 | server :: DHCPServerLeases( 192.168.10.10 , 192.168.10.0); 7 | 8 | FromDevice(eth0) 9 | -> Strip(14) 10 | -> Align(4, 0) 11 | -> ip_check::CheckIPHeader(CHECKSUM true) 12 | -> udp_check::CheckUDPHeader 13 | -> ipclass :: IPClassifier(icmp type echo-reply, -) 14 | 15 | ipclass[0] 16 | -> Print("ICMP ECHO REPLY") 17 | -> [1]serverOffer::DHCPServerOffer(server); 18 | 19 | ipclass[1] 20 | -> CheckDHCPMsg(request) 21 | -> class :: DHCPClassifier( discover, request, release, -) 22 | 23 | class[0] -> Print(DISCOVER) 24 | -> [0]serverOffer 25 | 26 | class[1] -> Print(REQUEST) 27 | -> DHCPServerACKorNAK(server) -> udp_encap -> eth_encap-> q::Queue(1000)->to_dev::ToDevice(eth0); 28 | 29 | class[2] -> Print(RELEASE) 30 | -> DHCPServerRelease(server); 31 | 32 | class[3] -> Print(OTHER) -> Discard; 33 | 34 | serverOffer[0]-> udp_encap -> eth_encap-> q; 35 | serverOffer[1]-> icmpEncap::ICMPPingEncap(192.168.10.10, 255.255.255.255) 36 | -> DHCPICMPEncap(serverOffer.dhcp_icmp_ping_src, serverOffer.dhcp_icmp_ping_dst) 37 | -> q; 38 | 39 | 40 | //DriverManager( 41 | // wait_time 2s, 42 | // write server.dhcpd_leases lease 192.168.10.128 { 43 | // starts 1130180078 44 | // ends 1130180090 45 | // hardware ethernet 52:54:00:e5:33:17 }, 46 | // wait_time 2s, 47 | // write server.dhcpd_conf range dynamic-bootp 192.168.10.128 192.168.10.254 default-lease-time 30 max-lease-time 60, 48 | // write server.dhcpd_conf 49 | //subnet 192.168.10.0 netmask 255.255.255.0{ 50 | // option routers 192.168.10.1 51 | // option subnet-mask 255.255.255.0 52 | // range dynamic-bootp 192.168.10.128 192.168.10.254 53 | // default-lease-time 30 54 | // max-lease-time 60 55 | //}, 56 | 57 | ////subnet 192.168.10.0 netmask 255.255.255.0 { 58 | //// option routers 192.168.10.1 59 | //// option subnet-mask 255.255.255.0 60 | //// range dynamic-bootp 192.168.10.128 192.168.10.254 61 | //// default-lease-time 30 62 | //// max-lease-time 60 63 | ////}, 64 | // save server.read_free_leases out.dump, 65 | // wait_time 10s, 66 | // save server.read_leases dhcpd.leases, 67 | // loop); 68 | -------------------------------------------------------------------------------- /dhcp/conf/server_tun.click: -------------------------------------------------------------------------------- 1 | require(dhcp) 2 | 3 | tun :: KernelTun(1.0.0.1/8); 4 | //tunq :: IPEncap(4, 1.0.0.2, 2.0.0.2)->Queue->tun 5 | 6 | tun -> IPPrint(gotIt) 7 | -> StripIPHeader 8 | -> Strip(14) 9 | -> Align(4, 0) 10 | -> ip_ch::CheckIPHeader(CHECKSUM true) 11 | -> CheckUDPHeader 12 | -> CheckDHCPMsg(request) 13 | -> Print(Discarding) 14 | -> Discard; 15 | 16 | -------------------------------------------------------------------------------- /dhcp/conf/test.click: -------------------------------------------------------------------------------- 1 | require(dhcp); 2 | 3 | //test :: SamplePackageElement; 4 | 5 | FromDevice(eth0)->class::Classifier( 12/0806 20/0001, 6 | 12/0806 20/0002, 7 | 12/0800, 8 | -); 9 | 10 | class[0]->Print()->Discard; 11 | class[1]->Print()->Discard; 12 | class[2]->Print() 13 | ->Strip(14) 14 | ->Align(4, 0) 15 | ->ip_check::CheckIPHeader(CHECKSUM true, DETAILS true)->Discard; 16 | 17 | 18 | class[3]->Print()->Discard; 19 | 20 | 21 | //QuitWatcher(test); 22 | -------------------------------------------------------------------------------- /dhcp/doc/.cvsignore: -------------------------------------------------------------------------------- 1 | *.aux *.bbl *.blg *.log *.dvi *.uptodate 2 | dhcp.pdf 3 | -------------------------------------------------------------------------------- /dhcp/doc/.gitignore: -------------------------------------------------------------------------------- 1 | *.aux 2 | *.bbl 3 | *.blg 4 | *.log 5 | *.dvi 6 | *.uptodate 7 | dhcp.pdf 8 | -------------------------------------------------------------------------------- /dhcp/doc/Makefile: -------------------------------------------------------------------------------- 1 | dhcp.pdf: dhcp.ltx dhcp_client_first_iter.pdf final_client.pdf \ 2 | final_server.pdf initial_server.pdf 3 | pdflatex dhcp.ltx 4 | pdflatex dhcp.ltx 5 | -------------------------------------------------------------------------------- /dhcp/doc/dhcp_client_first_iter.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kohler/click-packages/cec70da7cf460548ef08f1ddad6924db29d5c0c5/dhcp/doc/dhcp_client_first_iter.pdf -------------------------------------------------------------------------------- /dhcp/doc/dhcp_client_first_iter.sxd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kohler/click-packages/cec70da7cf460548ef08f1ddad6924db29d5c0c5/dhcp/doc/dhcp_client_first_iter.sxd -------------------------------------------------------------------------------- /dhcp/doc/final_client.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kohler/click-packages/cec70da7cf460548ef08f1ddad6924db29d5c0c5/dhcp/doc/final_client.pdf -------------------------------------------------------------------------------- /dhcp/doc/final_client.sxd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kohler/click-packages/cec70da7cf460548ef08f1ddad6924db29d5c0c5/dhcp/doc/final_client.sxd -------------------------------------------------------------------------------- /dhcp/doc/final_server.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kohler/click-packages/cec70da7cf460548ef08f1ddad6924db29d5c0c5/dhcp/doc/final_server.pdf -------------------------------------------------------------------------------- /dhcp/doc/final_server.sxd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kohler/click-packages/cec70da7cf460548ef08f1ddad6924db29d5c0c5/dhcp/doc/final_server.sxd -------------------------------------------------------------------------------- /dhcp/doc/initial_server.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kohler/click-packages/cec70da7cf460548ef08f1ddad6924db29d5c0c5/dhcp/doc/initial_server.pdf -------------------------------------------------------------------------------- /dhcp/doc/initial_server.sxd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kohler/click-packages/cec70da7cf460548ef08f1ddad6924db29d5c0c5/dhcp/doc/initial_server.sxd -------------------------------------------------------------------------------- /dhcp/package/.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile *.d *.kd *.ud *.ko *.uo 2 | kelements.conf kelements.mk kpackage.cc 3 | Kbuild .*.ko.cmd .*.o.cmd .tmp_versions kversion.c dhcp.mod.c 4 | uelements.conf uelements.mk upackage.cc 5 | elementmap-dhcp.xml 6 | -------------------------------------------------------------------------------- /dhcp/package/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | *.d 3 | *.kd 4 | *.ud 5 | *.ko 6 | *.uo 7 | kelements.conf 8 | kelements.mk 9 | kpackage.cc 10 | Kbuild 11 | .*.ko.cmd 12 | .*.o.cmd 13 | .tmp_versions 14 | kversion.c 15 | dhcp.mod.c 16 | uelements.conf 17 | uelements.mk 18 | upackage.cc 19 | elementmap-dhcp.xml 20 | -------------------------------------------------------------------------------- /dhcp/package/Makefile.in: -------------------------------------------------------------------------------- 1 | SHELL = @SHELL@ 2 | 3 | 4 | # THESE VARIABLES MAY CHANGE BETWEEN PACKAGES 5 | 6 | # Set 'package' to the name of your package. 7 | package := @CLICKPACKAGENAME@ 8 | 9 | # Set these variables appropriately. 10 | top_builddir := .. 11 | subdir := package 12 | 13 | # Require Click prefix settings. 14 | # Generally, you will provide a '--with-click=CLICKPREFIX' option, and set: 15 | clickbuild_prefix := @clickbuild_prefix@ 16 | include @clickbuild_datadir@/config.mk 17 | 18 | # Set 'MAKE_UPACKAGE', 'MAKE_KPACKAGE', and 'MAKE_BPACKAGE' to '0' or '1' 19 | # to determine whether to build userlevel, linuxmodule, and bsdmodule 20 | # packages, respectively. 21 | MAKE_UPACKAGE = @BUILD_USERLEVEL@ 22 | MAKE_KPACKAGE = @BUILD_LINUXMODULE@ 23 | MAKE_BPACKAGE = @BUILD_BSDMODULE@ 24 | 25 | # Set 'STRIP_UPACKAGE' to 'strip -g' to strip debugging symbols from the 26 | # userlevel package before installing. 27 | #STRIP_UPACKAGE = $(STRIP) -g 28 | 29 | # Set these variables as required. 30 | DEFS = @DEFS@ $(CLICKDEFS) 31 | INCLUDES = -I. -I$(top_builddir) -I$(srcdir) $(CLICKINCLUDES) 32 | 33 | # Set this variable to force 'click-elem2package' to include a header, 34 | # such as your package's '', if necessary. 35 | #ELEM2PACKAGE_INCLUDES = -i'' 36 | 37 | # END OF VARIABLES THAT MAY CHANGE BETWEEN PACKAGES 38 | 39 | 40 | # Everything below here will probably stay unchanged 41 | 42 | srcdir = @srcdir@ 43 | top_srcdir = @top_srcdir@ 44 | 45 | ifeq ($(CLICK_PACKAGE_MAKING),) 46 | prefix = @prefix@ 47 | exec_prefix = @exec_prefix@ 48 | bindir = @bindir@ 49 | sbindir = @sbindir@ 50 | libdir = @libdir@ 51 | mandir = @mandir@ 52 | datarootdir = @datarootdir@ 53 | datadir = @datadir@ 54 | endif 55 | 56 | include $(clickbuild_datadir)/pkg-Makefile 57 | -------------------------------------------------------------------------------- /dhcp/package/checkdhcpmsg.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * checkdhcpmsg.{cc,hh} -- check the magic bytes of a dhcp message 3 | * Lih Chen 4 | * 5 | * Copyright (c) 2004 Regents of the University of California 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, subject to the conditions 10 | * listed in the Click LICENSE file. These conditions include: you must 11 | * preserve this copyright notice, and you cannot mention the copyright 12 | * holders in advertising related to the Software without their permission. 13 | * The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This 14 | * notice is a summary of the Click LICENSE file; the license in that file is 15 | * legally binding. 16 | */ 17 | 18 | #include 19 | 20 | #include "dhcp_common.hh" 21 | #include 22 | #include 23 | #include "checkdhcpmsg.hh" 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | CLICK_DECLS 30 | 31 | CheckDHCPMsg::CheckDHCPMsg() 32 | { 33 | } 34 | 35 | CheckDHCPMsg::~CheckDHCPMsg() 36 | { 37 | } 38 | 39 | Packet* 40 | CheckDHCPMsg::simple_action(Packet *p) 41 | { 42 | dhcpMessage *dm = (dhcpMessage*)(((char *) p->ip_header()) + 43 | sizeof(click_ip) + 44 | sizeof(click_udp)); 45 | 46 | if (dm->magic != DHCP_MAGIC) { 47 | click_chatter("%s, %d bad magic 0x%08x vs 0x%08x", 48 | __FILE__, __LINE__, 49 | ntohl(dm->magic), ntohl(DHCP_MAGIC)); 50 | checked_output_push(1, p); 51 | return 0; 52 | } 53 | return p; 54 | } 55 | CLICK_ENDDECLS 56 | EXPORT_ELEMENT(CheckDHCPMsg) 57 | -------------------------------------------------------------------------------- /dhcp/package/checkdhcpmsg.hh: -------------------------------------------------------------------------------- 1 | #ifndef CHECKDHCPCOOKIE_HH 2 | #define CHECKDHCPCOOKIE_HH 3 | 4 | #include 5 | 6 | 7 | /* 8 | * =c 9 | * CheckDHCPMsg() 10 | * =s DHCP 11 | * Checks to see if an incoming packet is, in fact, a valid DHCP Message. 12 | * 13 | * =d 14 | * 15 | * On the client side, the first argument needs to be a 16 | * reply. On the server side, the first arguement is 17 | * reply. 18 | * 19 | * If a packet is classified as valid, it will be pushed out on 20 | * outgoing port 0. Otherwise, discarded by default, if port 1 is not 21 | * connected to any elemenets. 22 | */ 23 | 24 | class CheckDHCPMsg : public Element { 25 | 26 | public: 27 | 28 | CheckDHCPMsg(); 29 | ~CheckDHCPMsg(); 30 | 31 | const char *class_name() const { return "CheckDHCPMsg"; } 32 | const char *port_count() const { return "1/1-2"; } 33 | const char *processing() const { return AGNOSTIC; } 34 | 35 | Packet *simple_action(Packet *); 36 | }; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /dhcp/package/dhcpclassifier.cc: -------------------------------------------------------------------------------- 1 | // ALWAYS INCLUDE FIRST 2 | #include 3 | 4 | #include "dhcp_common.hh" 5 | #include "dhcpclassifier.hh" 6 | #include "dhcpoptionutil.hh" 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | 13 | DHCPClassifier::DHCPClassifier() 14 | : _dhcp_msg_to_outport_map(-1) 15 | { 16 | } 17 | 18 | DHCPClassifier::~DHCPClassifier() 19 | { 20 | } 21 | 22 | int 23 | DHCPClassifier::configure(Vector &conf, ErrorHandler *errh) 24 | { 25 | if (conf.size() != noutputs()) 26 | return errh->error("need %d arguments, one per output port", 27 | noutputs()); 28 | 29 | for (int argno = 0 ; argno < conf.size(); argno++) { 30 | String s = conf[argno]; 31 | if (s == "discover") { 32 | _dhcp_msg_to_outport_map[DHCP_DISCOVER] = argno; 33 | } else if (s == "offer") { 34 | _dhcp_msg_to_outport_map[DHCP_OFFER] = argno; 35 | } else if (s == "request") { 36 | _dhcp_msg_to_outport_map[DHCP_REQUEST] = argno; 37 | } else if (s == "decline") { 38 | _dhcp_msg_to_outport_map[DHCP_DECLINE] = argno; 39 | } else if (s == "ack") { 40 | _dhcp_msg_to_outport_map[DHCP_ACK] = argno; 41 | } else if (s == "nack") { 42 | _dhcp_msg_to_outport_map[DHCP_NACK] = argno; 43 | } else if (s == "release") { 44 | _dhcp_msg_to_outport_map[DHCP_RELEASE] = argno; 45 | } else if (s == "inform") { 46 | _dhcp_msg_to_outport_map[DHCP_INFORM] = argno; 47 | } else if (s == "-") { 48 | _dhcp_msg_to_outport_map[DHCP_REST] = argno; 49 | } else 50 | return errh->error("unknown DHCP type %<%s%>", s.printable().c_str()); 51 | } 52 | return 0; 53 | } 54 | 55 | void 56 | DHCPClassifier::push(int, Packet *p) 57 | { 58 | const uint8_t *mtype = DHCPOptionUtil::fetch(p, DHO_DHCP_MESSAGE_TYPE, 1); 59 | int port = -1; 60 | if (mtype) 61 | port = _dhcp_msg_to_outport_map.get(*mtype); 62 | if (port < 0) 63 | port = _dhcp_msg_to_outport_map.get(DHCP_REST); 64 | checked_output_push(port, p); 65 | } 66 | 67 | EXPORT_ELEMENT(DHCPClassifier) 68 | ELEMENT_REQUIRES(DHCPOptionUtil) 69 | -------------------------------------------------------------------------------- /dhcp/package/dhcpclassifier.hh: -------------------------------------------------------------------------------- 1 | #ifndef DHCPCLASSIFIER_HH 2 | #define DHCPCLASSIFIER_HH 3 | 4 | #include 5 | #include 6 | 7 | /* 8 | * =c 9 | * DHCPClassifier([ discover | offer | request | deline | ack | nack | release | inform ], -) 10 | * =s DHCP 11 | * Classifies dhcp packets by DHCP_MESSAGE_TYPE 12 | * 13 | * =d 14 | * Classifies dhcp packets according to the DHCP_MESSAGE_TYPE option field. 15 | * 16 | * =e 17 | * class::DHCPClassifier(discover, request, -); 18 | * 19 | * class[0] -> Print(DISCOVER) -> Discard; 20 | * class[1] -> Print(REQUEST) -> Discard; 21 | * class[2] -> Print(all others) -> Discard; 22 | * 23 | * =a 24 | * CheckDHCPMsg 25 | */ 26 | 27 | //class IPAddress; 28 | //class EtherAddress; 29 | //class dhcpMessage; 30 | //class DHCPInfo; 31 | 32 | class DHCPClassifier : public Element { 33 | 34 | public: 35 | DHCPClassifier(); 36 | ~DHCPClassifier(); 37 | 38 | const char *class_name() const { return "DHCPClassifier"; } 39 | const char *port_count() const { return "1/-"; } 40 | const char *processing() const { return PUSH; } 41 | 42 | int configure(Vector &, ErrorHandler *); 43 | virtual void push(int port, Packet *p); 44 | 45 | private: 46 | HashTable _dhcp_msg_to_outport_map; 47 | 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /dhcp/package/dhcpicmpencap.cc: -------------------------------------------------------------------------------- 1 | // ALWAYS INCLUDE FIRST 2 | #include 3 | 4 | #include "dhcpicmpencap.hh" 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | CLICK_DECLS 13 | 14 | DHCP_ICMP_Encap::DHCP_ICMP_Encap() 15 | :_src_ip_h(0), 16 | _dst_ip_h(0) 17 | { 18 | } 19 | 20 | DHCP_ICMP_Encap::~DHCP_ICMP_Encap() 21 | { 22 | delete _src_ip_h; 23 | delete _dst_ip_h; 24 | } 25 | 26 | int 27 | DHCP_ICMP_Encap::configure(Vector &conf, ErrorHandler *errh) 28 | { 29 | HandlerCall srch, dsth; 30 | if (Args(conf, this, errh) 31 | .read_mp("SRC_CALL", HandlerCallArg(HandlerCall::readable), srch) 32 | .read_mp("DST_CALL", HandlerCallArg(HandlerCall::readable), dsth) 33 | .complete() < 0) 34 | return -1; 35 | _src_ip_h = new HandlerCall(srch); 36 | _dst_ip_h = new HandlerCall(dsth); 37 | return 0; 38 | } 39 | 40 | int 41 | DHCP_ICMP_Encap::initialize(ErrorHandler *errh) 42 | { 43 | if( _src_ip_h->initialize_read(this, errh) < 0 ) 44 | return -1; 45 | if( _dst_ip_h->initialize_read(this, errh) < 0 ) 46 | return -1; 47 | 48 | return 0; 49 | } 50 | 51 | Packet * 52 | DHCP_ICMP_Encap::simple_action(Packet *p) 53 | { 54 | String src_str = _src_ip_h->call_read(); 55 | String dst_str = _dst_ip_h->call_read(); 56 | click_ip *ip = (click_ip *)(p->data()); 57 | 58 | ip->ip_src = IPAddress(src_str).in_addr(); 59 | ip->ip_dst = IPAddress(dst_str).in_addr(); 60 | 61 | click_icmp_echo *icmp = (struct click_icmp_echo *) (ip + 1); 62 | 63 | #if HAVE_FAST_CHECKSUM && FAST_CHECKSUM_ALIGNED 64 | if (_aligned) 65 | ip->ip_sum = ip_fast_csum((unsigned char *)ip, sizeof(click_ip) >> 2); 66 | else 67 | ip->ip_sum = click_in_cksum((unsigned char *)ip, sizeof(click_ip)); 68 | #elif HAVE_FAST_CHECKSUM 69 | ip->ip_sum = ip_fast_csum((unsigned char *)ip, sizeof(click_ip) >> 2); 70 | #else 71 | ip->ip_sum = click_in_cksum((unsigned char *)ip, sizeof(click_ip)); 72 | #endif 73 | icmp->icmp_cksum = click_in_cksum((const unsigned char *)icmp, p->length() - sizeof(click_ip)); 74 | 75 | return p; 76 | } 77 | 78 | EXPORT_ELEMENT(DHCP_ICMP_Encap) 79 | -------------------------------------------------------------------------------- /dhcp/package/dhcpicmpencap.hh: -------------------------------------------------------------------------------- 1 | #ifndef DHCPICMPENCAP_HH 2 | #define DHCPICMPENCAP_HH 3 | #include "dhcp_common.hh" 4 | #include 5 | class HandlerCall; 6 | 7 | /* 8 | * =c 9 | * DHCPICMPEncap(SRC_CALL, DST_CALL) 10 | * =s DHCP 11 | * change IP addresses of ICMP packet 12 | */ 13 | 14 | class DHCP_ICMP_Encap : public Element 15 | { 16 | public: 17 | DHCP_ICMP_Encap(); 18 | ~DHCP_ICMP_Encap(); 19 | 20 | const char *class_name() const { return "DHCPICMPEncap"; } 21 | const char *port_count() const { return PORTS_1_1; } 22 | const char *processing() const { return AGNOSTIC; } 23 | 24 | int initialize(ErrorHandler *); 25 | int configure(Vector &conf, ErrorHandler *errh); 26 | 27 | Packet *simple_action(Packet *); 28 | 29 | private: 30 | HandlerCall *_src_ip_h; 31 | HandlerCall *_dst_ip_h; 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /dhcp/package/dhcpoptionutil.hh: -------------------------------------------------------------------------------- 1 | #ifndef DHCPOPTIONUTIL_HH 2 | #define DHCPOPTIONUTIL_HH 3 | #include "dhcp_common.hh" 4 | #include 5 | #include 6 | namespace DHCPOptionUtil { 7 | 8 | const uint8_t *fetch_next(Packet *p, int want_option, int &overload, 9 | const uint8_t *o = 0); 10 | const uint8_t *fetch(Packet *p, int want_option, int expected_length); 11 | 12 | uint32_t rand_exp_backoff(uint32_t backoff_center); 13 | 14 | Packet *push_dhcp_udp_header(Packet *, IPAddress); 15 | 16 | } 17 | #endif 18 | -------------------------------------------------------------------------------- /dhcp/package/dhcpserverack.hh: -------------------------------------------------------------------------------- 1 | #ifndef DHCPSERVERACKNAK_HH 2 | #define DHCPSERVERACKNAK_HH 3 | 4 | #include 5 | #include "leasetable.hh" 6 | 7 | /* 8 | * =c 9 | * DHCPServerACKorNAK(LEASES) 10 | * 11 | * =s DHCP 12 | * 13 | * Handles incoming DHCP_REQUEST. Sends out DHCP_ACK or DHCP_NAK 14 | * accordingly. 15 | * 16 | * =d 17 | * 18 | * 19 | * =e 20 | * 21 | * =a 22 | * DHCPServerLeases, DHCPServerACKorNACK, DHCPServerOffer 23 | * 24 | * 25 | */ 26 | 27 | class DHCPServerACKorNAK : public Element 28 | { 29 | public: 30 | DHCPServerACKorNAK(); 31 | ~DHCPServerACKorNAK(); 32 | 33 | const char *class_name() const { return "DHCPServerACKorNAK"; } 34 | const char *port_count() const { return "1/1-2"; } 35 | const char *processing() const { return PUSH; } 36 | 37 | int configure(Vector &conf, ErrorHandler *errh); 38 | virtual void push(int port, Packet *p); 39 | Packet *make_ack_packet(Packet *p, Lease *lease); 40 | Packet *make_nak_packet(Packet *p, Lease *lease); 41 | 42 | private: 43 | DHCPLeaseTable *_leases; 44 | }; 45 | #endif 46 | -------------------------------------------------------------------------------- /dhcp/package/dhcpserveroffer.hh: -------------------------------------------------------------------------------- 1 | #ifndef DHCPSERVEROFFER_HH 2 | #define DHCPSERVEROFFER_HH 3 | 4 | #include 5 | #include 6 | #include "leasetable.hh" 7 | #include "dhcp_common.hh" 8 | 9 | /* 10 | * =c 11 | * DHCPServerOffer(LEASES) 12 | * 13 | * =s DHCP 14 | * 15 | * Handles incoming DHCP_DISCOVER. Sends out DHCP_OFFER if appropriate. 16 | * 17 | * =d 18 | * 19 | * DHPServerOffer has at most 2 input and at most 2 output 20 | * ports. Input port 0 is used for handling DHCP_DISCOVER 21 | * packets. Input port 1 is used for handling ICMP ECHO REPLY 22 | * packets. DHCP_OFFER packets go out from output port 0. ICMP_PING 23 | * packets go out from output port 1. The user can simply disconnect 24 | * the ICMP related connections to disable pinging prior to sending the 25 | * DHCP_OFFER packet. 26 | * 27 | * =e 28 | * 29 | * ... 30 | * ->ipclass:: IPClassifier(icmp type echo-reply, -) 31 | * 32 | * ipclass[0] -> [1]serverOffer::DHCPServerOffer(server); 33 | * 34 | * ipclass[1] -> CheckDHCPMsg(request) -> class :: DHCPClassifier( discover, - ); 35 | * 36 | * class[0]-> [0]serverOffer 37 | * 38 | * serverOffer[0] -> .... //udp_encap->eth_encap->...->ToDevice 39 | * serverOffer[1] -> ....// icmpEncap -> DHCPICMPEncap ->...->ToDevice 40 | * 41 | * =a 42 | * DHCPServerLeases, DHCPServerACKorNACK, DHCPServerRelease 43 | * 44 | */ 45 | 46 | class DHCPServerOffer : public Element 47 | { 48 | public: 49 | DHCPServerOffer(); 50 | ~DHCPServerOffer(); 51 | 52 | const char *class_name() const { return "DHCPServerOffer"; } 53 | const char *port_count() const { return "1-2/1-2"; } 54 | const char *processing() const { return PUSH; } 55 | 56 | int configure(Vector &conf, ErrorHandler *errh); 57 | virtual void push(int port, Packet *p); 58 | Packet* make_offer_packet(dhcpMessage *discover_msg, Lease *lease); 59 | 60 | void add_handlers(); 61 | 62 | 63 | private: 64 | DHCPLeaseTable *_leases; 65 | }; 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /dhcp/package/dhcpserverrelease.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "dhcp_common.hh" 10 | #include "dhcpserverrelease.hh" 11 | #include "dhcpoptionutil.hh" 12 | 13 | DHCPServerRelease::DHCPServerRelease() 14 | { 15 | } 16 | 17 | DHCPServerRelease::~DHCPServerRelease() 18 | { 19 | } 20 | 21 | int 22 | DHCPServerRelease::configure(Vector &conf, ErrorHandler *errh) 23 | { 24 | return Args(conf, this, errh) 25 | .read_mp("LEASES", ElementCastArg("DHCPLeaseTable"), _leases) 26 | .complete(); 27 | } 28 | 29 | void 30 | DHCPServerRelease::push(int, Packet *p) 31 | { 32 | dhcpMessage *release_msg 33 | = (dhcpMessage*)(p->data() + sizeof(click_ether) + 34 | sizeof(click_udp) + sizeof(click_ip)); 35 | EtherAddress eth(release_msg->chaddr); 36 | 37 | const uint8_t *opt = DHCPOptionUtil::fetch(p, DHO_DHCP_SERVER_IDENTIFIER, 4); 38 | IPAddress incoming_server_id(opt); 39 | IPAddress server_id = _leases->_ip; 40 | if (incoming_server_id != server_id) { 41 | click_chatter("[R] I am not the Server"); 42 | goto done; 43 | } 44 | 45 | _leases->remove(eth); 46 | 47 | done: 48 | p->kill(); 49 | } 50 | 51 | EXPORT_ELEMENT(DHCPServerRelease) 52 | ELEMENT_REQUIRES(DHCPOptionUtil) 53 | -------------------------------------------------------------------------------- /dhcp/package/dhcpserverrelease.hh: -------------------------------------------------------------------------------- 1 | #ifndef DHCPSERVERRLEASE_HH 2 | #define DHCPSERVERRLEASE_HH 3 | 4 | #include 5 | #include 6 | #include "leasetable.hh" 7 | 8 | /* 9 | * =c 10 | * DHCPServerRelease(LEASES) 11 | * =s DHCP 12 | * handles DHCP release address messages 13 | */ 14 | 15 | class DHCPServerRelease : public Element 16 | { 17 | public: 18 | DHCPServerRelease(); 19 | ~DHCPServerRelease(); 20 | 21 | const char *class_name() const { return "DHCPServerRelease"; } 22 | const char *port_count() const { return PORTS_1_0; } 23 | const char *processing() const { return PUSH; } 24 | 25 | int configure(Vector &conf, ErrorHandler *errh); 26 | 27 | virtual void push(int port, Packet *p); 28 | 29 | private: 30 | DHCPLeaseTable *_leases; 31 | }; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /dhcp/package/leasehash.hh: -------------------------------------------------------------------------------- 1 | #ifndef LEASEHASH_HH 2 | #define LEASEHASH_HH 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | #include "leasetable.hh" 13 | /* 14 | * =c 15 | * DHCPLeaseHash(ETH, MASK) 16 | * 17 | * =s DHCP 18 | * The core of the DHCP Server. Responsible of keeping track of 19 | * free and allocated leases 20 | * 21 | * =d 22 | * 23 | * DHCPLeaseHash is responsible of keeping track of free, 24 | * reserved, and allocated leases. 25 | * 26 | * =e 27 | * DHCPLeaseHash(192.168.10.9, 192.168.10.0); 28 | * 29 | * =a 30 | * DHCPServerOffer, DHCPServerACKorNACK, DHCPServerRelease 31 | * 32 | */ 33 | 34 | class LeaseHash : public DHCPLeaseTable 35 | { 36 | public: 37 | LeaseHash(); 38 | ~LeaseHash(); 39 | const char* class_name() const { return "DHCPLeaseHash"; } 40 | const char* processing() const { return AGNOSTIC; } 41 | void* cast(const char*); 42 | int configure(Vector &conf, ErrorHandler *errh); 43 | 44 | uint32_t get_default_duration(); 45 | uint32_t get_max_duration(); 46 | IPAddress get_server_ip_addr(); 47 | IPAddress get_subnet_mask(); 48 | 49 | void free_list_push(IPAddress); 50 | IPAddress free_list_pop(); 51 | 52 | bool _read_conf_file; 53 | bool _read_leases_file; 54 | uint32_t _default_duration; 55 | uint32_t _max_duration; 56 | 57 | String get_allocated_leases_string() const; 58 | 59 | Lease *new_lease(EtherAddress, IPAddress); 60 | Lease *new_lease_any(EtherAddress); 61 | IPAddress get_server_ip(); 62 | IPAddress hash(EtherAddress); 63 | private: 64 | 65 | IPAddress _subnet; 66 | }; 67 | 68 | #endif /* LEASEHASH_HH */ 69 | -------------------------------------------------------------------------------- /dhcp/package/leasepool.hh: -------------------------------------------------------------------------------- 1 | #ifndef LEASEPOOL_HH 2 | #define LEASEPOOL_HH 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include "leasetable.hh" 13 | 14 | /* 15 | * =c 16 | * DHCPLeasePool(ETH, IP, MASK, I ) 17 | * 18 | * =s DHCP 19 | * The core of the DHCP Server. Responsible of keeping track of 20 | * free and allocated leases. 21 | * 22 | * =d 23 | * 24 | * LeasePool is responsible of keeping track of free, 25 | * reservered, and allocated leases. 26 | * 27 | * =e 28 | * LeasePool(11:22:33:44:55:66, 192.168.10.1, 192.168.10.0, START 192.168.10.10, END 192.168.10.250); 29 | * 30 | * =a 31 | * DHCPServerOffer, DHCPServerACKorNACK, DHCPServerRelease 32 | * 33 | */ 34 | 35 | class LeasePool : public DHCPLeaseTable 36 | { 37 | public: 38 | LeasePool(); 39 | ~LeasePool(); 40 | 41 | const char *class_name() const { return "DHCPLeasePool"; } 42 | const char *processing() const { return AGNOSTIC; } 43 | void *cast(const char *); 44 | int configure(Vector &conf, ErrorHandler *errh); 45 | 46 | uint32_t get_default_duration(); 47 | uint32_t get_max_duration(); 48 | IPAddress get_server_ip_addr(); 49 | IPAddress get_subnet_mask(); 50 | 51 | void free_list_push(IPAddress); 52 | IPAddress free_list_pop(); 53 | 54 | bool _read_conf_file; 55 | bool _read_leases_file; 56 | uint32_t _default_duration; 57 | uint32_t _max_duration; 58 | 59 | String get_allocated_leases_string() const; 60 | 61 | void remove(EtherAddress); 62 | Lease *new_lease(EtherAddress, IPAddress); 63 | Lease *new_lease_any(EtherAddress); 64 | IPAddress get_server_ip(); 65 | bool insert(Lease); 66 | 67 | private: 68 | Deque _free_list; 69 | HashTable _free; 70 | IPAddress _start; 71 | IPAddress _end; 72 | }; 73 | 74 | #endif /* LEASEPOOL_HH */ 75 | -------------------------------------------------------------------------------- /dhcp/package/leasetable.hh: -------------------------------------------------------------------------------- 1 | #ifndef LEASETABLE_HH 2 | #define LEASETABLE_HH 3 | #include 4 | #include 5 | #include 6 | #include 7 | CLICK_DECLS 8 | 9 | 10 | 11 | class Lease { 12 | public: 13 | Lease() { } 14 | ~Lease() { } 15 | 16 | EtherAddress _eth; 17 | IPAddress _ip; 18 | Timestamp _start; 19 | Timestamp _end; 20 | Timestamp _duration; 21 | bool _valid; 22 | void extend() { 23 | Timestamp now = Timestamp::now(); 24 | _start.set_sec(now.sec()); 25 | _start.set_subsec(now.subsec()); 26 | _end.set_sec( _start.sec() + now.sec() ); 27 | _end.set_subsec( _start.subsec() + now.subsec() ); 28 | } 29 | }; 30 | 31 | 32 | /* 33 | * This is basically an abstract classs. If you want to 34 | * implement your own dhcp lease server, subclass this and 35 | * implement new_lease_any and new_lease. See leasepool.cc 36 | * for an example 37 | */ 38 | class DHCPLeaseTable : public Element { 39 | public: 40 | DHCPLeaseTable(); 41 | ~DHCPLeaseTable(); 42 | const char* class_name() const { return "DHCPLeaseTable"; } 43 | void* cast(const char*); 44 | int configure( Vector &conf, ErrorHandler *errh ); 45 | virtual Lease *lookup(IPAddress ip); 46 | virtual Lease *rev_lookup(EtherAddress eth); 47 | 48 | virtual void remove(EtherAddress eth); 49 | virtual Lease *new_lease_any(EtherAddress) { 50 | click_chatter("%{element}::%s: %s\n", this, __FILE__, __func__); 51 | return 0; 52 | } 53 | virtual Lease *new_lease(EtherAddress, IPAddress) { 54 | click_chatter("%{element}::%s: %s\n", this, __FILE__, __func__); 55 | return 0; 56 | } 57 | virtual bool insert(Lease); 58 | 59 | 60 | IPAddress _ip; 61 | IPAddress _subnet; 62 | EtherAddress _eth; 63 | typedef HashTable LeaseMap; 64 | typedef LeaseMap::const_iterator LeaseIter; 65 | LeaseMap _leases; 66 | 67 | HashTable _ips; 68 | 69 | 70 | static String read_handler(Element *e, void *thunk); 71 | void add_handlers(); 72 | 73 | }; 74 | 75 | CLICK_ENDDECLS 76 | #endif /* LEASETABLE_HH */ 77 | -------------------------------------------------------------------------------- /dhcp/test/t01.testie: -------------------------------------------------------------------------------- 1 | %script 2 | click CONFIG 3 | tcpdump -r fart 4 | 5 | %file CONFIG 6 | require(package dhcp) 7 | 8 | elementclass DHCPServer { 9 | $eth, $ip | 10 | lease :: DHCPLeaseHash($eth, $ip); 11 | checker :: CheckDHCPMsg; 12 | classifier :: DHCPClassifier(discover, request, release, -); 13 | input -> checker; 14 | checker[1] -> output; 15 | checker[0] -> classifier; 16 | classifier[0] -> Print(a) -> offer :: DHCPServerOffer(lease) -> output; 17 | classifier[1] -> Print(b) -> ack :: DHCPServerACKorNAK(lease) -> output; 18 | classifier[2] -> Print(c) -> release :: DHCPServerRelease(lease); 19 | classifier[3] -> Print(d) -> sink :: Discard; 20 | } 21 | 22 | FromIPSummaryDump(IN, STOP true) 23 | -> ToDump(fart, ENCAP ETHER) 24 | -> DHCPServer(1:1:1:1:1:1, 19.19.19.19) 25 | -> Print -> Discard; 26 | 27 | %file IN 28 | !IPSummaryDump 1.3 29 | !data eth_src eth_dst eth_type ip_src sport ip_dst dport ip_proto payload 30 | ec:35:86:9a:b0:cb ff:ff:ff:ff:ff:ff 0x0800 0.0.0.0 68 255.255.255.255 67 U "\<0101 0600 badb 6f27 0002 0000 0000 0000 0000 0000 0000 0000 0000 0000 ec35 869a b0cb 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 6382 5363 3501 0337 0601 0306 0f77 fc39 0205 dc3d 0701 ec35 869a b0cb 3204 c0a8 017d 3304 0076 a700 0c06 6950 686f 6e65 ff00 0000 0000 0000 0000 0000 0000 0000>" 31 | -------------------------------------------------------------------------------- /iias/.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | autom4te* 3 | config.h config.log config.status 4 | -------------------------------------------------------------------------------- /iias/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | autom4te* 3 | config.h 4 | config.log 5 | config.status 6 | -------------------------------------------------------------------------------- /iias/Makefile.in: -------------------------------------------------------------------------------- 1 | SHELL = @SHELL@ 2 | 3 | 4 | # THESE VARIABLES MAY CHANGE BETWEEN PACKAGES 5 | 6 | # Set 'package' to the name of your package. 7 | package := @CLICKPACKAGENAME@ 8 | 9 | # Set these variables appropriately. 10 | top_builddir := . 11 | subdir := . 12 | 13 | # Require Click prefix settings. 14 | # Generally, you will provide a '--with-click=CLICKPREFIX' option, and set: 15 | clickbuild_prefix := @clickbuild_prefix@ 16 | include @clickbuild_datadir@/config.mk 17 | include @clickbuild_datadir@/pkg-config.mk 18 | 19 | srcdir = @srcdir@ 20 | top_srcdir = @top_srcdir@ 21 | AUTOCONF = $(CLICKAUTOCONF) 22 | ACLOCAL = : 23 | 24 | TARGETS = gre ppp 25 | 26 | all: Makefile $(TARGETS) 27 | 28 | gre ppp: Makefile 29 | @cd $@ && $(MAKE) all 30 | 31 | elemlist install install-man: Makefile 32 | @for d in $(TARGETS); do (cd $$d && $(MAKE) $@) || exit 1; done 33 | 34 | $(srcdir)/configure: $(srcdir)/configure.ac 35 | cd $(srcdir) && $(ACLOCAL) && $(AUTOCONF) 36 | config.status: $(srcdir)/configure 37 | $(SHELL) $(srcdir)/configure @ac_configure_args@ 38 | Makefile: config.status $(srcdir)/Makefile.in 39 | cd $(top_builddir) && \ 40 | CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status 41 | 42 | clean: 43 | @-for d in $(TARGETS); do (cd $$d && $(MAKE) clean); done 44 | 45 | distclean: 46 | @-for d in $(TARGETS); do (cd $$d && $(MAKE) distclean); done 47 | -rm -f Makefile config.status config.cache config.log config.h 48 | 49 | .PHONY: all $(TARGETS) elemlist clean distclean \ 50 | install install-doc install-man install-include 51 | -------------------------------------------------------------------------------- /iias/conf/router.click: -------------------------------------------------------------------------------- 1 | // 2 | // router.click 3 | // Mark Huang 4 | // 5 | // This is a Click configuration for a router on an 6 | // IP-in-GRE-in-UDP-in-IP overlay network on PlanetLab. The overlay 7 | // network is actually composed of two distinct networks: a PPP 8 | // network of 1 local PPP concentrator and 2 remote PPP clients, and 9 | // an IP network that is fully connected in a static routing 10 | // scheme. For convenience, the overlay IP addresses are the same as 11 | // the real IP addresses of the nodes participating in the overlay. 12 | // 13 | // This configuration provides simple routing on the overlay. The 14 | // default route in this configuration is via the ingress node. 15 | // 16 | // Copyright (c) 2004 The Trustees of Princeton University (Trustees). 17 | // 18 | // $Id: router.click,v 1.1 2004/04/17 15:26:11 mhuang Exp $ 19 | // 20 | 21 | require(ppp,gre) 22 | 23 | AddressInfo( 24 | alice 128.112.139.80 128.112.139.80/32, 25 | planetlab-1 128.112.139.71 128.112.139.71/32, 26 | planetlab-2 128.112.139.72 128.112.139.72/32, 27 | planetlab-3 128.112.139.73 128.112.139.73/32, 28 | default 0.0.0.0/0 0.0.0.0/0, 29 | ); 30 | 31 | 32 | // Shared IP input path and routing table 33 | ip :: CheckIPHeader(INTERFACES planetlab-2) 34 | rt :: StaticIPLookup( 35 | planetlab-2 0, 36 | planetlab-1 1, 37 | planetlab-3 2, 38 | alice 3, 39 | default alice 3 40 | ); 41 | 42 | // Input path 43 | FromSocket(UDP, 0.0.0.0, 47) 44 | -> CheckGREHeader 45 | -> c :: Classifier(2/0800, -) 46 | c[0] 47 | -> StripGREHeader 48 | -> ip 49 | -> rt 50 | c[1] 51 | -> Print("non-IP") 52 | -> Discard 53 | 54 | // Local delivery 55 | rt[0] 56 | -> IPReassembler 57 | -> ipc :: IPClassifier(icmp type echo, -) 58 | ipc[0] 59 | -> ICMPPingResponder 60 | -> rt 61 | ipc[1] 62 | -> Print("toh") 63 | -> Discard 64 | 65 | // Output paths 66 | rt[1] 67 | -> GREEncap(0x0800) 68 | -> ToSocket(UDP, planetlab-1, 47) 69 | rt[2] 70 | -> GREEncap(0x0800) 71 | -> ToSocket(UDP, planetlab-3, 47) 72 | rt[3] 73 | -> GREEncap(0x0800) 74 | -> ToSocket(UDP, alice, 47) 75 | -------------------------------------------------------------------------------- /iias/gre/.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile *.d *.kd *.ud *.ko *.uo 2 | kelements.conf kelements.mk kpackage.cc 3 | Kbuild .*.ko.cmd .*.o.cmd .tmp_versions kversion.c gre.mod.c 4 | uelements.conf uelements.mk upackage.cc 5 | elementmap-gre.xml 6 | -------------------------------------------------------------------------------- /iias/gre/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | *.d 3 | *.kd 4 | *.ud 5 | *.ko 6 | *.uo 7 | kelements.conf 8 | kelements.mk 9 | kpackage.cc 10 | Kbuild 11 | .*.ko.cmd 12 | .*.o.cmd 13 | .tmp_versions 14 | kversion.c 15 | gre.mod.c 16 | uelements.conf 17 | uelements.mk 18 | upackage.cc 19 | elementmap-gre.xml 20 | -------------------------------------------------------------------------------- /iias/gre/Makefile.in: -------------------------------------------------------------------------------- 1 | SHELL = @SHELL@ 2 | 3 | 4 | # THESE VARIABLES MAY CHANGE BETWEEN PACKAGES 5 | 6 | # Set 'package' to the name of your package. 7 | package := gre 8 | 9 | # Set these variables appropriately. 10 | top_builddir := .. 11 | subdir := gre 12 | 13 | # Require Click prefix settings. 14 | # Generally, you will provide a '--with-click=CLICKPREFIX' option, and set: 15 | clickbuild_prefix := @clickbuild_prefix@ 16 | include @clickbuild_datadir@/config.mk 17 | 18 | # Set 'MAKE_UPACKAGE', 'MAKE_KPACKAGE', and 'MAKE_BPACKAGE' to '0' or '1' 19 | # to determine whether to build userlevel, linuxmodule, and bsdmodule 20 | # packages, respectively. 21 | MAKE_UPACKAGE = @BUILD_USERLEVEL@ 22 | MAKE_KPACKAGE = @BUILD_LINUXMODULE@ 23 | MAKE_BPACKAGE = @BUILD_BSDMODULE@ 24 | 25 | # Set 'STRIP_UPACKAGE' to 'strip -g' to strip debugging symbols from the 26 | # userlevel package before installing. 27 | #STRIP_UPACKAGE = $(STRIP) -g 28 | 29 | # Set these variables as required. 30 | DEFS = @DEFS@ $(CLICKDEFS) 31 | INCLUDES = -I. -I$(top_builddir) -I$(srcdir) $(CLICKINCLUDES) 32 | 33 | # Set this variable to force 'click-elem2package' to include a header, 34 | # such as your package's '', if necessary. 35 | #ELEM2PACKAGE_INCLUDES = -i'' 36 | 37 | # END OF VARIABLES THAT MAY CHANGE BETWEEN PACKAGES 38 | 39 | 40 | # Everything below here will probably stay unchanged 41 | 42 | srcdir = @srcdir@ 43 | top_srcdir = @top_srcdir@ 44 | 45 | ifeq ($(CLICK_PACKAGE_MAKING),) 46 | prefix = @prefix@ 47 | exec_prefix = @exec_prefix@ 48 | bindir = @bindir@ 49 | sbindir = @sbindir@ 50 | libdir = @libdir@ 51 | mandir = @mandir@ 52 | datarootdir = @datarootdir@ 53 | datadir = @datadir@ 54 | endif 55 | 56 | include $(clickbuild_datadir)/pkg-Makefile 57 | -------------------------------------------------------------------------------- /iias/gre/gre.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; c-basic-offset: 4 -*- */ 2 | #ifndef GRE_H 3 | #define GRE_H 4 | #include 5 | CLICK_CXX_PROTECT 6 | 7 | /* 8 | * our own definitions of GRE headers 9 | * based on a file from one of the BSDs 10 | */ 11 | 12 | #define GRE_CP 0x8000 /* Checksum Present */ 13 | #define GRE_RP 0x4000 /* Routing Present */ 14 | #define GRE_KP 0x2000 /* Key Present */ 15 | #define GRE_SP 0x1000 /* Sequence Present */ 16 | #define GRE_SS 0x0800 /* Strict Source Route */ 17 | #define GRE_VERSION 0x0007 /* Version Number */ 18 | 19 | struct click_gre { 20 | uint16_t flags; /* See above */ 21 | uint16_t protocol; /* Ethernet protocol type */ 22 | uint32_t options[3]; /* Optional fields (up to 12 bytes in GRE version 0) */ 23 | }; 24 | 25 | CLICK_CXX_UNPROTECT 26 | #include 27 | #endif 28 | -------------------------------------------------------------------------------- /iias/gre/stripgreheader.cc: -------------------------------------------------------------------------------- 1 | // -*- mode: c++; c-basic-offset: 2 -*- 2 | /* 3 | * stripgreheader.cc -- element removes GRE header 4 | * Mark Huang 5 | * 6 | * Copyright (c) 2004 The Trustees of Princeton University (Trustees). 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a 9 | * copy of this software and associated documentation files (the "Software"), 10 | * to deal in the Software without restriction, subject to the conditions 11 | * listed in the Click LICENSE file. These conditions include: you must 12 | * preserve this copyright notice, and you cannot mention the copyright 13 | * holders in advertising related to the Software without their permission. 14 | * The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This 15 | * notice is a summary of the Click LICENSE file; the license in that file is 16 | * legally binding. 17 | * 18 | * $Id: stripgreheader.cc,v 1.4 2005/09/19 22:45:07 eddietwo Exp $ 19 | */ 20 | 21 | #include 22 | #include "stripgreheader.hh" 23 | #include "gre.h" 24 | CLICK_DECLS 25 | 26 | StripGREHeader::StripGREHeader() 27 | { 28 | } 29 | 30 | StripGREHeader::~StripGREHeader() 31 | { 32 | } 33 | 34 | Packet * 35 | StripGREHeader::simple_action(Packet *p) 36 | { 37 | const click_gre *greh = reinterpret_cast(p->data()); 38 | uint16_t flags; 39 | unsigned hlen = 4; 40 | 41 | // avoid alignment issues 42 | memcpy(&flags, &greh->flags, sizeof(greh->flags)); 43 | 44 | if (flags & htons(GRE_CP)) 45 | hlen += 4; 46 | if (flags & htons(GRE_KP)) 47 | hlen += 4; 48 | if (flags & htons(GRE_SP)) 49 | hlen += 4; 50 | 51 | p->pull(hlen); 52 | return p; 53 | } 54 | 55 | CLICK_ENDDECLS 56 | EXPORT_ELEMENT(StripGREHeader) 57 | ELEMENT_MT_SAFE(StripGREHeader) 58 | -------------------------------------------------------------------------------- /iias/gre/stripgreheader.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * stripgreheader.hh -- element removes GRE header 3 | * Mark Huang 4 | * 5 | * Copyright (c) 2004 The Trustees of Princeton University (Trustees). 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, subject to the conditions 10 | * listed in the Click LICENSE file. These conditions include: you must 11 | * preserve this copyright notice, and you cannot mention the copyright 12 | * holders in advertising related to the Software without their permission. 13 | * The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This 14 | * notice is a summary of the Click LICENSE file; the license in that file is 15 | * legally binding. 16 | * 17 | * $Id: stripgreheader.hh,v 1.4 2006/02/24 17:18:18 eddietwo Exp $ 18 | */ 19 | 20 | #ifndef CLICK_STRIPGREHEADER_HH 21 | #define CLICK_STRIPGREHEADER_HH 22 | #include 23 | CLICK_DECLS 24 | 25 | /* 26 | * =c 27 | * StripGREHeader() 28 | * =s GRE 29 | * strips outermost GRE header 30 | * =d 31 | * Removes the outermost GRE header from GRE packets. 32 | * 33 | * =a GREEncap, CheckGREHeader 34 | */ 35 | 36 | class StripGREHeader : public Element { 37 | 38 | public: 39 | 40 | StripGREHeader(); 41 | ~StripGREHeader(); 42 | 43 | const char *class_name() const { return "StripGREHeader"; } 44 | const char *port_count() const { return PORTS_1_1; } 45 | 46 | Packet *simple_action(Packet *); 47 | 48 | }; 49 | 50 | CLICK_ENDDECLS 51 | #endif 52 | -------------------------------------------------------------------------------- /iias/ppp/.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile *.d *.kd *.ud *.ko *.uo 2 | kelements.conf kelements.mk kpackage.cc 3 | Kbuild .*.ko.cmd .*.o.cmd .tmp_versions kversion.c ppp.mod.c 4 | uelements.conf uelements.mk upackage.cc 5 | elementmap-ppp.xml 6 | -------------------------------------------------------------------------------- /iias/ppp/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | *.d 3 | *.kd 4 | *.ud 5 | *.ko 6 | *.uo 7 | kelements.conf 8 | kelements.mk 9 | kpackage.cc 10 | Kbuild 11 | .*.ko.cmd 12 | .*.o.cmd 13 | .tmp_versions 14 | kversion.c 15 | ppp.mod.c 16 | uelements.conf 17 | uelements.mk 18 | upackage.cc 19 | elementmap-ppp.xml 20 | -------------------------------------------------------------------------------- /iias/ppp/Makefile.in: -------------------------------------------------------------------------------- 1 | SHELL = @SHELL@ 2 | 3 | 4 | # THESE VARIABLES MAY CHANGE BETWEEN PACKAGES 5 | 6 | # Set 'package' to the name of your package. 7 | package := ppp 8 | 9 | # Set these variables appropriately. 10 | top_builddir := .. 11 | subdir := ppp 12 | 13 | # Require Click prefix settings. 14 | # Generally, you will provide a '--with-click=CLICKPREFIX' option, and set: 15 | clickbuild_prefix := @clickbuild_prefix@ 16 | include @clickbuild_datadir@/config.mk 17 | 18 | # Set 'MAKE_UPACKAGE', 'MAKE_KPACKAGE', and 'MAKE_BPACKAGE' to '0' or '1' 19 | # to determine whether to build userlevel, linuxmodule, and bsdmodule 20 | # packages, respectively. 21 | MAKE_UPACKAGE = @BUILD_USERLEVEL@ 22 | MAKE_KPACKAGE = @BUILD_LINUXMODULE@ 23 | MAKE_BPACKAGE = @BUILD_BSDMODULE@ 24 | 25 | # Set 'STRIP_UPACKAGE' to 'strip -g' to strip debugging symbols from the 26 | # userlevel package before installing. 27 | #STRIP_UPACKAGE = $(STRIP) -g 28 | 29 | # Set these variables as required. 30 | DEFS = @DEFS@ $(CLICKDEFS) 31 | INCLUDES = -I. -I$(top_builddir) -I$(srcdir) $(CLICKINCLUDES) 32 | 33 | # Set this variable to force 'click-elem2package' to include a header, 34 | # such as your package's '', if necessary. 35 | #ELEM2PACKAGE_INCLUDES = -i'' 36 | 37 | # END OF VARIABLES THAT MAY CHANGE BETWEEN PACKAGES 38 | 39 | 40 | # Everything below here will probably stay unchanged 41 | 42 | srcdir = @srcdir@ 43 | top_srcdir = @top_srcdir@ 44 | 45 | ifeq ($(CLICK_PACKAGE_MAKING),) 46 | prefix = @prefix@ 47 | exec_prefix = @exec_prefix@ 48 | bindir = @bindir@ 49 | sbindir = @sbindir@ 50 | libdir = @libdir@ 51 | mandir = @mandir@ 52 | datarootdir = @datarootdir@ 53 | datadir = @datadir@ 54 | endif 55 | 56 | include $(clickbuild_datadir)/pkg-Makefile 57 | -------------------------------------------------------------------------------- /iias/ppp/ipcp.hh: -------------------------------------------------------------------------------- 1 | // -*- mode: c++; c-basic-offset: 2 -*- 2 | /* 3 | * ipcp.hh -- PPP IP Control Protocol 4 | * Mark Huang 5 | * 6 | * Copyright (c) 2004 The Trustees of Princeton University (Trustees). 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a 9 | * copy of this software and associated documentation files (the "Software"), 10 | * to deal in the Software without restriction, subject to the conditions 11 | * listed in the Click LICENSE file. These conditions include: you must 12 | * preserve this copyright notice, and you cannot mention the copyright 13 | * holders in advertising related to the Software without their permission. 14 | * The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This 15 | * notice is a summary of the Click LICENSE file; the license in that file is 16 | * legally binding. 17 | * 18 | * $Id: ipcp.hh,v 1.3 2005/02/07 21:20:55 eddietwo Exp $ 19 | */ 20 | 21 | /* 22 | =c 23 | 24 | IPCP(LOCAL, REMOTE, [I]) 25 | 26 | =s PPP 27 | 28 | PPP IP Control Protocol (IPCP) Element. 29 | 30 | =d 31 | 32 | Expects PPP packets as input. Packets not of protocol type 0x8021 33 | (PPP_IPCP) are silently discarded. Outputs PPP_IPCP packets as 34 | required, which should be routed to the peer from which the input 35 | packets were received. 36 | 37 | Keyword arguments are: 38 | 39 | =over 8 40 | 41 | =item VERBOSE 42 | 43 | Boolean. When true, IPCP will print messages whenever it receives a 44 | packet. Default is false. 45 | 46 | =back 47 | 48 | =a PPPControlProtocol, LCP */ 49 | 50 | #ifndef CLICK_IPCP_HH 51 | #define CLICK_IPCP_HH 52 | #include 53 | #include 54 | #include "ppp_defs.h" 55 | #include "pppcontrolprotocol.hh" 56 | CLICK_DECLS 57 | 58 | class IPCP : public PPPControlProtocol { public: 59 | 60 | IPCP() : PPPControlProtocol(PPP_IPCP), _localip(0), _remoteip(0) { } 61 | ~IPCP() { } 62 | 63 | const char *class_name() const { return "IPCP"; } 64 | 65 | int configure(Vector &, ErrorHandler *); 66 | 67 | protected: 68 | 69 | unsigned addci(uint8_t *); 70 | void reqci(WritablePacket *); 71 | 72 | private: 73 | 74 | IPAddress _localip, _remoteip; 75 | 76 | }; 77 | 78 | CLICK_ENDDECLS 79 | #endif 80 | -------------------------------------------------------------------------------- /iias/ppp/lcp.hh: -------------------------------------------------------------------------------- 1 | // -*- mode: c++; c-basic-offset: 2 -*- 2 | /* 3 | * lcp.hh -- PPP Link Control Protocol 4 | * Mark Huang 5 | * 6 | * Copyright (c) 2004 The Trustees of Princeton University (Trustees). 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a 9 | * copy of this software and associated documentation files (the "Software"), 10 | * to deal in the Software without restriction, subject to the conditions 11 | * listed in the Click LICENSE file. These conditions include: you must 12 | * preserve this copyright notice, and you cannot mention the copyright 13 | * holders in advertising related to the Software without their permission. 14 | * The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This 15 | * notice is a summary of the Click LICENSE file; the license in that file is 16 | * legally binding. 17 | * 18 | * $Id: lcp.hh,v 1.3 2005/02/07 21:20:56 eddietwo Exp $ 19 | */ 20 | 21 | /* 22 | =c 23 | 24 | LCP([I]) 25 | 26 | =s PPP 27 | 28 | PPP Link Control Protocol (LCP) Element. 29 | 30 | =d 31 | 32 | Expects PPP packets as input. Packets not of protocol type 0xc021 33 | (PPP_LCP) are answered with an LCP Protocol Rejection. Outputs 34 | PPP_LCP packets as required, which should be routed to the peer from 35 | which the input packets were received. 36 | 37 | Keyword arguments are: 38 | 39 | =over 8 40 | 41 | =item VERBOSE 42 | 43 | Boolean. When true, LCP will print messages whenever it receives a 44 | packet. Default is false. 45 | 46 | =back 47 | 48 | =a PPPControlProtocol, IPCP */ 49 | 50 | #ifndef CLICK_LCP_HH 51 | #define CLICK_LCP_HH 52 | #include 53 | #include 54 | #include "ppp_defs.h" 55 | #include "pppcontrolprotocol.hh" 56 | CLICK_DECLS 57 | 58 | class LCP : public PPPControlProtocol { public: 59 | 60 | LCP() : PPPControlProtocol(PPP_LCP), magic(0) { } 61 | ~LCP() { } 62 | 63 | const char *class_name() const { return "LCP"; } 64 | 65 | protected: 66 | 67 | unsigned addci(uint8_t *); 68 | void reqci(WritablePacket *); 69 | void protreject(WritablePacket *); 70 | 71 | private: 72 | 73 | uint32_t magic; 74 | 75 | }; 76 | 77 | CLICK_ENDDECLS 78 | #endif 79 | -------------------------------------------------------------------------------- /iias/ppp/pppencap.cc: -------------------------------------------------------------------------------- 1 | // -*- mode: c++; c-basic-offset: 2 -*- 2 | /* 3 | * pppencap.cc -- element encapsulates packet in PPP header 4 | * Mark Huang 5 | * 6 | * Copyright (c) 2004 The Trustees of Princeton University (Trustees). 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a 9 | * copy of this software and associated documentation files (the "Software"), 10 | * to deal in the Software without restriction, subject to the conditions 11 | * listed in the Click LICENSE file. These conditions include: you must 12 | * preserve this copyright notice, and you cannot mention the copyright 13 | * holders in advertising related to the Software without their permission. 14 | * The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This 15 | * notice is a summary of the Click LICENSE file; the license in that file is 16 | * legally binding. 17 | * 18 | * $Id: pppencap.cc,v 1.1 2004/04/17 14:51:14 mhuang Exp $ 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include "ppp_defs.h" 27 | #include "pppencap.hh" 28 | 29 | CLICK_DECLS 30 | 31 | int 32 | PPPEncap::configure(Vector &conf, ErrorHandler *errh) 33 | { 34 | uint16_t protocol; 35 | 36 | if (cp_va_kparse(conf, this, errh, 37 | "PROTOCOL", cpkP, cpShort, &protocol, 38 | "ADDRESS", 0, cpByte, &_ppp.address, 39 | "CONTROL", 0, cpByte, &_ppp.control, 40 | cpEnd) < 0) 41 | return -1; 42 | 43 | _ppp.protocol = htons(protocol); 44 | 45 | return 0; 46 | } 47 | 48 | Packet * 49 | PPPEncap::simple_action(Packet *p_in) 50 | { 51 | WritablePacket *p = p_in->push(sizeof(struct ppp_header)); 52 | if (!p) return 0; 53 | 54 | struct ppp_header *ppp = reinterpret_cast(p->data()); 55 | 56 | memcpy(ppp, &_ppp, sizeof(struct ppp_header)); 57 | 58 | return p; 59 | } 60 | 61 | CLICK_ENDDECLS 62 | EXPORT_ELEMENT(PPPEncap) 63 | ELEMENT_MT_SAFE(PPPEncap) 64 | -------------------------------------------------------------------------------- /iias/ppp/pptpdefs.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kohler/click-packages/cec70da7cf460548ef08f1ddad6924db29d5c0c5/iias/ppp/pptpdefs.h -------------------------------------------------------------------------------- /iias/ppp/pptpserver.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kohler/click-packages/cec70da7cf460548ef08f1ddad6924db29d5c0c5/iias/ppp/pptpserver.cc -------------------------------------------------------------------------------- /iias/ppp/pptpserver.hh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kohler/click-packages/cec70da7cf460548ef08f1ddad6924db29d5c0c5/iias/ppp/pptpserver.hh -------------------------------------------------------------------------------- /ip6_natpt/.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile autom4te* 2 | config.log config.status config.h 3 | -------------------------------------------------------------------------------- /ip6_natpt/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | autom4te* 3 | config.log 4 | config.status 5 | config.h 6 | -------------------------------------------------------------------------------- /ip6_natpt/Makefile.in: -------------------------------------------------------------------------------- 1 | SHELL = @SHELL@ 2 | 3 | 4 | # THESE VARIABLES MAY CHANGE BETWEEN PACKAGES 5 | 6 | # Set 'package' to the name of your package. 7 | package := @CLICKPACKAGENAME@ 8 | 9 | # Set these variables appropriately. 10 | top_builddir := . 11 | subdir := . 12 | 13 | # Require Click prefix settings. 14 | # Generally, you will provide a '--with-click=CLICKPREFIX' option, and set: 15 | clickbuild_prefix := @clickbuild_prefix@ 16 | include @clickbuild_datadir@/config.mk 17 | include @clickbuild_datadir@/pkg-config.mk 18 | 19 | srcdir = @srcdir@ 20 | top_srcdir = @top_srcdir@ 21 | AUTOCONF = $(CLICKAUTOCONF) 22 | ACLOCAL = : 23 | 24 | TARGETS = package 25 | 26 | all: Makefile $(TARGETS) 27 | 28 | package: Makefile 29 | @cd package && $(MAKE) all 30 | 31 | elemlist: Makefile 32 | @cd package && $(MAKE) elemlist 33 | 34 | install: Makefile 35 | @for d in $(TARGETS); do (cd $$d && $(MAKE) install) || exit 1; done 36 | 37 | install-man: 38 | @cd package && $(MAKE) install-man 39 | 40 | $(srcdir)/configure: $(srcdir)/configure.ac 41 | cd $(srcdir) && $(ACLOCAL) && $(AUTOCONF) 42 | config.status: $(srcdir)/configure 43 | $(SHELL) $(srcdir)/configure @ac_configure_args@ 44 | Makefile: config.status $(srcdir)/Makefile.in 45 | cd $(top_builddir) && \ 46 | CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status 47 | 48 | clean: 49 | @-for d in $(TARGETS); do (cd $$d && $(MAKE) clean); done 50 | 51 | distclean: 52 | @-for d in $(TARGETS); do (cd $$d && $(MAKE) distclean); done 53 | -rm -f Makefile config.status config.cache config.log config.h 54 | 55 | .PHONY: all package elemlist clean distclean \ 56 | install install-doc install-man install-include 57 | -------------------------------------------------------------------------------- /ip6_natpt/include/clicknet/rfc1035.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Implementation of RFC 1035 (DNS). 3 | * Code taken from Squid Proxy Server http://www.squid-cache.org 4 | * By: Duane Wessels 5 | * 6 | * Added DNS IPv6 extensions by: Juan Luis Baptiste 7 | * 8 | * Distributed under de GNU General Public License (GNU/GPL). 9 | * 10 | */ 11 | #ifndef _RFC1035_H_ 12 | #define _RFC1035_H_ 13 | 14 | //#include 15 | #include 16 | 17 | 18 | /* rfc1035 - DNS */ 19 | #define RFC1035_TYPE_A 1 20 | #define RFC1035_TYPE_AAAA 28 21 | #define RFC1035_TYPE_PTR 12 22 | #define RFC1035_TYPE_NS 2 23 | #define RFC1035_CLASS_IN 1 24 | #define RFC1035_MAXHOSTNAMESZ 128 25 | #define RFC1035_MAXLABELSZ 63 26 | #define rfc1035_unpack_error 15 27 | 28 | static const char *Alphanum = 29 | "abcdefghijklmnopqrstuvwxyz" 30 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 31 | "0123456789"; 32 | 33 | typedef struct _rfc1035_header rfc1035_header; 34 | 35 | //int rfc1035_errno; 36 | //const char *rfc1035_error_message; 37 | struct _rfc1035_header { 38 | unsigned short id; 39 | unsigned int qr:1; 40 | unsigned int opcode:4; 41 | unsigned int aa:1; 42 | unsigned int tc:1; 43 | unsigned int rd:1; 44 | unsigned int ra:1; 45 | unsigned int rcode:4; 46 | unsigned short qdcount; 47 | unsigned short ancount; 48 | unsigned short nscount; 49 | unsigned short arcount; 50 | }; 51 | 52 | typedef struct _rfc1035_rr rfc1035_rr; 53 | struct _rfc1035_rr { 54 | char name[RFC1035_MAXHOSTNAMESZ]; 55 | unsigned short type; 56 | unsigned short _class; 57 | unsigned int ttl; 58 | unsigned short rdlength; 59 | char *rdata; 60 | }; 61 | #endif /* ndef _RFC1035_H_ */ 62 | -------------------------------------------------------------------------------- /ip6_natpt/package/.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile *.d *.kd *.ud *.ko *.uo 2 | kelements.conf kelements.mk kpackage.cc 3 | Kbuild .*.ko.cmd .*.o.cmd .tmp_versions kversion.c ip6_natpt.mod.c 4 | uelements.conf uelements.mk upackage.cc 5 | elementmap-ip6_natpt.xml 6 | -------------------------------------------------------------------------------- /ip6_natpt/package/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | *.d 3 | *.kd 4 | *.ud 5 | *.ko 6 | *.uo 7 | kelements.conf 8 | kelements.mk 9 | kpackage.cc 10 | Kbuild 11 | .*.ko.cmd 12 | .*.o.cmd 13 | .tmp_versions 14 | kversion.c 15 | ip6_natpt.mod.c 16 | uelements.conf 17 | uelements.mk 18 | upackage.cc 19 | elementmap-ip6_natpt.xml 20 | -------------------------------------------------------------------------------- /ip6_natpt/package/Makefile.in: -------------------------------------------------------------------------------- 1 | SHELL = @SHELL@ 2 | 3 | 4 | # THESE VARIABLES MAY CHANGE BETWEEN PACKAGES 5 | 6 | # Set 'package' to the name of your package. 7 | package := @CLICKPACKAGENAME@ 8 | 9 | # Set these variables appropriately. 10 | top_builddir := .. 11 | subdir := package 12 | 13 | # Require Click prefix settings. 14 | # Generally, you will provide a '--with-click=CLICKPREFIX' option, and set: 15 | clickbuild_prefix := @clickbuild_prefix@ 16 | include @clickbuild_datadir@/config.mk 17 | 18 | # Set 'MAKE_UPACKAGE', 'MAKE_KPACKAGE', and 'MAKE_BPACKAGE' to '0' or '1' 19 | # to determine whether to build userlevel, linuxmodule, and bsdmodule 20 | # packages, respectively. 21 | MAKE_UPACKAGE = @BUILD_USERLEVEL@ 22 | MAKE_KPACKAGE = @BUILD_LINUXMODULE@ 23 | MAKE_BPACKAGE = @BUILD_BSDMODULE@ 24 | 25 | # Set 'STRIP_UPACKAGE' to 'strip -g' to strip debugging symbols from the 26 | # userlevel package before installing. 27 | #STRIP_UPACKAGE = $(STRIP) -g 28 | 29 | # Set these variables as required. 30 | DEFS = @DEFS@ $(CLICKDEFS) 31 | INCLUDES = -I. -I$(top_builddir) -I$(srcdir) -I$(top_srcdir)/include $(CLICKINCLUDES) 32 | 33 | # Set this variable to force 'click-elem2package' to include a header, 34 | # such as your package's '', if necessary. 35 | #ELEM2PACKAGE_INCLUDES = -i'' 36 | 37 | # END OF VARIABLES THAT MAY CHANGE BETWEEN PACKAGES 38 | 39 | 40 | # Everything below here will probably stay unchanged 41 | 42 | srcdir = @srcdir@ 43 | top_srcdir = @top_srcdir@ 44 | 45 | ifeq ($(CLICK_PACKAGE_MAKING),) 46 | prefix = @prefix@ 47 | exec_prefix = @exec_prefix@ 48 | bindir = @bindir@ 49 | sbindir = @sbindir@ 50 | libdir = @libdir@ 51 | mandir = @mandir@ 52 | datarootdir = @datarootdir@ 53 | datadir = @datadir@ 54 | endif 55 | 56 | include $(clickbuild_datadir)/pkg-Makefile 57 | -------------------------------------------------------------------------------- /ip6_natpt/package/dnsalg.hh: -------------------------------------------------------------------------------- 1 | #ifndef DNSALG_HH 2 | #define DNSALG_HH 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "elements/ip6/addresstranslator.hh" 15 | #include 16 | #ifndef CLICK_LINUXMODULE 17 | #include 18 | #endif 19 | 20 | CLICK_DECLS 21 | 22 | 23 | /* 24 | * DNS Application Level Gateway 25 | * 26 | * RFC 1035, DOMAIN NAMES - IMPLEMENTATION AND SPECIFICATION (DNS)|http://www.ietf.org/rfc/rfc1035.txt> 27 | */ 28 | 29 | class DNSAlg : public Element { 30 | 31 | //Configuration parameters 32 | AddressTranslator *_at; 33 | String ipv4_dns_server_ptr_domain; 34 | String ipv6_dns_server_ptr_domain; 35 | String ipv4_dns_server_name; 36 | String ipv6_dns_server_name; 37 | 38 | public: 39 | 40 | DNSAlg(); 41 | ~DNSAlg(); 42 | 43 | const char *class_name() const { return "DNSAlg"; } 44 | const char *port_count() const { return "2/2"; } 45 | 46 | int configure(Vector &, ErrorHandler *); 47 | int initialize(ErrorHandler *); 48 | void uninitialize(); 49 | void push(int port, Packet *p); 50 | void translate_ipv4_ipv6(Packet *p); 51 | void translate_ipv6_ipv4(Packet *p); 52 | private: 53 | int get_query_ipv6_address(const char *ptr_domain, char *normal_ipv6_address); 54 | int get_query_ipv4_address(const char *ptr_domain, char *normal_ipv4_address); 55 | int extract_ipv4_address_from_ipv6_address(const char * new_ipv6_address, char *ipv4_address); 56 | void hex_ipv4_to_dec_ipv4(char *hex,int *dec); 57 | void make_ipv4_ptr_domain(struct in_addr addr, char * ptr_domain); 58 | void make_ipv4_ptr_domain(int *addr, char * ptr_domain); 59 | int my_atoi(const char *name); 60 | 61 | bool failed_query; 62 | 63 | }; 64 | CLICK_ENDDECLS 65 | #endif 66 | -------------------------------------------------------------------------------- /models/.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile autom4te* 2 | config.log config.status config.h 3 | -------------------------------------------------------------------------------- /models/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | autom4te* 3 | config.log 4 | config.status 5 | config.h 6 | -------------------------------------------------------------------------------- /models/Makefile.in: -------------------------------------------------------------------------------- 1 | SHELL = @SHELL@ 2 | 3 | 4 | # THESE VARIABLES MAY CHANGE BETWEEN PACKAGES 5 | 6 | # Set 'package' to the name of your package. 7 | package := @CLICKPACKAGENAME@ 8 | 9 | # Set these variables appropriately. 10 | top_builddir := . 11 | subdir := . 12 | 13 | # Require Click prefix settings. 14 | # Generally, you will provide a '--with-click=CLICKPREFIX' option, and set: 15 | clickbuild_prefix := @clickbuild_prefix@ 16 | include @clickbuild_datadir@/config.mk 17 | include @clickbuild_datadir@/pkg-config.mk 18 | 19 | srcdir = @srcdir@ 20 | top_srcdir = @top_srcdir@ 21 | AUTOCONF = $(CLICKAUTOCONF) 22 | ACLOCAL = : 23 | 24 | TARGETS = package 25 | 26 | all: Makefile $(TARGETS) 27 | 28 | package: Makefile 29 | @cd package && $(MAKE) all 30 | 31 | elemlist: Makefile 32 | @cd package && $(MAKE) elemlist 33 | 34 | install: Makefile 35 | @for d in $(TARGETS); do (cd $$d && $(MAKE) install) || exit 1; done 36 | 37 | install-man: 38 | @cd package && $(MAKE) install-man 39 | 40 | $(srcdir)/configure: $(srcdir)/configure.ac 41 | cd $(srcdir) && $(ACLOCAL) && $(AUTOCONF) 42 | config.status: $(srcdir)/configure 43 | $(SHELL) $(srcdir)/configure @ac_configure_args@ 44 | Makefile: config.status $(srcdir)/Makefile.in 45 | cd $(top_builddir) && \ 46 | CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status 47 | 48 | clean: 49 | @-for d in $(TARGETS); do (cd $$d && $(MAKE) clean); done 50 | 51 | distclean: 52 | @-for d in $(TARGETS); do (cd $$d && $(MAKE) distclean); done 53 | -rm -f Makefile config.status config.cache config.log config.h 54 | 55 | .PHONY: all package elemlist clean distclean \ 56 | install install-doc install-man install-include 57 | -------------------------------------------------------------------------------- /models/README: -------------------------------------------------------------------------------- 1 | THE MODELS PACKAGE FOR CLICK 2 | ============================ 3 | 4 | This directory contains the 'models' addons to the Click modular router. 5 | First make and install Click, then run './configure 6 | --prefix=CLICKINSTALLPREFIX' in this directory, and finally make install. 7 | 8 | The 'package' subdirectory defines a package, "models.uo", which Click will 9 | load in when given the "require(models)" statement. Elements in the package 10 | include CalculateTCPLossEvents. CalculateTCPLossEvents analyzes a trace 11 | that has been separated into TCP flows (such as by AggregateIPFlows), finds 12 | the loss events and other information, and generates an XML file. 13 | 14 | The 'tcpscape' Python script reads this XML file and shows a time-sequence 15 | plot that's easy to navigate. 16 | 17 | The 'scripts/lossxml.sh' script takes a tcpdump file as argument, and 18 | generates an XML loss file in the same directory with the same basename, by 19 | running a short Click configuration. Examples: 20 | 21 | scripts/lossxml.sh examples/sample.dump 22 | # Will create a file examples/sample.xml. 23 | scripts/lossxml.sh --config examples/sample.dump 24 | # Will write a Click script to standard output. 25 | 26 | examples/sample.xml is the output of scripts/lossxml.sh on 27 | examples/sample.dump. 28 | 29 | Try the following two tcpscape invocations to see what information the XML 30 | provides: 31 | 32 | ./tcpscape examples/sample.dump 33 | ./tcpscape examples/sample.xml 34 | 35 | 36 | COPYRIGHT AND LICENSE 37 | --------------------- 38 | 39 | Copyright (c) 2001-2006 Eddie Kohler unless otherwise specified. 40 | Distributed under the Click license. 41 | 42 | AUTHORS 43 | ------- 44 | 45 | Eddie Kohler 46 | Some elements by Jinyang Li 47 | MultiQ element based on code from Chuck Blake (Histogram), Dina Katabi, 48 | and Sachin Katti (MultiQ) 49 | -------------------------------------------------------------------------------- /models/config.h.in: -------------------------------------------------------------------------------- 1 | /* config.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | #ifndef CLICK_PKG_MODELS_CONFIG_H 4 | #define CLICK_PKG_MODELS_CONFIG_H 1 5 | 6 | /* Define to the address where bug reports for this package should be sent. */ 7 | #undef PACKAGE_BUGREPORT 8 | 9 | /* Define to the full name of this package. */ 10 | #undef PACKAGE_NAME 11 | 12 | /* Define to the full name and version of this package. */ 13 | #undef PACKAGE_STRING 14 | 15 | /* Define to the one symbol short name of this package. */ 16 | #undef PACKAGE_TARNAME 17 | 18 | /* Define to the version of this package. */ 19 | #undef PACKAGE_VERSION 20 | 21 | #endif /* CLICK_PKG_MODELS_CONFIG_H */ 22 | -------------------------------------------------------------------------------- /models/double_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kohler/click-packages/cec70da7cf460548ef08f1ddad6924db29d5c0c5/models/double_arrow.png -------------------------------------------------------------------------------- /models/double_arrow_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kohler/click-packages/cec70da7cf460548ef08f1ddad6924db29d5c0c5/models/double_arrow_small.png -------------------------------------------------------------------------------- /models/examples/sample.dump: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kohler/click-packages/cec70da7cf460548ef08f1ddad6924db29d5c0c5/models/examples/sample.dump -------------------------------------------------------------------------------- /models/package/.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile *.d *.kd *.ud *.ko *.uo 2 | kelements.conf kelements.mk kpackage.cc 3 | Kbuild .*.ko.cmd .*.o.cmd .tmp_versions kversion.c models.mod.c 4 | uelements.conf uelements.mk upackage.cc 5 | elementmap-models.xml 6 | -------------------------------------------------------------------------------- /models/package/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | *.d 3 | *.kd 4 | *.ud 5 | *.ko 6 | *.uo 7 | kelements.conf 8 | kelements.mk 9 | kpackage.cc 10 | Kbuild 11 | .*.ko.cmd 12 | .*.o.cmd 13 | .tmp_versions 14 | kversion.c 15 | models.mod.c 16 | uelements.conf 17 | uelements.mk 18 | upackage.cc 19 | elementmap-models.xml 20 | -------------------------------------------------------------------------------- /models/package/Makefile.in: -------------------------------------------------------------------------------- 1 | SHELL = @SHELL@ 2 | 3 | 4 | # THESE VARIABLES MAY CHANGE BETWEEN PACKAGES 5 | 6 | # Set 'package' to the name of your package. 7 | package := @CLICKPACKAGENAME@ 8 | 9 | # Set these variables appropriately. 10 | top_builddir := .. 11 | subdir := package 12 | 13 | # Require Click prefix settings. 14 | # Generally, you will provide a '--with-click=CLICKPREFIX' option, and set: 15 | clickbuild_prefix := @clickbuild_prefix@ 16 | include @clickbuild_datadir@/config.mk 17 | 18 | # Set 'MAKE_UPACKAGE', 'MAKE_KPACKAGE', and 'MAKE_BPACKAGE' to '0' or '1' 19 | # to determine whether to build userlevel, linuxmodule, and bsdmodule 20 | # packages, respectively. 21 | MAKE_UPACKAGE = @BUILD_USERLEVEL@ 22 | MAKE_KPACKAGE = @BUILD_LINUXMODULE@ 23 | MAKE_BPACKAGE = @BUILD_BSDMODULE@ 24 | 25 | # Set 'STRIP_UPACKAGE' to 'strip -g' to strip debugging symbols from the 26 | # userlevel package before installing. 27 | #STRIP_UPACKAGE = $(STRIP) -g 28 | 29 | # Set these variables as required. 30 | DEFS = @DEFS@ $(CLICKDEFS) 31 | INCLUDES = -I. -I$(top_builddir) -I$(srcdir) $(CLICKINCLUDES) 32 | 33 | # Set this variable to force 'click-elem2package' to include a header, 34 | # such as your package's '', if necessary. 35 | #ELEM2PACKAGE_INCLUDES = -i'' 36 | 37 | # END OF VARIABLES THAT MAY CHANGE BETWEEN PACKAGES 38 | 39 | 40 | # Everything below here will probably stay unchanged 41 | 42 | srcdir = @srcdir@ 43 | top_srcdir = @top_srcdir@ 44 | 45 | ifeq ($(CLICK_PACKAGE_MAKING),) 46 | prefix = @prefix@ 47 | exec_prefix = @exec_prefix@ 48 | bindir = @bindir@ 49 | sbindir = @sbindir@ 50 | libdir = @libdir@ 51 | mandir = @mandir@ 52 | datarootdir = @datarootdir@ 53 | datadir = @datadir@ 54 | endif 55 | 56 | include $(clickbuild_datadir)/pkg-Makefile 57 | -------------------------------------------------------------------------------- /models/package/ipaddrcolorpaint.hh: -------------------------------------------------------------------------------- 1 | // -*- c-basic-offset: 4 -*- 2 | #ifndef CLICK_IPADDRCOLORPAINT_HH 3 | #define CLICK_IPADDRCOLORPAINT_HH 4 | #include 5 | #include "ipaddrcolors.hh" 6 | CLICK_DECLS 7 | 8 | /* 9 | =c 10 | 11 | IPAddrColorPaint(FILENAME [, I]) 12 | 13 | =s ipmeasure 14 | 15 | Sets paint annotations based on destination IP address color. 16 | 17 | =d 18 | 19 | Expects IP packets with destination address annotations set. Looks up the 20 | color for each packet's destination address annotation, and assigns the paint 21 | annotation to the corresponding color. Packets whose addresses have unknown 22 | colors, or colors greater than 255, are dropped (or emitted on output 1, if 23 | present). The file FILENAME contains the relevant IP address coloring. 24 | 25 | Keyword arguments are: 26 | 27 | =over 8 28 | 29 | =item CAREFUL 30 | 31 | Boolean. If true, then check that the packet's source and destination 32 | addresses have compatible colors; if not, emit the packet on output 1. Default 33 | is false. 34 | 35 | =back 36 | 37 | =a 38 | 39 | InferIPAddrColors, TestIPAddrColors */ 40 | 41 | class IPAddrColorPaint : public Element, public IPAddrColors { public: 42 | 43 | IPAddrColorPaint(); 44 | ~IPAddrColorPaint(); 45 | 46 | const char *class_name() const { return "IPAddrColorPaint"; } 47 | const char *port_count() const { return "1/1-2"; } 48 | const char *processing() const { return "a/ah"; } 49 | 50 | int configure(const Vector &, ErrorHandler *); 51 | int initialize(ErrorHandler *); 52 | void cleanup(CleanupStage); 53 | 54 | void push(int, Packet *); 55 | Packet *pull(int); 56 | 57 | private: 58 | 59 | String _filename; 60 | bool _careful; 61 | 62 | }; 63 | 64 | CLICK_ENDDECLS 65 | #endif 66 | -------------------------------------------------------------------------------- /models/package/tcpscoreboard.cc: -------------------------------------------------------------------------------- 1 | // -*- mode: c++; c-basic-offset: 4 -*- 2 | #include 3 | #include "tcpscoreboard.hh" 4 | CLICK_DECLS 5 | 6 | void 7 | TCPScoreboard::add(tcp_seq_t seq, tcp_seq_t end_seq) 8 | { 9 | // common cases 10 | if (SEQ_GEQ(seq, end_seq) || SEQ_LEQ(end_seq, _cumack)) 11 | /* nothing to do */; 12 | else if (SEQ_LEQ(seq, _cumack) && !_sack.size()) 13 | _cumack = end_seq; 14 | else if (SEQ_LEQ(seq, _cumack)) { 15 | _cumack = end_seq; 16 | while (_sack.size() && SEQ_GEQ(_cumack, _sack[0])) { 17 | if (SEQ_LT(_cumack, _sack[1])) 18 | _cumack = _sack[1]; 19 | _sack.pop_front(); 20 | _sack.pop_front(); 21 | } 22 | } else if (!_sack.size() || SEQ_GT(seq, _sack.back())) { 23 | _sack.push_back(seq); 24 | _sack.push_back(end_seq); 25 | } else { 26 | int block; 27 | for (block = 0; block < _sack.size(); block += 2) 28 | if (SEQ_LEQ(seq, _sack[block + 1])) { 29 | if (SEQ_LT(end_seq, _sack[block])) { // add new block 30 | _sack.push_back(0); 31 | _sack.push_back(0); 32 | for (int i = _sack.size() - 1; i >= block + 2; i--) 33 | _sack[i] = _sack[i - 2]; 34 | _sack[block] = seq; 35 | _sack[block+1] = end_seq; 36 | } else { 37 | if (SEQ_LEQ(seq, _sack[block])) 38 | _sack[block] = seq; 39 | if (SEQ_GEQ(end_seq, _sack[block+1])) 40 | _sack[block+1] = end_seq; 41 | } 42 | break; 43 | } 44 | } 45 | } 46 | 47 | bool 48 | TCPScoreboard::contains(tcp_seq_t seq, tcp_seq_t end_seq) const 49 | { 50 | // common cases 51 | if (seq == end_seq) 52 | return false; 53 | else if (SEQ_LEQ(end_seq, _cumack)) 54 | return true; 55 | else { 56 | if (SEQ_LT(seq, _cumack)) 57 | seq = _cumack; 58 | for (int block = 0; block < _sack.size(); block += 2) 59 | if (SEQ_LT(seq, _sack[block])) 60 | return false; 61 | else if (SEQ_LEQ(end_seq, _sack[block+1])) 62 | return true; 63 | else if (SEQ_LEQ(seq, _sack[block+1])) 64 | seq = _sack[block+1]; 65 | return false; 66 | } 67 | } 68 | 69 | ELEMENT_PROVIDES(TCPScoreboard) 70 | CLICK_ENDDECLS 71 | -------------------------------------------------------------------------------- /models/package/tcpscoreboard.hh: -------------------------------------------------------------------------------- 1 | // -*- c-basic-offset: 4 -*- 2 | #ifndef CLICK_TCPSCOREBOARD_HH 3 | #define CLICK_TCPSCOREBOARD_HH 4 | #include 5 | #include 6 | CLICK_DECLS 7 | 8 | class TCPScoreboard { public: 9 | 10 | TCPScoreboard(tcp_seq_t cumack = 0) : _cumack(cumack) { } 11 | 12 | inline tcp_seq_t cumack() const { return _cumack; } 13 | bool contains(tcp_seq_t seq, tcp_seq_t end_seq) const; 14 | 15 | inline void clear(tcp_seq_t cumack = 0); 16 | void add(tcp_seq_t seq, tcp_seq_t end_seq); 17 | inline void add_cumack(tcp_seq_t cumack); 18 | 19 | public: 20 | 21 | tcp_seq_t _cumack; 22 | Deque _sack; 23 | 24 | }; 25 | 26 | inline void TCPScoreboard::clear(tcp_seq_t cumack) 27 | { 28 | _cumack = cumack; 29 | _sack.clear(); 30 | } 31 | 32 | inline void TCPScoreboard::add_cumack(tcp_seq_t cumack) 33 | { 34 | add(_cumack, cumack); 35 | } 36 | 37 | CLICK_ENDDECLS 38 | #endif 39 | -------------------------------------------------------------------------------- /models/scripts/lossxml.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | usage () { 4 | echo "Usage: lossxml.sh FILE" 1>&2 5 | exit 1 6 | } 7 | 8 | 9 | doconfig=0 10 | if test "$1" = '--config'; then 11 | shift 1; doconfig=1 12 | fi 13 | 14 | if test $# = 0; then 15 | usage 16 | fi 17 | 18 | wholefile="$1" 19 | if echo "$wholefile" | grep '/' >/dev/null; then 20 | dir=`echo "$wholefile" | sed 's/\(.*\/\)[^\/]*/\1/'` 21 | else 22 | dir='./' 23 | fi 24 | file=`echo "$wholefile" | sed 's/.*\///'` 25 | base=`echo "$file" | sed 's/\.gz// 26 | s/\.dump//'` 27 | 28 | from='' 29 | case $file in 30 | *.dump|*.dump.gz|*.bin) 31 | from='FromDump("'"$file"'", FORCE_IP true, STOP true)';; 32 | *.gz) 33 | text=`zcat "$wholefile" | head -c 2000`;; 34 | *) 35 | text=`head -c 2000 "$wholefile"`;; 36 | esac 37 | 38 | if test -z "$from"; then 39 | hex_a1b2c3d4=`printf "\241\262\303\324"` 40 | hex_d4c3b2a1=`printf "\324\303\262\241"` 41 | case "$text" in 42 | [0-9]*) 43 | from='FromTcpdump("'"$file"'", STOP true)';; 44 | $hex_a1b2c3d4*|$hex_d4c3b2a1*) 45 | from='FromDump("'"$file"'", FORCE_IP true, STOP true)';; 46 | !*) 47 | from='FromIPSummaryDump("'"$file"'", STOP true)';; 48 | *) 49 | echo "lossxml.sh: file type not recognized" 1>&2 50 | usage;; 51 | esac 52 | fi 53 | 54 | shift 1 55 | 56 | config=" 57 | require(models) 58 | fd :: $from 59 | -> aipf :: AggregateIPFlows 60 | -> IPFilter(0 tcp || icmp) 61 | -> loss :: CalculateTCPLossEvents(TRACEINFO $base.xml, /*FLOWDUMPS tifd,*/ SOURCE fd, IP_ID false, NOTIFIER aipf, ACKCAUSALITY true, UNDELIVERED true) 62 | // -> tifd :: ToIPFlowDumps($base.dir, NOTIFIER aipf, TCP_OPT true, TCP_WINDOW true) 63 | -> Discard; 64 | 65 | ProgressBar(fd.filepos, fd.filesize, BANNER '$dir$base') 66 | DriverManager(wait, write loss.clear, /*write tifd.clear,*/ stop) 67 | " 68 | 69 | if test $doconfig = 1; then 70 | echo "$config" 71 | else 72 | cd $dir || { echo "$!\n" 1>&2; exit 1; } 73 | click -e "$config" 74 | fi 75 | -------------------------------------------------------------------------------- /multicast/.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile *.d *.kd *.ud *.ko *.uo 2 | kelements.conf kelements.mk kpackage.cc 3 | Kbuild .*.ko.cmd .*.o.cmd .tmp_versions kversion.c multicast.mod.c 4 | uelements.conf uelements.mk upackage.cc 5 | elementmap-multicast.xml 6 | config.h configure config.log config.status 7 | autom4te* 8 | -------------------------------------------------------------------------------- /multicast/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | *.d 3 | *.kd 4 | *.ud 5 | *.ko 6 | *.uo 7 | kelements.conf 8 | kelements.mk 9 | kpackage.cc 10 | Kbuild 11 | .*.ko.cmd 12 | .*.o.cmd 13 | .tmp_versions 14 | kversion.c 15 | multicast.mod.c 16 | uelements.conf 17 | uelements.mk 18 | upackage.cc 19 | elementmap-multicast.xml 20 | config.h 21 | configure 22 | config.log 23 | config.status 24 | autom4te* 25 | -------------------------------------------------------------------------------- /multicast/Makefile.in: -------------------------------------------------------------------------------- 1 | SHELL = @SHELL@ 2 | 3 | 4 | # THESE VARIABLES MAY CHANGE BETWEEN PACKAGES 5 | 6 | # Set 'package' to the name of your package. 7 | package := @CLICKPACKAGENAME@ 8 | 9 | # Set these variables appropriately. 10 | top_builddir := . 11 | subdir := . 12 | 13 | # Require Click prefix settings. 14 | # Generally, you will provide a '--with-click=CLICKPREFIX' option, and set: 15 | clickbuild_prefix := @clickbuild_prefix@ 16 | include @clickbuild_datadir@/config.mk 17 | 18 | # Set 'MAKE_UPACKAGE', 'MAKE_KPACKAGE', and 'MAKE_BPACKAGE' to '0' or '1' 19 | # to determine whether to build userlevel, linuxmodule, and bsdmodule 20 | # packages, respectively. 21 | MAKE_UPACKAGE = @BUILD_USERLEVEL@ 22 | MAKE_KPACKAGE = @BUILD_LINUXMODULE@ 23 | MAKE_BPACKAGE = @BUILD_BSDMODULE@ 24 | 25 | # Set 'STRIP_UPACKAGE' to 'strip -g' to strip debugging symbols from the 26 | # userlevel package before installing. 27 | #STRIP_UPACKAGE = $(STRIP) -g 28 | 29 | # Set these variables as required. 30 | DEFS = @DEFS@ $(CLICKDEFS) 31 | INCLUDES = -I. -I$(top_builddir) -I$(srcdir) $(CLICKINCLUDES) 32 | 33 | # Set this variable to force 'click-elem2package' to include a header, 34 | # such as your package's '', if necessary. 35 | #ELEM2PACKAGE_INCLUDES = -i'' 36 | 37 | # END OF VARIABLES THAT MAY CHANGE BETWEEN PACKAGES 38 | 39 | 40 | # Everything below here will probably stay unchanged 41 | 42 | srcdir = @srcdir@ 43 | top_srcdir = @top_srcdir@ 44 | 45 | ifeq ($(CLICK_PACKAGE_MAKING),) 46 | prefix = @prefix@ 47 | exec_prefix = @exec_prefix@ 48 | bindir = @bindir@ 49 | sbindir = @sbindir@ 50 | libdir = @libdir@ 51 | mandir = @mandir@ 52 | datarootdir = @datarootdir@ 53 | datadir = @datadir@ 54 | endif 55 | 56 | include $(clickbuild_datadir)/pkg-Makefile 57 | -------------------------------------------------------------------------------- /multicast/debug.hh: -------------------------------------------------------------------------------- 1 | #ifndef MC_DEBUG_HH 2 | #define MC_DEBUG_HH 3 | 4 | #define CLICK_MC_DEBUG 5 | #ifdef CLICK_MC_DEBUG 6 | #define debug_msg(s...) click_chatter(s) 7 | #endif 8 | #ifndef CLICK_MC_DEBUG 9 | #define debug_msg(s...) if(0) 10 | #endif 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /multicast/fixpimsource.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_FIXPIMSOURCE_HH 2 | #define CLICK_FIXPIMSOURCE_HH 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "pimforwardingtable.hh" 9 | CLICK_DECLS 10 | 11 | /* 12 | =c 13 | FixPIMSource(outgoing interface's IP address, PIMForwardingTable) 14 | 15 | =s IPv4 Multicast 16 | 17 | =d 18 | Adds upstream interface IP to PIM join/prune messages and calculates the checksum. 19 | =e 20 | ...-> FixPIMSource(172.20.12.2, "pimft") 21 | 22 | =a 23 | IPMulticastTable, PIM, IGMP, PIMForwardingTable, IPMulticastEtherEncap 24 | 25 | */ 26 | 27 | class FixPIMSource : public Element { 28 | 29 | public: 30 | FixPIMSource(); 31 | ~FixPIMSource(); 32 | 33 | PIMForwardingTable *PIMTable; 34 | 35 | int configure(Vector &, ErrorHandler *); 36 | 37 | 38 | const char *class_name() const { return "FixPIMSource"; } 39 | const char *port_count() const { return PORTS_1_1; } 40 | const char *processing() const { return AGNOSTIC; } 41 | 42 | WritablePacket *fixpimsource(Packet *); 43 | Packet *simple_action(Packet *); 44 | 45 | private: 46 | 47 | IPAddress interfaceaddr; 48 | 49 | // 0, 4 byte 50 | struct PIMMessage { 51 | uint8_t ver_type; 52 | uint8_t reserved; 53 | uint16_t checksum; 54 | uint8_t addr_family; 55 | uint8_t encoding_type; 56 | uint16_t uaddr[2]; 57 | }; 58 | 59 | 60 | 61 | 62 | }; 63 | 64 | CLICK_ENDDECLS 65 | #endif 66 | -------------------------------------------------------------------------------- /multicast/mcastetherencap.hh: -------------------------------------------------------------------------------- 1 | #ifndef McastETHERENCAP_HH 2 | #define McastETHERENCAP_HH 3 | #include 4 | #include 5 | CLICK_DECLS 6 | 7 | /* 8 | =c 9 | 10 | IPMulticastEtherEncap(ETHERTYPE, SRC) 11 | 12 | =s IPv4 Multicast 13 | 14 | =d 15 | 16 | Encapsulates each packet in the Ethernet header specified by its arguments and the packet's Multicast IP destination address. 17 | ETHERTYPE should be in host order. 18 | 19 | =e 20 | 21 | Encapsulate packets in an Ethernet header with type 22 | ETHERTYPE_IP (0x0800) and source address 1:1:1:1:1:1 23 | 24 | EtherEncap(0x0800, 1:1:1:1:1:1) 25 | 26 | the destination MAC address is derived from the packets IP destination address like suggested in RFC1112. 27 | 28 | =n 29 | 30 | For unicast IP packets you probably want to use ARPQuerier or EtherEncap instead. 31 | 32 | =a 33 | 34 | ARPQuerier, EtherEncap, PIM, IGMP 35 | */ 36 | 37 | class IPMulticastEtherEncap : public Element { public: 38 | 39 | IPMulticastEtherEncap(); 40 | ~IPMulticastEtherEncap(); 41 | 42 | const char *class_name() const { return "IPMulticastEtherEncap"; } 43 | const char *port_count() const { return PORTS_1_1; } 44 | const char *processing() const { return AGNOSTIC; } 45 | 46 | int configure(Vector &, ErrorHandler *); 47 | 48 | Packet *smaction(Packet *); 49 | void push(int, Packet *); 50 | Packet *pull(int); 51 | 52 | private: 53 | 54 | click_ether _ethh; 55 | 56 | }; 57 | 58 | CLICK_ENDDECLS 59 | #endif 60 | -------------------------------------------------------------------------------- /multicast/pim.hh: -------------------------------------------------------------------------------- 1 | #ifndef PIM_HH 2 | #define PIM_HH 3 | #include "pimcontrol.hh" 4 | #include "pimforwardingtable.hh" 5 | #include "protocoldefinitions.hh" 6 | #include "ipmulticasttable.hh" 7 | #include 8 | #include 9 | 10 | 11 | /* 12 | =c 13 | PIM(IPMulticastTable, PIMForwardingTable, PIMControl, Interfaceaddress) 14 | 15 | =s IP Multicast 16 | 17 | =d 18 | Handles PIM messages. Arriving PIM messages are checked and processed. 19 | A working Click multicast configuration must have a PIM element attached to each 20 | incoming interface. 21 | This element manages the PIMForwardingTable. 22 | 23 | It manages the databank of PIM receivers kept in the PIMForwardingTable element. 24 | 25 | Takes the interface IP address it is connected to as last argument. 26 | 27 | =e 28 | pim1::PIM("pimft", "pimctl", 192.168.30.6); 29 | ... Paint(0) -> Strip(14) -> CheckIPHeader(INTERFACES 192.168.30.6/32 224.0.0.0/4) -> pim1; 30 | 31 | =a 32 | IPMulticastTable, IGMP, PIMControl, PIMForwardingTable, IPMulticastEtherEncap, FixPIMSource 33 | */ 34 | class PIM : public Element { public: 35 | 36 | PIM(); 37 | ~PIM(); 38 | 39 | PIMForwardingTable *PIMTable; 40 | PIMControl* PIMSpt; 41 | IPMulticastTable* MulticastTable; 42 | 43 | const char *class_name() const { return "PIM"; } 44 | const char *port_count() const { return "1/2"; } 45 | const char *processing() const { return "h/hh"; } 46 | 47 | 48 | int configure(Vector &, ErrorHandler *); 49 | 50 | void push(int port, Packet *); 51 | 52 | private: 53 | IPAddress interface; 54 | unsigned short calculate_checksum(const unsigned char*, int); 55 | }; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /multicast/pimcontrol.hh: -------------------------------------------------------------------------------- 1 | #ifndef PIM_CONTROL_HH 2 | #define PIM_CONTROL_HH 3 | #include "pimforwardingtable.hh" 4 | #include "protocoldefinitions.hh" 5 | #include 6 | #include 7 | 8 | /* 9 | =c 10 | PIMControl(PIMForwardingTable) 11 | 12 | =s IPv4 Multicast 13 | 14 | =d 15 | Handles the PIM protocol, i.e. generation of Hello-messages and detection of connected PIM routers. 16 | This management information is needed for PIMForwardingTable. 17 | 18 | =e 19 | PIMControl("pimft") -> rt; 20 | =a 21 | IPMulticastTable, PIM, IGMP, PIMForwardingTable, IPMulticastEtherEncap, FixPIMSource 22 | 23 | */ 24 | 25 | class PIMControl : public Element { public: 26 | 27 | PIMControl(); 28 | ~PIMControl(); 29 | 30 | bool source_connected; 31 | PIMForwardingTable *PIMTable; 32 | 33 | const char *class_name() const { return "PIMControl"; } 34 | const char *port_count() const { return "0/2"; } 35 | const char *processing() const { return "h/hh"; } 36 | 37 | 38 | 39 | int configure(Vector &, ErrorHandler *); 40 | int initialize(ErrorHandler *); 41 | void join(IPAddress, IPAddress); 42 | void prune(IPAddress, IPAddress); 43 | void generatejoin(IPAddress, IPAddress, bool); 44 | void run_timer(Timer *); 45 | void generate_hello(); 46 | bool noPIMreceivers(IPAddress, IPAddress); 47 | bool noIGMPreceivers(IPAddress, IPAddress); 48 | Timer _timer; 49 | 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /multicast/pimforwardingtable.hh: -------------------------------------------------------------------------------- 1 | #ifndef PIMFORWARDINGTABLE_HH 2 | #define PIMFORWARDINGTABLE_HH 3 | CLICK_DECLS 4 | #include 5 | 6 | /* 7 | =c 8 | PIMForwardingTable() 9 | 10 | =s IPv4 Multicast 11 | 12 | =d 13 | Takes care of arriving multicast traffic. Streams are duplicated and forwarded to neighbouring routers which are connected to Rendezvous Point or Source Path Trees. 14 | 15 | =a 16 | IPMulticastTable, IGMP, PIMControl, PIM, IPMulticastEtherEncap, FixPIMSource 17 | */ 18 | 19 | #define MODE unsigned char 20 | #define INCLUDEMODE 0x00 21 | #define EXCLUDEMODE 0x01 22 | #define MODE_NOT_SET 0x02 23 | 24 | class PIMForwardingTable : public Element { 25 | 26 | 27 | public: 28 | 29 | PIMForwardingTable(); 30 | ~PIMForwardingTable(); 31 | int configure(Vector &, ErrorHandler *); 32 | 33 | const char *class_name() const { return "PIMForwardingTable"; } 34 | const char *port_count() const { return "1/1"; } 35 | const char *processing() const { return "h/h"; } 36 | 37 | /* 38 | * groupsource holds a group address and all allowed sources 39 | * 40 | * a pair of group / source Address is also known as "channel" 41 | * 42 | */ 43 | struct groupsource { 44 | IPAddress neighbor; 45 | IPAddress group; 46 | IPAddress source; 47 | }; 48 | 49 | 50 | /* 51 | * pimtable holds the IP address of an interface and all source/group entries 52 | * 53 | */ 54 | struct piminterface { 55 | IPAddress interface; // interface 56 | IPAddress neighbor; 57 | Vector groupsources; 58 | }; 59 | 60 | Vector piminterfaces; 61 | 62 | bool addinterface(IPAddress, IPAddress); 63 | bool addgroup(IPAddress, IPAddress, IPAddress, IPAddress); 64 | bool delgroup(IPAddress); 65 | bool delgroup(IPAddress, IPAddress, IPAddress, IPAddress); 66 | bool printgroups(); 67 | void push(int, Packet *); 68 | uint32_t get_upstreamneighbor(IPAddress); 69 | bool getPIMreceivers(IPAddress, IPAddress); 70 | }; 71 | 72 | CLICK_ENDDECLS 73 | #endif 74 | -------------------------------------------------------------------------------- /multicast6/.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile *.d *.kd *.ud *.ko *.uo 2 | kelements.conf kelements.mk kpackage.cc 3 | Kbuild .*.ko.cmd .*.o.cmd .tmp_versions kversion.c multicast6.mod.c 4 | uelements.conf uelements.mk upackage.cc 5 | elementmap-multicast6.xml 6 | config.h configure config.log config.status 7 | autom4te* 8 | -------------------------------------------------------------------------------- /multicast6/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | *.d 3 | *.kd 4 | *.ud 5 | *.ko 6 | *.uo 7 | kelements.conf 8 | kelements.mk 9 | kpackage.cc 10 | Kbuild 11 | .*.ko.cmd 12 | .*.o.cmd 13 | .tmp_versions 14 | kversion.c 15 | multicast6.mod.c 16 | uelements.conf 17 | uelements.mk 18 | upackage.cc 19 | elementmap-multicast6.xml 20 | config.h 21 | configure 22 | config.log 23 | config.status 24 | autom4te* 25 | -------------------------------------------------------------------------------- /multicast6/Makefile.in: -------------------------------------------------------------------------------- 1 | SHELL = @SHELL@ 2 | 3 | 4 | # THESE VARIABLES MAY CHANGE BETWEEN PACKAGES 5 | 6 | # Set 'package' to the name of your package. 7 | package := @CLICKPACKAGENAME@ 8 | 9 | # Set these variables appropriately. 10 | top_builddir := . 11 | subdir := . 12 | 13 | # Require Click prefix settings. 14 | # Generally, you will provide a '--with-click=CLICKPREFIX' option, and set: 15 | clickbuild_prefix := @clickbuild_prefix@ 16 | include @clickbuild_datadir@/config.mk 17 | 18 | # Set 'MAKE_UPACKAGE', 'MAKE_KPACKAGE', and 'MAKE_BPACKAGE' to '0' or '1' 19 | # to determine whether to build userlevel, linuxmodule, and bsdmodule 20 | # packages, respectively. 21 | MAKE_UPACKAGE = @BUILD_USERLEVEL@ 22 | MAKE_KPACKAGE = @BUILD_LINUXMODULE@ 23 | MAKE_BPACKAGE = @BUILD_BSDMODULE@ 24 | 25 | # Set 'STRIP_UPACKAGE' to 'strip -g' to strip debugging symbols from the 26 | # userlevel package before installing. 27 | #STRIP_UPACKAGE = $(STRIP) -g 28 | 29 | # Set these variables as required. 30 | DEFS = @DEFS@ $(CLICKDEFS) 31 | INCLUDES = -I. -I$(top_builddir) -I$(srcdir) $(CLICKINCLUDES) 32 | 33 | # Set this variable to force 'click-elem2package' to include a header, 34 | # such as your package's '', if necessary. 35 | #ELEM2PACKAGE_INCLUDES = -i'' 36 | 37 | # END OF VARIABLES THAT MAY CHANGE BETWEEN PACKAGES 38 | 39 | 40 | # Everything below here will probably stay unchanged 41 | 42 | srcdir = @srcdir@ 43 | top_srcdir = @top_srcdir@ 44 | 45 | ifeq ($(CLICK_PACKAGE_MAKING),) 46 | prefix = @prefix@ 47 | exec_prefix = @exec_prefix@ 48 | bindir = @bindir@ 49 | sbindir = @sbindir@ 50 | libdir = @libdir@ 51 | mandir = @mandir@ 52 | datarootdir = @datarootdir@ 53 | datadir = @datadir@ 54 | endif 55 | 56 | include $(clickbuild_datadir)/pkg-Makefile 57 | -------------------------------------------------------------------------------- /multicast6/debug.hh: -------------------------------------------------------------------------------- 1 | #ifndef MC_DEBUG_HH 2 | #define MC_DEBUG_HH 3 | 4 | // #define CLICK_MC_DEBUG 5 | #ifdef CLICK_MC_DEBUG 6 | #define debug_msg(s...) click_chatter(s) 7 | #endif 8 | #ifndef CLICK_MC_DEBUG 9 | #define debug_msg(s...) if(0) 10 | #endif 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /multicast6/fixip6src.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_FIXIP6SRC_HH 2 | #define CLICK_FIXIP6SRC_HH 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | CLICK_DECLS 9 | 10 | /* 11 | * =c 12 | * FixIP6Src(IPADDR) 13 | * =s IPv6 14 | * sets IP source field if requested by annotation 15 | * =d 16 | * 17 | * Expects an IP packet as input. It 18 | * changes its IP source address field to IPADDR and recomputes the checksum. 19 | * It is used by MLD and PIM to set the correct outgoing interface IP6 address. 20 | * 21 | * =a MLD, PIM */ 22 | 23 | class FixIP6Src : public Element { 24 | 25 | 26 | public: 27 | FixIP6Src(); 28 | ~FixIP6Src(); 29 | 30 | IP6Address fixip6addr; 31 | // IP6Address src_ip; 32 | 33 | const char *class_name() const { return "FixIP6Src"; } 34 | const char *port_count() const { return PORTS_1_1; } 35 | const char *processing() const { return AGNOSTIC; } 36 | int configure(Vector &, ErrorHandler *); 37 | void printIP6(IP6Address); 38 | WritablePacket *fix_it(Packet *p_in); 39 | Packet *simple_action(Packet *); 40 | 41 | }; 42 | 43 | CLICK_ENDDECLS 44 | #endif 45 | -------------------------------------------------------------------------------- /multicast6/icmp6checksum.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_ICMP6CHECKSUM_HH 2 | #define CLICK_ICMP6CHECKSUM_HH 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | CLICK_DECLS 9 | 10 | /* 11 | * =c 12 | * ICMP6Checksum() 13 | * =s IPv6 14 | * computes ICMP6 messages checksum 15 | * =d 16 | * 17 | * Expects an IPv6 packet as input. Caclulates RFC 2463/2460 checksum. 18 | * 19 | * =a */ 20 | 21 | class ICMP6Checksum : public Element { 22 | 23 | 24 | public: 25 | ICMP6Checksum(); 26 | ~ICMP6Checksum(); 27 | 28 | const char *class_name() const { return "ICMP6Checksum"; } 29 | const char *port_count() const { return PORTS_1_1; } 30 | const char *processing() const { return AGNOSTIC; } 31 | WritablePacket *addchecksum(Packet *); 32 | void printIP6(IP6Address); 33 | Packet *simple_action(Packet *); 34 | 35 | 36 | private: 37 | 38 | struct hopbyhopheader { 39 | unsigned char type; 40 | unsigned char length; 41 | unsigned short parameter; 42 | unsigned int empty; 43 | }; 44 | struct mldv2querie { 45 | unsigned char type; // 1 byte 46 | unsigned char code; // 1 byte 47 | unsigned short checksum; // 2 byte 48 | unsigned short responsecode; // 2 byte 49 | unsigned short reserved; // 2 byte 50 | click_in6_addr group; // 16 byte 51 | unsigned char res_and_s_and_qrv; // 1 byte 52 | unsigned char qqic; // 1 byte 53 | unsigned short no_of_sources; // 2 byte 54 | // IP6Address sources[1]; 55 | }; 56 | 57 | 58 | }; 59 | 60 | CLICK_ENDDECLS 61 | #endif 62 | -------------------------------------------------------------------------------- /multicast6/ip6fixpimsource.hh: -------------------------------------------------------------------------------- 1 | #ifndef IP6CLICK_FIXPIMSOURCE_HH 2 | #define IP6CLICK_FIXPIMSOURCE_HH 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "ip6pimforwardingtable.hh" 9 | 10 | /* 11 | =c 12 | IP6FixPIMSource(PIMForwardingTable) 13 | 14 | =s IPv6 Multicast 15 | 16 | =d 17 | Adds upstream interface IP to PIM join/prune messages and calculates the checksum. 18 | =e 19 | ...-> FixPIMSource(3ffe:1001:7d0:2::3, "pimft") 20 | 21 | =e 22 | IP6FixPIMSource("pimft") -> rt; 23 | =a 24 | IP6MulticastTable, IP6PIM, MLD, IP6PIMForwardingTable, IP6MC_EtherEncap, IP6PIMControl 25 | 26 | */ 27 | 28 | class IP6FixPIMSource : public Element { 29 | 30 | 31 | public: 32 | IP6FixPIMSource(); 33 | ~IP6FixPIMSource(); 34 | 35 | IP6PIMForwardingTable *PIMTable; 36 | 37 | int configure(Vector &, ErrorHandler *); 38 | 39 | 40 | const char *class_name() const { return "IP6FixPIMSource"; } 41 | const char *port_count() const { return PORTS_1_1; } 42 | const char *processing() const { return AGNOSTIC; } 43 | 44 | WritablePacket *fixpimsource(Packet *); 45 | Packet *simple_action(Packet *); 46 | 47 | 48 | private: 49 | 50 | click_in6_addr interfaceaddr; 51 | 52 | // 0, 4 byte 53 | struct PIMMessage { 54 | uint8_t ver_type; 55 | uint8_t reserved; 56 | uint16_t checksum; 57 | uint8_t addr_family; 58 | uint8_t encoding_type; 59 | uint8_t uaddr[16]; 60 | }; 61 | 62 | 63 | 64 | 65 | }; 66 | 67 | CLICK_ENDDECLS 68 | #endif 69 | -------------------------------------------------------------------------------- /multicast6/ip6mcastetherencap.hh: -------------------------------------------------------------------------------- 1 | #ifndef IP6MC_ETHERENCAP_HH 2 | #define IP6MC_ETHERENCAP_HH 3 | #include 4 | #include 5 | CLICK_DECLS 6 | 7 | /* 8 | =c 9 | 10 | IP6MC_EtherEncap(ETHERTYPE, SRC) 11 | 12 | =s IPv6 Multicast 13 | 14 | =d 15 | 16 | Encapsulates each packet in the Ethernet header specified by its arguments and the packet's Multicast IP destination address. 17 | ETHERTYPE should be in host order. 18 | 19 | =e 20 | 21 | Encapsulate packets in an Ethernet header with type 22 | ETHERTYPE_IP (0x0800) and source address 1:1:1:1:1:1 23 | 24 | EtherEncap(0x0800, 1:1:1:1:1:1) 25 | 26 | the destination MAC address is derived from the packets IP destination address like suggested in RFC1112. 27 | 28 | =n 29 | 30 | For unicast IP packets you probably want to use ARPQuerier or EtherEncap instead. 31 | 32 | =a 33 | 34 | ARPQuerier, EtherEncap, PIM, IGMP 35 | */ 36 | 37 | class IP6mc_EtherEncap : public Element { public: 38 | 39 | IP6mc_EtherEncap(); 40 | ~IP6mc_EtherEncap(); 41 | 42 | const char *class_name() const { return "IP6mc_EtherEncap"; } 43 | const char *port_count() const { return PORTS_1_1; } 44 | const char *processing() const { return AGNOSTIC; } 45 | 46 | int configure(Vector &, ErrorHandler *); 47 | 48 | Packet *smaction(Packet *); 49 | void push(int, Packet *); 50 | Packet *pull(int); 51 | 52 | private: 53 | 54 | click_ether _ethh; 55 | 56 | }; 57 | 58 | CLICK_ENDDECLS 59 | #endif 60 | -------------------------------------------------------------------------------- /multicast6/ip6pim.hh: -------------------------------------------------------------------------------- 1 | #ifndef IP6PIM_HH 2 | #define IP6PIM_HH 3 | #include "ip6pimcontrol.hh" 4 | #include "ip6multicasttable.hh" 5 | #include "ip6pimforwardingtable.hh" 6 | #include "ip6protocoldefinitions.hh" 7 | #include 8 | #include 9 | #include 10 | 11 | /* 12 | =c 13 | IP6PIM(IP6PIMForwardingTable, IP6PIMControl, Interfaceaddress) 14 | 15 | =s IPv6 Multicast 16 | 17 | =d 18 | Handles PIM messages. Arriving PIM messages are checked and processed. 19 | A working Click multicast configuration must have a PIM element attached to each 20 | incoming interface. 21 | This element manages the IP6PIMForwardingTable. 22 | 23 | It manages the databank of PIM receivers kept in the IP6PIMForwardingTable element. 24 | 25 | Takes the interface IP address it is connected to as last argument. 26 | 27 | =e 28 | pim1::IP6PIM("pimft", "pimctl", 3ffe:1001:7d0:2::3); 29 | 30 | =a 31 | IP6MulticastTable, MLD, IP6PIMControl, IP6PIMForwardingTable, IP6MC_EtherEncap, IP6FixPIMSource 32 | */ 33 | 34 | class IP6PIM : public Element { public: 35 | 36 | IP6PIM(); 37 | ~IP6PIM(); 38 | 39 | IP6PIMForwardingTable *PIMTable; 40 | IP6PIMControl* PIMSpt; 41 | IP6MulticastTable* MulticastTable; 42 | 43 | const char *class_name() const { return "IP6PIM"; } 44 | const char *port_count() const { return "1/2"; } 45 | const char *processing() const { return "h/hh"; } 46 | 47 | 48 | int configure(Vector &, ErrorHandler *); 49 | 50 | 51 | void push(int port, Packet *); 52 | IP6Address extract_rp(IP6Address); 53 | 54 | 55 | 56 | private: 57 | click_in6_addr interface; 58 | unsigned short calculate_checksum(const unsigned char*, int); 59 | }; 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /multicast6/ip6pimcontrol.hh: -------------------------------------------------------------------------------- 1 | #ifndef IP6PIM_CONTROL_HH 2 | #define IP6PIM_CONTROL_HH 3 | #include "ip6pimforwardingtable.hh" 4 | #include "ip6protocoldefinitions.hh" 5 | #include 6 | #include 7 | 8 | /* 9 | =c 10 | IP6PIMControl(IP6PIMForwardingTable) 11 | 12 | =s IPv6 Multicast 13 | 14 | =d 15 | Handles the PIM protocol, i.e. generation of Hello-messages and detection of connected PIM routers. 16 | This management information is needed for PIMForwardingTable. 17 | 18 | =e 19 | IP6PIMControl("pimft") -> rt; 20 | =a 21 | IP6MulticastTable, IP6PIM, MLD, IP6PIMForwardingTable, IP6MC_EtherEncap, IP6FixPIMSource 22 | 23 | */ 24 | 25 | 26 | class IP6PIMControl : public Element { public: 27 | 28 | IP6PIMControl(); 29 | ~IP6PIMControl(); 30 | 31 | bool source_connected; 32 | 33 | IP6PIMForwardingTable *PIMTable; 34 | 35 | const char *class_name() const { return "IP6PIMControl"; } 36 | const char *port_count() const { return "0/1"; } 37 | const char *processing() const { return "h/h"; } 38 | 39 | int configure(Vector &, ErrorHandler *); 40 | int initialize(ErrorHandler *); 41 | void generatejoinprune(IP6Address, IP6Address, bool); 42 | void run_timer(Timer *); 43 | void generate_hello(); 44 | Timer _timer; 45 | bool noPIMreceivers(IP6Address, IP6Address); 46 | IP6Address extract_rp(IP6Address); 47 | }; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /multicast6/ip6pimforwardingtable.hh: -------------------------------------------------------------------------------- 1 | #ifndef IP6PIMFORWARDINGTABLE_HH 2 | #define IP6PIMFORWARDINGTABLE_HH 3 | CLICK_DECLS 4 | #include 5 | #include 6 | 7 | /* 8 | =c 9 | IP6PIMForwardingTable() 10 | 11 | =s IPv6 Multicast 12 | 13 | =d 14 | Takes care of arriving multicast traffic. Streams are duplicated and forwarded to neighbouring routers which are connected to Rendezvous Point or Source Path Trees. 15 | 16 | =a 17 | IPv6MulticastTable, MLD, IP6PIMControl, IP6PIM, IP6MC_EtherEncap, IP6FixPIMSource 18 | */ 19 | 20 | #define MODE unsigned char 21 | #define INCLUDEMODE 0x00 22 | #define EXCLUDEMODE 0x01 23 | #define MODE_NOT_SET 0x02 24 | 25 | class IP6PIMForwardingTable : public Element { 26 | 27 | 28 | public: 29 | 30 | IP6PIMForwardingTable(); 31 | ~IP6PIMForwardingTable(); 32 | int configure(Vector &, ErrorHandler *); 33 | 34 | const char *class_name() const { return "IP6PIMForwardingTable"; } 35 | const char *port_count() const { return "1/1"; } 36 | const char *processing() const { return "h/h"; } 37 | 38 | /* 39 | * groupsource holds a group address and all allowed sources 40 | * 41 | * a pair of group / source Address is also known as "channel" 42 | * 43 | */ 44 | struct groupsource { 45 | IP6Address neighbor; 46 | IP6Address group; 47 | IP6Address source; 48 | }; 49 | 50 | 51 | /* 52 | * pimtable holds the IP address of an interface and all source/group entries 53 | * 54 | */ 55 | struct piminterface { 56 | IP6Address interface; // interface 57 | IP6Address neighbor; // neighbor interface 58 | Vector groupsources; 59 | }; 60 | 61 | Vector piminterfaces; 62 | click_in6_addr get_upstreamneighbor(IP6Address); 63 | bool addinterface(IP6Address, IP6Address); 64 | bool addgroup(IP6Address, IP6Address, IP6Address, IP6Address); 65 | bool delgroup(IP6Address); 66 | bool delgroup(IP6Address, IP6Address, IP6Address, IP6Address); 67 | bool printgroups(); 68 | void push(int, Packet *); 69 | bool getPIMreceivers(IP6Address, IP6Address); 70 | }; 71 | 72 | CLICK_ENDDECLS 73 | #endif 74 | -------------------------------------------------------------------------------- /netflow/.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile *.d *.kd *.ud *.ko *.uo 2 | kelements.conf kelements.mk kpackage.cc 3 | Kbuild .*.ko.cmd .*.o.cmd .tmp_versions kversion.c netflow.mod.c 4 | uelements.conf uelements.mk upackage.cc 5 | elementmap-netflow.xml 6 | config.h configure config.log config.status 7 | autom4te* 8 | -------------------------------------------------------------------------------- /netflow/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | *.d 3 | *.kd 4 | *.ud 5 | *.ko 6 | *.uo 7 | kelements.conf 8 | kelements.mk 9 | kpackage.cc 10 | Kbuild 11 | .*.ko.cmd 12 | .*.o.cmd 13 | .tmp_versions 14 | kversion.c 15 | netflow.mod.c 16 | uelements.conf 17 | uelements.mk 18 | upackage.cc 19 | elementmap-netflow.xml 20 | config.h 21 | configure 22 | config.log 23 | config.status 24 | autom4te* 25 | stampa 26 | -------------------------------------------------------------------------------- /netflow/Makefile.in: -------------------------------------------------------------------------------- 1 | SHELL = @SHELL@ 2 | 3 | 4 | # THESE VARIABLES MAY CHANGE BETWEEN PACKAGES 5 | 6 | # Set 'package' to the name of your package. 7 | package := @CLICKPACKAGENAME@ 8 | 9 | # Set these variables appropriately. 10 | top_builddir := . 11 | subdir := . 12 | 13 | # Require Click prefix settings. 14 | # Generally, you will provide a '--with-click=CLICKPREFIX' option, and set: 15 | clickbuild_prefix := @clickbuild_prefix@ 16 | include @clickbuild_datadir@/config.mk 17 | 18 | # Set 'MAKE_UPACKAGE', 'MAKE_KPACKAGE', and 'MAKE_BPACKAGE' to '0' or '1' 19 | # to determine whether to build userlevel, linuxmodule, and bsdmodule 20 | # packages, respectively. 21 | MAKE_UPACKAGE = @BUILD_USERLEVEL@ 22 | MAKE_KPACKAGE = @BUILD_LINUXMODULE@ 23 | MAKE_BPACKAGE = @BUILD_BSDMODULE@ 24 | 25 | # Set 'STRIP_UPACKAGE' to 'strip -g' to strip debugging symbols from the 26 | # userlevel package before installing. 27 | #STRIP_UPACKAGE = $(STRIP) -g 28 | 29 | # Set these variables as required. 30 | DEFS = @DEFS@ $(CLICKDEFS) 31 | INCLUDES = -I. -I$(top_builddir) -I$(srcdir) $(CLICKINCLUDES) 32 | 33 | # Set this variable to force 'click-elem2package' to include a header, 34 | # such as your package's '', if necessary. 35 | #ELEM2PACKAGE_INCLUDES = -i'' 36 | 37 | # END OF VARIABLES THAT MAY CHANGE BETWEEN PACKAGES 38 | 39 | 40 | # Everything below here will probably stay unchanged 41 | 42 | srcdir = @srcdir@ 43 | top_srcdir = @top_srcdir@ 44 | 45 | ifeq ($(CLICK_PACKAGE_MAKING),) 46 | prefix = @prefix@ 47 | exec_prefix = @exec_prefix@ 48 | bindir = @bindir@ 49 | sbindir = @sbindir@ 50 | libdir = @libdir@ 51 | mandir = @mandir@ 52 | datarootdir = @datarootdir@ 53 | datadir = @datadir@ 54 | endif 55 | 56 | include $(clickbuild_datadir)/pkg-Makefile 57 | 58 | 59 | # Also build mkipfixtypes 60 | 61 | mkipfixtypes ipfixtypes: 62 | @cd mkipfixtypes && $(MAKE) all 63 | $(srcdir)/ipfixtypes.hh: $(srcdir)/mkipfixtypes/ipfixtypes.py $(wildcard $(srcdir)/mkipfixtypes/*.xml) 64 | @cd mkipfixtypes && $(MAKE) all 65 | 66 | .PHONY: mkipfixtypes ipfixtypes 67 | -------------------------------------------------------------------------------- /netflow/mkipfixtypes/.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile *.d 2 | -------------------------------------------------------------------------------- /netflow/mkipfixtypes/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | *.d 3 | -------------------------------------------------------------------------------- /netflow/mkipfixtypes/Makefile.in: -------------------------------------------------------------------------------- 1 | # 2 | # Build ipfixtypes.hh from the IPFIX specification and schema 3 | # 4 | # Copyright (c) 2006 Mazu Networks, Inc. 5 | # 6 | # $Id: Makefile.in,v 1.2 2006/05/19 22:40:09 eddietwo Exp $ 7 | # 8 | 9 | SHELL = @SHELL@ 10 | PYTHON = python 11 | 12 | top_srcdir = @top_srcdir@ 13 | srcdir = @srcdir@ 14 | top_builddir = .. 15 | subdir = mkipfixtypes 16 | 17 | all: $(top_srcdir)/ipfixtypes.hh 18 | all-local: all 19 | 20 | IPFIXTYPES_XML = $(wildcard $(srcdir)/*.xml) 21 | $(top_srcdir)/ipfixtypes.hh: $(srcdir)/ipfixtypes.py $(IPFIXTYPES_XML) always 22 | $(PYTHON) $(srcdir)/ipfixtypes.py $(IPFIXTYPES_XML) > $@ 23 | 24 | install: all-local 25 | install-local: all-local 26 | 27 | Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status 28 | cd $(top_builddir) \ 29 | && CONFIG_FILES=$(subdir)/$@ CONFIG_ELEMLISTS=no CONFIG_HEADERS= $(SHELL) ./config.status 30 | 31 | clean distclean uninstall always: 32 | @: 33 | 34 | .PHONY: all all-local clean distclean install install-local uninstall always 35 | -------------------------------------------------------------------------------- /netflow/mkipfixtypes/cisco.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 13 | 14 | 15 | Shortened interface name e.g. "FE1/0" 16 | 17 | 18 | 19 | 20 | See Cisco NetFlow Version 9 Flow-Record Format. 21 | 22 | 23 | 24 | 25 | 29 | 30 | 31 | Full interface name e.g. "FastEthernet 1/0" 32 | 33 | 34 | 35 | 36 | See Cisco NetFlow Version 9 Flow-Record Format. 37 | 38 | 39 | 40 | 41 | 45 | 46 | 47 | Name of the flow sampler 48 | 49 | 50 | 51 | 52 | See Cisco NetFlow Version 9 Flow-Record Format. 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /netflow/netflowprint.hh: -------------------------------------------------------------------------------- 1 | #ifndef NETFLOWPRINT_HH 2 | #define NETFLOWPRINT_HH 3 | 4 | #include 5 | #include 6 | #include "netflowtemplatecache.hh" 7 | CLICK_DECLS 8 | 9 | /* 10 | =c 11 | 12 | NetflowPrint([LABEL, KEYWORDS]) 13 | 14 | =s Netflow 15 | 16 | prints human-readable summary of Cisco NetFlow packets 17 | 18 | =d 19 | 20 | Prints a human-readable summary of Cisco NetFlow packets, optionally preceded 21 | by the TAG text. Incoming packets must have their IP header annotation set. 22 | Only UDP/IP-encapsulated NetFlow packets are printed, but all packets are 23 | forwarded to the single output port. 24 | 25 | Keyword arguments are: 26 | 27 | =over 8 28 | 29 | =item RECORDS 30 | 31 | Boolean. Determines whether to print individual flow records or not. Default 32 | is false. 33 | 34 | =item VERBOSE 35 | 36 | Boolean. Determines whether output should be very verbose or not. Default 37 | is false. 38 | 39 | =item CACHE 40 | 41 | The name of a NetflowTemplateCache element. If specified, then 42 | NetflowPrint will be able to print data records from Netflow V9 43 | flowsets. 44 | 45 | =item OUTFILE 46 | 47 | String. Only available at user level. Print information to the file specified 48 | by OUTFILE instead of standard error. 49 | 50 | =back 51 | 52 | =a 53 | 54 | NetflowArrivalCounter, UnsummarizeNetflow */ 55 | 56 | class NetflowPrint : public Element { 57 | public: 58 | 59 | NetflowPrint(); 60 | ~NetflowPrint(); 61 | 62 | const char *class_name() const { return "NetflowPrint"; } 63 | const char *port_count() const { return PORTS_1_1; } 64 | const char *processing() const { return AGNOSTIC; } 65 | 66 | int configure(Vector &, ErrorHandler *); 67 | int initialize(ErrorHandler *); 68 | void cleanup(CleanupStage); 69 | 70 | Packet *simple_action(Packet *); 71 | 72 | private: 73 | 74 | String _tag; 75 | bool _verbose; 76 | bool _records; 77 | NetflowTemplateCache *_template_cache; 78 | 79 | #if CLICK_USERLEVEL 80 | String _outfilename; 81 | FILE *_outfile; 82 | #endif 83 | 84 | }; 85 | 86 | CLICK_ENDDECLS 87 | #endif 88 | -------------------------------------------------------------------------------- /netflow/netflowtemplate.cc: -------------------------------------------------------------------------------- 1 | // -*- mode: c++; c-basic-offset: 2 -*- 2 | // 3 | // netflowtemplate.{cc,hh} -- represents a Netflow V9/IPFIX template 4 | // record 5 | // 6 | // Copyright (c) 2006 Mazu Networks, Inc. 7 | // 8 | 9 | #include 10 | #include "netflowtemplate.hh" 11 | CLICK_DECLS 12 | 13 | CLICK_ENDDECLS 14 | ELEMENT_PROVIDES(NetflowTemplate) 15 | -------------------------------------------------------------------------------- /netflow/netflowtemplate.hh: -------------------------------------------------------------------------------- 1 | // -*- mode: c++; c-basic-offset: 2 -*- 2 | // 3 | // netflowtemplate.{cc,hh} -- represents a Netflow V9/IPFIX template 4 | // record 5 | // 6 | // Copyright (c) 2006 Mazu Networks, Inc. 7 | // 8 | 9 | #ifndef NETFLOWTEMPLATE_HH 10 | #define NETFLOWTEMPLATE_HH 11 | 12 | #include 13 | CLICK_DECLS 14 | 15 | class NetflowTemplateField { 16 | 17 | public: 18 | 19 | NetflowTemplateField(uint32_t enterprise, uint16_t type, uint16_t length) 20 | : _enterprise(enterprise), _type(type), _length(length) { } 21 | 22 | uint32_t enterprise() const { return _enterprise; } 23 | uint16_t type() const { return _type; } 24 | uint16_t length() const { return _length; } 25 | 26 | private: 27 | uint32_t _enterprise; /* Enterprise number */ 28 | uint16_t _type; /* Field type (see below) */ 29 | uint16_t _length; /* Length in bytes of field value, 65535 means variable length */ 30 | }; 31 | 32 | class NetflowTemplate : public Vector { 33 | 34 | public: 35 | 36 | NetflowTemplate() { } 37 | 38 | unsigned length() const { 39 | unsigned ret = 0; 40 | 41 | for (int i = 0; i < size(); i++) { 42 | if (at(i).length() != 65535) { 43 | // Do not include variable length fields in the total 44 | ret += at(i).length(); 45 | } 46 | } 47 | 48 | return ret; 49 | } 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /netflow/netflowtemplatecache.cc: -------------------------------------------------------------------------------- 1 | // -*- mode: c++; c-basic-offset: 2 -*- 2 | // 3 | // netflowtemplatecache.{cc,hh} -- caches Netflow V9/IPFIX templates 4 | // 5 | // Copyright (c) 2006 Mazu Networks, Inc. 6 | // 7 | 8 | #include 9 | #include "netflowtemplatecache.hh" 10 | #include 11 | CLICK_DECLS 12 | 13 | bool 14 | NetflowTemplateCache::remove(IPAddress srcaddr, uint32_t source_id, uint16_t template_id) 15 | { 16 | const Netflow_Template_Key key = { srcaddr, source_id, template_id }; 17 | 18 | for (Table::iterator iter = _t.begin(); iter.live(); iter++) { 19 | if (key == iter.key()) { 20 | _t.erase(key); 21 | return true; 22 | } 23 | } 24 | 25 | return false; 26 | } 27 | 28 | bool 29 | NetflowTemplateCache::remove(IPAddress srcaddr, uint32_t source_id) 30 | { 31 | bool removed = false; 32 | 33 | for (Table::iterator iter = _t.begin(); iter.live(); iter++) { 34 | const Netflow_Template_Key key = iter.key(); 35 | if (key.srcaddr == srcaddr && key.source_id == source_id) { 36 | _t.erase(key); 37 | removed = true; 38 | } 39 | } 40 | 41 | return removed; 42 | } 43 | 44 | ELEMENT_REQUIRES(NetflowTemplate) 45 | EXPORT_ELEMENT(NetflowTemplateCache) 46 | CLICK_ENDDECLS 47 | -------------------------------------------------------------------------------- /roofnet/.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile *.d *.kd *.ud *.ko *.uo 2 | kelements.conf kelements.mk kpackage.cc 3 | Kbuild .*.ko.cmd .*.o.cmd .tmp_versions kversion.c roofnet.mod.c 4 | uelements.conf uelements.mk upackage.cc 5 | elementmap-roofnet.xml 6 | config.h configure config.log config.status 7 | autom4te* 8 | -------------------------------------------------------------------------------- /roofnet/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | *.d 3 | *.kd 4 | *.ud 5 | *.ko 6 | *.uo 7 | kelements.conf 8 | kelements.mk 9 | kpackage.cc 10 | Kbuild 11 | .*.ko.cmd 12 | .*.o.cmd 13 | .tmp_versions 14 | kversion.c 15 | roofnet.mod.c 16 | uelements.conf 17 | uelements.mk 18 | upackage.cc 19 | elementmap-roofnet.xml 20 | config.h 21 | configure 22 | config.log 23 | config.status 24 | autom4te* 25 | -------------------------------------------------------------------------------- /roofnet/Makefile.in: -------------------------------------------------------------------------------- 1 | SHELL = @SHELL@ 2 | 3 | 4 | # THESE VARIABLES MAY CHANGE BETWEEN PACKAGES 5 | 6 | # Set 'package' to the name of your package. 7 | package := @CLICKPACKAGENAME@ 8 | 9 | # Set these variables appropriately. 10 | top_builddir := . 11 | subdir := . 12 | 13 | # Require Click prefix settings. 14 | # Generally, you will provide a '--with-click=CLICKPREFIX' option, and set: 15 | clickbuild_prefix := @clickbuild_prefix@ 16 | include @clickbuild_datadir@/config.mk 17 | 18 | # Set 'MAKE_UPACKAGE', 'MAKE_KPACKAGE', and 'MAKE_BPACKAGE' to '0' or '1' 19 | # to determine whether to build userlevel, linuxmodule, and bsdmodule 20 | # packages, respectively. 21 | MAKE_UPACKAGE = @BUILD_USERLEVEL@ 22 | MAKE_KPACKAGE = @BUILD_LINUXMODULE@ 23 | MAKE_BPACKAGE = @BUILD_BSDMODULE@ 24 | 25 | # Set 'STRIP_UPACKAGE' to 'strip -g' to strip debugging symbols from the 26 | # userlevel package before installing. 27 | #STRIP_UPACKAGE = $(STRIP) -g 28 | 29 | # Set these variables as required. 30 | DEFS = @DEFS@ $(CLICKDEFS) 31 | INCLUDES = -I. -I$(top_builddir) -I$(srcdir) $(CLICKINCLUDES) 32 | 33 | # Set this variable to force 'click-elem2package' to include a header, 34 | # such as your package's '', if necessary. 35 | #ELEM2PACKAGE_INCLUDES = -i'' 36 | 37 | # END OF VARIABLES THAT MAY CHANGE BETWEEN PACKAGES 38 | 39 | 40 | # Everything below here will probably stay unchanged 41 | 42 | srcdir = @srcdir@ 43 | top_srcdir = @top_srcdir@ 44 | 45 | ifeq ($(CLICK_PACKAGE_MAKING),) 46 | prefix = @prefix@ 47 | exec_prefix = @exec_prefix@ 48 | bindir = @bindir@ 49 | sbindir = @sbindir@ 50 | libdir = @libdir@ 51 | mandir = @mandir@ 52 | datarootdir = @datarootdir@ 53 | datadir = @datadir@ 54 | endif 55 | 56 | include $(clickbuild_datadir)/pkg-Makefile 57 | -------------------------------------------------------------------------------- /roofnet/analysis/counterrors.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_COUNTERRORS_HH 2 | #define CLICK_COUNTERRORS_HH 3 | #include 4 | #include 5 | #include 6 | #include 7 | CLICK_DECLS 8 | 9 | class CountErrors : public Element { public: 10 | 11 | CountErrors(); 12 | ~CountErrors(); 13 | 14 | const char *class_name() const { return "CountErrors"; } 15 | const char *port_count() const { return PORTS_1_1; } 16 | const char *processing() const { return PUSH; } 17 | 18 | int configure(Vector &, ErrorHandler *); 19 | bool can_live_reconfigure() const { return true; } 20 | 21 | void push (int port, Packet *p_in); 22 | 23 | void add_handlers(); 24 | 25 | EtherAddress _bcast; 26 | 27 | int _sum_signal; 28 | int _sum_noise; 29 | int _packets; 30 | 31 | unsigned _length; 32 | uint16_t _et; 33 | EtherAddress _src; 34 | int good_packet; 35 | bool _runs; 36 | 37 | int _ok_bytes; 38 | int _error_bytes; 39 | int _correct_threshold; 40 | }; 41 | 42 | CLICK_ENDDECLS 43 | #endif 44 | -------------------------------------------------------------------------------- /roofnet/analysis/countfecbytes.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_COUNTFECBYTES_HH 2 | #define CLICK_COUNTFECBYTES_HH 3 | #include 4 | #include 5 | #include 6 | #include 7 | CLICK_DECLS 8 | 9 | class CountFecBytes : public Element { public: 10 | 11 | CountFecBytes(); 12 | ~CountFecBytes(); 13 | 14 | const char *class_name() const { return "CountFecBytes"; } 15 | const char *port_count() const { return PORTS_1_1; } 16 | const char *processing() const { return PUSH; } 17 | 18 | int configure(Vector &, ErrorHandler *); 19 | bool can_live_reconfigure() const { return true; } 20 | 21 | void push (int port, Packet *p_in); 22 | 23 | void add_handlers(); 24 | 25 | EtherAddress _bcast; 26 | 27 | int _sum_signal; 28 | int _sum_noise; 29 | int _packets; 30 | 31 | unsigned _length; 32 | uint16_t _et; 33 | EtherAddress _src; 34 | int good_packet; 35 | bool _runs; 36 | 37 | int _bytes; 38 | 39 | int _tolerate; 40 | int _overhead; 41 | bool _adaptive; 42 | 43 | int _min_errors; 44 | int _max_errors; 45 | int _sum_errors; 46 | int _packet_count; 47 | }; 48 | 49 | CLICK_ENDDECLS 50 | #endif 51 | -------------------------------------------------------------------------------- /roofnet/analysis/countfragbytes.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_COUNTFRAGBYTES_HH 2 | #define CLICK_COUNTFRAGBYTES_HH 3 | #include 4 | #include 5 | #include 6 | #include 7 | CLICK_DECLS 8 | 9 | class CountFragBytes : public Element { public: 10 | 11 | CountFragBytes(); 12 | ~CountFragBytes(); 13 | 14 | const char *class_name() const { return "CountFragBytes"; } 15 | const char *port_count() const { return PORTS_1_1; } 16 | const char *processing() const { return PUSH; } 17 | 18 | int configure(Vector &, ErrorHandler *); 19 | bool can_live_reconfigure() const { return true; } 20 | 21 | void push (int port, Packet *p_in); 22 | 23 | void add_handlers(); 24 | 25 | EtherAddress _bcast; 26 | 27 | int _sum_signal; 28 | int _sum_noise; 29 | int _packets; 30 | 31 | unsigned _length; 32 | unsigned _overhead; 33 | uint16_t _et; 34 | EtherAddress _src; 35 | int good_packet; 36 | bool _runs; 37 | 38 | unsigned _frag_size; 39 | int _bytes; 40 | 41 | bool _adaptive; 42 | int _adaptive_window; 43 | 44 | int _adaptive_window_bytes; 45 | int _adaptive_window_packets; 46 | 47 | int _adaptive_window_larger_bytes; 48 | 49 | int _adaptive_window_smaller_bytes; 50 | int _adaptive_window_smaller_packets; 51 | 52 | int _adaptive_window_smaller_sample; 53 | }; 54 | 55 | CLICK_ENDDECLS 56 | #endif 57 | -------------------------------------------------------------------------------- /roofnet/analysis/errorthreshold.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_ERRORTHRESHOLD_HH 2 | #define CLICK_ERRORTHRESHOLD_HH 3 | #include 4 | #include 5 | #include 6 | #include 7 | CLICK_DECLS 8 | 9 | 10 | class ErrorThreshold : public Element { public: 11 | 12 | ErrorThreshold(); 13 | ~ErrorThreshold(); 14 | 15 | const char *class_name() const { return "ErrorThreshold"; } 16 | const char *port_count() const { return "1/1-2"; } 17 | const char *processing() const { return PUSH; } 18 | 19 | int configure(Vector &, ErrorHandler *); 20 | bool can_live_reconfigure() const { return true; } 21 | 22 | void push (int port, Packet *p_in); 23 | 24 | unsigned _correct_threshold; 25 | unsigned _length; 26 | }; 27 | 28 | CLICK_ENDDECLS 29 | #endif 30 | -------------------------------------------------------------------------------- /roofnet/analysis/locationhistogram.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_LOCATIONHISTOGRAM_HH 2 | #define CLICK_LOCATIONHISTOGRAM_HH 3 | #include 4 | #include 5 | #include 6 | #include 7 | CLICK_DECLS 8 | 9 | class LocationHistogram : public Element { public: 10 | 11 | LocationHistogram(); 12 | ~LocationHistogram(); 13 | 14 | const char *class_name() const { return "LocationHistogram"; } 15 | const char *port_count() const { return PORTS_1_1; } 16 | const char *processing() const { return PUSH; } 17 | 18 | int configure(Vector &, ErrorHandler *); 19 | bool can_live_reconfigure() const { return true; } 20 | 21 | void push (int port, Packet *p_in); 22 | 23 | void add_handlers(); 24 | 25 | 26 | unsigned _length; 27 | Vector _byte_errors; 28 | }; 29 | 30 | CLICK_ENDDECLS 31 | #endif 32 | -------------------------------------------------------------------------------- /roofnet/analysis/printpower.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * printpower.{cc,hh} -- print power levels of a packet 3 | * John Bicket 4 | * 5 | * Copyright (c) 1999-2000 Massachusetts Institute of Technology 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, subject to the conditions 10 | * listed in the Click LICENSE file. These conditions include: you must 11 | * preserve this copyright notice, and you cannot mention the copyright 12 | * holders in advertising related to the Software without their permission. 13 | * The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This 14 | * notice is a summary of the Click LICENSE file; the license in that file is 15 | * legally binding. 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include "printpower.hh" 28 | CLICK_DECLS 29 | 30 | PrintPower::PrintPower() 31 | { 32 | } 33 | 34 | PrintPower::~PrintPower() 35 | { 36 | } 37 | 38 | int 39 | PrintPower::configure(Vector &conf, ErrorHandler*errh) 40 | { 41 | _print = false; 42 | _power = 0; 43 | int ret = cp_va_kparse(conf, this, errh, 44 | "PRINT", 0, cpBool, &_print, 45 | cpEnd); 46 | return ret; 47 | } 48 | 49 | Packet * 50 | PrintPower::simple_action(Packet *p) 51 | { 52 | struct click_wifi_extra *ceh = (struct click_wifi_extra *) p->user_anno(); 53 | if (_print) { 54 | click_chatter("%d\n", ceh->power); 55 | } 56 | _power = ceh->power; 57 | 58 | return p; 59 | } 60 | 61 | enum {H_POWER}; 62 | 63 | static String 64 | read_param(Element *e, void *thunk) 65 | { 66 | PrintPower *f = (PrintPower *)e; 67 | switch((intptr_t)thunk) { 68 | case H_POWER: return String(f->_power) + "\n"; 69 | } 70 | return String(); 71 | } 72 | 73 | void 74 | PrintPower::add_handlers() 75 | { 76 | add_read_handler("power", read_param, (void *)H_POWER); 77 | } 78 | CLICK_ENDDECLS 79 | EXPORT_ELEMENT(PrintPower) 80 | -------------------------------------------------------------------------------- /roofnet/analysis/printpower.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_PRINTPOWER_HH 2 | #define CLICK_PRINTPOWER_HH 3 | #include 4 | #include 5 | CLICK_DECLS 6 | 7 | /* 8 | * =c 9 | * PrintPower([TAG] [, KEYWORDS]) 10 | * =s debugging 11 | * =d 12 | * Assumes input packets are Wifi packets (ie a wifi_pkt struct from 13 | * wifi.hh). Prints out a description of those packets. 14 | * 15 | * Keyword arguments are: 16 | * 17 | * =over 8 18 | * 19 | * =a 20 | * Print, Wifi 21 | */ 22 | 23 | class PrintPower : public Element { 24 | public: 25 | 26 | PrintPower(); 27 | ~PrintPower(); 28 | 29 | const char *class_name() const { return "PrintPower"; } 30 | const char *port_count() const { return "1/1"; } 31 | const char *processing() const { return AGNOSTIC; } 32 | 33 | int configure(Vector &, ErrorHandler *); 34 | Packet *simple_action(Packet *); 35 | void add_handlers(); 36 | 37 | bool _print; 38 | int _power; 39 | }; 40 | 41 | CLICK_ENDDECLS 42 | #endif 43 | -------------------------------------------------------------------------------- /roofnet/analysis/printrate.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_PRINTRATE_HH 2 | #define CLICK_PRINTRATE_HH 3 | #include 4 | #include 5 | CLICK_DECLS 6 | 7 | /* 8 | * =c 9 | * PrintRate([TAG] [, KEYWORDS]) 10 | * =s debugging 11 | * =d 12 | * Assumes input packets are Wifi packets (ie a wifi_pkt struct from 13 | * wifi.hh). Prints out a description of those packets. 14 | * 15 | * Keyword arguments are: 16 | * 17 | * =over 8 18 | * 19 | * =a 20 | * Print, Wifi 21 | */ 22 | 23 | class PrintRate : public Element { 24 | public: 25 | 26 | PrintRate(); 27 | ~PrintRate(); 28 | 29 | const char *class_name() const { return "PrintRate"; } 30 | const char *port_count() const { return PORTS_1_1; } 31 | const char *processing() const { return AGNOSTIC; } 32 | 33 | int configure(Vector &, ErrorHandler *); 34 | Packet *simple_action(Packet *); 35 | void add_handlers(); 36 | 37 | bool _print; 38 | int _rate; 39 | }; 40 | 41 | CLICK_ENDDECLS 42 | #endif 43 | -------------------------------------------------------------------------------- /roofnet/analysis/printseq.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_PRINTSEQ_HH 2 | #define CLICK_PRINTSEQ_HH 3 | #include 4 | #include 5 | CLICK_DECLS 6 | 7 | /* 8 | * =c 9 | * PrintSeq([TAG] [, KEYWORDS]) 10 | * =s debugging 11 | * =d 12 | * Assumes input packets are Wifi packets (ie a wifi_pkt struct from 13 | * wifi.hh). Prints out a description of those packets. 14 | * 15 | * Keyword arguments are: 16 | * 17 | * =over 8 18 | * 19 | * =a 20 | * Print, Wifi 21 | */ 22 | 23 | class PrintSeq : public Element { 24 | 25 | String _label; 26 | 27 | public: 28 | 29 | PrintSeq(); 30 | ~PrintSeq(); 31 | 32 | const char *class_name() const { return "PrintSeq"; } 33 | const char *port_count() const { return "1/1"; } 34 | const char *processing() const { return AGNOSTIC; } 35 | 36 | int configure(Vector &, ErrorHandler *); 37 | 38 | Packet *simple_action(Packet *); 39 | 40 | bool _print_anno; 41 | bool _print_checksum; 42 | unsigned _offset; 43 | unsigned _bytes; 44 | }; 45 | 46 | CLICK_ENDDECLS 47 | #endif 48 | -------------------------------------------------------------------------------- /roofnet/copyrxstats.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "copyrxstats.hh" 10 | CLICK_DECLS 11 | 12 | CopyRXStats::CopyRXStats() 13 | { 14 | } 15 | 16 | CopyRXStats::~CopyRXStats() 17 | { 18 | } 19 | 20 | int 21 | CopyRXStats::configure(Vector &conf, ErrorHandler *errh) 22 | { 23 | if (cp_va_kparse(conf, this, errh, 24 | "OFFSET", cpkP+cpkM, cpUnsigned, &_offset, 25 | cpEnd) < 0) { 26 | return -1; 27 | } 28 | return 0; 29 | } 30 | 31 | Packet * 32 | CopyRXStats::simple_action(Packet *p_in) 33 | { 34 | struct click_wifi_extra *eh = (struct click_wifi_extra *) p_in->user_anno(); 35 | 36 | uint8_t rate = eh->rate; 37 | uint8_t signal = eh->rssi; 38 | uint8_t noise = eh->silence; 39 | 40 | WritablePacket *p = p_in->uniqueify(); 41 | if (!p) { return 0; } 42 | 43 | uint8_t *c = p->data(); 44 | c[_offset+0] = rate; 45 | c[_offset+1] = signal; 46 | c[_offset+2] = noise; 47 | 48 | return p; 49 | } 50 | 51 | CLICK_ENDDECLS 52 | EXPORT_ELEMENT(CopyRXStats) 53 | 54 | -------------------------------------------------------------------------------- /roofnet/copyrxstats.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_COPYRXSTATS_HH 2 | #define CLICK_COPYRXSTATS_HH 3 | #include 4 | #include 5 | CLICK_DECLS 6 | 7 | /* 8 | * =c 9 | * 10 | * CopyRXStats(OFFSET) 11 | * 12 | * =s Wifi 13 | * Copies rate, signal and noise annotations into the packet at the 14 | * specified offset. 15 | * 16 | * =d 17 | * Copies rate, signal and noise annotations into the packet at the 18 | * specified offset. This is a cheap hack to make it simple to run 19 | * experiments and accumulate these stats per-packet. 20 | * 21 | * 22 | */ 23 | 24 | class CopyRXStats : public Element { public: 25 | 26 | CopyRXStats(); 27 | ~CopyRXStats(); 28 | 29 | const char *class_name() const { return "CopyRXStats"; } 30 | const char *port_count() const { return PORTS_1_1; } 31 | const char *processing() const { return AGNOSTIC; } 32 | 33 | int configure(Vector &, ErrorHandler *); 34 | bool can_live_reconfigure() const { return true; } 35 | 36 | Packet *simple_action(Packet *); 37 | 38 | private: 39 | 40 | unsigned int _offset; 41 | }; 42 | 43 | CLICK_ENDDECLS 44 | #endif 45 | -------------------------------------------------------------------------------- /roofnet/dhcp/snoopdhcpreplies.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_SNOOPDHCPREPLIES_HH 2 | #define CLICK_SNOOPDHCPREPLIES_HH 3 | #include 4 | #include 5 | CLICK_DECLS 6 | 7 | /* 8 | =c 9 | 10 | SnoopDHCPReplies 11 | 12 | =s Roofnet 13 | 14 | Turns 802.11 packets into ethernet packets. 15 | 16 | =d 17 | 18 | Strips the 802.11 frame header and llc header off the packet and pushes 19 | an ethernet header onto the packet. Discards packets that are shorter 20 | than the length of the 802.11 frame header and llc header. 21 | 22 | 23 | =e 24 | 25 | FromDevice(ath0) 26 | -> ExtraDecap() 27 | -> FilterTX() 28 | -> FilterPhyErr() 29 | -> wifi_cl :: Classifier (0/08%0c); //data packets 30 | -> wifi_decap :: SnoopDHCPReplies() 31 | -> HostEtherFilter(ath0, DROP_OTHER true, DROP_OWN true) 32 | ... 33 | =a WifiEncap 34 | */ 35 | 36 | class SnoopDHCPReplies : public Element { public: 37 | 38 | SnoopDHCPReplies(); 39 | ~SnoopDHCPReplies(); 40 | 41 | const char *class_name() const { return "SnoopDHCPReplies"; } 42 | const char *port_count() const { return PORTS_1_1; } 43 | const char *processing() const { return AGNOSTIC; } 44 | 45 | int configure(Vector &, ErrorHandler *); 46 | bool can_live_reconfigure() const { return true; } 47 | 48 | Packet *simple_action(Packet *); 49 | 50 | 51 | void add_handlers(); 52 | 53 | 54 | bool _debug; 55 | private: 56 | 57 | String _ifname; 58 | }; 59 | 60 | CLICK_ENDDECLS 61 | #endif 62 | -------------------------------------------------------------------------------- /roofnet/frag/checkfragment.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_CHECKFRAGMENT_HH 2 | #define CLICK_CHECKFRAGMENT_HH 3 | #include 4 | #include 5 | #include 6 | #include 7 | CLICK_DECLS 8 | 9 | 10 | class CheckFragment : public Element { public: 11 | 12 | CheckFragment(); 13 | ~CheckFragment(); 14 | 15 | const char *class_name() const { return "CheckFragment"; } 16 | const char *port_count() const { return "1/0-2"; } 17 | const char *processing() const { return "a/ah"; } 18 | 19 | int configure(Vector &, ErrorHandler *); 20 | bool can_live_reconfigure() const { return true; } 21 | 22 | Packet *simple_action(Packet *); 23 | 24 | 25 | bool _header_only; 26 | 27 | private: 28 | 29 | }; 30 | 31 | CLICK_ENDDECLS 32 | #endif 33 | -------------------------------------------------------------------------------- /roofnet/frag/defragment.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_DEFRAGMENT_HH 2 | #define CLICK_DEFRAGMENT_HH 3 | #include 4 | #include 5 | #include 6 | #include 7 | CLICK_DECLS 8 | 9 | class Defragment : public Element { public: 10 | 11 | Defragment(); 12 | ~Defragment(); 13 | 14 | const char *class_name() const { return "Defragment"; } 15 | const char *port_count() const { return PORTS_1_1; } 16 | const char *processing() const { return AGNOSTIC; } 17 | 18 | int configure(Vector &, ErrorHandler *); 19 | bool can_live_reconfigure() const { return true; } 20 | 21 | Packet *simple_action(Packet *); 22 | 23 | 24 | void add_handlers(); 25 | 26 | 27 | struct PacketInfo { 28 | 29 | EtherAddress src; 30 | int packet; 31 | int num_frags; 32 | int frag_size; 33 | int fragments_rx; 34 | 35 | Vector fragments; 36 | PacketInfo() { 37 | 38 | } 39 | PacketInfo(EtherAddress s, int p, 40 | int fs, int nf) { 41 | src = s; 42 | packet = p; 43 | frag_size = fs; 44 | num_frags = nf; 45 | fragments_rx = 0; 46 | 47 | fragments.clear(); 48 | for (int x = 0; x < num_frags; x++) { 49 | fragments.push_back(0); 50 | } 51 | } 52 | }; 53 | 54 | 55 | typedef HashMap PacketInfoTable; 56 | typedef PacketInfoTable::const_iterator PIIter; 57 | 58 | PacketInfoTable _packets; 59 | bool _debug; 60 | private: 61 | 62 | }; 63 | 64 | CLICK_ENDDECLS 65 | #endif 66 | -------------------------------------------------------------------------------- /roofnet/frag/fragment.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_FRAGMENT_HH 2 | #define CLICK_FRAGMENT_HH 3 | #include 4 | #include 5 | #include 6 | CLICK_DECLS 7 | 8 | class Fragment : public Element { public: 9 | 10 | Fragment(); 11 | ~Fragment(); 12 | 13 | const char *class_name() const { return "Fragment"; } 14 | const char *port_count() const { return PORTS_1_1; } 15 | const char *processing() const { return PUSH; } 16 | 17 | int configure(Vector &, ErrorHandler *); 18 | bool can_live_reconfigure() const { return true; } 19 | 20 | void push(int, Packet *); 21 | 22 | 23 | void add_handlers(); 24 | 25 | 26 | bool _debug; 27 | private: 28 | 29 | }; 30 | 31 | CLICK_ENDDECLS 32 | #endif 33 | -------------------------------------------------------------------------------- /roofnet/frag/fragmentack.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_FRAGMENTACK_HH 2 | #define CLICK_FRAGMENTACK_HH 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "frag.hh" 9 | CLICK_DECLS 10 | 11 | class FragmentAck : public Element { public: 12 | 13 | FragmentAck(); 14 | ~FragmentAck(); 15 | 16 | const char *class_name() const { return "FragmentAck"; } 17 | const char *port_count() const { return "1/1-2"; } 18 | const char *processing() const { return "a/ah"; } 19 | 20 | int configure(Vector &, ErrorHandler *); 21 | bool can_live_reconfigure() const { return true; } 22 | 23 | void send_ack(EtherAddress src); 24 | 25 | Packet * simple_action(Packet *p); 26 | struct WindowInfo { 27 | EtherAddress src; 28 | Vector frags_rx; 29 | Timestamp first_rx; 30 | bool waiting; 31 | WindowInfo() { } 32 | WindowInfo(EtherAddress s) { src = s; } 33 | 34 | bool add(struct fragid f) { 35 | for (int x = 0; x < frags_rx.size(); x++) { 36 | if (frags_rx[x] == f) { 37 | return false; 38 | } 39 | } 40 | 41 | frags_rx.push_back(f); 42 | return true; 43 | } 44 | 45 | }; 46 | 47 | 48 | 49 | typedef HashMap FragTable; 50 | typedef FragTable::const_iterator FIter; 51 | 52 | FragTable _frags; 53 | 54 | EtherAddress _en; 55 | uint16_t _et; 56 | unsigned _window_size; 57 | 58 | unsigned _ack_timeout_ms; 59 | 60 | bool _debug; 61 | private: 62 | 63 | }; 64 | 65 | CLICK_ENDDECLS 66 | #endif 67 | -------------------------------------------------------------------------------- /roofnet/frag/fragmentdecap.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_FRAGMENTDECAP_HH 2 | #define CLICK_FRAGMENTDECAP_HH 3 | #include 4 | #include 5 | #include 6 | #include 7 | CLICK_DECLS 8 | 9 | 10 | class FragmentDecap : public Element { public: 11 | 12 | FragmentDecap(); 13 | ~FragmentDecap(); 14 | 15 | const char *class_name() const { return "FragmentDecap"; } 16 | const char *port_count() const { return PORTS_1_1; } 17 | const char *processing() const { return AGNOSTIC; } 18 | 19 | int configure(Vector &, ErrorHandler *); 20 | bool can_live_reconfigure() const { return true; } 21 | 22 | Packet *simple_action(Packet *); 23 | 24 | 25 | void add_handlers(); 26 | 27 | 28 | bool _debug; 29 | private: 30 | 31 | }; 32 | 33 | CLICK_ENDDECLS 34 | #endif 35 | -------------------------------------------------------------------------------- /roofnet/frag/fragmentdupefilter.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_FRAGMENTDUPEFILTER_HH 2 | #define CLICK_FRAGMENTDUPEFILTER_HH 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "frag.hh" 10 | CLICK_DECLS 11 | 12 | class FragmentDupeFilter : public Element { public: 13 | 14 | FragmentDupeFilter(); 15 | ~FragmentDupeFilter(); 16 | 17 | const char *class_name() const { return "FragmentDupeFilter"; } 18 | const char *port_count() const { return "1/1-2"; } 19 | const char *processing() const { return "a/ah"; } 20 | 21 | int configure(Vector &, ErrorHandler *); 22 | bool can_live_reconfigure() const { return true; } 23 | 24 | void send_dupefilter(EtherAddress src); 25 | 26 | Packet * simple_action(Packet *p); 27 | 28 | struct DstInfo { 29 | EtherAddress src; 30 | Deque frags; 31 | DstInfo() { } 32 | DstInfo(EtherAddress s) { src = s; } 33 | }; 34 | 35 | 36 | typedef HashMap FragTable; 37 | typedef FragTable::const_iterator FIter; 38 | 39 | FragTable _frags; 40 | 41 | EtherAddress _en; 42 | uint16_t _et; 43 | unsigned _window_size; 44 | 45 | 46 | bool _debug; 47 | private: 48 | 49 | }; 50 | 51 | CLICK_ENDDECLS 52 | #endif 53 | -------------------------------------------------------------------------------- /roofnet/frag/fragmentencap.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_FRAGMENTENCAP_HH 2 | #define CLICK_FRAGMENTENCAP_HH 3 | #include 4 | #include 5 | #include 6 | CLICK_DECLS 7 | 8 | class FragmentEncap : public Element { public: 9 | 10 | FragmentEncap(); 11 | ~FragmentEncap(); 12 | 13 | const char *class_name() const { return "FragmentEncap"; } 14 | const char *port_count() const { return PORTS_1_1; } 15 | const char *processing() const { return AGNOSTIC; } 16 | 17 | int configure(Vector &, ErrorHandler *); 18 | bool can_live_reconfigure() const { return true; } 19 | 20 | Packet *simple_action(Packet *); 21 | 22 | 23 | void add_handlers(); 24 | 25 | 26 | bool _debug; 27 | 28 | unsigned _frag_length; 29 | unsigned _packet_num; 30 | private: 31 | 32 | }; 33 | 34 | CLICK_ENDDECLS 35 | #endif 36 | -------------------------------------------------------------------------------- /roofnet/frag/printfragment.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_PRINTFRAGMENT_HH 2 | #define CLICK_PRINTFRAGMENT_HH 3 | #include 4 | #include 5 | #include 6 | #include 7 | CLICK_DECLS 8 | 9 | class PrintFragment : public Element { public: 10 | 11 | PrintFragment(); 12 | ~PrintFragment(); 13 | 14 | const char *class_name() const { return "PrintFragment"; } 15 | const char *port_count() const { return PORTS_1_1; } 16 | const char *processing() const { return AGNOSTIC; } 17 | 18 | int configure(Vector &, ErrorHandler *); 19 | bool can_live_reconfigure() const { return true; } 20 | 21 | Packet *simple_action(Packet *); 22 | 23 | 24 | String _label; 25 | private: 26 | 27 | }; 28 | 29 | CLICK_ENDDECLS 30 | #endif 31 | -------------------------------------------------------------------------------- /roofnet/setwifiextraflag.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_SETWIFIEXTRAFLAG_HH 2 | #define CLICK_SETWIFIEXTRAFLAG_HH 3 | #include 4 | #include 5 | 6 | CLICK_DECLS 7 | 8 | /* 9 | * =c 10 | * 11 | * SetWifiExtraFlag(Unsigned) 12 | * 13 | * =s Wifi 14 | * 15 | * Sets the Wifi flags on a packet. 16 | * 17 | */ 18 | 19 | class SetWifiExtraFlag : public Element { public: 20 | 21 | SetWifiExtraFlag(); 22 | ~SetWifiExtraFlag(); 23 | 24 | const char *class_name() const { return "SetWifiExtraFlag"; } 25 | const char *port_count() const { return PORTS_1_1; } 26 | const char *processing() const { return AGNOSTIC; } 27 | 28 | int configure(Vector &, ErrorHandler *); 29 | Packet *simple_action(Packet *); 30 | 31 | void add_handlers(); 32 | unsigned _flag; 33 | }; 34 | 35 | CLICK_ENDDECLS 36 | #endif 37 | -------------------------------------------------------------------------------- /roofnet/sr/checksrheader.hh: -------------------------------------------------------------------------------- 1 | #ifndef CHECKSRHEADER_HH 2 | #define CHECKSRHEADER_HH 3 | #include 4 | #include 5 | #include 6 | CLICK_DECLS 7 | 8 | /* 9 | =c 10 | 11 | CheckSRHeader() 12 | 13 | =s Roofnet 14 | 15 | Check the Source Route header of a packet. 16 | 17 | =d 18 | 19 | Expects SR packets as input. 20 | Checks that the packet's length is reasonable, 21 | and that the SR header length, length, and 22 | checksum fields are valid. 23 | 24 | =a SetSRChecksum 25 | */ 26 | 27 | class CheckSRHeader : public Element { 28 | 29 | typedef HashMap BadTable; 30 | typedef BadTable::const_iterator BTIter; 31 | 32 | BadTable _bad_table; 33 | int _drops; 34 | 35 | public: 36 | 37 | CheckSRHeader(); 38 | ~CheckSRHeader(); 39 | 40 | const char *class_name() const { return "CheckSRHeader"; } 41 | const char *port_count() const { return "1/1-2"; } 42 | const char *processing() const { return "a/ah"; } 43 | 44 | int drops() const { return _drops; } 45 | 46 | 47 | Packet *simple_action(Packet *); 48 | void drop_it(Packet *); 49 | 50 | String bad_nodes(); 51 | void add_handlers(); 52 | 53 | }; 54 | 55 | CLICK_ENDDECLS 56 | #endif 57 | -------------------------------------------------------------------------------- /roofnet/sr/dupefilter.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_DUPEFILTER_HH 2 | #define CLICK_DUPEFILTER_HH 3 | #include 4 | #include 5 | #include 6 | #include 7 | CLICK_DECLS 8 | 9 | /* 10 | * =c 11 | * DupeFilter([TAG] [, KEYWORDS]) 12 | * =s debugging 13 | * =d 14 | * Assumes input packets are SR packets (ie a sr_pkt struct from 15 | * sr.hh). Prints out a description of those packets. 16 | * 17 | * Keyword arguments are: 18 | * 19 | * =over 8 20 | * 21 | * =a 22 | * Print, SR 23 | */ 24 | 25 | class DupeFilter : public Element { 26 | 27 | public: 28 | 29 | DupeFilter(); 30 | ~DupeFilter(); 31 | 32 | const char *class_name() const { return "DupeFilter"; } 33 | const char *port_count() const { return PORTS_1_1; } 34 | const char *processing() const { return AGNOSTIC; } 35 | 36 | int configure(Vector &, ErrorHandler *); 37 | 38 | Packet *simple_action(Packet *); 39 | 40 | static String static_read_stats(Element *xf, void *); 41 | static String static_read_debug(Element *xf, void *); 42 | static int static_write_debug(const String &arg, Element *e, 43 | void *, ErrorHandler *errh); 44 | void add_handlers(); 45 | 46 | class PathInfo { 47 | public: 48 | Path _p; 49 | Timestamp _last; 50 | int _dupes; 51 | int _packets; 52 | Deque _sequences; //most recently received seq nos 53 | PathInfo(Path p) { 54 | _p = p; 55 | } 56 | PathInfo () { } 57 | void clear() { 58 | _dupes = 0; 59 | _packets = 0; 60 | _sequences.clear(); 61 | _last.assign_now(); 62 | } 63 | }; 64 | 65 | typedef HashMap PathTable; 66 | typedef PathTable::const_iterator PathIter; 67 | 68 | PathTable _paths; 69 | int _window; 70 | int _debug; 71 | }; 72 | 73 | CLICK_ENDDECLS 74 | #endif 75 | -------------------------------------------------------------------------------- /roofnet/sr/ettmetric.hh: -------------------------------------------------------------------------------- 1 | #ifndef ETTMETRIC_HH 2 | #define ETTMETRIC_HH 3 | #include 4 | #include "linkmetric.hh" 5 | #include 6 | #include 7 | #include 8 | #include "ettstat.hh" 9 | #include 10 | CLICK_DECLS 11 | 12 | /* 13 | * =c 14 | * ETTMetric 15 | * =s Wifi 16 | * Estimated Transmission Time (ETT) metric 17 | * 18 | * =io 19 | * None 20 | * 21 | */ 22 | 23 | 24 | 25 | inline unsigned ett_metric(int ack_prob, int data_prob, int data_rate) 26 | { 27 | 28 | if (!ack_prob || ! data_prob) { 29 | return 0; 30 | } 31 | int retries = 100 * 100 * 100 / (ack_prob * data_prob) - 100; 32 | unsigned low_usecs = calc_usecs_wifi_packet(1500, data_rate, retries/100); 33 | unsigned high_usecs = calc_usecs_wifi_packet(1500, data_rate, (retries/100) + 1); 34 | 35 | unsigned diff = retries % 100; 36 | unsigned average = (diff * high_usecs + (100 - diff) * low_usecs) / 100; 37 | return average; 38 | 39 | } 40 | 41 | class ETTStat; 42 | 43 | class ETTMetric : public LinkMetric { 44 | 45 | public: 46 | 47 | 48 | ETTMetric(); 49 | ~ETTMetric(); 50 | const char *class_name() const { return "ETTMetric"; } 51 | const char *processing() const { return AGNOSTIC; } 52 | 53 | int configure(Vector &, ErrorHandler *); 54 | 55 | void *cast(const char *); 56 | 57 | static String read_stats(Element *xf, void *); 58 | 59 | void update_link(IPAddress from, IPAddress to, 60 | Vector rs, 61 | Vector fwd, Vector rev, 62 | uint32_t seq); 63 | 64 | int get_tx_rate(EtherAddress); 65 | 66 | private: 67 | class LinkTable *_link_table; 68 | 69 | }; 70 | 71 | CLICK_ENDDECLS 72 | #endif 73 | -------------------------------------------------------------------------------- /roofnet/sr/ipaddresscounter.hh: -------------------------------------------------------------------------------- 1 | #ifndef IPADDRESSCOUNTER_HH 2 | #define IPADDRESSCOUNTER_HH 3 | 4 | /* 5 | =c 6 | 7 | IPAddressCounter() 8 | 9 | =s Roofnet 10 | 11 | Count traffic for individual ip addresses. 12 | 13 | =d 14 | 15 | Expects a SR MAC packet as input. 16 | Calculates the SR header's checksum and sets the version and checksum header fields. 17 | 18 | =a 19 | CheckSRHeader */ 20 | 21 | #include 22 | #include 23 | #include 24 | CLICK_DECLS 25 | 26 | class IPAddressCounter : public Element { 27 | public: 28 | IPAddressCounter(); 29 | ~IPAddressCounter(); 30 | 31 | const char *class_name() const { return "IPAddressCounter"; } 32 | const char *port_count() const { return PORTS_1_1; } 33 | const char *processing() const { return AGNOSTIC; } 34 | 35 | static int write_param(const String &arg, Element *e, 36 | void *, ErrorHandler *errh); 37 | 38 | static String read_param(Element *e, void *); 39 | 40 | 41 | String stats(); 42 | void add_handlers(); 43 | 44 | int configure (Vector &conf, ErrorHandler *errh); 45 | 46 | class IPAddressInfo { 47 | public: 48 | IPAddressInfo() { 49 | _packets = 0; 50 | _bytes = 0; 51 | } 52 | IPAddressInfo(IPAddress ip) { 53 | _ip = ip; 54 | _packets = 0; 55 | _bytes = 0; 56 | } 57 | IPAddress _ip; 58 | int _packets; 59 | int _bytes; 60 | }; 61 | 62 | typedef HashMap IPInfoTable; 63 | typedef IPInfoTable::const_iterator IPIter; 64 | 65 | 66 | IPInfoTable _table; 67 | 68 | bool _track_src; 69 | bool _track_dst; 70 | 71 | Packet *simple_action(Packet *); 72 | }; 73 | 74 | CLICK_ENDDECLS 75 | #endif 76 | -------------------------------------------------------------------------------- /roofnet/sr/linkmetric.hh: -------------------------------------------------------------------------------- 1 | #ifndef LINKMETRIC_HH 2 | #define LINKMETRIC_HH 3 | #include 4 | #include 5 | #include "ettstat.hh" 6 | CLICK_DECLS 7 | 8 | 9 | class LinkMetric : public Element { 10 | public: 11 | LinkMetric() { } 12 | 13 | virtual ~LinkMetric() { } 14 | 15 | 16 | }; 17 | 18 | CLICK_ENDDECLS 19 | #endif 20 | -------------------------------------------------------------------------------- /roofnet/sr/localbroadcast.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_LOCALBROADCAST_HH 2 | #define CLICK_LOCALBROADCAST_HH 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "localbroadcast.hh" 15 | #include 16 | CLICK_DECLS 17 | 18 | /* 19 | =c 20 | LocalBroadcast(IP, ETH, ETHERTYPE, LocalBroadcast element, LinkTable element, ARPtable element, 21 | [METRIC GridGenericMetric], [WARMUP period in seconds]) 22 | 23 | =s Roofnet 24 | 25 | Floods a packet to 1-hop neighbors. 26 | 27 | */ 28 | 29 | 30 | class LocalBroadcast : public Element { 31 | public: 32 | 33 | LocalBroadcast(); 34 | ~LocalBroadcast(); 35 | 36 | const char *class_name() const { return "LocalBroadcast"; } 37 | const char *port_count() const { return "2/2"; } 38 | const char *processing() const { return PUSH; } 39 | int initialize(ErrorHandler *); 40 | int configure(Vector &conf, ErrorHandler *errh); 41 | 42 | 43 | static String static_print_debug(Element *f, void *); 44 | static int static_write_debug(const String &arg, Element *e, 45 | void *, ErrorHandler *errh); 46 | 47 | static String static_print_stats(Element *e, void *); 48 | String print_stats(); 49 | 50 | void push(int, Packet *); 51 | void run_timer(Timer *); 52 | 53 | void add_handlers(); 54 | private: 55 | 56 | u_long _seq; // Next query sequence number to use. 57 | Timer _timer; 58 | IPAddress _ip; // My IP address. 59 | EtherAddress _en; // My ethernet address. 60 | uint32_t _et; // This protocol's ethertype 61 | IPAddress _bcast_ip; 62 | 63 | EtherAddress _bcast; 64 | 65 | bool _debug; 66 | 67 | 68 | int _packets_originated; 69 | int _packets_tx; 70 | int _packets_rx; 71 | }; 72 | 73 | 74 | CLICK_ENDDECLS 75 | #endif 76 | -------------------------------------------------------------------------------- /roofnet/sr/printsr.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_PRINTSR_HH 2 | #define CLICK_PRINTSR_HH 3 | #include 4 | #include 5 | CLICK_DECLS 6 | 7 | /* 8 | * =c 9 | * PrintSR([TAG] [, KEYWORDS]) 10 | * =s debugging 11 | * =d 12 | * Assumes input packets are SR packets (ie a sr_pkt struct from 13 | * sr.hh). Prints out a description of those packets. 14 | * 15 | * Keyword arguments are: 16 | * 17 | * =over 8 18 | * 19 | * =a 20 | * Print, SR 21 | */ 22 | 23 | class PrintSR : public Element { 24 | 25 | String _label; 26 | 27 | public: 28 | 29 | PrintSR(); 30 | ~PrintSR(); 31 | 32 | const char *class_name() const { return "PrintSR"; } 33 | const char *port_count() const { return PORTS_1_1; } 34 | const char *processing() const { return AGNOSTIC; } 35 | 36 | int configure(Vector &, ErrorHandler *); 37 | 38 | Packet *simple_action(Packet *); 39 | static String sr_to_string(struct srpacket *); 40 | bool _print_anno; 41 | bool _print_checksum; 42 | }; 43 | 44 | CLICK_ENDDECLS 45 | #endif 46 | -------------------------------------------------------------------------------- /roofnet/sr/setsrchecksum.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * setsrchecksum.{cc,hh} -- element sets SR header checksum 3 | * John Bicket 4 | * apapted from setwifichecksum.{cc,hh} by Douglas S. J. De Couto 5 | * adapted from setipchecksum.{cc,hh} by Robert Morris 6 | * 7 | * Copyright (c) 1999-2000 Massachusetts Institute of Technology 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a 10 | * copy of this software and associated documentation files (the "Software"), 11 | * to deal in the Software without restriction, subject to the conditions 12 | * listed in the Click LICENSE file. These conditions include: you must 13 | * preserve this copyright notice, and you cannot mention the copyright 14 | * holders in advertising related to the Software without their permission. 15 | * The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This 16 | * notice is a summary of the Click LICENSE file; the license in that file is 17 | * legally binding. 18 | */ 19 | 20 | #include 21 | #include 22 | #include "setsrchecksum.hh" 23 | #include 24 | #include "srpacket.hh" 25 | #include 26 | #include 27 | CLICK_DECLS 28 | 29 | SetSRChecksum::SetSRChecksum() 30 | { 31 | } 32 | 33 | SetSRChecksum::~SetSRChecksum() 34 | { 35 | } 36 | 37 | Packet * 38 | SetSRChecksum::simple_action(Packet *xp) 39 | { 40 | click_ether *eh = (click_ether *) xp->data(); 41 | struct srpacket *pk = (struct srpacket *) (eh+1); 42 | unsigned plen = xp->length(); 43 | unsigned int tlen = 0; 44 | 45 | if (!pk) 46 | goto bad; 47 | 48 | if (pk->_type & PT_DATA) { 49 | tlen = pk->hlen_with_data(); 50 | } else { 51 | tlen = pk->hlen_wo_data(); 52 | } 53 | 54 | if (plen < sizeof(struct srpacket)) 55 | goto bad; 56 | 57 | if (tlen > plen - sizeof(click_ether)) 58 | goto bad; 59 | 60 | pk->_version = _sr_version; 61 | pk->set_checksum(); 62 | 63 | return xp; 64 | 65 | bad: 66 | click_chatter("%{element}: bad lengths plen %d, tlen %d", 67 | this, 68 | plen, 69 | tlen); 70 | xp->kill(); 71 | return(0); 72 | } 73 | 74 | CLICK_ENDDECLS 75 | EXPORT_ELEMENT(SetSRChecksum) 76 | -------------------------------------------------------------------------------- /roofnet/sr/setsrchecksum.hh: -------------------------------------------------------------------------------- 1 | #ifndef SETSRCHECKSUM_HH 2 | #define SETSRCHECKSUM_HH 3 | 4 | /* 5 | =c 6 | 7 | SetSRChecksum() 8 | 9 | =s Roofnet 10 | 11 | Set Checksum for Source Routed packet. 12 | 13 | =d 14 | 15 | Expects a SR MAC packet as input. Calculates the SR header's checksum 16 | and sets the version and checksum header fields. 17 | 18 | =a CheckSRHeader 19 | */ 20 | 21 | #include 22 | #include 23 | CLICK_DECLS 24 | 25 | class SetSRChecksum : public Element { 26 | public: 27 | SetSRChecksum(); 28 | ~SetSRChecksum(); 29 | 30 | const char *class_name() const { return "SetSRChecksum"; } 31 | const char *port_count() const { return PORTS_1_1; } 32 | const char *processing() const { return AGNOSTIC; } 33 | 34 | Packet *simple_action(Packet *); 35 | }; 36 | 37 | CLICK_ENDDECLS 38 | #endif 39 | -------------------------------------------------------------------------------- /roofnet/sr/setsrflag.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_SETSRFLAG_HH 2 | #define CLICK_SETSRFLAG_HH 3 | #include 4 | #include 5 | CLICK_DECLS 6 | 7 | /* 8 | * =c 9 | * SetSRFlag([TAG] [, KEYWORDS]) 10 | * =s debugging 11 | * =d 12 | * Assumes input packets are SR packets (ie a sr_pkt struct from 13 | * sr.hh). Prints out a description of those packets. 14 | * 15 | * Keyword arguments are: 16 | * 17 | * =over 8 18 | * 19 | * =a 20 | * Print, SR 21 | */ 22 | 23 | class SetSRFlag : public Element { 24 | 25 | uint16_t _flags; 26 | public: 27 | 28 | SetSRFlag(); 29 | ~SetSRFlag(); 30 | 31 | const char *class_name() const { return "SetSRFlag"; } 32 | const char *port_count() const { return PORTS_1_1; } 33 | const char *processing() const { return AGNOSTIC; } 34 | 35 | int configure(Vector &, ErrorHandler *); 36 | 37 | Packet *simple_action(Packet *); 38 | 39 | void add_handlers(); 40 | static String static_print_flags(Element *e, void *); 41 | String print_flags(); 42 | }; 43 | 44 | CLICK_ENDDECLS 45 | #endif 46 | -------------------------------------------------------------------------------- /roofnet/sr/sr1gatewayresponder.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_SR1GATEWAYRESPONDER_HH 2 | #define CLICK_SR1GATEWAYRESPONDER_HH 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "gatewayselector.hh" 15 | CLICK_DECLS 16 | 17 | /* 18 | =c 19 | 20 | SR1GatewayResponder(IP, ETH, ETHERTYPE, SR1GatewayResponder element, LinkTable element, ARPtable element, 21 | [METRIC GridGenericMetric], [WARMUP period in seconds]) 22 | 23 | =s Roofnet 24 | 25 | Responds to queries destined for this node. 26 | 27 | */ 28 | 29 | 30 | class SR1GatewayResponder : public Element { 31 | public: 32 | 33 | SR1GatewayResponder(); 34 | ~SR1GatewayResponder(); 35 | 36 | const char *class_name() const { return "SR1GatewayResponder"; } 37 | const char *port_count() const { return PORTS_0_1; } 38 | const char *processing() const { return PUSH; } 39 | const char *flow_code() const { return "#/#"; } 40 | int initialize(ErrorHandler *); 41 | int configure(Vector &conf, ErrorHandler *errh); 42 | void run_timer(Timer *); 43 | void add_handlers(); 44 | 45 | IPAddress _ip; // My IP address. 46 | EtherAddress _en; // My ethernet address. 47 | uint32_t _et; // This protocol's ethertype 48 | unsigned int _period; // msecs 49 | bool _debug; 50 | 51 | class LinkTable *_link_table; 52 | class ARPTable *_arp_table; 53 | class GatewaySelector *_gw_sel; 54 | 55 | Timer _timer; 56 | }; 57 | 58 | 59 | CLICK_ENDDECLS 60 | #endif 61 | -------------------------------------------------------------------------------- /roofnet/sr/srdestcache.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_SRDESTCACHE_HH 2 | #define CLICK_SRDESTCACHE_HH 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include "srpacket.hh" 17 | #include "gatewayselector.hh" 18 | #include 19 | CLICK_DECLS 20 | 21 | /* 22 | * =c 23 | * SRDestCache([GW ipaddress], [SEL GatewaySelector element]) 24 | * =s Roofnet 25 | * =d 26 | * 27 | * This element marks the gateway for a packet to be sent to. 28 | * Either manually specifiy an gw using the GW keyword 29 | * or automatically select it using a GatewaySelector element. 30 | * 31 | */ 32 | 33 | 34 | class SRDestCache : public Element { 35 | public: 36 | 37 | SRDestCache(); 38 | ~SRDestCache(); 39 | 40 | const char *class_name() const { return "SRDestCache"; } 41 | const char *port_count() const { return "2/2"; } 42 | const char *processing() const { return PUSH; } 43 | const char *flow_code() const { return "#/#"; } 44 | 45 | 46 | /* handler stuff */ 47 | void add_handlers(); 48 | static String read_param(Element *e, void *vparam); 49 | void push(int, Packet *); 50 | private: 51 | 52 | class CacheEntry { 53 | public: 54 | IPAddress _client; 55 | IPAddress _ap; 56 | Timestamp _last; 57 | CacheEntry() { 58 | _last = Timestamp::now(); 59 | } 60 | 61 | CacheEntry(const CacheEntry &e) : 62 | _client(e._client), 63 | _ap(e._ap), 64 | _last(e._last) 65 | { } 66 | CacheEntry(IPAddress c, IPAddress ap) { 67 | CacheEntry(); 68 | _client = c; 69 | _ap = ap; 70 | } 71 | 72 | }; 73 | 74 | typedef HashMap Cache; 75 | typedef Cache::const_iterator FTIter; 76 | Cache _cache; 77 | 78 | }; 79 | 80 | 81 | CLICK_ENDDECLS 82 | #endif 83 | -------------------------------------------------------------------------------- /roofnet/sr/srlog.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_SRLOG_HH 2 | #define CLICK_SRLOG_HH 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | CLICK_DECLS 9 | 10 | /* 11 | * =c 12 | * SRLog(I) 13 | * 14 | * =s Wifi 15 | * Log transmit feedback stats for later analysis. 16 | * 17 | * =d 18 | * SRLog records the size, timestamp, and other infor for 19 | * each packet that passed through. The list of 20 | * recorded data can be dumped (and cleared) by repeated calls to the 21 | * read handler 'log'. 22 | * 23 | * =h log read-only 24 | * Print as much of the list of logged packets as possible, clearing 25 | * printed packets from the log. 26 | * =h more read-only 27 | * Returns how many entries are left to be read. 28 | * =h reset write-only 29 | * Clears the log. 30 | * 31 | */ 32 | 33 | class SRLog : public Element { public: 34 | 35 | SRLog(); 36 | ~SRLog(); 37 | 38 | const char *class_name() const { return "SRLog"; } 39 | const char *port_count() const { return PORTS_1_1; } 40 | const char *processing() const { return AGNOSTIC; } 41 | const char *flow_code() const { return "#/#"; } 42 | 43 | int configure(Vector &, ErrorHandler *); 44 | bool can_live_reconfigure() const { return true; } 45 | 46 | Packet *simple_action(Packet *); 47 | 48 | void add_handlers(); 49 | 50 | class Fo { 51 | public: 52 | char header[500]; 53 | int rate; 54 | int retries; 55 | uint32_t flags; 56 | 57 | }; 58 | 59 | Deque _p; 60 | Deque _t; 61 | 62 | bool _active; 63 | }; 64 | 65 | CLICK_ENDDECLS 66 | #endif 67 | -------------------------------------------------------------------------------- /roofnet/sr/stripsrheader.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * stripsrheader.{cc,hh} -- element removes SR header 3 | * John Bicket 4 | * sampled from stripipheader.cc by Eddie Kohler 5 | * 6 | * Copyright (c) 2000 Massachusetts Institute of Technology 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a 9 | * copy of this software and associated documentation files (the "Software"), 10 | * to deal in the Software without restriction, subject to the conditions 11 | * listed in the Click LICENSE file. These conditions include: you must 12 | * preserve this copyright notice, and you cannot mention the copyright 13 | * holders in advertising related to the Software without their permission. 14 | * The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This 15 | * notice is a summary of the Click LICENSE file; the license in that file is 16 | * legally binding. 17 | */ 18 | 19 | #include 20 | #include "stripsrheader.hh" 21 | #include "srpacket.hh" 22 | #include 23 | CLICK_DECLS 24 | 25 | StripSRHeader::StripSRHeader() 26 | { 27 | } 28 | 29 | StripSRHeader::~StripSRHeader() 30 | { 31 | } 32 | 33 | Packet * 34 | StripSRHeader::simple_action(Packet *p) 35 | { 36 | 37 | click_ether *eh = (click_ether *) p->data(); 38 | struct srpacket *pk = (struct srpacket *) (eh+1); 39 | 40 | int extra = pk->hlen_wo_data() + sizeof(click_ether); 41 | p->pull(extra); 42 | return p; 43 | } 44 | 45 | CLICK_ENDDECLS 46 | EXPORT_ELEMENT(StripSRHeader) 47 | ELEMENT_MT_SAFE(StripSRHeader) 48 | -------------------------------------------------------------------------------- /roofnet/sr/stripsrheader.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_STRIPSRHEADER_HH 2 | #define CLICK_STRIPSRHEADER_HH 3 | #include 4 | CLICK_DECLS 5 | 6 | /* 7 | =c 8 | StripSRHeader() 9 | 10 | =s Roofnet 11 | 12 | Strips outermost SR header 13 | 14 | =d 15 | 16 | Removes the outermost SR header from SR packets based on the SR Header 17 | annotation. 18 | 19 | =a CheckSRHeader 20 | 21 | */ 22 | 23 | class StripSRHeader : public Element { 24 | 25 | public: 26 | 27 | StripSRHeader(); 28 | ~StripSRHeader(); 29 | 30 | const char *class_name() const { return "StripSRHeader"; } 31 | const char *port_count() const { return PORTS_1_1; } 32 | 33 | Packet *simple_action(Packet *); 34 | 35 | }; 36 | 37 | CLICK_ENDDECLS 38 | #endif 39 | -------------------------------------------------------------------------------- /roofnet/sr/txcountmetric.hh: -------------------------------------------------------------------------------- 1 | #ifndef TXCOUNTMETRIC_HH 2 | #define TXCOUNTMETRIC_HH 3 | #include 4 | #include "linkmetric.hh" 5 | #include 6 | #include 7 | #include 8 | #include "ettstat.hh" 9 | #include 10 | CLICK_DECLS 11 | 12 | /* 13 | * =c 14 | * TXCountMetric(LinkStat, LinkStat) 15 | * =s Wifi 16 | * The Estimated Transmission Count metric (ETX). 17 | * =a ETTMetric 18 | */ 19 | 20 | 21 | 22 | inline unsigned txcount_metric(int ack_prob, int data_prob, int data_rate) 23 | { 24 | 25 | if (!ack_prob || ! data_prob) { 26 | return 0; 27 | } 28 | int retries = 100 * 100 * 100 / (ack_prob * data_prob) - 100; 29 | unsigned low_usecs = calc_usecs_wifi_packet(1500, data_rate, retries/100); 30 | unsigned high_usecs = calc_usecs_wifi_packet(1500, data_rate, (retries/100) + 1); 31 | 32 | unsigned diff = retries % 100; 33 | unsigned average = (diff * high_usecs + (100 - diff) * low_usecs) / 100; 34 | return average; 35 | 36 | } 37 | 38 | class ETTStat; 39 | 40 | class TXCountMetric : public LinkMetric { 41 | 42 | public: 43 | 44 | 45 | TXCountMetric(); 46 | ~TXCountMetric(); 47 | const char *class_name() const { return "TXCountMetric"; } 48 | const char *processing() const { return AGNOSTIC; } 49 | 50 | int configure(Vector &, ErrorHandler *); 51 | 52 | void *cast(const char *); 53 | 54 | static String read_stats(Element *xf, void *); 55 | 56 | void update_link(IPAddress from, IPAddress to, 57 | Vector rs, 58 | Vector fwd, Vector rev, 59 | uint32_t seq); 60 | 61 | private: 62 | class LinkTable *_link_table; 63 | 64 | }; 65 | 66 | CLICK_ENDDECLS 67 | #endif 68 | -------------------------------------------------------------------------------- /roofnet/sr2/sr2checkheader.hh: -------------------------------------------------------------------------------- 1 | #ifndef SR2CHECKHEADER_HH 2 | #define SR2CHECKHEADER_HH 3 | #include 4 | #include 5 | #include 6 | CLICK_DECLS 7 | 8 | /* 9 | =c 10 | 11 | SR2CheckHeader() 12 | 13 | =s Roofnet 14 | 15 | Check the Source Route header of a packet. 16 | 17 | =d 18 | 19 | Expects SR packets as input. 20 | Checks that the packet's length is reasonable, 21 | and that the SR header length, length, and 22 | checksum fields are valid. 23 | 24 | =a SetSRChecksum 25 | */ 26 | 27 | class SR2CheckHeader : public Element { 28 | 29 | typedef HashMap BadTable; 30 | typedef BadTable::const_iterator BTIter; 31 | 32 | BadTable _bad_table; 33 | int _drops; 34 | 35 | public: 36 | 37 | SR2CheckHeader(); 38 | ~SR2CheckHeader(); 39 | 40 | const char *class_name() const { return "SR2CheckHeader"; } 41 | const char *port_count() const { return "1/1-2"; } 42 | const char *processing() const { return "a/ah"; } 43 | 44 | int drops() const { return _drops; } 45 | 46 | 47 | Packet *simple_action(Packet *); 48 | void drop_it(Packet *); 49 | 50 | String bad_nodes(); 51 | void add_handlers(); 52 | 53 | }; 54 | 55 | CLICK_ENDDECLS 56 | #endif 57 | -------------------------------------------------------------------------------- /roofnet/sr2/sr2destcache.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_SR2DESTCACHE_HH 2 | #define CLICK_SR2DESTCACHE_HH 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include "sr2packet.hh" 17 | #include "sr2gatewayselector.hh" 18 | CLICK_DECLS 19 | 20 | /* 21 | * =c 22 | * SR2DestCache([GW ipaddress], [SEL GatewaySelector element]) 23 | * =s Roofnet 24 | * =d 25 | * 26 | * This element marks the gateway for a packet to be sent to. 27 | * Either manually specifiy an gw using the GW keyword 28 | * or automatically select it using a GatewaySelector element. 29 | * 30 | * 31 | */ 32 | 33 | 34 | class SR2DestCache : public Element { 35 | public: 36 | 37 | SR2DestCache(); 38 | ~SR2DestCache(); 39 | 40 | const char *class_name() const { return "SR2DestCache"; } 41 | const char *port_count() const { return "2/2"; } 42 | const char *processing() const { return PUSH; } 43 | const char *flow_code() const { return "#/#"; } 44 | 45 | 46 | /* handler stuff */ 47 | void add_handlers(); 48 | static String read_param(Element *e, void *vparam); 49 | void push(int, Packet *); 50 | private: 51 | 52 | class CacheEntry { 53 | public: 54 | IPAddress _client; 55 | IPAddress _ap; 56 | Timestamp _last; 57 | CacheEntry() { 58 | _last = Timestamp::now(); 59 | } 60 | 61 | CacheEntry(const CacheEntry &e) : 62 | _client(e._client), 63 | _ap(e._ap), 64 | _last(e._last) 65 | { } 66 | CacheEntry(IPAddress c, IPAddress ap) { 67 | CacheEntry(); 68 | _client = c; 69 | _ap = ap; 70 | } 71 | 72 | }; 73 | 74 | typedef HashMap Cache; 75 | typedef Cache::const_iterator FTIter; 76 | Cache _cache; 77 | 78 | }; 79 | 80 | 81 | CLICK_ENDDECLS 82 | #endif 83 | -------------------------------------------------------------------------------- /roofnet/sr2/sr2ettmetric.hh: -------------------------------------------------------------------------------- 1 | #ifndef SR2ETTMETRIC_HH 2 | #define SR2ETTMETRIC_HH 3 | #include 4 | #include "sr2linkmetric.hh" 5 | #include 6 | #include 7 | #include 8 | #include "sr2ettstat.hh" 9 | #include 10 | CLICK_DECLS 11 | 12 | /* 13 | * =c 14 | * SR2ETTMetric 15 | * =s Wifi 16 | * Estimated Transmission Time (ETT) metric 17 | * 18 | * =io 19 | * None 20 | * 21 | */ 22 | 23 | inline unsigned sr2_ett_metric(int ack_prob, int data_prob, int data_rate) 24 | { 25 | 26 | if (!ack_prob || ! data_prob) { 27 | return 0; 28 | } 29 | int retries = 100 * 100 * 100 / (ack_prob * data_prob) - 100; 30 | unsigned low_usecs = calc_usecs_wifi_packet(1500, data_rate, retries/100); 31 | unsigned high_usecs = calc_usecs_wifi_packet(1500, data_rate, (retries/100) + 1); 32 | 33 | unsigned diff = retries % 100; 34 | unsigned average = (diff * high_usecs + (100 - diff) * low_usecs) / 100; 35 | return average; 36 | 37 | } 38 | 39 | class SR2ETTMetric : public SR2LinkMetric { 40 | 41 | public: 42 | 43 | SR2ETTMetric(); 44 | ~SR2ETTMetric(); 45 | const char *class_name() const { return "SR2ETTMetric"; } 46 | const char *processing() const { return AGNOSTIC; } 47 | 48 | void update_link(IPAddress from, IPAddress to, 49 | Vector rs, 50 | Vector fwd, Vector rev, 51 | uint32_t seq); 52 | 53 | }; 54 | 55 | CLICK_ENDDECLS 56 | #endif 57 | -------------------------------------------------------------------------------- /roofnet/sr2/sr2gatewayresponder.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_SR2GATEWAYRESPONDER_HH 2 | #define CLICK_SR2GATEWAYRESPONDER_HH 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "sr2gatewayselector.hh" 15 | CLICK_DECLS 16 | 17 | /* 18 | =c 19 | 20 | SR2GatewayResponder(IP, ETH, ETHERTYPE, SR2GatewayResponder element, LinkTable element, ARPtable element, 21 | [METRIC GridGenericMetric], [WARMUP period in seconds]) 22 | 23 | =s Roofnet 24 | 25 | Responds to queries destined for this node. 26 | 27 | */ 28 | 29 | 30 | class SR2GatewayResponder : public Element { 31 | public: 32 | 33 | SR2GatewayResponder(); 34 | ~SR2GatewayResponder(); 35 | 36 | const char *class_name() const { return "SR2GatewayResponder"; } 37 | const char *port_count() const { return PORTS_0_1; } 38 | const char *processing() const { return PUSH; } 39 | const char *flow_code() const { return "#/#"; } 40 | int initialize(ErrorHandler *); 41 | int configure(Vector &conf, ErrorHandler *errh); 42 | void run_timer(Timer *); 43 | void add_handlers(); 44 | 45 | IPAddress _ip; // My IP address. 46 | EtherAddress _en; // My ethernet address. 47 | uint32_t _et; // This protocol's ethertype 48 | unsigned int _period; // msecs 49 | bool _debug; 50 | 51 | class LinkTable *_link_table; 52 | class ARPTable *_arp_table; 53 | class SR2GatewaySelector *_gw_sel; 54 | 55 | Timer _timer; 56 | 57 | }; 58 | 59 | 60 | CLICK_ENDDECLS 61 | #endif 62 | -------------------------------------------------------------------------------- /roofnet/sr2/sr2linkmetric.hh: -------------------------------------------------------------------------------- 1 | #ifndef SR2LINKMETRIC_HH 2 | #define SR2LINKMETRIC_HH 3 | #include 4 | #include 5 | #include "sr2ettstat.hh" 6 | CLICK_DECLS 7 | 8 | class SR2LinkMetric : public Element { 9 | public: 10 | SR2LinkMetric(); 11 | virtual ~SR2LinkMetric(); 12 | 13 | int configure(Vector &, ErrorHandler *); 14 | 15 | protected: 16 | class LinkTable *_link_table; 17 | 18 | }; 19 | 20 | CLICK_ENDDECLS 21 | #endif 22 | -------------------------------------------------------------------------------- /roofnet/sr2/sr2localbroadcast.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_SR2LOCALBROADCAST_HH 2 | #define CLICK_SR2LOCALBROADCAST_HH 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "sr2localbroadcast.hh" 15 | #include 16 | CLICK_DECLS 17 | 18 | /* 19 | =c 20 | SR2LocalBroadcast(IP, ETH, ETHERTYPE, SR2LocalBroadcast element, LinkTable element, ARPtable element, 21 | [METRIC GridGenericMetric], [WARMUP period in seconds]) 22 | 23 | =s Roofnet 24 | 25 | Floods a packet to 1-hop neighbors. 26 | 27 | */ 28 | 29 | 30 | class SR2LocalBroadcast : public Element { 31 | public: 32 | 33 | SR2LocalBroadcast(); 34 | ~SR2LocalBroadcast(); 35 | 36 | const char *class_name() const { return "SR2LocalBroadcast"; } 37 | const char *port_count() const { return "2/2"; } 38 | const char *processing() const { return PUSH; } 39 | int initialize(ErrorHandler *); 40 | int configure(Vector &conf, ErrorHandler *errh); 41 | 42 | 43 | static String static_print_debug(Element *f, void *); 44 | static int static_write_debug(const String &arg, Element *e, 45 | void *, ErrorHandler *errh); 46 | 47 | static String static_print_stats(Element *e, void *); 48 | String print_stats(); 49 | 50 | void push(int, Packet *); 51 | void run_timer(Timer *); 52 | 53 | void add_handlers(); 54 | private: 55 | 56 | u_long _seq; // Next query sequence number to use. 57 | Timer _timer; 58 | IPAddress _ip; // My IP address. 59 | EtherAddress _en; // My ethernet address. 60 | uint16_t _et; // This protocol's ethertype 61 | IPAddress _bcast_ip; 62 | 63 | EtherAddress _bcast; 64 | 65 | bool _debug; 66 | 67 | 68 | int _packets_originated; 69 | int _packets_tx; 70 | int _packets_rx; 71 | }; 72 | 73 | 74 | CLICK_ENDDECLS 75 | #endif 76 | -------------------------------------------------------------------------------- /roofnet/sr2/sr2print.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_SR2PRINT_HH 2 | #define CLICK_SR2PRINT_HH 3 | #include 4 | #include 5 | CLICK_DECLS 6 | 7 | /* 8 | * =c 9 | * SR2Print([TAG] [, KEYWORDS]) 10 | * =s debugging 11 | * =d 12 | * Assumes input packets are SR packets (ie a sr_pkt struct from 13 | * sr.hh). Prints out a description of those packets. 14 | * 15 | * Keyword arguments are: 16 | * 17 | * =over 8 18 | * 19 | * =a 20 | * Print, SR 21 | */ 22 | 23 | class SR2Print : public Element { 24 | 25 | String _label; 26 | 27 | public: 28 | 29 | SR2Print(); 30 | ~SR2Print(); 31 | 32 | const char *class_name() const { return "SR2Print"; } 33 | const char *port_count() const { return PORTS_1_1; } 34 | const char *processing() const { return AGNOSTIC; } 35 | 36 | int configure(Vector &, ErrorHandler *); 37 | 38 | Packet *simple_action(Packet *); 39 | static String sr_to_string(struct sr2packet *); 40 | bool _print_anno; 41 | bool _print_checksum; 42 | }; 43 | 44 | CLICK_ENDDECLS 45 | #endif 46 | -------------------------------------------------------------------------------- /roofnet/sr2/sr2setchecksum.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * sr2setchecksum.{cc,hh} -- element sets SR header checksum 3 | * John Bicket 4 | * apapted from setwifichecksum.{cc,hh} by Douglas S. J. De Couto 5 | * adapted from setipchecksum.{cc,hh} by Robert Morris 6 | * 7 | * Copyright (c) 1999-2000 Massachusetts Institute of Technology 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a 10 | * copy of this software and associated documentation files (the "Software"), 11 | * to deal in the Software without restriction, subject to the conditions 12 | * listed in the Click LICENSE file. These conditions include: you must 13 | * preserve this copyright notice, and you cannot mention the copyright 14 | * holders in advertising related to the Software without their permission. 15 | * The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This 16 | * notice is a summary of the Click LICENSE file; the license in that file is 17 | * legally binding. 18 | */ 19 | 20 | #include 21 | #include 22 | #include "sr2setchecksum.hh" 23 | #include 24 | #include "sr2packet.hh" 25 | #include 26 | #include 27 | CLICK_DECLS 28 | 29 | SR2SetChecksum::SR2SetChecksum() 30 | { 31 | } 32 | 33 | SR2SetChecksum::~SR2SetChecksum() 34 | { 35 | } 36 | 37 | Packet * 38 | SR2SetChecksum::simple_action(Packet *xp) 39 | { 40 | click_ether *eh = (click_ether *) xp->data(); 41 | struct sr2packet *pk = (struct sr2packet *) (eh+1); 42 | unsigned plen = xp->length(); 43 | unsigned int tlen = 0; 44 | 45 | if (!pk) 46 | goto bad; 47 | 48 | if (pk->_type & SR2_PT_DATA) { 49 | tlen = pk->hlen_with_data(); 50 | } else { 51 | tlen = pk->hlen_wo_data(); 52 | } 53 | 54 | if (plen < sizeof(struct sr2packet)) 55 | goto bad; 56 | 57 | if (tlen > plen - sizeof(click_ether)) 58 | goto bad; 59 | 60 | pk->_version = _sr2_version; 61 | //pk->set_checksum(); 62 | 63 | return xp; 64 | 65 | bad: 66 | click_chatter("%s: bad lengths plen %d, tlen %d", 67 | name().c_str(), 68 | plen, 69 | tlen); 70 | xp->kill(); 71 | return(0); 72 | } 73 | 74 | CLICK_ENDDECLS 75 | EXPORT_ELEMENT(SR2SetChecksum) 76 | -------------------------------------------------------------------------------- /roofnet/sr2/sr2setchecksum.hh: -------------------------------------------------------------------------------- 1 | #ifndef SR2SETCHECKSUM_HH 2 | #define SR2SETCHECKSUM_HH 3 | 4 | /* 5 | =c 6 | 7 | SR2SetChecksum() 8 | 9 | =s Roofnet 10 | 11 | Set Checksum for Source Routed packet. 12 | 13 | =d 14 | 15 | Expects a SR MAC packet as input. Calculates the SR header's checksum 16 | and sets the version and checksum header fields. 17 | 18 | =a CheckSRHeader 19 | */ 20 | 21 | #include 22 | #include 23 | CLICK_DECLS 24 | 25 | class SR2SetChecksum : public Element { 26 | public: 27 | SR2SetChecksum(); 28 | ~SR2SetChecksum(); 29 | 30 | const char *class_name() const { return "SR2SetChecksum"; } 31 | const char *port_count() const { return PORTS_1_1; } 32 | const char *processing() const { return AGNOSTIC; } 33 | 34 | Packet *simple_action(Packet *); 35 | }; 36 | 37 | CLICK_ENDDECLS 38 | #endif 39 | -------------------------------------------------------------------------------- /roofnet/sr2/sr2stripheader.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * sr2stripheader.{cc,hh} -- element removes SR header 3 | * John Bicket 4 | * sampled from stripipheader.cc by Eddie Kohler 5 | * 6 | * Copyright (c) 2000 Massachusetts Institute of Technology 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a 9 | * copy of this software and associated documentation files (the "Software"), 10 | * to deal in the Software without restriction, subject to the conditions 11 | * listed in the Click LICENSE file. These conditions include: you must 12 | * preserve this copyright notice, and you cannot mention the copyright 13 | * holders in advertising related to the Software without their permission. 14 | * The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This 15 | * notice is a summary of the Click LICENSE file; the license in that file is 16 | * legally binding. 17 | */ 18 | 19 | #include 20 | #include "sr2stripheader.hh" 21 | #include "sr2packet.hh" 22 | #include 23 | CLICK_DECLS 24 | 25 | SR2StripHeader::SR2StripHeader() 26 | { 27 | } 28 | 29 | SR2StripHeader::~SR2StripHeader() 30 | { 31 | } 32 | 33 | Packet * 34 | SR2StripHeader::simple_action(Packet *p) 35 | { 36 | 37 | click_ether *eh = (click_ether *) p->data(); 38 | struct sr2packet *pk = (struct sr2packet *) (eh+1); 39 | 40 | int extra = pk->hlen_wo_data() + sizeof(click_ether); 41 | p->pull(extra); 42 | return p; 43 | } 44 | 45 | CLICK_ENDDECLS 46 | EXPORT_ELEMENT(SR2StripHeader) 47 | ELEMENT_MT_SAFE(SR2StripHeader) 48 | -------------------------------------------------------------------------------- /roofnet/sr2/sr2stripheader.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_SR2STRIPHEADER_HH 2 | #define CLICK_SR2STRIPHEADER_HH 3 | #include 4 | CLICK_DECLS 5 | 6 | /* 7 | =c 8 | SR2StripHeader() 9 | 10 | =s Roofnet 11 | 12 | Strips outermost SR header 13 | 14 | =d 15 | 16 | Removes the outermost SR header from SR packets based on the SR Header 17 | annotation. 18 | 19 | =a CheckSRHeader 20 | 21 | */ 22 | 23 | class SR2StripHeader : public Element { 24 | 25 | public: 26 | 27 | SR2StripHeader(); 28 | ~SR2StripHeader(); 29 | 30 | const char *class_name() const { return "SR2StripHeader"; } 31 | const char *port_count() const { return PORTS_1_1; } 32 | 33 | Packet *simple_action(Packet *); 34 | 35 | }; 36 | 37 | CLICK_ENDDECLS 38 | #endif 39 | -------------------------------------------------------------------------------- /roofnet/sr2/sr2txcountmetric.hh: -------------------------------------------------------------------------------- 1 | #ifndef SR2TXCOUNTMETRIC_HH 2 | #define SR2TXCOUNTMETRIC_HH 3 | #include 4 | #include "sr2linkmetric.hh" 5 | #include 6 | #include 7 | #include 8 | #include "sr2ettstat.hh" 9 | #include 10 | CLICK_DECLS 11 | 12 | /* 13 | * =c 14 | * SR2ETTMetric 15 | * =s Wifi 16 | * Estimated Transmission Count metric (ETX). 17 | * 18 | * =io 19 | * None 20 | * 21 | */ 22 | 23 | class SR2TXCountMetric : public SR2LinkMetric { 24 | 25 | public: 26 | 27 | SR2TXCountMetric(); 28 | ~SR2TXCountMetric(); 29 | const char *class_name() const { return "SR2TXCountMetric"; } 30 | const char *processing() const { return AGNOSTIC; } 31 | 32 | void update_link(IPAddress from, IPAddress to, 33 | Vector rs, 34 | Vector fwd, Vector rev, 35 | uint32_t seq); 36 | 37 | }; 38 | 39 | CLICK_ENDDECLS 40 | #endif 41 | -------------------------------------------------------------------------------- /roofnet/txflog.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_TXFLOG_HH 2 | #define CLICK_TXFLOG_HH 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | CLICK_DECLS 9 | 10 | /* 11 | * =c 12 | * TXFLog(I) 13 | * 14 | * =s Wifi 15 | * Log transmit feedback stats for later analysis. 16 | * 17 | * =d 18 | * TXFLog records the size, timestamp, and other infor for 19 | * each packet that passed through. The list of 20 | * recorded data can be dumped (and cleared) by repeated calls to the 21 | * read handler 'log'. 22 | * 23 | * =h log read-only 24 | * Print as much of the list of logged packets as possible, clearing 25 | * printed packets from the log. 26 | * =h more read-only 27 | * Returns how many entries are left to be read. 28 | * =h reset write-only 29 | * Clears the log. 30 | * 31 | */ 32 | 33 | class TXFLog : public Element { public: 34 | 35 | TXFLog(); 36 | ~TXFLog(); 37 | 38 | const char *class_name() const { return "TXFLog"; } 39 | const char *port_count() const { return PORTS_1_1; } 40 | const char *processing() const { return AGNOSTIC; } 41 | const char *flow_code() const { return "#/#"; } 42 | 43 | bool can_live_reconfigure() const { return true; } 44 | 45 | Packet *simple_action(Packet *); 46 | 47 | void add_handlers(); 48 | 49 | 50 | DEQueue _p; 51 | DEQueue _t; 52 | 53 | }; 54 | 55 | CLICK_ENDDECLS 56 | #endif 57 | -------------------------------------------------------------------------------- /security/.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile *.d *.kd *.ud *.ko *.uo 2 | kelements.conf kelements.mk kpackage.cc 3 | Kbuild .*.ko.cmd .*.o.cmd .tmp_versions kversion.c snmp.mod.c 4 | uelements.conf uelements.mk upackage.cc 5 | elementmap-security.xml 6 | config.h configure config.log config.status 7 | autom4te* 8 | -------------------------------------------------------------------------------- /security/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | *.d 3 | *.kd 4 | *.ud 5 | *.ko 6 | *.uo 7 | kelements.conf 8 | kelements.mk 9 | kpackage.cc 10 | Kbuild 11 | .*.ko.cmd 12 | .*.o.cmd 13 | .tmp_versions 14 | kversion.c 15 | snmp.mod.c 16 | uelements.conf 17 | uelements.mk 18 | upackage.cc 19 | elementmap-security.xml 20 | config.h 21 | configure 22 | config.log 23 | config.status 24 | autom4te* 25 | -------------------------------------------------------------------------------- /security/Makefile.in: -------------------------------------------------------------------------------- 1 | SHELL = @SHELL@ 2 | 3 | 4 | # THESE VARIABLES MAY CHANGE BETWEEN PACKAGES 5 | 6 | # Set 'package' to the name of your package. 7 | package := @CLICKPACKAGENAME@ 8 | 9 | # Set these variables appropriately. 10 | top_builddir := . 11 | subdir := . 12 | 13 | # Require Click prefix settings. 14 | # Generally, you will provide a '--with-click=CLICKPREFIX' option, and set: 15 | clickbuild_prefix := @clickbuild_prefix@ 16 | include @clickbuild_datadir@/config.mk 17 | 18 | # Set 'MAKE_UPACKAGE', 'MAKE_KPACKAGE', and 'MAKE_BPACKAGE' to '0' or '1' 19 | # to determine whether to build userlevel, linuxmodule, and bsdmodule 20 | # packages, respectively. 21 | MAKE_UPACKAGE = @BUILD_USERLEVEL@ 22 | MAKE_KPACKAGE = @BUILD_LINUXMODULE@ 23 | MAKE_BPACKAGE = @BUILD_BSDMODULE@ 24 | 25 | # Set 'STRIP_UPACKAGE' to 'strip -g' to strip debugging symbols from the 26 | # userlevel package before installing. 27 | #STRIP_UPACKAGE = $(STRIP) -g 28 | 29 | # Set these variables as required. 30 | DEFS = @DEFS@ $(CLICKDEFS) 31 | INCLUDES = -I. -I$(top_builddir) -I$(srcdir) $(CLICKINCLUDES) 32 | 33 | # Set this variable to force 'click-elem2package' to include a header, 34 | # such as your package's '', if necessary. 35 | #ELEM2PACKAGE_INCLUDES = -i'' 36 | 37 | # END OF VARIABLES THAT MAY CHANGE BETWEEN PACKAGES 38 | 39 | 40 | # Everything below here will probably stay unchanged 41 | 42 | srcdir = @srcdir@ 43 | top_srcdir = @top_srcdir@ 44 | 45 | ifeq ($(CLICK_PACKAGE_MAKING),) 46 | prefix = @prefix@ 47 | exec_prefix = @exec_prefix@ 48 | bindir = @bindir@ 49 | sbindir = @sbindir@ 50 | libdir = @libdir@ 51 | mandir = @mandir@ 52 | datarootdir = @datarootdir@ 53 | datadir = @datadir@ 54 | endif 55 | 56 | include $(clickbuild_datadir)/pkg-Makefile 57 | -------------------------------------------------------------------------------- /security/map_trw_example.click: -------------------------------------------------------------------------------- 1 | 2 | // Classifies into IP, ARP, and other 3 | only_ip0 :: Classifier(12/0800, 12/0806, -); 4 | only_ip1 :: Classifier(12/0800, 12/0806, -); 5 | 6 | 7 | toEth0 :: Queue; 8 | toEth1 :: Queue; 9 | 10 | trw :: MapTRW(10.10.1.254, CA:FE:BA:BE:00:01, 255.255.255.0, IP_TABLE_MIN_COUNT -15, IP_TABLE_MAX_COUNT 20, 11 | IP_TABLE_BLOCK_COUNT 5); 12 | 13 | 14 | FromDevice(eth2, PROMISC true) -> only_ip0[0] -> MarkIPHeader(14) -> 15 | [0]trw[0] -> toEth1 -> ToDevice(eth1); 16 | 17 | only_ip0[1] -> [0]trw; 18 | only_ip0[2] -> toEth1; 19 | 20 | FromDevice(eth1, PROMISC true) -> only_ip1[0] -> MarkIPHeader(14) -> 21 | [1]trw[1]-> toEth0 -> 22 | ToDevice(eth2); 23 | 24 | only_ip1[1] -> [1]trw; 25 | only_ip1[2] -> toEth0; -------------------------------------------------------------------------------- /security/rc5.hh: -------------------------------------------------------------------------------- 1 | #ifndef NW_RC5_HH 2 | #define NW_RC5_HH 3 | #include 4 | 5 | // This file is copyright 2005/2006 by the International Computer 6 | // Science Institute. It can be used for any purposes 7 | // (Berkeley-liscence) as long as this notice remains intact. 8 | 9 | // THERE IS NO WARANTEE ON THIS CODE! 10 | 11 | uint16_t * rc5_keygen(uint64_t key); 12 | uint32_t rc5_encrypt(uint32_t data, uint16_t *key); 13 | uint32_t rc5_decrypt(uint32_t data, uint16_t *key); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /security/trw_packet_utils.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "trw_packet_utils.hh" 9 | 10 | // This file is copyright 2005/2006 by the International Computer 11 | // Science Institute. It can be used for any purposes 12 | // (Berkeley-liscence) as long as this notice remains intact. 13 | 14 | // THERE IS NO WARANTEE ON THIS CODE! 15 | 16 | // Does this get dropped if we are overcount, even though 17 | // the connection is established? 18 | // Currently, its UDP, TCP SYN (and no ACK), 19 | bool block_policy(Packet *p){ 20 | const click_ip *iph = p->ip_header(); 21 | if(iph->ip_p == IP_PROTO_TCP){ 22 | const click_tcp *tcph = p->tcp_header(); 23 | if( (tcph->th_flags & TH_SYN) && 24 | !(tcph->th_flags & TH_ACK)){ 25 | return true; 26 | } 27 | } else if(iph->ip_p == IP_PROTO_UDP){ 28 | return true; 29 | } else { 30 | } 31 | return false; 32 | } 33 | 34 | // Is this a valid acknowledgement packet 35 | bool valid_ack(Packet *p){ 36 | const click_ip *iph = p->ip_header(); 37 | if(iph->ip_p == IP_PROTO_TCP){ 38 | const click_tcp *tcph = p->tcp_header(); 39 | if( (tcph->th_flags & TH_FIN) || 40 | (tcph->th_flags & TH_RST)){ 41 | // TCP FIN & RST are not valid ack, but 42 | // normal 43 | return false; 44 | } 45 | return true; 46 | } else if(iph->ip_p == IP_PROTO_UDP){ 47 | return true; 48 | } else if(iph->ip_p == IP_PROTO_ICMP){ 49 | const click_icmp *icmph = p->icmp_header(); 50 | if (icmph->icmp_type == ICMP_ECHOREPLY) { 51 | return true; 52 | } 53 | return false; 54 | } else { 55 | return true; 56 | } 57 | } 58 | 59 | 60 | CLICK_ENDDECLS 61 | ELEMENT_PROVIDES(trw_packet_utils) 62 | 63 | -------------------------------------------------------------------------------- /security/trw_packet_utils.hh: -------------------------------------------------------------------------------- 1 | #ifndef NW_PUTILS_HH 2 | #define NW_PUTILS_HH 3 | #include 4 | 5 | // This file is copyright 2005/2006 by the International Computer 6 | // Science Institute. It can be used for any purposes 7 | // (Berkeley-liscence) as long as this notice remains intact. 8 | 9 | // THERE IS NO WARANTEE ON THIS CODE! 10 | 11 | 12 | // On TRW, does this packet get blocked if a system is being blocked? 13 | bool block_policy(Packet *p); 14 | 15 | // Is this packet really an acknowledgement? 16 | bool valid_ack(Packet *p); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /snmp/.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile *.d *.kd *.ud *.ko *.uo 2 | kelements.conf kelements.mk kpackage.cc 3 | Kbuild .*.ko.cmd .*.o.cmd .tmp_versions kversion.c snmp.mod.c 4 | uelements.conf uelements.mk upackage.cc 5 | elementmap-snmp.xml 6 | config.h configure config.log config.status 7 | autom4te* 8 | -------------------------------------------------------------------------------- /snmp/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | *.d 3 | *.kd 4 | *.ud 5 | *.ko 6 | *.uo 7 | kelements.conf 8 | kelements.mk 9 | kpackage.cc 10 | Kbuild 11 | .*.ko.cmd 12 | .*.o.cmd 13 | .tmp_versions 14 | kversion.c 15 | snmp.mod.c 16 | uelements.conf 17 | uelements.mk 18 | upackage.cc 19 | elementmap-snmp.xml 20 | config.h 21 | configure 22 | config.log 23 | config.status 24 | autom4te* 25 | -------------------------------------------------------------------------------- /snmp/Makefile.in: -------------------------------------------------------------------------------- 1 | SHELL = @SHELL@ 2 | 3 | 4 | # THESE VARIABLES MAY CHANGE BETWEEN PACKAGES 5 | 6 | # Set 'package' to the name of your package. 7 | package := @CLICKPACKAGENAME@ 8 | 9 | # Set these variables appropriately. 10 | top_builddir := . 11 | subdir := . 12 | 13 | # Require Click prefix settings. 14 | # Generally, you will provide a '--with-click=CLICKPREFIX' option, and set: 15 | clickbuild_prefix := @clickbuild_prefix@ 16 | include @clickbuild_datadir@/config.mk 17 | 18 | # Set 'MAKE_UPACKAGE', 'MAKE_KPACKAGE', and 'MAKE_BPACKAGE' to '0' or '1' 19 | # to determine whether to build userlevel, linuxmodule, and bsdmodule 20 | # packages, respectively. 21 | MAKE_UPACKAGE = @BUILD_USERLEVEL@ 22 | MAKE_KPACKAGE = @BUILD_LINUXMODULE@ 23 | MAKE_BPACKAGE = @BUILD_BSDMODULE@ 24 | 25 | # Set 'STRIP_UPACKAGE' to 'strip -g' to strip debugging symbols from the 26 | # userlevel package before installing. 27 | #STRIP_UPACKAGE = $(STRIP) -g 28 | 29 | # Set these variables as required. 30 | DEFS = @DEFS@ $(CLICKDEFS) 31 | INCLUDES = -I. -I$(top_builddir) -I$(srcdir) $(CLICKINCLUDES) 32 | 33 | # Set this variable to force 'click-elem2package' to include a header, 34 | # such as your package's '', if necessary. 35 | #ELEM2PACKAGE_INCLUDES = -i'' 36 | 37 | # END OF VARIABLES THAT MAY CHANGE BETWEEN PACKAGES 38 | 39 | 40 | # Everything below here will probably stay unchanged 41 | 42 | srcdir = @srcdir@ 43 | top_srcdir = @top_srcdir@ 44 | 45 | ifeq ($(CLICK_PACKAGE_MAKING),) 46 | prefix = @prefix@ 47 | exec_prefix = @exec_prefix@ 48 | bindir = @bindir@ 49 | sbindir = @sbindir@ 50 | libdir = @libdir@ 51 | mandir = @mandir@ 52 | datarootdir = @datarootdir@ 53 | datadir = @datadir@ 54 | endif 55 | 56 | include $(clickbuild_datadir)/pkg-Makefile 57 | -------------------------------------------------------------------------------- /snmp/README: -------------------------------------------------------------------------------- 1 | Click SNMP elements 2 | =================== 3 | 4 | This directory is an add-on package for the Click modular router, 5 | http://www.read.cs.ucla.edu/click/. A prerequisite for building and using 6 | the SNMP package is building and installing a recent version of Click. The 7 | elements are documented; after "make install", try "man SNMPTrapSource". 8 | For a documented example configuration, see conf/test-trap.click. 9 | -------------------------------------------------------------------------------- /snmp/conf/test-trap.click: -------------------------------------------------------------------------------- 1 | require(snmp); 2 | 3 | /* This file demonstrates the use of Click's SNMP support elements. */ 4 | 5 | /* Part 1: The basic router */ 6 | 7 | // Send packets from source to sink via a queue. The queue will quickly 8 | // overflow. 9 | TimedSource(INTERVAL 0.1s) 10 | -> q :: Queue(10) 11 | -> TimedSink(INTERVAL 0.3s); 12 | 13 | 14 | /* Part 2: SNMP support */ 15 | 16 | // Declare an enterprise OID for our traps. The enterprise is named 17 | // "clicktest". 18 | SNMPOidInfo(clicktest private.244); 19 | 20 | // Declare an SNMP variable binding. The variable "clicktest.1" -- that is, 21 | // OID "private.244.1", or "1.3.6.1.4.244.1" -- has Counter32 type, and its 22 | // value is found by reading handler "q.drops". 23 | SNMPVariableInfo(clicktest.1 Counter32 q.drops); 24 | 25 | // Trap generation path. 26 | trapsource :: SNMPTrapSource( 27 | // Set UDP/IP source & destination addresses & ports. 28 | // Default destination port is 162. 29 | SRC 1.0.0.1, SPORT 11111, DST 2.0.0.2, 30 | // Enterprise generating the trap. 31 | ENTERPRISE clicktest, 32 | // Declare a trap named "qdrops". This trap's packets 33 | // will contain variable "clicktest.1.0", which was declared 34 | // above to correspond to the Queue's "drops" handler. 35 | // To send the trap, write to the "trapsource.send_qdrops" 36 | // handler. 37 | TRAP qdrops clicktest.1.0) 38 | -> IPPrint(LABEL trap) 39 | -> Discard; // or try "-> ToDump(foo, ENCAP IP)" 40 | 41 | // This Script element directs trap generation by poking "trapsource" when 42 | // drops happen. 43 | sendtrap :: Script( 44 | init drops 0, // initialize $drops to 0 45 | wait 1s, // wait 1 second 46 | set newdrops $(q.drops), // loop if no new drops 47 | goto begin $(eq $drops $newdrops), 48 | set drops $newdrops, 49 | write trapsource.send_qdrops, // otherwise, send trap 50 | goto begin); // and loop 51 | -------------------------------------------------------------------------------- /snmp/snmpoidtree.hh: -------------------------------------------------------------------------------- 1 | #ifndef SNMPOIDTREE_HH 2 | #define SNMPOIDTREE_HH 3 | #include 4 | #include "snmpbasics.hh" 5 | 6 | class SNMPOidTree { public: 7 | 8 | struct Node; 9 | 10 | SNMPOidTree(); 11 | ~SNMPOidTree(); 12 | 13 | int find(const SNMPOid &) const; 14 | int find_prefix(const SNMPOid &, int *prefix_length) const; 15 | Node *insert(const SNMPOid &, int); 16 | 17 | void extract_oid(Node *, SNMPOid *) const; 18 | 19 | const Node *find_node(const SNMPOid &) const; 20 | Node *force_node(const SNMPOid &); 21 | static int node_data(const Node *n) { return n->data; } 22 | static void set_node_data(Node *n, int d) { n->data = d; } 23 | 24 | struct Node { 25 | uint32_t suffix; 26 | Node *parent; 27 | Node *sibling; 28 | Node *child; 29 | int data; 30 | }; 31 | 32 | private: 33 | 34 | Node **_nodes; 35 | int _nnodes; 36 | int _nodes_cap; 37 | 38 | enum { NODES_PER_GROUP = 256 }; 39 | 40 | SNMPOidTree(const SNMPOidTree &); 41 | SNMPOidTree &operator=(const SNMPOidTree &); 42 | 43 | Node *root_node() const; 44 | Node *alloc_node(uint32_t, Node *, Node *); 45 | 46 | }; 47 | 48 | inline SNMPOidTree::Node * 49 | SNMPOidTree::root_node() const 50 | { 51 | assert(_nnodes > 0); 52 | return &(_nodes[0][0]); 53 | } 54 | 55 | inline int 56 | SNMPOidTree::find(const SNMPOid &oid) const 57 | { 58 | if (const Node *n = find_node(oid)) 59 | return n->data; 60 | else 61 | return -1; 62 | } 63 | 64 | inline SNMPOidTree::Node * 65 | SNMPOidTree::insert(const SNMPOid &oid, int data) 66 | { 67 | Node *n = force_node(oid); 68 | if (n) 69 | n->data = data; 70 | return n; 71 | } 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /unibo_qos/.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile autom4te* 2 | config.log config.status config.h 3 | -------------------------------------------------------------------------------- /unibo_qos/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | autom4te* 3 | config.log 4 | config.status 5 | config.h 6 | -------------------------------------------------------------------------------- /unibo_qos/Makefile.in: -------------------------------------------------------------------------------- 1 | SHELL = @SHELL@ 2 | 3 | 4 | # THESE VARIABLES MAY CHANGE BETWEEN PACKAGES 5 | 6 | # Set 'package' to the name of your package. 7 | package := @CLICKPACKAGENAME@ 8 | 9 | # Set these variables appropriately. 10 | top_builddir := . 11 | subdir := . 12 | 13 | # Require Click prefix settings. 14 | # Generally, you will provide a '--with-click=CLICKPREFIX' option, and set: 15 | clickbuild_prefix := @clickbuild_prefix@ 16 | include @clickbuild_datadir@/config.mk 17 | include @clickbuild_datadir@/pkg-config.mk 18 | 19 | srcdir = @srcdir@ 20 | top_srcdir = @top_srcdir@ 21 | AUTOCONF = $(CLICKAUTOCONF) 22 | ACLOCAL = : 23 | 24 | TARGETS = package 25 | 26 | all: Makefile $(TARGETS) 27 | 28 | package: Makefile 29 | @cd package && $(MAKE) all 30 | 31 | elemlist: Makefile 32 | @cd package && $(MAKE) elemlist 33 | 34 | install: Makefile 35 | @for d in $(TARGETS); do (cd $$d && $(MAKE) install) || exit 1; done 36 | 37 | install-man: 38 | @cd package && $(MAKE) install-man 39 | 40 | $(srcdir)/configure: $(srcdir)/configure.ac 41 | cd $(srcdir) && $(ACLOCAL) && $(AUTOCONF) 42 | config.status: $(srcdir)/configure 43 | $(SHELL) $(srcdir)/configure @ac_configure_args@ 44 | Makefile: config.status $(srcdir)/Makefile.in 45 | cd $(top_builddir) && \ 46 | CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status 47 | 48 | clean: 49 | @-for d in $(TARGETS); do (cd $$d && $(MAKE) clean); done 50 | 51 | distclean: 52 | @-for d in $(TARGETS); do (cd $$d && $(MAKE) distclean); done 53 | -rm -f Makefile config.status config.cache config.log config.h 54 | 55 | .PHONY: all package elemlist clean distclean \ 56 | install install-doc install-man install-include 57 | -------------------------------------------------------------------------------- /unibo_qos/package/.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile *.d *.kd *.ud *.ko *.uo 2 | kelements.conf kelements.mk kpackage.cc 3 | Kbuild .*.ko.cmd .*.o.cmd .tmp_versions kversion.c unibo_qos.mod.c 4 | uelements.conf uelements.mk upackage.cc 5 | elementmap-unibo_qos.xml 6 | -------------------------------------------------------------------------------- /unibo_qos/package/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | *.d 3 | *.kd 4 | *.ud 5 | *.ko 6 | *.uo 7 | kelements.conf 8 | kelements.mk 9 | kpackage.cc 10 | Kbuild 11 | .*.ko.cmd 12 | .*.o.cmd 13 | .tmp_versions 14 | kversion.c 15 | unibo_qos.mod.c 16 | uelements.conf 17 | uelements.mk 18 | upackage.cc 19 | elementmap-unibo_qos.xml 20 | -------------------------------------------------------------------------------- /unibo_qos/package/Makefile.in: -------------------------------------------------------------------------------- 1 | SHELL = @SHELL@ 2 | 3 | 4 | # THESE VARIABLES MAY CHANGE BETWEEN PACKAGES 5 | 6 | # Set 'package' to the name of your package. 7 | package := @CLICKPACKAGENAME@ 8 | 9 | # Set these variables appropriately. 10 | top_builddir := .. 11 | subdir := package 12 | 13 | # Require Click prefix settings. 14 | # Generally, you will provide a '--with-click=CLICKPREFIX' option, and set: 15 | clickbuild_prefix := @clickbuild_prefix@ 16 | include @clickbuild_datadir@/config.mk 17 | 18 | # Set 'MAKE_UPACKAGE', 'MAKE_KPACKAGE', and 'MAKE_BPACKAGE' to '0' or '1' 19 | # to determine whether to build userlevel, linuxmodule, and bsdmodule 20 | # packages, respectively. 21 | MAKE_UPACKAGE = @BUILD_USERLEVEL@ 22 | MAKE_KPACKAGE = @BUILD_LINUXMODULE@ 23 | MAKE_BPACKAGE = @BUILD_BSDMODULE@ 24 | 25 | # Set 'STRIP_UPACKAGE' to 'strip -g' to strip debugging symbols from the 26 | # userlevel package before installing. 27 | #STRIP_UPACKAGE = $(STRIP) -g 28 | 29 | # Set these variables as required. 30 | DEFS = @DEFS@ $(CLICKDEFS) 31 | INCLUDES = -I. -I$(top_builddir) -I$(srcdir) $(CLICKINCLUDES) 32 | 33 | # Set this variable to force 'click-elem2package' to include a header, 34 | # such as your package's '', if necessary. 35 | #ELEM2PACKAGE_INCLUDES = -i'' 36 | 37 | # END OF VARIABLES THAT MAY CHANGE BETWEEN PACKAGES 38 | 39 | 40 | # Everything below here will probably stay unchanged 41 | 42 | srcdir = @srcdir@ 43 | top_srcdir = @top_srcdir@ 44 | 45 | ifeq ($(CLICK_PACKAGE_MAKING),) 46 | prefix = @prefix@ 47 | exec_prefix = @exec_prefix@ 48 | bindir = @bindir@ 49 | sbindir = @sbindir@ 50 | libdir = @libdir@ 51 | mandir = @mandir@ 52 | datarootdir = @datarootdir@ 53 | datadir = @datadir@ 54 | endif 55 | 56 | include $(clickbuild_datadir)/pkg-Makefile 57 | -------------------------------------------------------------------------------- /unibo_qos/package/getssrc.hh: -------------------------------------------------------------------------------- 1 | #ifndef GETSSRC_HH 2 | #define GETSSRC_HH 3 | #include 4 | #include 5 | 6 | /* 7 | * =c 8 | * GetSSRC(OFFSET) 9 | * =s QoS 10 | * splits packets _possibly_ containing an SSRC field (used by the RTP protocol): this is copied it inside the packet annotation field 11 | * =processing 12 | * Push 13 | * 14 | * =d 15 | * GetSSRC has two output ports. All incoming packets _possibly_ having an SSRC field 16 | * marked up are directed to output port 0, any remaining packets are emitted on 17 | * output port 1 (since they cannot absolutely pertain to an RTP flow). 18 | * 19 | * =e 20 | * elementclass class_RTP { 21 | * $ssrc, $dscp | 22 | * get::GetSSRC($ssrc); 23 | * rtp::RTPClassifier; 24 | * set::SetIPDSCP($dscp); 25 | * input->get[0]->rtp; 26 | * get[1]->[1]output; 27 | * rtp[0]->set->[0]output; 28 | * rtp[1]->[1]output; 29 | * } 30 | * 31 | * In the above example, GetSSRC is used in combination with the RTPClassifier and SetIPDSCP elements 32 | * to hook an RTP flow and mark its packets' DSCP field. 33 | * 34 | * =h SSRC offset in bytes (write-only) 35 | * Offset (in bytes) of the SSRC field from the beginning of the Ethernet datagram (50 bytes). 36 | * See also RFC 3550. 37 | * 38 | * =a RTPClassifier, SetIPDSCP */ 39 | 40 | 41 | class GetSSRC : public Element { 42 | 43 | unsigned _offset; 44 | uint8_t _ssrc,i; 45 | 46 | public: 47 | 48 | GetSSRC(); 49 | ~GetSSRC(); 50 | 51 | const char *class_name() const { return "GetSSRC"; } 52 | const char *port_count() const { return "1/2"; } 53 | const char *processing() const { return AGNOSTIC; } 54 | 55 | GetSSRC *clone() const { return new GetSSRC; } 56 | int configure(Vector &, ErrorHandler *); 57 | 58 | void push(int,Packet *); 59 | 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /unibo_qos/package/packet_anno.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICKMODULE_UNIBO_QOS_PACKET_ANNO_HH 2 | #define CLICKMODULE_UNIBO_QOS_PACKET_ANNO_HH 3 | 4 | // bytes 8-11 5 | #define SSRC_ANNO(p) ((p)->user_anno_u8(2)) 6 | #define SET_SSRC_ANNO(p, v) ((p)->set_user_anno_u8(2, (v))) 7 | 8 | #endif /* CLICKMODULE_UNIBO_QOS_PACKET_ANNO_HH */ 9 | -------------------------------------------------------------------------------- /unibo_qos/package/splitfirst.hh: -------------------------------------------------------------------------------- 1 | #ifndef CLICK_SPLITFIRST_HH 2 | #define CLICK_SPLITFIRST_HH 3 | #include 4 | 5 | 6 | /* 7 | * =c 8 | * SplitFirst(THRESHOLD) 9 | * =s QoS, classification 10 | * splits the first N packets to output port 1, to port 0 otherwise. 11 | * =processing 12 | * Push 13 | * 14 | * =d 15 | * SplitFirst splits the first incoming THRESHOLD packets to output port 1: this 16 | * behavior is useful to use only the following packets (which should 17 | * represent a more "stable" flow) to statistically hook a real-time (not-RTP) flow. 18 | * 19 | * =e 20 | * elementclass class_stat { 21 | * $first, $av_length, $av_rate, $dscp | 22 | * split::SplitFirst($first); 23 | * check_length::CheckAverageLength($av_length); 24 | * check_rate::Meter($av_rate); 25 | * set::SetIPDSCP($dscp); 26 | * input->split; 27 | * split[1]->[1]output; 28 | * split[0]->check_length; 29 | * check_length[0]->[2]output; 30 | * check_length[1]->check_rate; 31 | * check_rate[0]->[3]output; 32 | * check_rate[1]->set->[0]output; 33 | * } 34 | * 35 | * In the above example, SplitFirst is used in combination with CheckAveragelength, Meter and IPDSCP 36 | * elements to hook a real-time (not-RTP) flow and mark its packets' DSCP field. 37 | * 38 | * =h threshold (write-only) 39 | * Number of first incoming packets to filter out. 40 | * 41 | * =a CheckAverageLength, Meter, SetIPDSCP */ 42 | 43 | 44 | class SplitFirst : public Element { public: 45 | 46 | SplitFirst(); 47 | ~SplitFirst(); 48 | 49 | const char *class_name() const { return "SplitFirst"; } 50 | const char *port_count() const { return "1/2"; } 51 | const char *processing() const { return PUSH; } 52 | SplitFirst *clone() const { return new SplitFirst; } 53 | 54 | int configure(Vector &, ErrorHandler *); 55 | 56 | void push(int port, Packet *); 57 | 58 | private: 59 | 60 | unsigned threshold,current_no_of_packets; 61 | 62 | 63 | }; 64 | 65 | #endif 66 | --------------------------------------------------------------------------------