├── samples ├── lighttpd-1.4.32 │ ├── [config.h].in │ ├── src │ │ ├── mod_auth.h │ │ ├── config │ │ │ └── arp.conf │ │ ├── logs │ │ │ └── .gitignore │ │ ├── inet_ntop_cache.h │ │ ├── request.h │ │ ├── stream.h │ │ ├── version.h │ │ ├── network.h │ │ ├── crc32.h │ │ ├── joblist.h │ │ ├── stat_cache.h │ │ ├── server.h │ │ ├── sys-mmap.h │ │ ├── bitset.h │ │ ├── etag.h │ │ ├── http_chunk.h │ │ ├── status_counter.h │ │ ├── mod_cml_funcs.h │ │ ├── sys-socket.h │ │ ├── mod_ssi_exprparser.h │ │ ├── proc_open.h │ │ ├── log.h │ │ ├── mod_magnet_cache.h │ │ ├── connections.h │ │ ├── splaytree.h │ │ ├── mod_ssi_expr.h │ │ ├── mod_cml.h │ │ ├── mod_ssi.h │ │ ├── response.h │ │ ├── configfile.h │ │ ├── configparser.h │ │ ├── etag.c │ │ ├── settings.h │ │ ├── connections-glue.c │ │ ├── bitset.c │ │ ├── data_integer.c │ │ ├── data_array.c │ │ ├── data_count.c │ │ ├── data_fastcgi.c │ │ ├── md5.h │ │ ├── status_counter.c │ │ ├── inet_ntop_cache.c │ │ ├── joblist.c │ │ ├── http_auth.h │ │ └── stream.c │ ├── tests │ │ ├── lighttpd.user │ │ ├── docroot │ │ │ ├── 123 │ │ │ │ ├── 12345.html │ │ │ │ ├── 12345.txt │ │ │ │ ├── dummyfile.bla │ │ │ │ ├── phpinfo.php │ │ │ │ └── Makefile.am │ │ │ ├── www │ │ │ │ ├── expire │ │ │ │ │ ├── access.txt │ │ │ │ │ ├── modification.txt │ │ │ │ │ └── Makefile.am │ │ │ │ ├── 404.html │ │ │ │ ├── phpinfo.php │ │ │ │ ├── go │ │ │ │ │ ├── Makefile.am │ │ │ │ │ └── cgi.php │ │ │ │ ├── ssi.shtml │ │ │ │ ├── exec-date.shtml │ │ │ │ ├── indexfile │ │ │ │ │ ├── index.php │ │ │ │ │ ├── Makefile.am │ │ │ │ │ ├── rewrite.php │ │ │ │ │ └── return-404.php │ │ │ │ ├── prefix.fcgi │ │ │ │ ├── get-server-env.php │ │ │ │ ├── redirect.php │ │ │ │ ├── get-env.php │ │ │ │ ├── crlfcrash.pl │ │ │ │ ├── cgi.pl │ │ │ │ ├── cgi-pathinfo.pl │ │ │ │ ├── send404.pl │ │ │ │ ├── cgi.php │ │ │ │ ├── get-header.pl │ │ │ │ ├── nph-status.pl │ │ │ │ ├── get-post-len.pl │ │ │ │ ├── Makefile.am │ │ │ │ ├── sendfile.php │ │ │ │ ├── 404.fcgi │ │ │ │ └── 404.pl │ │ │ └── Makefile.am │ │ ├── lighttpd.htpasswd │ │ ├── wrapper.sh │ │ ├── cleanup.sh │ │ ├── run-tests.pl │ │ ├── fcgi-auth.c │ │ ├── mod-access.t │ │ ├── mod-ssi.t │ │ ├── var-include-sub.conf │ │ ├── mod-compress.conf │ │ ├── mod-userdir.t │ │ ├── SConscript │ │ ├── fcgi-responder.c │ │ ├── var-include.conf │ │ ├── mod-setenv.t │ │ ├── Makefile.am │ │ ├── 404-handler.conf │ │ ├── prepare.sh │ │ ├── core-var-include.t │ │ ├── mod-redirect.t │ │ └── mod-secdownload.t │ ├── doc │ │ ├── systemd │ │ │ ├── Makefile.am │ │ │ └── lighttpd.service │ │ ├── config │ │ │ ├── vhosts.d │ │ │ │ ├── Makefile.am │ │ │ │ └── vhosts.template │ │ │ ├── Makefile.am │ │ │ └── conf.d │ │ │ │ ├── mod.template │ │ │ │ ├── ssi.conf │ │ │ │ ├── Makefile.am │ │ │ │ ├── magnet.conf │ │ │ │ ├── rrdtool.conf │ │ │ │ ├── evhost.conf │ │ │ │ ├── expire.conf │ │ │ │ ├── cml.conf │ │ │ │ ├── status.conf │ │ │ │ ├── access_log.conf │ │ │ │ ├── webdav.conf │ │ │ │ ├── secdownload.conf │ │ │ │ ├── compress.conf │ │ │ │ ├── simple_vhost.conf │ │ │ │ ├── geoip.conf │ │ │ │ ├── proxy.conf │ │ │ │ ├── auth.conf │ │ │ │ ├── userdir.conf │ │ │ │ ├── cgi.conf │ │ │ │ ├── debug.conf │ │ │ │ ├── mysql_vhost.conf │ │ │ │ ├── scgi.conf │ │ │ │ └── dirlisting.conf │ │ ├── scripts │ │ │ ├── Makefile.am │ │ │ ├── rrdtool-graph.sh │ │ │ └── spawn-php.sh │ │ ├── initscripts │ │ │ ├── sysconfig.lighttpd │ │ │ ├── Makefile.am │ │ │ └── rc.lighttpd.redhat │ │ ├── Makefile.am │ │ ├── outdated │ │ │ ├── fastcgi-state.dot │ │ │ ├── skeleton.txt │ │ │ ├── state.dot │ │ │ ├── alias.txt │ │ │ ├── scgi.txt │ │ │ ├── setenv.txt │ │ │ ├── evhost.txt │ │ │ ├── access.txt │ │ │ ├── security.txt │ │ │ ├── cgi.txt │ │ │ ├── expire.txt │ │ │ ├── redirect.txt │ │ │ ├── fastcgi-state.txt │ │ │ ├── traffic-shaping.txt │ │ │ ├── mysqlvhost.txt │ │ │ ├── webdav.txt │ │ │ ├── ssl.txt │ │ │ ├── trigger_b4_dl.txt │ │ │ ├── Makefile.am │ │ │ ├── ssi.txt │ │ │ └── userdir.txt │ │ ├── oldstyle.css │ │ └── newstyle.css │ ├── NEWS │ ├── Makefile.am │ ├── AUTHORS │ ├── m4 │ │ └── ltversion.m4 │ ├── COPYING │ └── distribute.sh.in ├── epserver │ ├── config │ │ └── epserver.conf │ ├── logs │ │ └── .gitignore │ └── Makefile.in ├── epwget │ ├── logs │ │ └── .gitignore │ ├── config │ │ └── epwget.conf │ └── Makefile.in ├── midstat │ ├── logs │ │ └── .gitignore │ ├── config │ │ └── .gitignore │ ├── README │ └── Makefile.in ├── nat │ ├── logs │ │ └── .gitignore │ ├── config │ │ └── nat.conf │ └── Makefile.in ├── common │ ├── config │ │ └── .gitignore │ └── applib.h └── simple_firewall │ ├── logs │ └── .gitignore │ ├── config │ └── simple_firewall.conf │ └── Makefile.in ├── core ├── include │ ├── mos_api.h │ ├── mtcp_api.h │ ├── mtcp_epoll.h │ └── mtcp_util.h ├── lib │ └── .gitignore ├── src │ ├── include │ │ ├── cpu.h │ │ ├── proxy_tcp.h │ │ ├── eth_in.h │ │ ├── util.h │ │ ├── pipe.h │ │ ├── eth_out.h │ │ ├── memory_mgt.h │ │ ├── ip_out.h │ │ ├── tcp.h │ │ ├── tcp_util.h │ │ ├── arp.h │ │ ├── tcp_sb_queue.h │ │ ├── key_value_store.h │ │ ├── tcp_rb_frag_queue.h │ │ ├── fhash.h │ │ ├── logger.h │ │ ├── ip_in.h │ │ ├── tcp_send_buffer.h │ │ ├── stat.h │ │ ├── eventpoll.h │ │ ├── bpf │ │ │ └── nlpid.h │ │ └── tcp_out.h │ ├── bpf │ │ ├── Makefile │ │ └── main.c │ └── cpu.c └── test │ ├── tree │ ├── Makefile │ └── test.c │ ├── tcprb │ ├── Makefile │ └── test.c │ └── scalable_event │ └── Makefile ├── VERSION ├── util ├── include │ ├── cpu.h │ ├── rss.h │ ├── ring_buffer.h │ ├── http_parsing.h │ ├── netlib.h │ └── debug.h └── cpu.c ├── .gitmodules ├── scripts └── Makefile.test ├── README.md ├── docs ├── man │ ├── mtcp_destroy │ ├── mtcp_destroy_context │ ├── mtcp_set_uctx │ └── mtcp_settimer └── Makefile.template ├── .travis.yml ├── dpdk-iface-kmod ├── dpdk_iface_common.h └── Makefile ├── LICENSE └── .standalone-template.conf /samples/lighttpd-1.4.32/[config.h].in: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/mod_auth.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /core/include/mos_api.h: -------------------------------------------------------------------------------- 1 | ../src/include/mos_api.h -------------------------------------------------------------------------------- /core/include/mtcp_api.h: -------------------------------------------------------------------------------- 1 | ../src/include/mtcp_api.h -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 28/05/2016 2 | ---------- 3 | mos_release_0.3 -------------------------------------------------------------------------------- /core/include/mtcp_epoll.h: -------------------------------------------------------------------------------- 1 | ../src/include/mtcp_epoll.h -------------------------------------------------------------------------------- /core/include/mtcp_util.h: -------------------------------------------------------------------------------- 1 | ../src/include/mtcp_util.h -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/lighttpd.user: -------------------------------------------------------------------------------- 1 | jan:jan 2 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/docroot/123/12345.html: -------------------------------------------------------------------------------- 1 | 12345 2 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/docroot/123/12345.txt: -------------------------------------------------------------------------------- 1 | 12345 2 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/docroot/www/expire/access.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/docroot/123/dummyfile.bla: -------------------------------------------------------------------------------- 1 | 12345 2 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/docroot/www/expire/modification.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/docroot/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS=123 www 2 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/docroot/www/404.html: -------------------------------------------------------------------------------- 1 | static not found 2 | -------------------------------------------------------------------------------- /samples/epserver/config/epserver.conf: -------------------------------------------------------------------------------- 1 | www_main = www 2 | core_limit = 4 3 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/docroot/123/phpinfo.php: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/docroot/www/phpinfo.php: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/systemd/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST=lighttpd.service 2 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/docroot/www/go/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST=cgi.php 2 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/config/vhosts.d/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST=vhosts.template 2 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/docroot/www/ssi.shtml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/config/arp.conf: -------------------------------------------------------------------------------- 1 | ARP_ENTRY 1 2 | 10.0.0.10/32 90:e2:ba:7c:1f:a4 -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/docroot/www/exec-date.shtml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/docroot/www/expire/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST=access.txt modification.txt 2 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/docroot/www/indexfile/index.php: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/docroot/www/prefix.fcgi: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /core/lib/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/scripts/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST= \ 2 | rrdtool-graph.sh \ 3 | spawn-php.sh 4 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/lighttpd.htpasswd: -------------------------------------------------------------------------------- 1 | des:12tMnfw882VDQ 2 | md5:$1$md5$kIa7Juuiv8zja0ILQPR36/ 3 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/initscripts/sysconfig.lighttpd: -------------------------------------------------------------------------------- 1 | LIGHTTPD_CONF_PATH=/etc/lighttpd/lighttpd.conf 2 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/docroot/www/get-server-env.php: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /samples/epwget/logs/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/config/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS=conf.d vhosts.d 2 | EXTRA_DIST=lighttpd.conf modules.conf 3 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/initscripts/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST=rc.lighttpd rc.lighttpd.redhat sysconfig.lighttpd 2 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/docroot/123/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST=12345.html 12345.txt dummyfile.bla phpinfo.php 2 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/docroot/www/indexfile/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST=index.php return-404.php rewrite.php 2 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/docroot/www/indexfile/rewrite.php: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /samples/midstat/logs/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /samples/nat/logs/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /core/src/include/cpu.h: -------------------------------------------------------------------------------- 1 | #ifndef __CPU_H_ 2 | #define __CPU_H_ 3 | 4 | int GetNumCPUs(); 5 | 6 | #endif /* __CPU_H_ */ 7 | -------------------------------------------------------------------------------- /samples/common/config/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /samples/epserver/logs/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/NEWS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mos-stack/mOS-networking-stack/HEAD/samples/lighttpd-1.4.32/NEWS -------------------------------------------------------------------------------- /samples/midstat/config/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /samples/nat/config/nat.conf: -------------------------------------------------------------------------------- 1 | core_limit = 1 2 | ip_in = 10.0.0.48 3 | ip_out = 10.0.0.48 4 | port_in = 3333 5 | port_out = 80 -------------------------------------------------------------------------------- /samples/simple_firewall/logs/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/logs/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/docroot/www/redirect.php: -------------------------------------------------------------------------------- 1 | 5 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/docroot/www/get-env.php: -------------------------------------------------------------------------------- 1 | 5 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/docroot/www/crlfcrash.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | # 3 | print "Location: http://www.example.org/\r\n\n\n"; 4 | exit; 5 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/docroot/www/indexfile/return-404.php: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /util/include/cpu.h: -------------------------------------------------------------------------------- 1 | #ifndef __CPU_H_ 2 | #define __CPU_H_ 3 | 4 | int GetNumCPUs(); 5 | int CoreAffinitize(int cpu); 6 | 7 | #endif /* __CPU_H_ */ 8 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/docroot/www/cgi.pl: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl 2 | 3 | print "Content-Type: text/html\r\n\r\n"; 4 | 5 | print $ENV{"SCRIPT_NAME"}; 6 | 7 | 0; 8 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/docroot/www/cgi-pathinfo.pl: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl 2 | 3 | print "Content-Type: text/html\r\n\r\n"; 4 | 5 | print $ENV{"PATH_INFO"}; 6 | 7 | 0; 8 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "drivers/dpdk"] 2 | path = drivers/dpdk 3 | url = https://dpdk.org/git/dpdk 4 | branch = master 5 | commit = 0da7f445df445630c794897347ee360d6fe6348b 6 | 7 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS=config scripts initscripts systemd outdated 2 | dist_man8_MANS=lighttpd.8 3 | 4 | EXTRA_DIST= \ 5 | newstyle.css \ 6 | oldstyle.css 7 | -------------------------------------------------------------------------------- /samples/epwget/config/epwget.conf: -------------------------------------------------------------------------------- 1 | url = 10.0.0.4/index-8192.html 2 | dest_port = 80 3 | total_flows = 100000000 4 | #total_flows = 100000 5 | total_concurrency = 4000 6 | core_limit = 4 7 | -------------------------------------------------------------------------------- /scripts/Makefile.test: -------------------------------------------------------------------------------- 1 | samples = epserver epwget midstat nat simple_firewall 2 | 3 | test: samples 4 | for i in $(samples) ; do \ 5 | cd samples/$$i ; \ 6 | make ; \ 7 | cd ../.. ; \ 8 | done 9 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/docroot/www/send404.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use CGI qw/:standard/; 3 | print header ( -status => 404 4 | -type => 'text/plain' ); 5 | print ("send404\n"); 6 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/wrapper.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ## get some parameters from the makefile 4 | 5 | srcdir=$1 6 | top_builddir=$2 7 | export SHELL srcdir top_builddir 8 | 9 | exec $3 10 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/outdated/fastcgi-state.dot: -------------------------------------------------------------------------------- 1 | digraph fcgistate { 2 | init -> connect -> prepwrite -> write -> read -> close 3 | write -> write 4 | read -> read 5 | connect -> connect 6 | } 7 | -------------------------------------------------------------------------------- /samples/midstat/README: -------------------------------------------------------------------------------- 1 | How To 2 | 3 | PCAP is only for single CPU core 4 | If you are using PCAP, then 5 | $ make 6 | $ ./midstat -c 1 7 | 8 | If you are using DPDK, then 9 | $ make 10 | $ ./midstat 11 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/inet_ntop_cache.h: -------------------------------------------------------------------------------- 1 | #ifndef _INET_NTOP_CACHE_H_ 2 | #define _INET_NTOP_CACHE_H_ 3 | 4 | #include "base.h" 5 | const char * inet_ntop_cache_get_ip(server *srv, sock_addr *addr); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /core/src/include/proxy_tcp.h: -------------------------------------------------------------------------------- 1 | #ifndef __PROXY_TCP_H_ 2 | #define __PROXY_TCP_H_ 3 | 4 | struct tcp_proxy { 5 | 6 | int socket_id; 7 | 8 | int client_id; 9 | int server_id; 10 | 11 | }; 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS=src doc tests 2 | 3 | EXTRA_DIST=autogen.sh SConstruct 4 | 5 | ACLOCAL_AMFLAGS = -I m4 6 | 7 | distcleancheck_listfiles = find -type f -exec sh -c 'test -f $(srcdir)/{} || echo {}' ';' 8 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/docroot/www/cgi.php: -------------------------------------------------------------------------------- 1 | \n"; 5 | #phpinfo(); 6 | #header("Content-Length: ".ob_get_length()); 7 | #ob_end_flush(); 8 | 9 | ?> 10 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/docroot/www/go/cgi.php: -------------------------------------------------------------------------------- 1 | \n"; 5 | #phpinfo(); 6 | #header("Content-Length: ".ob_get_length()); 7 | #ob_end_flush(); 8 | 9 | ?> 10 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/docroot/www/get-header.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | my $s = $ENV{$ENV{"QUERY_STRING"}}; 4 | 5 | printf("Content-Length: %d\r\n", length($s)); 6 | print "Content-Type: text/plain\r\n\r\n"; 7 | 8 | print $s; 9 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/AUTHORS: -------------------------------------------------------------------------------- 1 | Jan Kneschke 2 | Elan Ruusamäe 3 | Marcus Rückert 4 | mOo 5 | Robert Jakabosky 6 | Stefan Bühler 7 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/request.h: -------------------------------------------------------------------------------- 1 | #ifndef _REQUEST_H_ 2 | #define _REQUEST_H_ 3 | 4 | #include "server.h" 5 | 6 | int http_request_parse(server *srv, connection *con); 7 | int http_request_header_finished(server *srv, connection *con); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/cleanup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if test x$srcdir = x; then 4 | srcdir=. 5 | fi 6 | 7 | tmpdir=$top_builddir/tests/tmp/ 8 | 9 | # remove test-framework 10 | rm -rf $tmpdir 11 | 12 | printf "%-40s" "cleaning up" 13 | 14 | exit 0 15 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/docroot/www/nph-status.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | my $status = 200; 4 | 5 | if (defined $ENV{"QUERY_STRING"}) { 6 | $status = $ENV{"QUERY_STRING"}; 7 | } 8 | 9 | print "HTTP/1.0 ".$status." FooBar\r\n"; 10 | print "\r\n"; 11 | -------------------------------------------------------------------------------- /samples/simple_firewall/config/simple_firewall.conf: -------------------------------------------------------------------------------- 1 | # Simple firewall rules 2 | #(act) (src) (dst) (port) 3 | DROP 10.0.0.0/24 10.0.0.0/24 dport:80 4 | ACCEPT 10.0.1.7 10.0.1.9 sport:1024 5 | ACCEPT 10.0.2.7 10.0.2.9 6 | ACCEPT 10.0.3.0/24 10.0.3.0/24 -------------------------------------------------------------------------------- /core/src/include/eth_in.h: -------------------------------------------------------------------------------- 1 | #ifndef __ETH_IN_H_ 2 | #define __ETH_IN_H_ 3 | 4 | #include "mtcp.h" 5 | 6 | int 7 | ProcessPacket(mtcp_manager_t mtcp, const int ifidx, const int index, 8 | uint32_t cur_ts, unsigned char *pkt_data, int len); 9 | 10 | #endif /* __ETH_IN_H_ */ 11 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/stream.h: -------------------------------------------------------------------------------- 1 | #ifndef _STREAM_H_ 2 | #define _STREAM_H_ 3 | 4 | #include "buffer.h" 5 | 6 | typedef struct { 7 | char *start; 8 | off_t size; 9 | } stream; 10 | 11 | int stream_open(stream *f, buffer *fn); 12 | int stream_close(stream *f); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/version.h: -------------------------------------------------------------------------------- 1 | #ifndef _VERSION_H_ 2 | #define _VERSION_H_ 3 | 4 | #ifdef HAVE_VERSION_H 5 | # include "versionstamp.h" 6 | #else 7 | # define REPO_VERSION "" 8 | #endif 9 | 10 | #define PACKAGE_DESC PACKAGE_NAME "/" PACKAGE_VERSION REPO_VERSION 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /core/src/include/util.h: -------------------------------------------------------------------------------- 1 | #ifndef __UTIL_H_ 2 | #define __UTIL_H_ 3 | 4 | #include 5 | 6 | /* sip, dip, sp, dp: in network byte order */ 7 | int GetRSSCPUCore(in_addr_t sip, in_addr_t dip, 8 | in_port_t sp, in_port_t dp, int num_queues); 9 | 10 | #endif /* __UTIL_H_ */ 11 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/docroot/www/get-post-len.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | 4 | print "Content-Type: text/plain\r\n\r\n"; 5 | 6 | if ($ENV{"REQUEST_METHOD"} eq "POST") { 7 | my $l = 0; 8 | while(<>) { 9 | $l += length($_); 10 | } 11 | print $l; 12 | } else { 13 | print "0"; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/systemd/lighttpd.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Lighttpd Daemon 3 | After=network.target 4 | 5 | [Service] 6 | ExecStartPre=/usr/sbin/lighttpd -t -f /etc/lighttpd/lighttpd.conf 7 | ExecStart=/usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf 8 | 9 | [Install] 10 | WantedBy=multi-user.target 11 | -------------------------------------------------------------------------------- /core/test/tree/Makefile: -------------------------------------------------------------------------------- 1 | 2 | PROG=tree 3 | 4 | .PRECIOUS: $(PROG) 5 | 6 | SRC=../../src 7 | PS_DIR=../../../../io_engine/io_engine-2.0.38.2 8 | 9 | all: clean $(PROG) 10 | 11 | $(PROG): test.c 12 | gcc -g -Wall $^ -DTEST -I$(SRC)/include -I$(PS_DIR)/include -o $@ 13 | ./$(PROG) 14 | 15 | clean: 16 | rm -f $(PROG) 17 | rm -f core 18 | -------------------------------------------------------------------------------- /core/src/bpf/Makefile: -------------------------------------------------------------------------------- 1 | CC=gcc 2 | INC=../include/bpf/ 3 | CFLAGS=-g -O3 -I$(INC) -DTEST_BPF 4 | LDFLAGS= 5 | TARGET=main 6 | 7 | all: sf_bpf_filter.c sfbpf-int.c sf_gencode.c sf_grammar.c \ 8 | sf_nametoaddr.c sf_optimize.c sf_scanner.c main.c 9 | $(CC) $(CFLAGS) $(LDFLAGS) $? -o $(TARGET) 10 | clean: 11 | rm -rf *.o $(TARGET) *~ 12 | 13 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/network.h: -------------------------------------------------------------------------------- 1 | #ifndef _NETWORK_H_ 2 | #define _NETWORK_H_ 3 | 4 | #include "server.h" 5 | 6 | int network_write_chunkqueue(server *srv, connection *con, chunkqueue *c, off_t max_bytes); 7 | 8 | int network_init(server *srv); 9 | int network_close(server *srv); 10 | 11 | int network_register_fdevents(server *srv); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/docroot/www/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST=cgi.php cgi.pl index.html index.txt phpinfo.php \ 2 | redirect.php cgi-pathinfo.pl get-env.php get-server-env.php \ 3 | nph-status.pl prefix.fcgi get-header.pl ssi.shtml get-post-len.pl \ 4 | exec-date.shtml 404.fcgi 404.html 404.pl send404.pl crlfcrash.pl sendfile.php 5 | SUBDIRS=go indexfile expire 6 | -------------------------------------------------------------------------------- /core/test/tcprb/Makefile: -------------------------------------------------------------------------------- 1 | 2 | .PRECIOUS: test 3 | 4 | SRC=../../src 5 | PS_DIR=../../../../io_engine/io_engine-2.0.38.2 6 | 7 | all: clean test 8 | 9 | test: test.c $(SRC)/tcp_rb.c $(SRC)/include/tcp_rb.h \ 10 | $(SRC)/memory_mgt.c 11 | gcc -g -Wall $^ -DTEST -I$(SRC)/include -I$(PS_DIR)/include -o $@ 12 | ./test 13 | 14 | clean: 15 | rm -f test 16 | rm -f core 17 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/docroot/www/sendfile.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/crc32.h: -------------------------------------------------------------------------------- 1 | #ifndef __crc32cr_table_h__ 2 | #define __crc32cr_table_h__ 3 | 4 | #ifdef HAVE_CONFIG_H 5 | # include "config.h" 6 | #endif 7 | 8 | #include 9 | 10 | #if defined HAVE_STDINT_H 11 | # include 12 | #elif defined HAVE_INTTYPES_H 13 | # include 14 | #endif 15 | 16 | uint32_t generate_crc32c(char *string, size_t length); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/config/conf.d/mod.template: -------------------------------------------------------------------------------- 1 | ####################################################################### 2 | ## 3 | ## Foo Module 4 | ## --------------- 5 | ## 6 | ## http://www.lighttpd.net/documentation/Foo.html 7 | ## 8 | server.modules += ( "mod_Foo" ) 9 | 10 | ## 11 | ## foo 12 | ## 13 | #foo.bar = 1 14 | 15 | ## 16 | ####################################################################### 17 | -------------------------------------------------------------------------------- /util/include/rss.h: -------------------------------------------------------------------------------- 1 | #ifndef _RSS_H_ 2 | #define _RSS_H_ 3 | 4 | #include 5 | 6 | /* return RSS hash value (32 bit) based on 4 tuple values */ 7 | uint32_t GetRSSHash(in_addr_t sip, in_addr_t dip, 8 | in_port_t sp, in_port_t dp); 9 | 10 | /* sip, dip, sp, dp: host-byte order */ 11 | int GetRSSCPUCore(in_addr_t sip, in_addr_t dip, 12 | in_port_t sp, in_port_t dp, int num_cpus); 13 | #endif 14 | -------------------------------------------------------------------------------- /core/src/include/pipe.h: -------------------------------------------------------------------------------- 1 | #ifndef __MTCP_PIPE_H_ 2 | #define __MTCP_PIPE_H_ 3 | 4 | #include 5 | 6 | int 7 | PipeRead(mctx_t mctx, int pipeid, char *buf, int len); 8 | 9 | int 10 | PipeWrite(mctx_t mctx, int pipeid, const char *buf, int len); 11 | 12 | int 13 | RaisePendingPipeEvents(mctx_t mctx, int epid, int pipeid); 14 | 15 | int 16 | PipeClose(mctx_t mctx, int pipeid); 17 | 18 | #endif /* __MTCP_PIPE_H_ */ 19 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/joblist.h: -------------------------------------------------------------------------------- 1 | #ifndef _JOB_LIST_H_ 2 | #define _JOB_LIST_H_ 3 | 4 | #include "base.h" 5 | 6 | int joblist_append(server *srv, connection *con); 7 | void joblist_free(server *srv, connections *joblist); 8 | 9 | int fdwaitqueue_append(server *srv, connection *con); 10 | void fdwaitqueue_free(server *srv, connections *fdwaitqueue); 11 | connection *fdwaitqueue_unshift(server *srv, connections *fdwaitqueue); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/stat_cache.h: -------------------------------------------------------------------------------- 1 | #ifndef _FILE_CACHE_H_ 2 | #define _FILE_CACHE_H_ 3 | 4 | #include "base.h" 5 | 6 | stat_cache *stat_cache_init(void); 7 | void stat_cache_free(stat_cache *fc); 8 | 9 | handler_t stat_cache_get_entry(server *srv, connection *con, buffer *name, stat_cache_entry **fce); 10 | handler_t stat_cache_handle_fdevent(server *srv, void *_fce, int revent); 11 | 12 | int stat_cache_trigger_cleanup(server *srv); 13 | #endif 14 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/server.h: -------------------------------------------------------------------------------- 1 | #ifndef _SERVER_H_ 2 | #define _SERVER_H_ 3 | 4 | #include "base.h" 5 | 6 | typedef struct { 7 | char *key; 8 | char *value; 9 | } two_strings; 10 | 11 | typedef enum { CONFIG_UNSET, CONFIG_DOCUMENT_ROOT } config_var_t; 12 | 13 | int config_read(server *srv, const char *fn); 14 | int config_set_defaults(server *srv); 15 | buffer *config_get_value_buffer(server *srv, connection *con, config_var_t field); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/sys-mmap.h: -------------------------------------------------------------------------------- 1 | #ifndef WIN32_MMAP_H 2 | #define WIN32_MMAP_H 3 | 4 | #ifdef __WIN32 5 | 6 | #define MAP_FAILED -1 7 | #define PROT_SHARED 0 8 | #define MAP_SHARED 0 9 | #define PROT_READ 0 10 | 11 | #define mmap(a, b, c, d, e, f) (-1) 12 | #define munmap(a, b) (-1) 13 | 14 | #include 15 | 16 | #else 17 | #include 18 | 19 | #ifndef MAP_FAILED 20 | #define MAP_FAILED -1 21 | #endif 22 | #endif 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/bitset.h: -------------------------------------------------------------------------------- 1 | #ifndef _BITSET_H_ 2 | #define _BITSET_H_ 3 | 4 | #include 5 | 6 | typedef struct { 7 | size_t *bits; 8 | size_t nbits; 9 | } bitset; 10 | 11 | bitset *bitset_init(size_t nbits); 12 | void bitset_reset(bitset *set); 13 | void bitset_free(bitset *set); 14 | 15 | void bitset_clear_bit(bitset *set, size_t pos); 16 | void bitset_set_bit(bitset *set, size_t pos); 17 | int bitset_test_bit(bitset *set, size_t pos); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/etag.h: -------------------------------------------------------------------------------- 1 | #ifndef ETAG_H 2 | #define ETAG_H 3 | 4 | #include "buffer.h" 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | typedef enum { ETAG_USE_INODE = 1, ETAG_USE_MTIME = 2, ETAG_USE_SIZE = 4 } etag_flags_t; 11 | 12 | int etag_is_equal(buffer *etag, const char *matches); 13 | int etag_create(buffer *etag, struct stat *st, etag_flags_t flags); 14 | int etag_mutate(buffer *mut, buffer *etag); 15 | 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /core/test/scalable_event/Makefile: -------------------------------------------------------------------------------- 1 | 2 | PROG=scev 3 | 4 | .PRECIOUS: $(PROG) 5 | 6 | SRC_DIR=../../src 7 | PS_DIR=../../../../io_engine/io_engine-2.0.38.2 8 | 9 | CORE_SRC=$(addprefix $(SRC_DIR)/,scalable_event.c key_value_store.c fhash.c util.c) 10 | 11 | all: clean $(PROG) 12 | 13 | $(PROG): test.c $(CORE_SRC) 14 | gcc -gdwarf-2 -g3 -Wall $^ -DTEST -DNEWEV -I$(SRC_DIR)/include -I$(PS_DIR)/include -o $@ 15 | ./$(PROG) -p 0.5 -d 10 16 | 17 | clean: 18 | rm -f $(PROG) 19 | rm -f core 20 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/http_chunk.h: -------------------------------------------------------------------------------- 1 | #ifndef _HTTP_CHUNK_H_ 2 | #define _HTTP_CHUNK_H_ 3 | 4 | #include "server.h" 5 | #include 6 | 7 | int http_chunk_append_mem(server *srv, connection *con, const char * mem, size_t len); 8 | int http_chunk_append_buffer(server *srv, connection *con, buffer *mem); 9 | int http_chunk_append_file(server *srv, connection *con, buffer *fn, off_t offset, off_t len); 10 | off_t http_chunkqueue_length(server *srv, connection *con); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/config/conf.d/ssi.conf: -------------------------------------------------------------------------------- 1 | ####################################################################### 2 | ## 3 | ## Server Side Includes 4 | ## ----------------------- 5 | ## 6 | ## see /usr/share/doc/packages/lighttpd/ssi.html 7 | ## 8 | server.modules += ( "mod_ssi" ) 9 | 10 | ## 11 | ## which extensions should be ran through mod_ssi. 12 | ## 13 | ssi.extension = ( ".shtml" ) 14 | 15 | ## 16 | ####################################################################### 17 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/status_counter.h: -------------------------------------------------------------------------------- 1 | #ifndef _STATUS_COUNTER_H_ 2 | #define _STATUS_COUNTER_H_ 3 | 4 | #include "array.h" 5 | #include "base.h" 6 | 7 | #include 8 | 9 | data_integer *status_counter_get_counter(server *srv, const char *s, size_t len); 10 | int status_counter_inc(server *srv, const char *s, size_t len); 11 | int status_counter_dec(server *srv, const char *s, size_t len); 12 | int status_counter_set(server *srv, const char *s, size_t len, int val); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/oldstyle.css: -------------------------------------------------------------------------------- 1 | table { 2 | border: 1px solid black; 3 | padding: 1px; 4 | } 5 | th { 6 | background-color: black; 7 | border: 1px solid white; 8 | color: white; 9 | padding-right: 2px; 10 | padding-left: 2px; 11 | } 12 | td { 13 | background-color: #f0f0f0; 14 | border: 1px solid white; 15 | padding-right: 2px; 16 | padding-left: 2px; 17 | } 18 | td.s { 19 | background-color: #f0f0f0; 20 | text-align: right; 21 | padding-left: 14px; 22 | } 23 | div.foot { 24 | margin-top: 4px; 25 | } 26 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/outdated/skeleton.txt: -------------------------------------------------------------------------------- 1 | =================== 2 | headline 3 | =================== 4 | 5 | -------------------- 6 | Module: mod_skeleton 7 | -------------------- 8 | 9 | :Author: Jan Kneschke 10 | :Date: $Date: 2004/11/03 22:26:05 $ 11 | :Revision: $Revision: 1.2 $ 12 | 13 | :abstract: 14 | a nice, short abstrace about the module 15 | 16 | .. meta:: 17 | :keywords: lighttpd, skeleton 18 | 19 | .. contents:: Table of Contents 20 | 21 | Description 22 | =========== 23 | 24 | ... 25 | 26 | Options 27 | ======= 28 | 29 | ... 30 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/config/conf.d/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST=access_log.conf \ 2 | auth.conf \ 3 | cgi.conf \ 4 | cml.conf \ 5 | compress.conf \ 6 | debug.conf \ 7 | dirlisting.conf \ 8 | evhost.conf \ 9 | expire.conf \ 10 | fastcgi.conf \ 11 | geoip.conf \ 12 | magnet.conf \ 13 | mime.conf \ 14 | mod.template \ 15 | mysql_vhost.conf \ 16 | proxy.conf \ 17 | rrdtool.conf \ 18 | scgi.conf \ 19 | secdownload.conf \ 20 | simple_vhost.conf \ 21 | ssi.conf \ 22 | status.conf \ 23 | trigger_b4_dl.conf \ 24 | userdir.conf \ 25 | webdav.conf 26 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/mod_cml_funcs.h: -------------------------------------------------------------------------------- 1 | #ifndef _MOD_CML_FUNCS_H_ 2 | #define _MOD_CML_FUNCS_H_ 3 | 4 | #ifdef HAVE_CONFIG_H 5 | # include "config.h" 6 | #endif 7 | 8 | #ifdef HAVE_LUA_H 9 | #include 10 | 11 | int f_crypto_md5(lua_State *L); 12 | int f_file_mtime(lua_State *L); 13 | int f_file_isreg(lua_State *L); 14 | int f_file_isdir(lua_State *L); 15 | int f_dir_files(lua_State *L); 16 | 17 | int f_memcache_exists(lua_State *L); 18 | int f_memcache_get_string(lua_State *L); 19 | int f_memcache_get_long(lua_State *L); 20 | #endif 21 | #endif 22 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/sys-socket.h: -------------------------------------------------------------------------------- 1 | #ifndef WIN32_SOCKET_H 2 | #define WIN32_SOCKET_H 3 | 4 | #ifdef __WIN32 5 | 6 | #include 7 | 8 | #define ECONNRESET WSAECONNRESET 9 | #define EINPROGRESS WSAEINPROGRESS 10 | #define EALREADY WSAEALREADY 11 | #define ECONNABORTED WSAECONNABORTED 12 | #define ioctl ioctlsocket 13 | #define hstrerror(x) "" 14 | #else 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | #endif 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /core/src/include/eth_out.h: -------------------------------------------------------------------------------- 1 | #ifndef __ETH_OUT_H_ 2 | #define __ETH_OUT_H_ 3 | 4 | #include 5 | 6 | #include "mtcp.h" 7 | #include "tcp_stream.h" 8 | #include "mos_api.h" 9 | 10 | #define MAX_SEND_PCK_CHUNK 64 11 | 12 | int 13 | FlushSendChunkBuf(mtcp_manager_t mtcp, int nif); 14 | 15 | uint8_t * 16 | EthernetOutput(struct mtcp_manager *mtcp, struct pkt_ctx *pctx, 17 | uint16_t h_proto, int nif, unsigned char* dst_haddr, uint16_t iplen, 18 | uint32_t cur_ts); 19 | 20 | void 21 | ForwardEthernetFrame(struct mtcp_manager *mtcp, struct pkt_ctx *pctx); 22 | 23 | #endif /* __ETH_OUT_H_ */ 24 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/run-tests.pl: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env perl 2 | 3 | use strict; 4 | 5 | use Test::Harness qw(&runtests $verbose); 6 | $verbose = (defined $ENV{'VERBOSE'} ? $ENV{'VERBOSE'} : 0); 7 | my $tests = (defined $ENV{'RUNTESTS'} ? $ENV{'RUNTESTS'} : ''); 8 | 9 | my $srcdir = (defined $ENV{'srcdir'} ? $ENV{'srcdir'} : '.'); 10 | 11 | opendir DIR, $srcdir; 12 | my (@fs, $f); 13 | while ($f = readdir(DIR)) { 14 | if ($f =~ /^(.*)\.t$/) { 15 | next if ($tests ne '' and $tests !~ /(^|\s+)$1(\s+|$)/); 16 | push @fs, $srcdir.'/'.$f; 17 | } 18 | } 19 | closedir DIR; 20 | runtests (sort @fs); 21 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/mod_ssi_exprparser.h: -------------------------------------------------------------------------------- 1 | #define TK_AND 1 2 | #define TK_OR 2 3 | #define TK_EQ 3 4 | #define TK_NE 4 5 | #define TK_GT 5 6 | #define TK_GE 6 7 | #define TK_LT 7 8 | #define TK_LE 8 9 | #define TK_NOT 9 10 | #define TK_LPARAN 10 11 | #define TK_RPARAN 11 12 | #define TK_VALUE 12 13 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/config/conf.d/magnet.conf: -------------------------------------------------------------------------------- 1 | ####################################################################### 2 | ## 3 | ## Magnet Module 4 | ## --------------- 5 | ## 6 | ## see http://trac.lighttpd.net/trac/wiki/Docs%3AModMagnet 7 | ## 8 | server.modules += ( "mod_magnet" ) 9 | 10 | ## 11 | ## 12 | ## 13 | #magnet.attract-raw-url-to = ( ) 14 | 15 | ## 16 | ## as an example for that see the mod_magnet docs and 17 | ## http://pixel.global-banlist.de./ 18 | ## 19 | #magnet.attract-physical-path-to = ( conf_dir + "/cleanurl.lua" ) 20 | 21 | ## 22 | ####################################################################### 23 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/proc_open.h: -------------------------------------------------------------------------------- 1 | 2 | #include "buffer.h" 3 | 4 | #ifdef WIN32 5 | #include 6 | typedef HANDLE descriptor_t; 7 | typedef HANDLE proc_pid_t; 8 | #else 9 | typedef int descriptor_t; 10 | typedef pid_t proc_pid_t; 11 | #endif 12 | 13 | typedef struct { 14 | descriptor_t parent, child; 15 | int fd; 16 | } pipe_t; 17 | 18 | typedef struct { 19 | pipe_t in, out, err; 20 | proc_pid_t child; 21 | } proc_handler_t; 22 | 23 | int proc_close(proc_handler_t *ht); 24 | int proc_open(proc_handler_t *ht, const char *command); 25 | int proc_open_buffer(const char *command, buffer *in, buffer *out, buffer *err); 26 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/outdated/state.dot: -------------------------------------------------------------------------------- 1 | digraph state { 2 | edge [color=green]; 3 | connect -> reqstart -> read -> reqend -> handlereq -> respstart -> write -> respend -> connect; 4 | edge [color=grey]; 5 | reqend -> readpost -> handlereq [ label="POST" ]; 6 | edge [ color=blue] 7 | respend -> reqstart [ label="keep-alive" ]; 8 | edge [ color=lightblue] 9 | handlereq -> handlereq [ label="sub-request" ]; 10 | edge [style=dashed, color=red]; 11 | error -> close -> connect; 12 | error -> connect; 13 | handlereq -> error; 14 | read -> error; 15 | readpost -> error; 16 | write -> error; 17 | connect [shape=box]; 18 | } 19 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/log.h: -------------------------------------------------------------------------------- 1 | #ifndef _LOG_H_ 2 | #define _LOG_H_ 3 | 4 | #include "server.h" 5 | 6 | /* Close fd and _try_ to get a /dev/null for it instead. 7 | * Returns 0 on success and -1 on failure (fd gets closed in all cases) 8 | */ 9 | int openDevNull(int fd); 10 | 11 | #define WP() log_error_write(srv, __FILE__, __LINE__, ""); 12 | 13 | int open_logfile_or_pipe(server *srv, const char* logfile); 14 | 15 | int log_error_open(server *srv); 16 | int log_error_close(server *srv); 17 | int log_error_write(server *srv, const char *filename, unsigned int line, const char *fmt, ...); 18 | int log_error_cycle(server *srv); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/config/conf.d/rrdtool.conf: -------------------------------------------------------------------------------- 1 | ####################################################################### 2 | ## 3 | ## RRD Tool Module 4 | ## ----------------- 5 | ## 6 | ## see http://www.lighttpd.net/documentation/rrdtool.html 7 | ## 8 | server.modules += ( "mod_rrdtool" ) 9 | 10 | ## 11 | ## Path to the rrdtool binary. 12 | ## 13 | rrdtool.binary = "/usr/bin/rrdtool" 14 | 15 | ## 16 | ## Path to the rrdtool database. You can override this in conditionals. 17 | ## 18 | rrdtool.db-name = "/var/lib/lighttpd/lighttpd.rrd" 19 | 20 | ## 21 | ####################################################################### 22 | -------------------------------------------------------------------------------- /core/src/include/memory_mgt.h: -------------------------------------------------------------------------------- 1 | #ifndef __MEMORY_MGT_H_ 2 | #define __MEMORY_MGT_H_ 3 | 4 | struct mem_pool; 5 | typedef struct mem_pool* mem_pool_t; 6 | 7 | /* create a memory pool with a chunk size and total size 8 | an return the pointer to the memory pool */ 9 | mem_pool_t MPCreate(int chunk_size, size_t total_size, int is_hugepage); 10 | 11 | /* allocate one chunk */ 12 | void *MPAllocateChunk(mem_pool_t mp); 13 | 14 | /* free one chunk */ 15 | void MPFreeChunk(mem_pool_t mp, void *p); 16 | 17 | /* destroy the memory pool */ 18 | void MPDestroy(mem_pool_t mp); 19 | 20 | /* return the number of free chunks */ 21 | int MPGetFreeChunks(mem_pool_t mp); 22 | 23 | #endif /* __MEMORY_MGT_H_ */ 24 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/config/conf.d/evhost.conf: -------------------------------------------------------------------------------- 1 | ####################################################################### 2 | ## 3 | ## Enhanced virtual hosting 4 | ## -------------------------- 5 | ## 6 | ## See http://www.lighttpd.net/documentation/evhost.html 7 | ## 8 | server.modules += ( "mod_evhost" ) 9 | 10 | ## 11 | ## define a pattern for the host url finding 12 | ## %% => % sign 13 | ## %0 => domain name + tld 14 | ## %1 => tld 15 | ## %2 => domain name without tld 16 | ## %3 => subdomain 1 name 17 | ## %4 => subdomain 2 name 18 | ## 19 | evhost.path-pattern = vhosts_dir + "/%3/htdocs/" 20 | 21 | ## 22 | ####################################################################### 23 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/mod_magnet_cache.h: -------------------------------------------------------------------------------- 1 | #ifndef _MOD_MAGNET_CACHE_H_ 2 | #define _MOD_MAGNET_CACHE_H_ 3 | 4 | #include "buffer.h" 5 | #include "base.h" 6 | 7 | #ifdef HAVE_LUA_H 8 | #include 9 | 10 | typedef struct { 11 | buffer *name; 12 | buffer *etag; 13 | 14 | lua_State *L; 15 | 16 | time_t last_used; /* LRU */ 17 | } script; 18 | 19 | typedef struct { 20 | script **ptr; 21 | 22 | size_t used; 23 | size_t size; 24 | } script_cache; 25 | 26 | script_cache *script_cache_init(void); 27 | void script_cache_free(script_cache *cache); 28 | 29 | lua_State *script_cache_get_script(server *srv, connection *con, 30 | script_cache *cache, buffer *name); 31 | 32 | #endif 33 | #endif 34 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/connections.h: -------------------------------------------------------------------------------- 1 | #ifndef _CONNECTIONS_H_ 2 | #define _CONNECTIONS_H_ 3 | 4 | #include "server.h" 5 | #include "fdevent.h" 6 | 7 | connection *connection_init(server *srv); 8 | int connection_reset(server *srv, connection *con); 9 | void connections_free(server *srv); 10 | 11 | connection * connection_accept(server *srv, server_socket *srv_sock); 12 | int connection_close(server *srv, connection *con); 13 | 14 | int connection_set_state(server *srv, connection *con, connection_state_t state); 15 | const char * connection_get_state(connection_state_t state); 16 | const char * connection_get_short_state(connection_state_t state); 17 | int connection_state_machine(server *srv, connection *con); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/config/conf.d/expire.conf: -------------------------------------------------------------------------------- 1 | ####################################################################### 2 | ## 3 | ## Expire Module 4 | ## --------------- 5 | ## 6 | ## See http://www.lighttpd.net/documentation/expire.html 7 | ## 8 | server.modules += ( "mod_expire" ) 9 | 10 | ## 11 | ## assignes a expiration to all files below the specified path. The 12 | ## specification of the time is made up of: 13 | ## 14 | ## 15 | ## 16 | #expire.url = ( 17 | # "/buggy/" => "access 2 hours", 18 | # "/images/" => "access plus 1 seconds 2 minutes" 19 | #) 20 | 21 | ## 22 | ####################################################################### 23 | -------------------------------------------------------------------------------- /core/src/include/ip_out.h: -------------------------------------------------------------------------------- 1 | #ifndef __IP_OUT_H_ 2 | #define __IP_OUT_H_ 3 | 4 | #include 5 | #include "tcp_stream.h" 6 | #include "mos_api.h" 7 | 8 | extern inline int 9 | GetOutputInterface(uint32_t daddr); 10 | 11 | void 12 | ForwardIPPacket(mtcp_manager_t mtcp, struct pkt_ctx *pctx); 13 | 14 | void 15 | ForwardIPv4Packet(mtcp_manager_t mtcp, int nif_in, char *buf, int len); 16 | 17 | uint8_t * 18 | IPOutputStandalone(struct mtcp_manager *mtcp, 19 | uint16_t ip_id, uint32_t saddr, uint32_t daddr, uint16_t tcplen, 20 | struct pkt_ctx *pctx, uint32_t cur_ts); 21 | 22 | uint8_t * 23 | IPOutput(struct mtcp_manager *mtcp, tcp_stream *stream, uint16_t tcplen, 24 | struct pkt_ctx *pctx, uint32_t cur_ts); 25 | 26 | #endif /* __IP_OUT_H_ */ 27 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/outdated/alias.txt: -------------------------------------------------------------------------------- 1 | ===== 2 | Alias 3 | ===== 4 | 5 | ----------------- 6 | Module: mod_alias 7 | ----------------- 8 | 9 | :Author: Jan Kneschke 10 | :Date: $Date: 2004/08/29 09:43:49 $ 11 | :Revision: $Revision: 1.1 $ 12 | 13 | :abstract: 14 | The alias module ... 15 | 16 | .. meta:: 17 | :keywords: lighttpd, alias 18 | 19 | .. contents:: Table of Contents 20 | 21 | Description 22 | =========== 23 | 24 | The alias module is used to specify a special document-root for a given url-subset. 25 | 26 | Options 27 | ======= 28 | 29 | alias.url 30 | rewrites the document-root for a URL-subset 31 | 32 | Default: empty 33 | 34 | Example: :: 35 | 36 | alias.url = ( "/cgi-bin/" => "/var/www/servers/www.example.org/cgi-bin/" ) 37 | -------------------------------------------------------------------------------- /core/src/include/tcp.h: -------------------------------------------------------------------------------- 1 | #ifndef __TCP_H_ 2 | #define __TCP_H_ 3 | 4 | #include "tcp_stream.h" 5 | #include "mos_api.h" 6 | #include "mtcp.h" 7 | 8 | extern inline void 9 | FillPacketContextTCPInfo(struct pkt_ctx *pctx, struct tcphdr * tcph); 10 | 11 | extern inline void 12 | FillFlowContext(struct pkt_ctx *pctx, 13 | tcp_stream *cur_stream, int cpu); 14 | 15 | extern inline void 16 | HandleSingleCallback(mtcp_manager_t mtcp, uint32_t hooking_point, 17 | struct pkt_ctx *pctx, uint64_t events); 18 | 19 | int 20 | ProcessInTCPPacket(mtcp_manager_t mtcp, struct pkt_ctx *pctx); 21 | 22 | void 23 | UpdateMonitor(mtcp_manager_t mtcp, struct tcp_stream *sendside_stream, 24 | struct tcp_stream *recvside_stream, struct pkt_ctx *pctx, 25 | bool is_pkt_reception); 26 | #endif 27 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/fcgi-auth.c: -------------------------------------------------------------------------------- 1 | #ifdef HAVE_CONFIG_H 2 | #include "config.h" 3 | #endif 4 | #ifdef HAVE_FASTCGI_FASTCGI_H 5 | #include 6 | #else 7 | #include 8 | #endif 9 | #include 10 | #include 11 | #include 12 | 13 | int main (void) { 14 | char* p; 15 | 16 | while (FCGI_Accept() >= 0) { 17 | /* wait for fastcgi authorizer request */ 18 | 19 | printf("Content-type: text/html\r\n"); 20 | 21 | if (((p = getenv("QUERY_STRING")) == NULL) || 22 | strcmp(p, "ok") != 0) { 23 | printf("Status: 403 Forbidden\r\n\r\n"); 24 | } else { 25 | printf("\r\n"); 26 | /* default Status is 200 - allow access */ 27 | } 28 | 29 | printf("foobar\r\n"); 30 | } 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /core/src/bpf/main.c: -------------------------------------------------------------------------------- 1 | #ifdef TEST_BPF 2 | 3 | #include "sfbpf.h" 4 | #include "sfbpf_dlt.h" 5 | #include 6 | #include 7 | #include 8 | 9 | int 10 | main() 11 | { 12 | struct sfbpf_program fcode; 13 | const char *filter = "tcp"; 14 | char data[1514]; 15 | int len = 1514; 16 | 17 | memset(data, 0, sizeof(data)); 18 | 19 | if (sfbpf_compile(1514, DLT_EN10MB, &fcode, filter, 1, 0) < 0) { 20 | fprintf(stderr, "%s: BPF state machine compilation failed!", __FUNCTION__); 21 | return EXIT_FAILURE; 22 | } 23 | 24 | if (fcode.bf_insns && sfbpf_filter(fcode.bf_insns, data, len, len) == 0) { 25 | fprintf(stderr, "Packet ignored!\n"); 26 | } 27 | 28 | sfbpf_freecode(&fcode); 29 | 30 | return EXIT_SUCCESS; 31 | } 32 | 33 | #endif /* !TEST_BPF */ 34 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/config/conf.d/cml.conf: -------------------------------------------------------------------------------- 1 | ####################################################################### 2 | ## 3 | ## CML Module 4 | ## --------------- 5 | ## 6 | ## see http://www.lighttpd.net/documentation/cml.html 7 | ## 8 | server.modules += ( "mod_cml" ) 9 | index-file.names += ( "index.cml" ) 10 | 11 | ## 12 | ## The file extension that is bound to the cml-module. 13 | ## 14 | cml.extension = ".cml" 15 | 16 | ## 17 | ## Memcached hosts used for memcache* functions. 18 | ## 19 | #cml.memcache-hosts = ( "127.0.0.1:11211" ) 20 | 21 | ## 22 | ## A cml file that is executed for each request. 23 | ## 24 | #cml.power-magnet = server_root + "/htdocs/powermagnet.cml" 25 | 26 | ## 27 | ####################################################################### 28 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/config/conf.d/status.conf: -------------------------------------------------------------------------------- 1 | ####################################################################### 2 | ## 3 | ## Status Module 4 | ## --------------- 5 | ## 6 | ## see http://www.lighttpd.net/documentation/status.html 7 | ## 8 | server.modules += ( "mod_status" ) 9 | 10 | $HTTP["remoteip"] == "127.0.0.0/8" { 11 | ## 12 | ## configure urls for the various parts of the module. 13 | ## 14 | status.status-url = "/server-status" 15 | status.config-url = "/server-config" 16 | status.statistics-url = "/server-statistics" 17 | ## 18 | ## add JavaScript which allows client-side sorting for the connection 19 | ## overview 20 | ## 21 | status.enable-sort = "enable" 22 | } 23 | ## 24 | ####################################################################### 25 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/m4/ltversion.m4: -------------------------------------------------------------------------------- 1 | # ltversion.m4 -- version numbers -*- Autoconf -*- 2 | # 3 | # Copyright (C) 2004, 2011-2015 Free Software Foundation, Inc. 4 | # Written by Scott James Remnant, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # @configure_input@ 11 | 12 | # serial 4179 ltversion.m4 13 | # This file is part of GNU Libtool 14 | 15 | m4_define([LT_PACKAGE_VERSION], [2.4.6]) 16 | m4_define([LT_PACKAGE_REVISION], [2.4.6]) 17 | 18 | AC_DEFUN([LTVERSION_VERSION], 19 | [macro_version='2.4.6' 20 | macro_revision='2.4.6' 21 | _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) 22 | _LT_DECL(, macro_revision, 0) 23 | ]) 24 | -------------------------------------------------------------------------------- /core/src/include/tcp_util.h: -------------------------------------------------------------------------------- 1 | #ifndef __TCP_UTIL_H_ 2 | #define __TCP_UTIL_H_ 3 | 4 | #include "mtcp.h" 5 | #include "tcp_stream.h" 6 | 7 | struct tcp_timestamp 8 | { 9 | uint32_t ts_val; 10 | uint32_t ts_ref; 11 | }; 12 | 13 | void ParseTCPOptions(tcp_stream *cur_stream, 14 | uint32_t cur_ts, uint8_t *tcpopt, int len); 15 | 16 | extern inline int 17 | ParseTCPTimestamp(tcp_stream *cur_stream, 18 | struct tcp_timestamp *ts, uint8_t *tcpopt, int len); 19 | 20 | #if TCP_OPT_SACK_ENABLED 21 | void 22 | ParseSACKOption(tcp_stream *cur_stream, 23 | uint32_t ack_seq, uint8_t *tcpopt, int len); 24 | #endif 25 | 26 | uint16_t 27 | TCPCalcChecksum(uint16_t *buf, uint16_t len, uint32_t saddr, uint32_t daddr); 28 | 29 | void 30 | PrintTCPOptions(uint8_t *tcpopt, int len); 31 | 32 | #endif /* __TCP_UTIL_H_ */ 33 | -------------------------------------------------------------------------------- /core/src/include/arp.h: -------------------------------------------------------------------------------- 1 | #ifndef __ARP_H_ 2 | #define __ARP_H_ 3 | 4 | #include "mos_api.h" 5 | 6 | #define MAX_ARPENTRY 1024 7 | #define RUN_ARP 1 8 | #define ARP_TIMEOUT_SEC 1 9 | 10 | int 11 | InitARPTable(); 12 | 13 | unsigned char * 14 | GetHWaddr(uint32_t ip); 15 | 16 | unsigned char * 17 | GetDestinationHWaddr(uint32_t dip); 18 | 19 | void 20 | RequestARP(mtcp_manager_t mtcp, uint32_t ip, int nif, uint32_t cur_ts); 21 | 22 | int 23 | ProcessARPPacket(mtcp_manager_t mtcp, uint32_t cur_ts, 24 | const int ifidx, unsigned char* pkt_data, int len); 25 | 26 | void 27 | PublishARP(mtcp_manager_t mtcp); 28 | 29 | void 30 | PrintARPTable(); 31 | 32 | void 33 | ForwardARPPacket(mtcp_manager_t mtcp, struct pkt_ctx *pctx); 34 | 35 | void 36 | ARPTimer(mtcp_manager_t mtcp, uint32_t cur_ts); 37 | 38 | #endif /* __ARP_H_ */ 39 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/splaytree.h: -------------------------------------------------------------------------------- 1 | #ifndef _SPLAY_TREE_H_ 2 | #define _SPLAY_TREE_H_ 3 | 4 | typedef struct tree_node { 5 | struct tree_node * left, * right; 6 | int key; 7 | int size; /* maintained to be the number of nodes rooted here */ 8 | 9 | void *data; 10 | } splay_tree; 11 | 12 | 13 | splay_tree * splaytree_splay (splay_tree *t, int key); 14 | splay_tree * splaytree_insert(splay_tree *t, int key, void *data); 15 | splay_tree * splaytree_delete(splay_tree *t, int key); 16 | splay_tree * splaytree_size(splay_tree *t); 17 | 18 | #define splaytree_size(x) (((x)==NULL) ? 0 : ((x)->size)) 19 | /* This macro returns the size of a node. Unlike "x->size", */ 20 | /* it works even if x=NULL. The test could be avoided by using */ 21 | /* a special version of NULL which was a real node with size 0. */ 22 | 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/mod_ssi_expr.h: -------------------------------------------------------------------------------- 1 | #ifndef _MOD_SSI_EXPR_H_ 2 | #define _MOD_SSI_EXPR_H_ 3 | 4 | #include "buffer.h" 5 | 6 | typedef struct { 7 | enum { SSI_TYPE_UNSET, SSI_TYPE_BOOL, SSI_TYPE_STRING } type; 8 | 9 | buffer *str; 10 | int bo; 11 | } ssi_val_t; 12 | 13 | typedef struct { 14 | int ok; 15 | 16 | ssi_val_t val; 17 | 18 | void *srv; 19 | } ssi_ctx_t; 20 | 21 | typedef enum { SSI_COND_UNSET, SSI_COND_LE, SSI_COND_GE, SSI_COND_EQ, SSI_COND_NE, SSI_COND_LT, SSI_COND_GT } ssi_expr_cond; 22 | 23 | void *ssiexprparserAlloc(void *(*mallocProc)(size_t)); 24 | void ssiexprparserFree(void *p, void (*freeProc)(void*)); 25 | void ssiexprparser(void *yyp, int yymajor, buffer *yyminor, ssi_ctx_t *ctx); 26 | 27 | int ssi_val_tobool(ssi_val_t *B); 28 | ssi_val_t *ssi_val_init(); 29 | void ssi_val_free(ssi_val_t *s); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/config/conf.d/access_log.conf: -------------------------------------------------------------------------------- 1 | ####################################################################### 2 | ## 3 | ## Corresponding documentation: 4 | ## 5 | ## http://www.lighttpd.net/documentation/access.html 6 | ## 7 | server.modules += ( "mod_accesslog" ) 8 | 9 | ## 10 | ## Default access log. 11 | ## 12 | accesslog.filename = log_root + "/access.log" 13 | 14 | ## 15 | ## The default format produces CLF compatible output. 16 | ## For available parameters see access.txt 17 | ## 18 | #accesslog.format = "%h %l %u %t \"%r\" %b %>s \"%{User-Agent}i\" \"%{Referer}i\"" 19 | 20 | ## 21 | ## If you want to log to syslog you have to unset the 22 | ## accesslog.use-syslog setting and uncomment the next line. 23 | ## 24 | #accesslog.use-syslog = "enable" 25 | 26 | # 27 | ####################################################################### 28 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/outdated/scgi.txt: -------------------------------------------------------------------------------- 1 | ================== 2 | the SCGI Interface 3 | ================== 4 | 5 | ------------------- 6 | Module: mod_scgi 7 | ------------------- 8 | 9 | :Author: Jan Kneschke 10 | :Date: $Date: 2004/11/03 22:26:05 $ 11 | :Revision: $Revision: 1.3 $ 12 | 13 | :abstract: 14 | SCGI is a fast and simplified CGI interface. It is mostly 15 | used by Python + WSGI. 16 | 17 | .. meta:: 18 | :keywords: lighttpd, FastCGI 19 | 20 | .. contents:: Table of Contents 21 | 22 | Description 23 | =========== 24 | 25 | The SCGI module is heavily based on the FastCGI when it comes 26 | to configuration. Only the internal protocol between server 27 | and client has been replaced. Please check the documentation 28 | of the FastCGI module for more information. 29 | 30 | History 31 | ======= 32 | 33 | Added in lighttpd 1.3.14 as it was really simple to do. 34 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/config/conf.d/webdav.conf: -------------------------------------------------------------------------------- 1 | ####################################################################### 2 | ## 3 | ## WebDAV Module 4 | ## --------------- 5 | ## 6 | ## http://www.lighttpd.net/documentation/webdav.html 7 | ## 8 | server.modules += ( "mod_webdav" ) 9 | 10 | $HTTP["url"] =~ "^/dav($|/)" { 11 | ## 12 | ## enable webdav for this location 13 | ## 14 | webdav.activate = "enable" 15 | 16 | ## 17 | ## By default the webdav url is writable. 18 | ## Uncomment the following line if you want to make it readonly. 19 | ## 20 | #webdav.is-readonly = "enable" 21 | 22 | ## 23 | ## Log the XML Request bodies for debugging 24 | ## 25 | #webdav.log-xml = "disable" 26 | 27 | ## 28 | ## 29 | ## 30 | webdav.sqlite-db-name = home_dir + "/webdav.db" 31 | } 32 | ## 33 | ####################################################################### 34 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/outdated/setenv.txt: -------------------------------------------------------------------------------- 1 | =========================== 2 | Conditional Request Headers 3 | =========================== 4 | 5 | ------------------ 6 | Module: mod_setenv 7 | ------------------ 8 | 9 | :Author: Jan Kneschke 10 | :Date: $Date: 2004/11/03 22:26:05 $ 11 | :Revision: $Revision: 1.2 $ 12 | 13 | :abstract: 14 | mod_setenv is used to add request 15 | 16 | .. meta:: 17 | :keywords: lighttpd, skeleton 18 | 19 | .. contents:: Table of Contents 20 | 21 | Description 22 | =========== 23 | 24 | ... 25 | 26 | Options 27 | ======= 28 | 29 | setenv.add-environment 30 | adds a value to the process environment that is passed to the external applications 31 | 32 | 33 | setenv.add-response-header 34 | adds a header to the HTTP response sent to the client 35 | 36 | setenv.add-request-header 37 | adds a header to the HTTP request that was received from the client 38 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/mod_cml.h: -------------------------------------------------------------------------------- 1 | #ifndef _MOD_CACHE_H_ 2 | #define _MOD_CACHE_H_ 3 | 4 | #include "buffer.h" 5 | #include "server.h" 6 | #include "response.h" 7 | 8 | #include "stream.h" 9 | #include "plugin.h" 10 | 11 | #if defined(HAVE_MEMCACHE_H) 12 | #include 13 | #endif 14 | 15 | #define plugin_data mod_cache_plugin_data 16 | 17 | typedef struct { 18 | buffer *ext; 19 | 20 | array *mc_hosts; 21 | buffer *mc_namespace; 22 | #if defined(HAVE_MEMCACHE_H) 23 | struct memcache *mc; 24 | #endif 25 | buffer *power_magnet; 26 | } plugin_config; 27 | 28 | typedef struct { 29 | PLUGIN_DATA; 30 | 31 | buffer *basedir; 32 | buffer *baseurl; 33 | 34 | buffer *trigger_handler; 35 | 36 | plugin_config **config_storage; 37 | 38 | plugin_config conf; 39 | } plugin_data; 40 | 41 | int cache_parse_lua(server *srv, connection *con, plugin_data *p, buffer *fn); 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /core/test/tree/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "tree.h" 4 | 5 | struct tree { 6 | int id; 7 | TREE_NODE(tree) link; 8 | }; 9 | 10 | int 11 | main (int argc, char **argv) 12 | { 13 | struct tree nodes[10]; 14 | TREE_SCRATCH(tree, 10) scratch; 15 | int i; 16 | 17 | struct tree *walk; 18 | 19 | for (i = 0; i < 10; i++) { 20 | nodes[i].id = i; 21 | TREE_INIT_NODE(&nodes[i], link); 22 | } 23 | 24 | TREE_INSERT_CHILD(&nodes[0], &nodes[1], link); 25 | TREE_INSERT_CHILD(&nodes[1], &nodes[2], link); 26 | TREE_INSERT_CHILD(&nodes[1], &nodes[3], link); 27 | TREE_INSERT_CHILD(&nodes[2], &nodes[4], link); 28 | TREE_INSERT_CHILD(&nodes[3], &nodes[5], link); 29 | 30 | TREE_DFS_FOREACH(walk, &nodes[0], &scratch, link) 31 | printf("DFS: %d\n", walk->id); 32 | 33 | TREE_BFS_FOREACH(walk, &nodes[0], &scratch, link) 34 | printf("BFS: %d\n", walk->id); 35 | 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/mod_ssi.h: -------------------------------------------------------------------------------- 1 | #ifndef _MOD_SSI_H_ 2 | #define _MOD_SSI_H_ 3 | 4 | #include "base.h" 5 | #include "buffer.h" 6 | #include "array.h" 7 | 8 | #include "plugin.h" 9 | 10 | #ifdef HAVE_PCRE_H 11 | #include 12 | #endif 13 | 14 | /* plugin config for all request/connections */ 15 | 16 | typedef struct { 17 | array *ssi_extension; 18 | buffer *content_type; 19 | } plugin_config; 20 | 21 | typedef struct { 22 | PLUGIN_DATA; 23 | 24 | #ifdef HAVE_PCRE_H 25 | pcre *ssi_regex; 26 | #endif 27 | buffer *timefmt; 28 | int sizefmt; 29 | 30 | buffer *stat_fn; 31 | 32 | array *ssi_vars; 33 | array *ssi_cgi_env; 34 | 35 | int if_level, if_is_false_level, if_is_false, if_is_false_endif; 36 | 37 | plugin_config **config_storage; 38 | 39 | plugin_config conf; 40 | } plugin_data; 41 | 42 | int ssi_eval_expr(server *srv, connection *con, plugin_data *p, const char *expr); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /core/src/include/tcp_sb_queue.h: -------------------------------------------------------------------------------- 1 | #ifndef __TCP_SB_QUEUE_ 2 | #define __TCP_SB_QUEUE_ 3 | 4 | #include "tcp_send_buffer.h" 5 | 6 | /*---------------------------------------------------------------------------*/ 7 | typedef struct sb_queue* sb_queue_t; 8 | /*---------------------------------------------------------------------------*/ 9 | sb_queue_t 10 | CreateSBQueue(int capacity); 11 | /*---------------------------------------------------------------------------*/ 12 | void 13 | DestroySBQueue(sb_queue_t sq); 14 | /*---------------------------------------------------------------------------*/ 15 | int 16 | SBEnqueue(sb_queue_t sq, struct tcp_send_buffer *buf); 17 | /*---------------------------------------------------------------------------*/ 18 | struct tcp_send_buffer * 19 | SBDequeue(sb_queue_t sq); 20 | /*---------------------------------------------------------------------------*/ 21 | 22 | #endif /* __TCP_SB_QUEUE_ */ 23 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/config/conf.d/secdownload.conf: -------------------------------------------------------------------------------- 1 | ####################################################################### 2 | ## 3 | ## Secure Download Module 4 | ## ------------------------ 5 | ## 6 | ## see http://www.lighttpd.net/documentation/secdownload.html 7 | ## 8 | server.modules += ( "mod_secdownload" ) 9 | 10 | ## 11 | ## Document root for the download area. 12 | ## The directory should not be below your normal 13 | ## document root! 14 | ## 15 | #secdownload.document-root = server_root + "/downloads" 16 | 17 | ## 18 | ## Secret string that will be used for the checksum calculation. 19 | ## 20 | #secdownload.secret = "" 21 | 22 | ## 23 | ## How long is the secret valid? 24 | ## 25 | ## Default: 60 seconds 26 | ## 27 | #secdownload.timeout = 60 28 | 29 | ## 30 | ## Prefix for the download area. 31 | ## 32 | #secdownload.uri-prefix = "/download/" 33 | 34 | ## 35 | ####################################################################### 36 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/response.h: -------------------------------------------------------------------------------- 1 | #ifndef _RESPONSE_H_ 2 | #define _RESPONSE_H_ 3 | 4 | #include "server.h" 5 | 6 | #include 7 | 8 | int http_response_parse(server *srv, connection *con); 9 | int http_response_write_header(server *srv, connection *con); 10 | 11 | int response_header_insert(server *srv, connection *con, const char *key, size_t keylen, const char *value, size_t vallen); 12 | int response_header_overwrite(server *srv, connection *con, const char *key, size_t keylen, const char *value, size_t vallen); 13 | int response_header_append(server *srv, connection *con, const char *key, size_t keylen, const char *value, size_t vallen); 14 | 15 | handler_t http_response_prepare(server *srv, connection *con); 16 | int http_response_redirect_to_directory(server *srv, connection *con); 17 | int http_response_handle_cachable(server *srv, connection *con, buffer * mtime); 18 | 19 | buffer * strftime_cache_get(server *srv, time_t last_mod); 20 | #endif 21 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/mod-access.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | BEGIN { 3 | # add current source dir to the include-path 4 | # we need this for make distcheck 5 | (my $srcdir = $0) =~ s,/[^/]+$,/,; 6 | unshift @INC, $srcdir; 7 | } 8 | 9 | use strict; 10 | use IO::Socket; 11 | use Test::More tests => 4; 12 | use LightyTest; 13 | 14 | my $tf = LightyTest->new(); 15 | my $t; 16 | 17 | ok($tf->start_proc == 0, "Starting lighttpd") or die(); 18 | 19 | $t->{REQUEST} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ]; 24 | ok($tf->handle_http($t) == 0, 'forbid access to ...~'); 25 | 26 | $t->{REQUEST} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ]; 31 | ok($tf->handle_http($t) == 0, '#1230 - forbid access to ...~ - trailing slash'); 32 | 33 | ok($tf->stop_proc == 0, "Stopping lighttpd"); 34 | 35 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/config/conf.d/compress.conf: -------------------------------------------------------------------------------- 1 | ####################################################################### 2 | ## 3 | ## Output Compression 4 | ## -------------------- 5 | ## 6 | ## see http://www.lighttpd.net/documentation/compress.html 7 | ## 8 | server.modules += ( "mod_compress" ) 9 | 10 | ## 11 | ## where should the compressed files be cached? 12 | ## see the base config for the declaration of the variable. 13 | ## 14 | ## This directory should be changed per vhost otherwise you can 15 | ## run into trouble with overlapping filenames 16 | ## 17 | compress.cache-dir = cache_dir + "/compress" 18 | 19 | ## 20 | ## FileTypes to compress. 21 | ## 22 | compress.filetype = ("text/plain", "text/html") 23 | 24 | ## 25 | ## Maximum filesize that will be compressed. 26 | ## Default is 0, which means unlimited file size. 27 | ## 28 | #compress.max-filesize = 0 29 | 30 | ## 31 | ####################################################################### 32 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/config/conf.d/simple_vhost.conf: -------------------------------------------------------------------------------- 1 | ####################################################################### 2 | ## 3 | ## Simple Virtual hosting 4 | ## ------------------------ 5 | ## 6 | ## http://www.lighttpd.net/documentation/simple-vhost.html 7 | ## 8 | server.modules += ( "mod_simple_vhost" ) 9 | 10 | ## If you want name-based virtual hosting add the next three settings and load 11 | ## mod_simple_vhost 12 | ## 13 | ## document-root = 14 | ## virtual-server-root + virtual-server-default-host + virtual-server-docroot 15 | ## or 16 | ## virtual-server-root + http-host + virtual-server-docroot 17 | ## 18 | simple-vhost.server-root = vhosts_dir + "/" 19 | simple-vhost.default-host = "default.example.com" 20 | simple-vhost.document-root = "/htdocs/" 21 | 22 | ## 23 | ## Print some errors for finding the document-root 24 | ## 25 | #simple-vhost.debug = "enable" 26 | 27 | ## 28 | ####################################################################### 29 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/docroot/www/404.fcgi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | #use CGI qw/:standard/; 3 | use CGI::Fast qw(:standard); 4 | my $cgi = new CGI; 5 | while (new CGI::Fast) { 6 | my $request_uri = $ENV{'REQUEST_URI'}; 7 | print (STDERR "REQUEST_URI: $request_uri\n"); 8 | if ($request_uri =~ m/^\/dynamic\/200\// ) { 9 | print header ( -status => 200, 10 | -type => 'text/plain' ); 11 | print ("found here\n"); 12 | } 13 | elsif ($request_uri =~ m|^/dynamic/302/| ) { 14 | print header( -status=>302, 15 | -location => 'http://www.example.org/'); 16 | } 17 | elsif ($request_uri =~ m/^\/dynamic\/404\// ) { 18 | print header ( -status => 404 19 | -type => 'text/plain' ); 20 | print ("Not found here\n"); 21 | } 22 | else { 23 | print header ( -status => 500, 24 | -type => 'text/plain'); 25 | print ("huh\n"); 26 | }; 27 | }; 28 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/config/conf.d/geoip.conf: -------------------------------------------------------------------------------- 1 | ####################################################################### 2 | ## 3 | ## GeoIP Module 4 | ## --------------- 5 | ## 6 | ## mod_geoip is a module for fast ip/location lookups. It uses MaxMind 7 | ## GeoIP / GeoCity databases. If the ip was found in the database the 8 | ## module sets the appropriate environments variables to the request, 9 | ## thus making other modules/fcgi be informed. 10 | ## 11 | server.modules += ( "mod_geoip" ) 12 | 13 | ## 14 | ## mod_geoip will determine the database type automatically so if you 15 | ## enter GeoCity databse path it will load GeoCity Env. 16 | ## 17 | #geoip.db-filename = "/path/to/GeoCityLite.dat" 18 | 19 | ## 20 | ## If enabled, mod_geoip will load the database binary file to memory 21 | ## for very fast lookups. The only penalty is memory usage. 22 | ## 23 | #geoip.memory-cache = "disable" 24 | 25 | ## 26 | ####################################################################### 27 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/newstyle.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: #F5F5F5; 3 | } 4 | a, a:active { 5 | text-decoration: none; 6 | color: blue; 7 | } 8 | a:visited { 9 | color: #48468F; 10 | } 11 | a:hover, a:focus { 12 | text-decoration: underline; 13 | color: red; 14 | } 15 | h2 { 16 | margin-bottom: 12px; 17 | } 18 | table { 19 | margin-left: 12px; 20 | } 21 | th, td { 22 | font-family: "Courier New", Courier, monospace; 23 | font-size: 10pt; 24 | text-align: left; 25 | } 26 | th { 27 | font-weight: bold; 28 | padding-right: 14px; 29 | padding-bottom: 3px; 30 | } 31 | td { 32 | padding-right: 14px; 33 | } 34 | td.s, th.s { 35 | text-align: right; 36 | } 37 | div.list { 38 | background-color: white; 39 | border-top: 1px solid #646464; 40 | border-bottom: 1px solid #646464; 41 | padding-top: 10px; 42 | padding-bottom: 14px; 43 | } 44 | div.foot { 45 | font-family: "Courier New", Courier, monospace; 46 | font-size: 10pt; 47 | color: #787878; 48 | padding-top: 4px; 49 | } 50 | -------------------------------------------------------------------------------- /core/src/include/key_value_store.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | typedef uint64_t _key_t; 7 | 8 | struct kvs_entry { 9 | _key_t key; 10 | void *value; 11 | 12 | TAILQ_ENTRY(kvs_entry) link; 13 | }; 14 | 15 | typedef struct kvs_bucket_head { 16 | struct kvs_entry *tqh_first; 17 | struct kvs_entry **tqh_last; 18 | } kvs_bucket_head; 19 | 20 | /* hashtable structure */ 21 | typedef struct _kvs_t { 22 | int kvs_count ; // count for # entry 23 | int num_buckets; 24 | int num_entries; 25 | 26 | kvs_bucket_head *kvs_table; 27 | kvs_bucket_head kvs_free; 28 | struct kvs_entry *kvs_cont; 29 | } kvs_t; 30 | 31 | /*functions for hashtable*/ 32 | kvs_t * 33 | kvs_create(int num_buckets, int num_entries); 34 | void 35 | kvs_destroy(kvs_t *ht); 36 | 37 | int 38 | kvs_insert(kvs_t *ht, _key_t const key, void * const value); 39 | void * 40 | kvs_remove(kvs_t *ht, _key_t const key); 41 | void * 42 | kvs_search(kvs_t *ht, _key_t const key); 43 | -------------------------------------------------------------------------------- /core/src/include/tcp_rb_frag_queue.h: -------------------------------------------------------------------------------- 1 | #ifndef __TCP_RB_FRAG_QUEUE_ 2 | #define __TCP_RB_FRAG_QUEUE_ 3 | 4 | #include "tcp_ring_buffer.h" 5 | 6 | /*---------------------------------------------------------------------------*/ 7 | typedef struct rb_frag_queue* rb_frag_queue_t; 8 | /*---------------------------------------------------------------------------*/ 9 | rb_frag_queue_t 10 | CreateRBFragQueue(int capacity); 11 | /*---------------------------------------------------------------------------*/ 12 | void 13 | DestroyRBFragQueue(rb_frag_queue_t rb_fragq); 14 | /*---------------------------------------------------------------------------*/ 15 | int 16 | RBFragEnqueue(rb_frag_queue_t rb_fragq, struct fragment_ctx *frag); 17 | /*---------------------------------------------------------------------------*/ 18 | struct fragment_ctx * 19 | RBFragDequeue(rb_frag_queue_t rb_fragq); 20 | /*---------------------------------------------------------------------------*/ 21 | 22 | #endif /* __TCP_RB_FRAG_QUEUE_ */ 23 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/config/conf.d/proxy.conf: -------------------------------------------------------------------------------- 1 | ####################################################################### 2 | ## 3 | ## Proxy Module 4 | ## --------------- 5 | ## 6 | ## http://www.lighttpd.net/documentation/proxy.html 7 | ## 8 | server.modules += ( "mod_proxy" ) 9 | 10 | ## 11 | ## a value between 0 and 65535 to set the debug-level in the Proxy module. 12 | ## Currently only 0 and 1 are used. Use 1 to enable some debug output, 0 to 13 | ## disable it. 14 | ## 15 | #proxy.debug = 1 16 | 17 | ## 18 | ## might be one of 'hash', 'round-robin' or 'fair' (default). 19 | ## 20 | #proxy.balance = "fair" 21 | 22 | ## 23 | ## Handle all jsp requests via 192.168.0.101 24 | ## 25 | #proxy.server = ( ".jsp" => 26 | # ( "tomcat" => 27 | # ( 28 | # "host" => "192.168.0.101", 29 | # "port" => 80 30 | # ) 31 | # ) 32 | # ) 33 | 34 | ## 35 | ####################################################################### 36 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/mod-ssi.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | BEGIN { 3 | # add current source dir to the include-path 4 | # we need this for make distcheck 5 | (my $srcdir = $0) =~ s,/[^/]+$,/,; 6 | unshift @INC, $srcdir; 7 | } 8 | 9 | use strict; 10 | use IO::Socket; 11 | use Test::More tests => 4; 12 | use LightyTest; 13 | 14 | my $tf = LightyTest->new(); 15 | my $t; 16 | 17 | ok($tf->start_proc == 0, "Starting lighttpd") or die(); 18 | 19 | # mod-cgi 20 | # 21 | $t->{REQUEST} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => "/ssi.shtml\n" } ]; 26 | ok($tf->handle_http($t) == 0, 'ssi - echo '); 27 | 28 | 29 | ## bug #280 30 | $t->{REQUEST} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => "2\n\n" } ]; 35 | ok($tf->handle_http($t) == 0, 'ssi - echo '); 36 | 37 | 38 | ok($tf->stop_proc == 0, "Stopping lighttpd"); 39 | 40 | -------------------------------------------------------------------------------- /core/src/include/fhash.h: -------------------------------------------------------------------------------- 1 | #ifndef __FHASH_H_ 2 | #define __FHASH_H_ 3 | 4 | #include 5 | #include "tcp_stream.h" 6 | 7 | #define NUM_BINS (131072) /* 132 K entries per thread*/ 8 | #define TCP_AR_CNT (3) 9 | 10 | #define STATIC_TABLE FALSE 11 | #define INVALID_HASH (NUM_BINS + 1) 12 | 13 | typedef struct hash_bucket_head { 14 | tcp_stream *tqh_first; 15 | tcp_stream **tqh_last; 16 | } hash_bucket_head; 17 | 18 | /* hashtable structure */ 19 | struct hashtable { 20 | uint8_t ht_count ; // count for # entry 21 | 22 | #if STATIC_TABLE 23 | tcp_stream* ht_array[NUM_BINS][TCP_AR_CNT]; 24 | #endif 25 | hash_bucket_head ht_table[NUM_BINS]; 26 | }; 27 | 28 | /*functions for hashtable*/ 29 | struct hashtable *CreateHashtable(void); 30 | void DestroyHashtable(struct hashtable *ht); 31 | 32 | 33 | int HTInsert(struct hashtable *ht, tcp_stream *, unsigned int *hash); 34 | void* HTRemove(struct hashtable *ht, tcp_stream *); 35 | tcp_stream* HTSearch(struct hashtable *ht, const tcp_stream *, unsigned int *hash); 36 | 37 | #endif /* __FHASH_H_ */ 38 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/config/conf.d/auth.conf: -------------------------------------------------------------------------------- 1 | ####################################################################### 2 | ## 3 | ## Authentication Module 4 | ## ----------------------- 5 | ## 6 | ## See http://www.lighttpd.net/documentation/authentification.html 7 | ## for more info. 8 | ## 9 | 10 | #auth.backend = "plain" 11 | #auth.backend.plain.userfile = "/etc/lighttpd/lighttpd.user" 12 | #auth.backend.plain.groupfile = "/etc/lighttpd/lighttpd.group" 13 | 14 | #auth.backend.ldap.hostname = "localhost" 15 | #auth.backend.ldap.base-dn = "dc=my-domain,dc=com" 16 | #auth.backend.ldap.filter = "(uid=$)" 17 | 18 | #auth.require = ( "/server-status" => 19 | # ( 20 | # "method" => "digest", 21 | # "realm" => "Server Status", 22 | # "require" => "valid-user" 23 | # ), 24 | # ) 25 | 26 | ## 27 | ####################################################################### 28 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/outdated/evhost.txt: -------------------------------------------------------------------------------- 1 | ======================== 2 | Enhanced Virtual-Hosting 3 | ======================== 4 | 5 | ------------------ 6 | Module: mod_evhost 7 | ------------------ 8 | 9 | :Author: Jan Kneschke 10 | :Date: $Date: 2004/08/29 09:43:49 $ 11 | :Revision: $Revision: 1.1 $ 12 | 13 | :abstract: 14 | virtual hosting 15 | 16 | .. meta:: 17 | :keywords: lighttpd, virtual hosting 18 | 19 | .. contents:: Table of Contents 20 | 21 | Description 22 | =========== 23 | 24 | mod_evhost builds the document-root based on a pattern which contains 25 | wildcards. Those wildcards can represent parts if the submitted hostname 26 | 27 | 28 | :: 29 | 30 | %% => % sign 31 | %0 => domain name + tld 32 | %1 => tld 33 | %2 => domain name without tld 34 | %3 => subdomain 1 name 35 | %4 => subdomain 2 name 36 | %_ => the complete hostname (without port info) 37 | 38 | evhost.path-pattern = "/home/www/servers/%3/pages/" 39 | 40 | Options 41 | ======= 42 | 43 | evhost.path-pattern 44 | pattern with wildcards to be replace to build a documentroot 45 | 46 | 47 | -------------------------------------------------------------------------------- /core/src/include/logger.h: -------------------------------------------------------------------------------- 1 | #ifndef __LOGGER_H_ 2 | #define __LOGGER_H_ 3 | 4 | #include 5 | 6 | #define LOG_BUFF_SIZE (256*1024) 7 | #define NUM_LOG_BUFF (100) 8 | 9 | enum { 10 | IDLE_LOGT, 11 | ACTIVE_LOGT 12 | } log_thread_state; 13 | 14 | typedef struct log_buff 15 | { 16 | int tid; 17 | FILE* fid; 18 | int buff_len; 19 | char buff[LOG_BUFF_SIZE]; 20 | TAILQ_ENTRY(log_buff) buff_link; 21 | } log_buff; 22 | 23 | typedef struct log_thread_context { 24 | pthread_t thread; 25 | int cpu; 26 | int done; 27 | int sp_fd; 28 | int pair_sp_fd; 29 | int free_buff_cnt; 30 | int job_buff_cnt; 31 | 32 | uint8_t state; 33 | 34 | pthread_mutex_t mutex; 35 | pthread_mutex_t free_mutex; 36 | 37 | TAILQ_HEAD(, log_buff) working_queue; 38 | TAILQ_HEAD(, log_buff) free_queue; 39 | 40 | } log_thread_context; 41 | 42 | log_buff* DequeueFreeBuffer (log_thread_context *ctx); 43 | void EnqueueJobBuffer(log_thread_context *ctx, log_buff* working_bp); 44 | void InitLogThreadContext (log_thread_context *ctx, int cpu); 45 | void *ThreadLogMain(void* arg); 46 | 47 | #endif /* __LOGGER_H_ */ 48 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/outdated/access.txt: -------------------------------------------------------------------------------- 1 | ====== 2 | Access 3 | ====== 4 | 5 | ------------------ 6 | Module: mod_access 7 | ------------------ 8 | 9 | :Author: Allan Wind 10 | :Date: $Date: 2005/01/30 11:34:32 $ 11 | :Revision: $Revision: 1.1 $ 12 | 13 | :abstract: 14 | The access module is used to deny access to files with given trailing path names. 15 | 16 | .. meta:: 17 | :keywords: lighttpd, trailing path access control 18 | 19 | .. contents:: Table of Contents 20 | 21 | Description 22 | =========== 23 | 24 | The access module is used to deny access to files with given trailing path names. 25 | 26 | Options 27 | ======= 28 | 29 | url.access-deny 30 | Denies access to all files with any of given trailing path names. 31 | 32 | Default: empty 33 | 34 | Example: :: 35 | 36 | url.access-deny = ( "~", ".inc") 37 | 38 | will deny access to all files ended with a diacritical mark (~) or .inc 39 | such as example~ or example.inc. A trailing diacritical mark is often 40 | used by editors for backup files. And the .inc extension is often used 41 | for include files with code. 42 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/docroot/www/404.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use CGI qw/:standard/; 3 | my $cgi = new CGI; 4 | my $request_uri = $ENV{'REQUEST_URI'}; 5 | print (STDERR "REQUEST_URI: $request_uri\n"); 6 | 7 | if ($request_uri =~ m/^\/dynamic\/200\// ) { 8 | print header ( -status => 200, 9 | -type => 'text/plain' ); 10 | print ("found here\n"); 11 | } 12 | elsif ($request_uri =~ m|^/dynamic/302/| ) { 13 | print header( -status=>302, 14 | -location => 'http://www.example.org/'); 15 | } 16 | elsif ($request_uri =~ m/^\/dynamic\/404\// ) { 17 | print header ( -status => 404 18 | -type => 'text/plain' ); 19 | print ("Not found here\n"); 20 | } 21 | elsif ($request_uri =~ m/^\/send404\.pl/ ) { 22 | print header ( -status => 404 23 | -type => 'text/plain' ); 24 | print ("Not found here (send404)\n"); 25 | } 26 | elsif ($request_uri =~ m/^\/dynamic\/nostatus\// ) { 27 | print ("found here\n"); 28 | } 29 | else { 30 | print header ( -status => 500, 31 | -type => 'text/plain'); 32 | print ("huh\n"); 33 | }; 34 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/config/conf.d/userdir.conf: -------------------------------------------------------------------------------- 1 | ####################################################################### 2 | ## 3 | ## Userdir Module 4 | ## ---------------- 5 | ## 6 | ## for all details see: 7 | ## http://www.lighttpd.net/documentation/userdir.html 8 | ## 9 | server.modules += ( "mod_userdir" ) 10 | 11 | ## 12 | ## usually it should be set to "public_html" to take ~/public_html/ as 13 | ## the document root 14 | ## Default: empty (document root is the home directory) 15 | ## 16 | userdir.path = "public_html" 17 | 18 | ## 19 | ## If set, don't check /etc/passwd for homedir 20 | ## Default: empty 21 | #userdir.basepath = server_root + "/users/" 22 | 23 | ## 24 | ## list of usernames which may not use this feature 25 | ## Default: empty (all users may use it) 26 | ## 27 | #userdir.exclude-user = ( "root", "postmaster" ) 28 | 29 | ## 30 | ## if set, only users from this list may use the feature 31 | ## Default: empty (all users may use it) 32 | ## 33 | #userdir.include-user = ("user1", "user2") 34 | 35 | ## 36 | ####################################################################### 37 | 38 | -------------------------------------------------------------------------------- /util/include/ring_buffer.h: -------------------------------------------------------------------------------- 1 | #ifndef __APP_RELAYBUFFER 2 | #define __APP_RELAYBUFFER 3 | 4 | #include 5 | 6 | #define MAX_REP_LEN (10*1024) 7 | 8 | typedef struct ring_buffer ring_buffer; 9 | 10 | ring_buffer* InitBuffer(int size); 11 | 12 | int GetTotSizeRBuffer(ring_buffer* r_buff); 13 | int GetDataSizeRBuffer(ring_buffer* r_buff); 14 | int GetCumSizeRBuffer(ring_buffer* r_buff); 15 | int GetRemainBufferSize(ring_buffer *r_buff); 16 | int CheckAvailableSize(ring_buffer *r_buff, int size); 17 | 18 | u_char* GetDataPoint(ring_buffer* r_buff); 19 | u_char* GetInputPoint(ring_buffer *r_buff); 20 | 21 | int RemoveDataFromBuffer(ring_buffer *r_buff, int size); 22 | int AddDataLen(ring_buffer *r_buffer, int size); 23 | 24 | int CopyData(ring_buffer *dest_buff, ring_buffer *src_buff, int len); 25 | int MoveData(ring_buffer *dest_buff, ring_buffer *src_buff, int len); 26 | int MoveToREPData(ring_buffer *dest_buff, ring_buffer *src_buff, int len); 27 | 28 | int MtcpWriteFromBuffer(mctx_t mtcp, int fid, ring_buffer *r_buff); 29 | int MtcpReadFromBuffer(mctx_t mtcp, int fid, ring_buffer *r_buff); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/config/vhosts.d/vhosts.template: -------------------------------------------------------------------------------- 1 | ####################################################################### 2 | ## 3 | ## For more examples check: 4 | ## 5 | ## http://www.lighttpd.net/documentation/configuration.html#conditional-configuration 6 | ## 7 | $HTTP["host"] == "download.example.com" { 8 | var.server_name = "download.example.com" 9 | 10 | server.name = server_name 11 | ## 12 | ## use trigger before download 13 | ## 14 | include "conf.d/trigger_b4_dl.conf" 15 | 16 | server.document-root = vhosts_dir + "/example.com/download/htdocs" 17 | ## 18 | ## use a seperate access log file 19 | ## At the moment you cant have different error log files. 20 | ## 21 | accesslog.filename = log_root + "/" + server_name "/access.log" 22 | } 23 | 24 | $SERVER["socket"] == "127.0.0.1:443" { 25 | server.name = "localhost" 26 | ssl.pemfile = "/etc/ssl/private/lighttpd-localhost.pem" 27 | ssl.engine = "enable" 28 | 29 | server.document-root = vhosts_dir + "/ssl-localhost/pages/" 30 | } 31 | 32 | ## 33 | ####################################################################### 34 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/config/conf.d/cgi.conf: -------------------------------------------------------------------------------- 1 | ####################################################################### 2 | ## 3 | ## CGI modules 4 | ## --------------- 5 | ## 6 | ## http://www.lighttpd.net/documentation/cgi.html 7 | ## 8 | server.modules += ( "mod_cgi" ) 9 | 10 | ## 11 | ## Plain old CGI handling 12 | ## 13 | ## For PHP don't forget to set cgi.fix_pathinfo = 1 in the php.ini. 14 | ## 15 | cgi.assign = ( ".pl" => "/usr/bin/perl", 16 | ".cgi" => "/usr/bin/perl", 17 | ".rb" => "/usr/bin/ruby", 18 | ".erb" => "/usr/bin/eruby", 19 | ".py" => "/usr/bin/python" ) 20 | 21 | ## 22 | ## to get the old cgi-bin behavior of apache 23 | ## 24 | ## Note: make sure that mod_alias is loaded if you uncomment the 25 | ## next line. (see modules.conf) 26 | ## 27 | #alias.url += ( "/cgi-bin" => server_root + "/cgi-bin" ) 28 | #$HTTP["url"] =~ "^/cgi-bin" { 29 | # cgi.assign = ( "" => "" ) 30 | #} 31 | 32 | ## 33 | ####################################################################### 34 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/configfile.h: -------------------------------------------------------------------------------- 1 | #ifndef _CONFIG_PARSER_H_ 2 | #define _CONFIG_PARSER_H_ 3 | 4 | #include "array.h" 5 | #include "buffer.h" 6 | #include "server.h" 7 | 8 | typedef struct { 9 | server *srv; 10 | int ok; 11 | array *all_configs; 12 | array *configs_stack; /* to parse nested block */ 13 | data_config *current; /* current started with { */ 14 | buffer *basedir; 15 | } config_t; 16 | 17 | void *configparserAlloc(void *(*mallocProc)(size_t)); 18 | void configparserFree(void *p, void (*freeProc)(void*)); 19 | void configparser(void *yyp, int yymajor, buffer *yyminor, config_t *ctx); 20 | int config_parse_file(server *srv, config_t *context, const char *fn); 21 | int config_parse_cmd(server *srv, config_t *context, const char *cmd); 22 | data_unset *configparser_merge_data(data_unset *op1, const data_unset *op2); 23 | 24 | void config_cond_cache_reset(server *srv, connection *con); 25 | void config_cond_cache_reset_item(server *srv, connection *con, comp_key_t item); 26 | 27 | #define config_cond_cache_reset_all_items(srv, con) \ 28 | config_cond_cache_reset_item(srv, con, COMP_LAST_ELEMENT); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /core/src/include/ip_in.h: -------------------------------------------------------------------------------- 1 | #ifndef __IP_IN_H_ 2 | #define __IP_IN_H_ 3 | 4 | #include "mtcp.h" 5 | #include "mos_api.h" 6 | 7 | int 8 | ProcessInIPv4Packet(mtcp_manager_t mtcp, struct pkt_ctx *pctx); 9 | 10 | static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl) 11 | { 12 | unsigned int sum; 13 | 14 | asm(" movl (%1), %0\n" 15 | " subl $4, %2\n" 16 | " jbe 2f\n" 17 | " addl 4(%1), %0\n" 18 | " adcl 8(%1), %0\n" 19 | " adcl 12(%1), %0\n" 20 | "1: adcl 16(%1), %0\n" 21 | " lea 4(%1), %1\n" 22 | " decl %2\n" 23 | " jne 1b\n" 24 | " adcl $0, %0\n" 25 | " movl %0, %2\n" 26 | " shrl $16, %0\n" 27 | " addw %w2, %w0\n" 28 | " adcl $0, %0\n" 29 | " notl %0\n" 30 | "2:" 31 | /* Since the input registers which are loaded with iph and ih 32 | are modified, we must also specify them as outputs, or gcc 33 | will assume they contain their original values. */ 34 | : "=r" (sum), "=r" (iph), "=r" (ihl) 35 | : "1" (iph), "2" (ihl) 36 | : "memory"); 37 | return (__sum16)sum; 38 | } 39 | 40 | #endif /* __IP_IN_H_ */ 41 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/var-include-sub.conf: -------------------------------------------------------------------------------- 1 | # file to be included 2 | $HTTP["host"] =~ "^" + server.name + "$" { 3 | url.redirect = ( 4 | "^/include$" => "/good_include", 5 | "^/concat$" => "/good_" + "concat", 6 | "^/servername1$" => "/good_" + server.name, 7 | "^/servername2$" => server.name + "/good_", 8 | "^/servername3$" => "/good_" + server.name + "/", 9 | "^/var.myvar$" => "/good_var_myvar" + var.myvar, 10 | "^/myvar$" => "/good_myvar" + myvar, 11 | "^/number1$" => "/good_number" + one, 12 | "^/number2$" => one + "/good_number", 13 | "^/env$" => "/" + env.env_test, 14 | ) 15 | num = 1 16 | num2 = 2 17 | num2 += 1 18 | # without var prefix 19 | mystr = "string" 20 | mystr += "_append" 21 | # from parent 22 | one += 1 23 | url.redirect += ( 24 | "^/array_append$" => "/good_array_append", 25 | "^/string_append$" => "/good_" + mystr, 26 | "^/number_append$" => "/good_" + one, 27 | ) 28 | 29 | cmd = "echo cmd_ok=456" 30 | include_shell cmd 31 | url.redirect += ( 32 | "^/include_shell$" => "/good_include_shell_" + cmd_ok, 33 | ) 34 | } 35 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/outdated/security.txt: -------------------------------------------------------------------------------- 1 | ================= 2 | Security Features 3 | ================= 4 | 5 | ------------ 6 | Module: core 7 | ------------ 8 | 9 | :Author: Jan Kneschke 10 | :Date: $Date: 2004/08/29 09:44:53 $ 11 | :Revision: $Revision: 1.2 $ 12 | 13 | :abstract: 14 | lighttpd was developed with security in mind ... 15 | 16 | .. meta:: 17 | :keywords: lighttpd, security 18 | 19 | .. contents:: Table of Contents 20 | 21 | Description 22 | =========== 23 | 24 | Limiting POST requests 25 | ---------------------- 26 | 27 | 28 | 29 | :: 30 | 31 | server.max-request-size = 32 | 33 | System Security 34 | --------------- 35 | 36 | Running daemons as root with full privileges is a bad idea in general. 37 | lighttpd runs best without any extra privileges and runs perfectly in chroot. 38 | 39 | Change Root 40 | ``````````` 41 | 42 | server.chroot = "..." 43 | 44 | Drop root privileges 45 | ```````````````````` 46 | 47 | server.username = "..." 48 | server.groupname = "..." 49 | 50 | FastCGI 51 | ``````` 52 | 53 | fastcgi + chroot 54 | 55 | Permissions 56 | ``````````` 57 | 58 | :: 59 | 60 | $ useradd wwwrun ... 61 | -------------------------------------------------------------------------------- /util/cpu.c: -------------------------------------------------------------------------------- 1 | #ifndef _GNU_SOURCE 2 | #define _GNU_SOURCE 3 | #endif 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | /*----------------------------------------------------------------------------*/ 13 | int GetNumCPUs() 14 | { 15 | return sysconf(_SC_NPROCESSORS_ONLN); 16 | } 17 | /*----------------------------------------------------------------------------*/ 18 | int 19 | CoreAffinitize(int cpu) 20 | { 21 | cpu_set_t *cmask; 22 | struct bitmask *bmask; 23 | size_t n; 24 | int ret; 25 | 26 | n = GetNumCPUs(); 27 | 28 | if (cpu < 0 || cpu >= (int) n) { 29 | errno = -EINVAL; 30 | return -1; 31 | } 32 | 33 | cmask = CPU_ALLOC(n); 34 | if (cmask == NULL) 35 | return -1; 36 | 37 | CPU_ZERO_S(n, cmask); 38 | CPU_SET_S(cpu, n, cmask); 39 | 40 | ret = sched_setaffinity(0, n, cmask); 41 | 42 | CPU_FREE(cmask); 43 | 44 | if (numa_max_node() == 0) 45 | return ret; 46 | 47 | bmask = numa_bitmask_alloc(16); 48 | assert(bmask); 49 | 50 | numa_bitmask_setbit(bmask, cpu %2); 51 | numa_set_membind(bmask); 52 | numa_bitmask_free(bmask); 53 | 54 | return ret; 55 | } 56 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/outdated/cgi.txt: -------------------------------------------------------------------------------- 1 | === 2 | CGI 3 | === 4 | 5 | --------------- 6 | Module: mod_cgi 7 | --------------- 8 | 9 | :Author: Jan Kneschke 10 | :Date: $Date: 2004/11/03 22:26:05 $ 11 | :Revision: $Revision: 1.2 $ 12 | 13 | :abstract: 14 | The cgi module provides a CGI-conforming interface. 15 | 16 | .. meta:: 17 | :keywords: lighttpd, cgi 18 | 19 | .. contents:: Table of Contents 20 | 21 | Description 22 | =========== 23 | 24 | CGI programs allow you to enhance the functionality of the server in a very 25 | straight and simple way.. 26 | 27 | Options 28 | ======= 29 | 30 | cgi.assign 31 | 32 | file-extensions that are handled by a CGI program 33 | 34 | e.g.: :: 35 | 36 | cgi.assign = ( ".pl" => "/usr/bin/perl", 37 | ".cgi" => "/usr/bin/perl" ) 38 | 39 | Examples 40 | ======== 41 | 42 | To setup a executable which doesn't need the help of a external program you 43 | just don't specify a handler for the extension. :: 44 | 45 | cgi.assign = ( ".sh" => "" ) 46 | 47 | If the file has no extension keep in mind that lighttpd matches not the 48 | extension itself but the right part of the URL: :: 49 | 50 | cgi.assign = ( "/testfile" => "" ) 51 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/config/conf.d/debug.conf: -------------------------------------------------------------------------------- 1 | ####################################################################### 2 | ## 3 | ## Debug options 4 | ## --------------- 5 | ## 6 | ## Enable those options for debugging the behavior 7 | ## 8 | ## The settings can be set per location/vhost. 9 | ## 10 | 11 | ## 12 | ## log-request-handling allows you to track the request 13 | ## handing inside lighttpd. 14 | ## 15 | #debug.log-request-handling = "enable" 16 | 17 | ## 18 | ## log all request headers. 19 | ## 20 | #debug.log-request-header = "enable" 21 | 22 | ## 23 | ## similar to log-request-header. 24 | ## but only logs if we encountered an error. 25 | ## (return codes 400 and 5xx) 26 | ## 27 | #debug.log-request-header-on-error = "enable" 28 | 29 | ## 30 | ## log the header we send out to the client. 31 | ## 32 | #debug.log-response-header = "enable" 33 | 34 | ## 35 | ## log if a file wasnt found in the error log. 36 | ## 37 | #debug.log-file-not-found = "enable" 38 | 39 | ## 40 | ## debug conditionals handling 41 | ## 42 | #debug.log-condition-handling = "enable" 43 | 44 | # 45 | ####################################################################### 46 | 47 | 48 | -------------------------------------------------------------------------------- /samples/common/applib.h: -------------------------------------------------------------------------------- 1 | #ifndef _APP_LIB_H_ 2 | #define _APP_LIB_H_ 3 | 4 | #define MAX_LINE_LEN (1000) 5 | #define MAX_FLOW_NUM (1000000) 6 | #define MAX_EVENTS (MAX_FLOW_NUM * 3) 7 | #ifndef MAX_CPUS 8 | #define MAX_CPUS (16) // max number of CPU cores 9 | #endif 10 | 11 | #define MAX(a, b) ((a)>(b)?(a):(b)) 12 | #define MIN(a, b) ((a)<(b)?(a):(b)) 13 | 14 | #ifndef TRUE 15 | #define TRUE (1) 16 | #endif 17 | 18 | #ifndef FALSE 19 | #define FALSE (0) 20 | #endif 21 | 22 | #ifndef ERROR 23 | #define ERROR (-1) 24 | #endif 25 | 26 | #define TIMEVAL_TO_MSEC(t) ((t.tv_sec * 1000) + (t.tv_usec / 1000)) 27 | #define TIMEVAL_TO_USEC(t) ((t.tv_sec * 1000000) + (t.tv_usec)) 28 | #define TS_GT(a,b) ((int64_t)((a)-(b)) > 0) 29 | 30 | /*----------------------------------------------------------------------------*/ 31 | #define CONF_VALUE_LEN 100 32 | struct conf_var { 33 | char *name; 34 | char value[CONF_VALUE_LEN + 1]; 35 | }; 36 | /*----------------------------------------------------------------------------*/ 37 | 38 | char * 39 | strevent(uint64_t ev); 40 | 41 | char * 42 | strcbevent(uint64_t ev); 43 | 44 | int 45 | LoadConfig(char *file_name, struct conf_var *vlist, int size); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/mod-compress.conf: -------------------------------------------------------------------------------- 1 | debug.log-request-handling = "enable" 2 | debug.log-response-header = "disable" 3 | debug.log-request-header = "disable" 4 | 5 | server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" 6 | server.pid-file = env.SRCDIR + "/tmp/lighttpd/lighttpd.pid" 7 | 8 | ## bind to port (default: 80) 9 | server.port = 2048 10 | 11 | ## bind to localhost (default: all interfaces) 12 | server.bind = "localhost" 13 | server.errorlog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log" 14 | server.breakagelog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log" 15 | server.name = "www.example.org" 16 | 17 | server.modules = ( 18 | "mod_compress" 19 | ) 20 | 21 | ######################## MODULE CONFIG ############################ 22 | 23 | mimetype.assign = ( 24 | ".html" => "text/html", 25 | ".txt" => "text/plain; charset=utf-8", 26 | ) 27 | 28 | $HTTP["host"] == "cache.example.org" { 29 | compress.cache-dir = env.SRCDIR + "/tmp/lighttpd/cache/compress/" 30 | } 31 | compress.filetype = ("text/plain", "text/html") 32 | 33 | compress.allowed-encodings = ( "gzip", "deflate" ) 34 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/outdated/expire.txt: -------------------------------------------------------------------------------- 1 | =============================================== 2 | Controlling the Expiration of Content in Caches 3 | =============================================== 4 | 5 | ------------------ 6 | Module: mod_expire 7 | ------------------ 8 | 9 | :Author: Jan Kneschke 10 | :Date: $Date: 2004/11/03 22:26:05 $ 11 | :Revision: $Revision: 1.2 $ 12 | 13 | :abstract: 14 | mod_expire controls the setting of the the Expire Response header 15 | 16 | .. meta:: 17 | :keywords: lighttpd, expire 18 | 19 | .. contents:: Table of Contents 20 | 21 | Description 22 | =========== 23 | 24 | mod_expire controls the Expire header in the Response Header of HTTP/1.0 25 | messages. It is usefull to set it for static files which should be cached 26 | aggressivly like images, stylesheets or similar. 27 | 28 | Options 29 | ======= 30 | 31 | expire.url 32 | assignes a expiration to all files below the specified path. The 33 | specification of the time is made up of: :: 34 | 35 | 36 | 37 | following the syntax used by mod_expire in Apache 1.3.x and later. 38 | 39 | Example: :: 40 | 41 | expire.url = ( "/images/" => "access 1 hour" ) 42 | 43 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/outdated/redirect.txt: -------------------------------------------------------------------------------- 1 | =============== 2 | URL Redirection 3 | =============== 4 | 5 | -------------------- 6 | Module: mod_redirect 7 | -------------------- 8 | 9 | :Author: Jan Kneschke 10 | :Date: $Date: 2004/08/29 09:43:49 $ 11 | :Revision: $Revision: 1.1 $ 12 | 13 | :abstract: 14 | url redirection 15 | 16 | .. meta:: 17 | :keywords: lighttpd, redirect 18 | 19 | .. contents:: Table of Contents 20 | 21 | Description 22 | =========== 23 | 24 | ... 25 | 26 | Options 27 | ======= 28 | 29 | url.redirect 30 | redirects a set of URLs externally 31 | 32 | e.g. :: 33 | 34 | url.redirect = ( "^/show/([0-9]+)/([0-9]+)$" => "http://www.example.org/show.php?isdn=$1&page$2", 35 | "^/get/([0-9]+)/([0-9]+)$" => "http://www.example.org/get.php?isdn=$1&page$2" ) 36 | 37 | # make a external redirect 38 | # from any www.host (with www.) to the host (without www.) 39 | $HTTP["host"] =~ "^www\.(.*)" { 40 | url.redirect = ( "^/(.*)" => "http://%1/$1" ) 41 | } 42 | 43 | Warning 44 | ======= 45 | 46 | Do NOT use mod_redirect to protect specific urls, as the original url passed from the client 47 | is matched against your rules, for example strings like "/abc/../xyz%2f/path". 48 | -------------------------------------------------------------------------------- /util/include/http_parsing.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __NRE_HTTP_PARSING 3 | #define __NRE_HTTP_PARSING 4 | 5 | 6 | #define HTTP_GET "GET" 7 | #define CONTENT_LENGTH_HDR "Content-Length:" 8 | #define CONN_HDR_FLD "Connection:" 9 | #define KEEP_ALIVE_STR "Keep-Alive" 10 | 11 | enum { 12 | GET = 1, 13 | POST 14 | }; 15 | 16 | int find_http_header(char *data, int len); 17 | int is_http_response(char *data, int len); 18 | int is_http_request(char *data, int len); 19 | 20 | char* http_header_str_val(const char* buf, const char *key, const int key_len, char* value, int value_len); 21 | long int http_header_long_val(const char* buf, const char *key, int key_len); 22 | 23 | char* http_get_http_version_resp(char* data, int len, char* value, int value_len); 24 | char* http_get_url(char * data, int data_len, char* value, int value_len); 25 | int http_get_status_code(void *response); 26 | int http_get_maxage(char *cache_ctl, int len); 27 | 28 | time_t http_header_date(const char* data, const char* field, int len); 29 | 30 | enum {HTTP_09, HTTP_10, HTTP_11}; /* http version */ 31 | int http_parse_first_resp_line(const char* data, int len, int* scode, int* ver); 32 | int http_check_header_field(const char* data, const char* field); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/configparser.h: -------------------------------------------------------------------------------- 1 | #define TK_EOL 1 2 | #define TK_ASSIGN 2 3 | #define TK_APPEND 3 4 | #define TK_LKEY 4 5 | #define TK_PLUS 5 6 | #define TK_STRING 6 7 | #define TK_INTEGER 7 8 | #define TK_LPARAN 8 9 | #define TK_RPARAN 9 10 | #define TK_COMMA 10 11 | #define TK_ARRAY_ASSIGN 11 12 | #define TK_GLOBAL 12 13 | #define TK_LCURLY 13 14 | #define TK_RCURLY 14 15 | #define TK_ELSE 15 16 | #define TK_DOLLAR 16 17 | #define TK_SRVVARNAME 17 18 | #define TK_LBRACKET 18 19 | #define TK_RBRACKET 19 20 | #define TK_EQ 20 21 | #define TK_MATCH 21 22 | #define TK_NE 22 23 | #define TK_NOMATCH 23 24 | #define TK_INCLUDE 24 25 | #define TK_INCLUDE_SHELL 25 26 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/outdated/fastcgi-state.txt: -------------------------------------------------------------------------------- 1 | ================= 2 | FastCGI Internals 3 | ================= 4 | 5 | --------------- 6 | Module: fastcgi 7 | --------------- 8 | 9 | :Author: Jan Kneschke 10 | :Date: $Date: 2004/08/01 07:01:29 $ 11 | :Revision: $Revision: 1.1 $ 12 | 13 | :abstract: 14 | This is a short summary of the state-engine which is driving the FastCGI 15 | module. It describes the basic concepts and the way the different parts 16 | of the module are connected. 17 | 18 | .. meta:: 19 | :keywords: lighttpd, state-engine, fastcgi 20 | 21 | .. contents:: Table of Contents 22 | 23 | Description 24 | =========== 25 | 26 | States 27 | ------ 28 | 29 | The state-engine is currently made of 6 states which are walk-through on 30 | the way each connection. 31 | 32 | :init: 33 | prepare fastcgi-connection 34 | :connect: 35 | waiting for a connection 36 | :prepwrite: 37 | build the fastcgi-request 38 | :write: 39 | write the fastcgi-request to the network 40 | :read: 41 | read fastcgi-response from network and push it to the write-queue 42 | :close: 43 | terminate the connection 44 | 45 | .. image:: fastcgi-state.png 46 | 47 | Delays 48 | ------ 49 | 50 | connect, write and read may need to wait for an fdevent. That's the reason 51 | for the loop in the state-diagram. 52 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/config/conf.d/mysql_vhost.conf: -------------------------------------------------------------------------------- 1 | ####################################################################### 2 | ## 3 | ## Virtual hosting with MySQL 4 | ## ---------------------------- 5 | ## 6 | ## http://www.lighttpd.net/documentation/mysqlvhost.html 7 | ## 8 | server.modules += ( "mod_mysql_vhost" ) 9 | 10 | ## 11 | ## Either set the the socket or host (and port) 12 | ## 13 | ## Local path to the mysql socket 14 | ## 15 | #mysql-vhost.sock = "/var/lib/mysql/mysql.sock" 16 | 17 | ## 18 | ## Host of the MySQL server. 19 | ## 20 | #mysql-vhost.hostname = "localhost" 21 | 22 | ## 23 | ## Optional: port to use. 24 | ## 25 | #mysql-vhost.port = 3306 26 | 27 | ## 28 | ## Name of the database 29 | ## 30 | mysql-vhost.db = "lighttpd" 31 | 32 | ## 33 | ## SQL User/Password for the connection 34 | ## 35 | mysql-vhost.user = "lighttpd" 36 | mysql-vhost.pass = "secret" 37 | 38 | ## 39 | ## The query to get the needed informations from the database. 40 | ## 41 | ## It doesnt matter how you name the fields the first field is always used 42 | ## as the document root. 43 | ## 44 | mysql-vhost.sql = "SELECT docroot FROM domains WHERE domain='?'" 45 | 46 | ## 47 | ####################################################################### 48 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/mod-userdir.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | BEGIN { 3 | # add current source dir to the include-path 4 | # we need this for make distcheck 5 | (my $srcdir = $0) =~ s,/[^/]+$,/,; 6 | unshift @INC, $srcdir; 7 | } 8 | 9 | use strict; 10 | use IO::Socket; 11 | use Test::More tests => 5; 12 | use LightyTest; 13 | 14 | my $tf = LightyTest->new(); 15 | my $t; 16 | 17 | ok($tf->start_proc == 0, "Starting lighttpd") or die(); 18 | 19 | # get current user 20 | 21 | $t->{REQUEST} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } ]; 26 | ok($tf->handle_http($t) == 0, 'valid user'); 27 | 28 | $t->{REQUEST} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => 'http://'.$tf->{HOSTNAME}.':'.$tf->{PORT}.'/~jan/' } ]; 33 | ok($tf->handle_http($t) == 0, 'valid user + redirect'); 34 | 35 | $t->{REQUEST} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => 'http://www.example.org/~jan/' } ]; 41 | ok($tf->handle_http($t) == 0, 'valid user + redirect'); 42 | 43 | ok($tf->stop_proc == 0, "Stopping lighttpd"); 44 | 45 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/ndsl-kaist/mOS-networking-stack.svg?branch=master)](https://travis-ci.org/ndsl-kaist/mOS-networking-stack) 2 | [![Build Status](https://scan.coverity.com/projects/11918/badge.svg)](https://scan.coverity.com/projects/mos-networking-stack) 3 | 4 | # mOS-networking-stack 5 | 6 | mOS networking stack provides a high performance user-space programming library 7 | specifically targeted for building software-based stateful monitoring solutions. 8 | Our API offers powerful event-based abstractions that can potentially simplify the 9 | codebase of future middleboxes that are developed on our stack. 10 | 11 | We suggest you to browse through our example (```samples/```) programs to 12 | see how stateful middleboxes can be built using the mOS networking API. 13 | 14 | To download our source, type: 15 | 16 | ``` 17 | # git clone https://github.com/ndsl-kaist/mOS-networking-stack.git 18 | ``` 19 | 20 | Pull requests and bug fixes are welcomed! 21 | 22 | ## Documentation 23 | Please visit http://mos.kaist.edu/ for more instructions. 24 | 25 | ## Acknowledgment 26 | This project is supported by ICT Research and Development Program of MSIP/IITP, 27 | Korea, under Grant B0101-16-1368, [Development of an NFV-inspired networked 28 | switch and an operating system for multi-middlebox services]. 29 | -------------------------------------------------------------------------------- /util/include/netlib.h: -------------------------------------------------------------------------------- 1 | #ifndef _NET_LIB_H_ 2 | #define _NET_LIB_H_ 3 | 4 | #include 5 | 6 | #ifndef TRUE 7 | #define TRUE 1 8 | #endif 9 | 10 | #ifndef FALSE 11 | #define FALSE 0 12 | #endif 13 | 14 | #ifndef MAX 15 | #define MAX(x, y) ((x) > (y) ? (x) : (y)) 16 | #endif 17 | 18 | #ifndef MIN 19 | #define MIN(x, y) ((x) < (y) ? (x) : (y)) 20 | #endif 21 | 22 | #ifndef VERIFY 23 | #define VERIFY(x) if (!(x)) {fprintf(stderr, "error: FILE:%s LINE:%d FUNC: %s", __FILE__, __LINE__, __FUNCTION__); assert(0);} 24 | #endif 25 | 26 | #ifndef FREE 27 | #define FREE(x) if (x) {free(x); (x) = NULL;} 28 | #endif 29 | 30 | int GetNumCPUCores(void); 31 | int AffinitizeThreadToCore(int core); 32 | int CreateServerSocket(int port, int isNonBlocking); 33 | int CreateConnectionSocket(in_addr_t addr, int port, int isNonBlocking); 34 | 35 | /* processing options */ 36 | struct Options { 37 | char *op_name; 38 | char **op_varptr; 39 | char *op_comment; 40 | } Options; 41 | void ParseOptions(int argc, const char** argv, struct Options* ops); 42 | void PrintOptions(const struct Options* ops, int printVal); 43 | 44 | 45 | /* HTTP header processing */ 46 | char *GetHeaderString(const char *buf, const char* header, int hdrsize); 47 | int GetHeaderLong(const char* buf, const char* header, int hdrsize, long int *val); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/etag.c: -------------------------------------------------------------------------------- 1 | #include "buffer.h" 2 | #include "etag.h" 3 | 4 | #if defined HAVE_STDINT_H 5 | # include 6 | #elif defined HAVE_INTTYPES_H 7 | # include 8 | #endif 9 | 10 | #include 11 | 12 | int etag_is_equal(buffer *etag, const char *matches) { 13 | if (etag && !buffer_is_empty(etag) && 0 == strcmp(etag->ptr, matches)) return 1; 14 | return 0; 15 | } 16 | 17 | int etag_create(buffer *etag, struct stat *st,etag_flags_t flags) { 18 | if (0 == flags) return 0; 19 | 20 | buffer_reset(etag); 21 | 22 | if (flags & ETAG_USE_INODE) { 23 | buffer_append_off_t(etag, st->st_ino); 24 | buffer_append_string_len(etag, CONST_STR_LEN("-")); 25 | } 26 | 27 | if (flags & ETAG_USE_SIZE) { 28 | buffer_append_off_t(etag, st->st_size); 29 | buffer_append_string_len(etag, CONST_STR_LEN("-")); 30 | } 31 | 32 | if (flags & ETAG_USE_MTIME) { 33 | buffer_append_long(etag, st->st_mtime); 34 | } 35 | 36 | return 0; 37 | } 38 | 39 | int etag_mutate(buffer *mut, buffer *etag) { 40 | size_t i; 41 | uint32_t h; 42 | 43 | for (h=0, i=0; i < etag->used-1; ++i) h = (h<<5)^(h>>27)^(etag->ptr[i]); 44 | 45 | buffer_reset(mut); 46 | buffer_copy_string_len(mut, CONST_STR_LEN("\"")); 47 | buffer_append_off_t(mut, h); 48 | buffer_append_string_len(mut, CONST_STR_LEN("\"")); 49 | 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/settings.h: -------------------------------------------------------------------------------- 1 | #ifndef _LIGHTTPD_SETTINGS_H_ 2 | #define _LIGHTTPD_SETTINGS_H_ 3 | 4 | #ifndef _GNU_SOURCE 5 | # define _GNU_SOURCE 6 | #endif 7 | 8 | #ifndef __USE_GNU 9 | # define __USE_GNU /* a hack in my eyes, F_SETSIG should work with _GNU_SOURCE */ 10 | #endif 11 | 12 | #define BV(x) (1 << x) 13 | 14 | #define INET_NTOP_CACHE_MAX 4 15 | #define FILE_CACHE_MAX 16 16 | 17 | /** 18 | * max size of a buffer which will just be reset 19 | * to ->used = 0 instead of really freeing the buffer 20 | * 21 | * 64kB (no real reason, just a guess) 22 | */ 23 | #define BUFFER_MAX_REUSE_SIZE (4 * 1024) 24 | 25 | /* both should be way smaller than SSIZE_MAX :) */ 26 | #define MAX_READ_LIMIT (256*1024) 27 | #define MAX_WRITE_LIMIT (256*1024) 28 | 29 | /** 30 | * max size of the HTTP request header 31 | * 32 | * 32k should be enough for everything (just a guess) 33 | * 34 | */ 35 | #define MAX_HTTP_REQUEST_HEADER (32 * 1024) 36 | 37 | typedef enum { HANDLER_UNSET, 38 | HANDLER_GO_ON, 39 | HANDLER_FINISHED, 40 | HANDLER_COMEBACK, 41 | HANDLER_WAIT_FOR_EVENT, 42 | HANDLER_ERROR, 43 | HANDLER_WAIT_FOR_FD 44 | } handler_t; 45 | 46 | #define HTTP_LINGER_TIMEOUT 5 47 | 48 | /* we use it in a enum */ 49 | #ifdef TRUE 50 | #undef TRUE 51 | #endif 52 | 53 | #ifdef FALSE 54 | #undef FALSE 55 | #endif 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /docs/man/mtcp_destroy: -------------------------------------------------------------------------------- 1 | .TH mtcp_destroy 3 2017-02-01 "Linux" "mOS Library Functions Manual" 2 | .SH NAME 3 | mtcp_destroy \- clean up the mTCP stack. 4 | .SH SYNOPSIS 5 | .B #include 6 | .sp 7 | .BI "void mtcp_destroy();" 8 | 9 | .SH DESCRIPTION 10 | .BR mtcp_destroy () 11 | call is used to clean up the networking stack for the mTCP 12 | application. This is usually the last call the application 13 | makes before terminating. 14 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 15 | .SH RETURN VALUE 16 | Nothing is returned. 17 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 18 | .SH NOTES 19 | This function only needs to be called once in an mTCP 20 | application. 21 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 22 | .\""""".SH CONFORMING TO 23 | .\"""""POSIX.1-2001. 24 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 25 | .SH AUTHORS 26 | mOS development team 27 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 28 | .SH SEE ALSO 29 | .BR mtcp_init () 30 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""" 31 | .SH COLOPHON 32 | This page is part of mOS release 0.3 33 | .I "docs" 34 | section. A description of the project, and information 35 | about reporting bugs, can be found at 36 | \%http://mos.kaist.edu/. 37 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""" 38 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/outdated/traffic-shaping.txt: -------------------------------------------------------------------------------- 1 | =============== 2 | Traffic Shaping 3 | =============== 4 | 5 | ------------ 6 | Module: core 7 | ------------ 8 | 9 | :Author: Jan Kneschke 10 | :Date: $Date: 2004/11/03 22:26:05 $ 11 | :Revision: $Revision: 1.2 $ 12 | 13 | :abstract: 14 | limiting bandwidth usage 15 | 16 | .. meta:: 17 | :keywords: lighttpd, bandwidth limit, traffic shaping 18 | 19 | .. contents:: Table of Contents 20 | 21 | Description 22 | =========== 23 | 24 | Starting with 1.3.8, lighttpd supports limiting the bandwidth for 25 | a single connection or config context like a virtual host or a URL. 26 | 27 | Options 28 | ======= 29 | 30 | :connection.kbytes-per-second: 31 | limit the throughput for each single connection to the given 32 | limit in kbyte/s 33 | 34 | default: 0 (no limit) 35 | 36 | :server.kbytes-per-second: 37 | limit the throughput for all connections to the given limit 38 | in kbyte/s 39 | 40 | if you want to specify a limit for a special virtual server 41 | use: :: 42 | 43 | $HTTP["host"] == "www.example.org" { 44 | server.kbytes-per-second = 128 45 | } 46 | 47 | which will override the default for this host. 48 | 49 | default: 0 (no limit) 50 | 51 | Additional Notes 52 | ================ 53 | 54 | Keep in mind that a limit below 32kb/s might actually limit the traffic to 32kb/s. This 55 | is caused by the size of the TCP send buffer. 56 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/SConscript: -------------------------------------------------------------------------------- 1 | Import('env') 2 | 3 | tests = Split('prepare.sh \ 4 | run-tests.pl \ 5 | cleanup.sh') 6 | 7 | extra_dist = Split('fastcgi-10.conf \ 8 | fastcgi-auth.conf \ 9 | fastcgi-responder.conf \ 10 | fastcgi-13.conf \ 11 | bug-06.conf \ 12 | bug-12.conf \ 13 | core-var-include.t \ 14 | var-include.conf \ 15 | var-include-sub.conf \ 16 | condition.conf \ 17 | core-condition.t \ 18 | core-request.t \ 19 | core-response.t \ 20 | core-keepalive.t \ 21 | core.t \ 22 | mod-access.t \ 23 | mod-auth.t \ 24 | mod-cgi.t \ 25 | mod-compress.t \ 26 | mod-compress.conf \ 27 | mod-fastcgi.t \ 28 | mod-redirect.t \ 29 | mod-userdir.t \ 30 | mod-rewrite.t \ 31 | request.t \ 32 | mod-ssi.t \ 33 | LightyTest.pm \ 34 | mod-setenv.t') 35 | 36 | t = env.Command('foo1', 'prepare.sh', '(cd ./tests/; ./prepare.sh; cd ..)') 37 | t += env.Command('foo2', 'run-tests.pl', '( cd ./tests/; SHELL=/bin/sh ./run-tests.pl; cd ..)') 38 | t += env.Command('foo3', 'cleanup.sh', '(cd ./tests/; ./cleanup.sh; cd ..)') 39 | 40 | if env['LIBFCGI']: 41 | fcgis = [] 42 | fcgis += env.Program("fcgi-auth", "fcgi-auth.c", LIBS=env['LIBFCGI']) 43 | fcgis += env.Program("fcgi-responder", "fcgi-responder.c", LIBS=env['LIBFCGI']) 44 | env.Depends(t, fcgis) 45 | 46 | env.Alias('check', t ) 47 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/fcgi-responder.c: -------------------------------------------------------------------------------- 1 | #ifdef HAVE_CONFIG_H 2 | #include "config.h" 3 | #endif 4 | #ifdef HAVE_FASTCGI_FASTCGI_H 5 | #include 6 | #else 7 | #include 8 | #endif 9 | #include 10 | #include 11 | #include 12 | 13 | int main (void) { 14 | int num_requests = 2; 15 | 16 | while (num_requests > 0 && 17 | FCGI_Accept() >= 0) { 18 | char* p; 19 | 20 | if (NULL != (p = getenv("QUERY_STRING"))) { 21 | if (0 == strcmp(p, "lf")) { 22 | printf("Status: 200 OK\n\n"); 23 | } else if (0 == strcmp(p, "crlf")) { 24 | printf("Status: 200 OK\r\n\r\n"); 25 | } else if (0 == strcmp(p, "slow-lf")) { 26 | printf("Status: 200 OK\n"); 27 | fflush(stdout); 28 | printf("\n"); 29 | } else if (0 == strcmp(p,"slow-crlf")) { 30 | printf("Status: 200 OK\r\n"); 31 | fflush(stdout); 32 | printf("\r\n"); 33 | } else if (0 == strcmp(p, "die-at-end")) { 34 | printf("Status: 200 OK\r\n\r\n"); 35 | num_requests--; 36 | } else { 37 | printf("Status: 200 OK\r\n\r\n"); 38 | } 39 | } else { 40 | printf("Status: 500 Internal Foo\r\n\r\n"); 41 | } 42 | 43 | if (0 == strcmp(p, "path_info")) { 44 | printf("%s", getenv("PATH_INFO")); 45 | } else if (0 == strcmp(p, "script_name")) { 46 | printf("%s", getenv("SCRIPT_NAME")); 47 | } else { 48 | printf("test123"); 49 | } 50 | } 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/scripts/rrdtool-graph.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | RRDTOOL=/usr/bin/rrdtool 4 | OUTDIR=/var/www/servers/www.example.org/pages/rrd/ 5 | INFILE=/var/www/lighttpd.rrd 6 | OUTPRE=lighttpd-traffic 7 | 8 | DISP="DEF:bin=$INFILE:InOctets:AVERAGE \ 9 | DEF:binmin=$INFILE:InOctets:MIN \ 10 | DEF:binmax=$INFILE:InOctets:MAX \ 11 | DEF:bout=$INFILE:OutOctets:AVERAGE \ 12 | DEF:boutmin=$INFILE:OutOctets:MIN \ 13 | DEF:boutmax=$INFILE:OutOctets:MAX \ 14 | LINE1:bin#0000FF:in \ 15 | LINE1:binmin#2222FF: \ 16 | STACK:binmax#2222FF: \ 17 | LINE1:bout#FF0000:out \ 18 | LINE1:boutmin#FF2222: \ 19 | STACK:boutmax#FF2222: \ 20 | -v bytes/s" 21 | 22 | $RRDTOOL graph $OUTDIR/$OUTPRE-hour.png -a PNG --start -14400 $DISP 23 | $RRDTOOL graph $OUTDIR/$OUTPRE-day.png -a PNG --start -86400 $DISP 24 | $RRDTOOL graph $OUTDIR/$OUTPRE-month.png -a PNG --start -2592000 $DISP 25 | 26 | OUTPRE=lighttpd-requests 27 | 28 | DISP="DEF:req=$INFILE:Requests:AVERAGE \ 29 | DEF:reqmin=$INFILE:Requests:MIN \ 30 | DEF:reqmax=$INFILE:Requests:MAX \ 31 | LINE1:req#0000FF:requests \ 32 | LINE1:reqmin#2222FF: \ 33 | STACK:reqmax#2222FF: \ 34 | -v req/s" 35 | 36 | $RRDTOOL graph $OUTDIR/$OUTPRE-hour.png -a PNG --start -14400 $DISP 37 | $RRDTOOL graph $OUTDIR/$OUTPRE-day.png -a PNG --start -86400 $DISP 38 | $RRDTOOL graph $OUTDIR/$OUTPRE-month.png -a PNG --start -2592000 $DISP 39 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | dist: trusty 3 | language: c 4 | 5 | notifications: 6 | email: 7 | on_success: change 8 | on_failure: change 9 | 10 | matrix: 11 | include: 12 | - env: COMPILER=gcc VERSION=6 13 | - env: COMPILER=gcc VERSION=5 14 | - env: COMPILER=gcc VERSION=4.8 15 | 16 | before_install: 17 | - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test 18 | - sudo apt-get update -qq 19 | - | 20 | if [ "$VERSION" = "6" ]; then 21 | sudo apt-get install -qq -y gcc-6 22 | elif [ "$VERSION" = "5" ]; then 23 | sudo apt-get install -qq -y gcc-5 24 | elif [ "$VERSION" = "4.8" ]; then 25 | sudo apt-get install -qq -y gcc-4.8 26 | fi 27 | 28 | before_script: 29 | - | 30 | if [ "$VERSION" = "6" ]; then 31 | export CC=gcc-6 32 | elif [ "$VERSION" = "5" ]; then 33 | export CC=gcc-5 34 | elif [ "$VERSION" = "4.8" ]; then 35 | export CC=gcc-4.8 36 | fi 37 | 38 | install: 39 | - sudo apt-get -qq update 40 | - sudo apt-get install -y linux-headers-$(uname -r) 41 | - sudo apt-get install libnuma-dev libpcap-dev 42 | 43 | script: 44 | - export RTE_SDK=`echo $PWD`/drivers/dpdk 45 | - export RTE_TARGET=x86_64-native-linuxapp-gcc 46 | - echo | ./setup.sh --compile-dpdk 47 | - make -f scripts/Makefile.test 48 | - ./setup.sh --compile-netmap 49 | - make -f scripts/Makefile.test 50 | - ./setup.sh --compile-pcap 51 | - make -f scripts/Makefile.test 52 | 53 | 54 | -------------------------------------------------------------------------------- /docs/man/mtcp_destroy_context: -------------------------------------------------------------------------------- 1 | .TH mtcp_destroy_context 3 2017-02-01 "Linux" "mOS Library Functions Manual" 2 | .SH NAME 3 | mtcp_destroy_context \- destroy mTCP context 4 | .SH SYNOPSIS 5 | .B #include 6 | .sp 7 | .BI "void mtcp_destroy_context(mctx_t " mctx ); 8 | 9 | .SH DESCRIPTION 10 | .BR mtcp_destroy_context () 11 | cleans up the per-thread (with CPU core-id as specified 12 | in the 13 | .I "mctx" 14 | structure) mTCP context in the process. 15 | This is usually the last function called (specific to 16 | mTCP API) before the mTCP application thread is 17 | terminated from the process address space. 18 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 19 | .SH RETURN VALUE 20 | .BR mtcp_destroy_context() 21 | returns nothing. 22 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 23 | .\""""".SH CONFORMING TO 24 | .\"""""POSIX.1-2001. 25 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 26 | .SH AUTHORS 27 | mOS development team 28 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 29 | .SH SEE ALSO 30 | .BR mtcp_create_context (), 31 | .BR mtcp_init (), 32 | .BR mtcp_destroy () 33 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""" 34 | .SH COLOPHON 35 | This page is part of mOS release 0.3 36 | .I "docs" 37 | section. A description of the project, and information 38 | about reporting bugs, can be found at 39 | \%http://mos.kaist.edu/. 40 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""" 41 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/var-include.conf: -------------------------------------------------------------------------------- 1 | 2 | debug.log-request-handling = "enable" 3 | debug.log-condition-handling = "enable" 4 | 5 | server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" 6 | 7 | ## bind to port (default: 80) 8 | server.port = 2048 9 | 10 | ## bind to localhost (default: all interfaces) 11 | server.bind = "localhost" 12 | server.errorlog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log" 13 | server.breakagelog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log" 14 | server.name = "www.example.org" 15 | server.tag = "Apache 1.3.29" 16 | 17 | 18 | server.modules = ( "mod_redirect", 19 | "mod_accesslog" ) 20 | 21 | ######################## MODULE CONFIG ############################ 22 | 23 | 24 | accesslog.filename = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.access.log" 25 | 26 | mimetype.assign = ( ".html" => "text/html" ) 27 | 28 | url.redirect = ("^" => "/default") 29 | 30 | $HTTP["host"] == "www.example.org" { 31 | server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" 32 | server.name = "www.example.org" 33 | url.redirect = ("^" => "/redirect") 34 | } 35 | $HTTP["host"] == "test.example.org" { 36 | server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" 37 | server.name = "test.example.org" 38 | var.myvar = "good" 39 | var.one = 1 40 | include "var-include-sub.conf" 41 | } 42 | -------------------------------------------------------------------------------- /samples/nat/Makefile.in: -------------------------------------------------------------------------------- 1 | TARGET = nat 2 | 3 | ###################################################################### 4 | # GCC and compilation options 5 | ###################################################################### 6 | GCC = $(CC) 7 | GCC_OPT = -m64 -Wall -Werror -fgnu89-inline 8 | GCC_OPT += -DNDEBUG -O3 -g -DNETSTAT -DINFO -DDBGERR -DDBGCERR 9 | GCC_OPT += $(DBG_OPT) 10 | ifeq ($V,) # no echo 11 | export MSG=@echo 12 | export HIDE=@ 13 | else 14 | export MSG=@\# 15 | export HIDE= 16 | endif 17 | 18 | ###################################################################### 19 | # LIBRARIES AND INCLUDES 20 | ###################################################################### 21 | MTCP_FLD = ../../core 22 | MTCP_INC =-I$(MTCP_FLD)/include 23 | MTCP_TARGET = $(MTCP_FLD)/lib/libmtcp.a 24 | LIBS += -lmtcp -lssl -lcrypto -lnuma -lpthread -lrt 25 | LIB_DIR += -L$(MTCP_FLD)/lib 26 | CMN_DIR = ../common 27 | CMN_INC = -I$(CMN_DIR) 28 | UTIL_INC = -I../../util/include 29 | 30 | # I/O library parameter (PSIO or DPDK) 31 | __IO_LIB_ARGS 32 | 33 | ###################################################################### 34 | 35 | default: $(TARGET) 36 | 37 | $(MTCP_TARGET): 38 | cd $(MTCP_FLD)/src && make 39 | 40 | $(TARGET): $(MTCP_TARGET) $(TARGET).c $(CMN_DIR)/*.c 41 | $(MSG) " CC $<" 42 | $(HIDE) $(GCC) $(GCC_OPT) -o $@ $^ $(MTCP_INC) $(CMN_INC) $(UTIL_INC) $(LIB_DIR) $(LIBS) 43 | 44 | clean: 45 | rm -rf *~ *.o $(TARGET) logs/* 46 | 47 | cleanall: clean 48 | rm -rf Makefile 49 | 50 | 51 | -------------------------------------------------------------------------------- /samples/midstat/Makefile.in: -------------------------------------------------------------------------------- 1 | TARGET = midstat 2 | 3 | ###################################################################### 4 | # GCC and compilation options 5 | ###################################################################### 6 | GCC = $(CC) 7 | GCC_OPT = -m64 -Wall -Werror -fgnu89-inline 8 | GCC_OPT += -DNDEBUG -O3 -g -DNETSTAT -DINFO -DDBGERR -DDBGCERR 9 | GCC_OPT += $(DBG_OPT) 10 | ifeq ($V,) # no echo 11 | export MSG=@echo 12 | export HIDE=@ 13 | else 14 | export MSG=@\# 15 | export HIDE= 16 | endif 17 | 18 | ###################################################################### 19 | # LIBRARIES AND INCLUDES 20 | ###################################################################### 21 | MTCP_FLD = ../../core 22 | MTCP_INC =-I$(MTCP_FLD)/include 23 | MTCP_TARGET = $(MTCP_FLD)/lib/libmtcp.a 24 | LIBS += -lmtcp -lssl -lcrypto -lnuma -lpthread -lrt 25 | LIB_DIR += -L$(MTCP_FLD)/lib 26 | CMN_DIR = ../common 27 | CMN_INC = -I$(CMN_DIR) 28 | UTIL_INC = -I../../util/include 29 | 30 | # I/O library parameter (PSIO or DPDK) 31 | __IO_LIB_ARGS 32 | 33 | ###################################################################### 34 | 35 | default: $(TARGET) 36 | 37 | $(MTCP_TARGET): 38 | cd $(MTCP_FLD)/src && make 39 | 40 | $(TARGET): $(MTCP_TARGET) $(TARGET).c $(CMN_DIR)/*.c 41 | $(MSG) " CC $<" 42 | $(HIDE) $(GCC) $(GCC_OPT) -o $@ $^ $(MTCP_INC) $(CMN_INC) $(UTIL_INC) $(LIB_DIR) $(LIBS) 43 | 44 | clean: 45 | rm -rf *~ *.o $(TARGET) logs/* 46 | 47 | cleanall: clean 48 | rm -rf Makefile 49 | 50 | 51 | -------------------------------------------------------------------------------- /dpdk-iface-kmod/dpdk_iface_common.h: -------------------------------------------------------------------------------- 1 | #ifndef __DPDK_IFACE_COMMON_H__ 2 | #define __DPDK_IFACE_COMMON_H__ 3 | /*--------------------------------------------------------------------------*/ 4 | /* for ETH_ALEN */ 5 | #ifndef __KERNEL__ 6 | #include 7 | #endif 8 | #include 9 | /*--------------------------------------------------------------------------*/ 10 | /* dev name */ 11 | #define DEV_NAME "dpdk-iface" 12 | #define DEV_PATH "/dev/"DEV_NAME 13 | #define DEV_PROC_PATH "/proc/devices" 14 | /* ioctl# */ 15 | #define SEND_STATS 0 16 | #define CREATE_IFACE 1 17 | #define CLEAR_IFACE 4 18 | #define FETCH_PCI_ADDRESS 5 19 | /* max qid */ 20 | #define MAX_QID 128 21 | #ifndef MAX_DEVICES 22 | #define MAX_DEVICES 128 23 | #endif 24 | #define PCI_DOM "%04hX" 25 | #define PCI_BUS "%02hhX" 26 | #define PCI_DEVICE "%02hhX" 27 | #define PCI_FUNC "%01hhX" 28 | #define PCI_LENGTH 13 29 | /*--------------------------------------------------------------------------*/ 30 | typedef struct PciAddress { 31 | uint16_t domain; 32 | uint8_t bus; 33 | uint8_t device; 34 | uint8_t function; 35 | } PciAddress; 36 | /*--------------------------------------------------------------------------*/ 37 | typedef struct PciDevice { 38 | union { 39 | uint8_t *ports_eth_addr; 40 | char ifname[IFNAMSIZ]; 41 | }; 42 | PciAddress pa; 43 | int numa_socket; 44 | } PciDevice __attribute__((aligned(__BITS_PER_LONG))); 45 | /*--------------------------------------------------------------------------*/ 46 | #endif /* __DPDK_IFACE_COMMON_H__ */ 47 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/connections-glue.c: -------------------------------------------------------------------------------- 1 | #include "base.h" 2 | #include "connections.h" 3 | 4 | const char *connection_get_state(connection_state_t state) { 5 | switch (state) { 6 | case CON_STATE_CONNECT: return "connect"; 7 | case CON_STATE_READ: return "read"; 8 | case CON_STATE_READ_POST: return "readpost"; 9 | case CON_STATE_WRITE: return "write"; 10 | case CON_STATE_CLOSE: return "close"; 11 | case CON_STATE_ERROR: return "error"; 12 | case CON_STATE_HANDLE_REQUEST: return "handle-req"; 13 | case CON_STATE_REQUEST_START: return "req-start"; 14 | case CON_STATE_REQUEST_END: return "req-end"; 15 | case CON_STATE_RESPONSE_START: return "resp-start"; 16 | case CON_STATE_RESPONSE_END: return "resp-end"; 17 | default: return "(unknown)"; 18 | } 19 | } 20 | 21 | const char *connection_get_short_state(connection_state_t state) { 22 | switch (state) { 23 | case CON_STATE_CONNECT: return "."; 24 | case CON_STATE_READ: return "r"; 25 | case CON_STATE_READ_POST: return "R"; 26 | case CON_STATE_WRITE: return "W"; 27 | case CON_STATE_CLOSE: return "C"; 28 | case CON_STATE_ERROR: return "E"; 29 | case CON_STATE_HANDLE_REQUEST: return "h"; 30 | case CON_STATE_REQUEST_START: return "q"; 31 | case CON_STATE_REQUEST_END: return "Q"; 32 | case CON_STATE_RESPONSE_START: return "s"; 33 | case CON_STATE_RESPONSE_END: return "S"; 34 | default: return "x"; 35 | } 36 | } 37 | 38 | int connection_set_state(server *srv, connection *con, connection_state_t state) { 39 | UNUSED(srv); 40 | 41 | con->state = state; 42 | 43 | return 0; 44 | } 45 | 46 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/outdated/mysqlvhost.txt: -------------------------------------------------------------------------------- 1 | ==================== 2 | MySQL-based vhosting 3 | ==================== 4 | 5 | ----------------------- 6 | Module: mod_mysql_vhost 7 | ----------------------- 8 | 9 | :Author: ada@riksnet.se 10 | :Date: $Date: 2004/08/29 09:43:49 $ 11 | :Revision: $Revision: 1.1 $ 12 | 13 | :abstract: 14 | This module provides virtual hosts (vhosts) based on a MySQL table 15 | 16 | .. meta:: 17 | :keywords: lighttpd, mysql, vhost 18 | 19 | .. contents:: Table of Contents 20 | 21 | Description 22 | =========== 23 | 24 | With MySQL-based vhosting you can store the path to a given host's 25 | document root in a MySQL database. 26 | 27 | .. note:: Keep in mind that only one vhost module should be active at a time. 28 | Don't mix mod_simple_vhost with mod_mysql_vhost. 29 | 30 | Options 31 | ======= 32 | 33 | Example: :: 34 | 35 | mysql-vhost.db = "lighttpd" 36 | mysql-vhost.user = "lighttpd" 37 | mysql-vhost.pass = "secret" 38 | mysql-vhost.sock = "/var/mysql.lighttpd.sock" 39 | mysql-vhost.sql = "SELECT docroot FROM domains WHERE domain='?'" 40 | 41 | 42 | MySQL setup: :: 43 | 44 | GRANT SELECT ON lighttpd.* TO lighttpd@localhost IDENTIFIED BY 'secret'; 45 | 46 | CREATE DATABASE lighttpd; 47 | 48 | USE lighttpd; 49 | 50 | CREATE TABLE domains ( 51 | domain varchar(64) not null primary key, 52 | docroot varchar(128) not null 53 | ); 54 | 55 | INSERT INTO domains VALUES ('host.dom.ain','/http/host.dom.ain/'); 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/bitset.c: -------------------------------------------------------------------------------- 1 | #include "buffer.h" 2 | #include "bitset.h" 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #define BITSET_BITS \ 11 | ( CHAR_BIT * sizeof(size_t) ) 12 | 13 | #define BITSET_MASK(pos) \ 14 | ( ((size_t)1) << ((pos) % BITSET_BITS) ) 15 | 16 | #define BITSET_WORD(set, pos) \ 17 | ( (set)->bits[(pos) / BITSET_BITS] ) 18 | 19 | #define BITSET_USED(nbits) \ 20 | ( ((nbits) + (BITSET_BITS - 1)) / BITSET_BITS ) 21 | 22 | bitset *bitset_init(size_t nbits) { 23 | bitset *set; 24 | 25 | set = malloc(sizeof(*set)); 26 | assert(set); 27 | 28 | set->bits = calloc(BITSET_USED(nbits), sizeof(*set->bits)); 29 | set->nbits = nbits; 30 | 31 | assert(set->bits); 32 | 33 | return set; 34 | } 35 | 36 | void bitset_reset(bitset *set) { 37 | memset(set->bits, 0, BITSET_USED(set->nbits) * sizeof(*set->bits)); 38 | } 39 | 40 | void bitset_free(bitset *set) { 41 | free(set->bits); 42 | free(set); 43 | } 44 | 45 | void bitset_clear_bit(bitset *set, size_t pos) { 46 | if (pos >= set->nbits) { 47 | SEGFAULT(); 48 | } 49 | 50 | BITSET_WORD(set, pos) &= ~BITSET_MASK(pos); 51 | } 52 | 53 | void bitset_set_bit(bitset *set, size_t pos) { 54 | if (pos >= set->nbits) { 55 | SEGFAULT(); 56 | } 57 | 58 | BITSET_WORD(set, pos) |= BITSET_MASK(pos); 59 | } 60 | 61 | int bitset_test_bit(bitset *set, size_t pos) { 62 | if (pos >= set->nbits) { 63 | SEGFAULT(); 64 | } 65 | 66 | return (BITSET_WORD(set, pos) & BITSET_MASK(pos)) != 0; 67 | } 68 | -------------------------------------------------------------------------------- /samples/simple_firewall/Makefile.in: -------------------------------------------------------------------------------- 1 | TARGET = simple_firewall 2 | 3 | ###################################################################### 4 | # GCC and compilation options 5 | ###################################################################### 6 | GCC = $(CC) 7 | GCC_OPT = -m64 -Wall -Werror -fgnu89-inline 8 | GCC_OPT += -DNDEBUG -O3 -g -DNETSTAT -DINFO -DDBGERR -DDBGCERR 9 | GCC_OPT += $(DBG_OPT) 10 | ifeq ($V,) # no echo 11 | export MSG=@echo 12 | export HIDE=@ 13 | else 14 | export MSG=@\# 15 | export HIDE= 16 | endif 17 | 18 | ###################################################################### 19 | # LIBRARIES AND INCLUDES 20 | ###################################################################### 21 | MTCP_FLD = ../../core 22 | MTCP_INC =-I$(MTCP_FLD)/include 23 | MTCP_TARGET = $(MTCP_FLD)/lib/libmtcp.a 24 | LIBS += -lmtcp -lssl -lcrypto -lnuma -lpthread -lrt 25 | LIB_DIR += -L$(MTCP_FLD)/lib 26 | CMN_DIR = ../common 27 | CMN_INC = -I$(CMN_DIR) 28 | UTIL_INC = -I../../util/include 29 | 30 | # I/O library parameter (PSIO or DPDK) 31 | __IO_LIB_ARGS 32 | 33 | ###################################################################### 34 | 35 | default: $(TARGET) 36 | 37 | $(MTCP_TARGET): 38 | cd $(MTCP_FLD)/src && make 39 | 40 | $(TARGET): $(MTCP_TARGET) $(TARGET).c $(CMN_DIR)/*.c 41 | $(MSG) " CC $<" 42 | $(HIDE) $(GCC) $(GCC_OPT) -o $@ $^ $(MTCP_INC) $(CMN_INC) $(UTIL_INC) $(LIB_DIR) $(LIBS) 43 | 44 | clean: 45 | rm -rf *~ *.o $(TARGET) logs/* 46 | 47 | cleanall: clean 48 | rm -rf Makefile 49 | 50 | 51 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/scripts/spawn-php.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ## ABSOLUTE path to the spawn-fcgi binary 4 | SPAWNFCGI="/home/weigon/projects/spawn-fcgi/src/spawn-fcgi" 5 | 6 | ## ABSOLUTE path to the PHP binary 7 | FCGIPROGRAM="/usr/local/bin/php" 8 | 9 | ## TCP port to which to bind on localhost 10 | FCGIPORT="1026" 11 | 12 | ## number of PHP children to spawn 13 | PHP_FCGI_CHILDREN=10 14 | 15 | ## maximum number of requests a single PHP process can serve before it is restarted 16 | PHP_FCGI_MAX_REQUESTS=1000 17 | 18 | ## IP addresses from which PHP should access server connections 19 | FCGI_WEB_SERVER_ADDRS="127.0.0.1,192.168.2.10" 20 | 21 | # allowed environment variables, separated by spaces 22 | ALLOWED_ENV="ORACLE_HOME PATH USER" 23 | 24 | ## if this script is run as root, switch to the following user 25 | USERID=wwwrun 26 | GROUPID=wwwrun 27 | 28 | 29 | ################## no config below this line 30 | 31 | if test x$PHP_FCGI_CHILDREN = x; then 32 | PHP_FCGI_CHILDREN=5 33 | fi 34 | 35 | export PHP_FCGI_MAX_REQUESTS 36 | export FCGI_WEB_SERVER_ADDRS 37 | 38 | ALLOWED_ENV="$ALLOWED_ENV PHP_FCGI_MAX_REQUESTS FCGI_WEB_SERVER_ADDRS" 39 | 40 | if test x$UID = x0; then 41 | EX="$SPAWNFCGI -p $FCGIPORT -f $FCGIPROGRAM -u $USERID -g $GROUPID -C $PHP_FCGI_CHILDREN" 42 | else 43 | EX="$SPAWNFCGI -p $FCGIPORT -f $FCGIPROGRAM -C $PHP_FCGI_CHILDREN" 44 | fi 45 | 46 | # copy the allowed environment variables 47 | E= 48 | 49 | for i in $ALLOWED_ENV; do 50 | E="$E $i=${!i}" 51 | done 52 | 53 | # clean the environment and set up a new one 54 | env - $E $EX 55 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/config/conf.d/scgi.conf: -------------------------------------------------------------------------------- 1 | ####################################################################### 2 | ## 3 | ## FastCGI Module 4 | ## --------------- 5 | ## 6 | ## http://www.lighttpd.net/documentation/scgi.html 7 | ## 8 | server.modules += ( "mod_scgi" ) 9 | 10 | ## 11 | ## Ruby on Rails Example 12 | ## 13 | ## Normally you only run one Rails application on one vhost. 14 | ## 15 | #$HTTP["host"] == "rails1.example.com" { 16 | # server.document-root = server_root + "/rails/someapp/public" 17 | # server.error-handler-404 = "/dispatch.fcgi" 18 | # scgi.server = ( ".scgi" => 19 | # ("scgi-someapp" => 20 | # ( "socket" => socket_dir + "/someapp-scgi.socket", 21 | # "bin-path" => server_root + "/rails/someapp/public/dispatch.scgi", 22 | # "bin-environment" => ( 23 | # "RAILS_ENV" => "production", 24 | # "TMP" => home_dir + "/rails/someapp", 25 | # ), 26 | # ) 27 | # ) 28 | # ) 29 | #} 30 | 31 | ## 32 | ## 2nd Ruby on Rails Example 33 | ## 34 | ## This time we launch the rails application via scgi_rails externally. 35 | ## 36 | #$HTTP["host"] == "rails2.example.com" { 37 | # server.document-root = server_root + "/rails/someapp/public" 38 | # server.error-handler-404 = "/dispatch.scgi" 39 | # scgi.server = ( ".scgi" => 40 | # ( "scgi-tcp" => 41 | # ( 42 | # "host" => "127.0.0.1", 43 | # "port" => 9998, 44 | # "check-local" => "disable", 45 | # ) 46 | # ) 47 | # ) 48 | #} 49 | 50 | ## 51 | ####################################################################### 52 | -------------------------------------------------------------------------------- /core/test/tcprb/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "tcp_rb.h" 6 | 7 | #define FREE(x) do { free(x); x = NULL; } while (0) 8 | #ifndef MIN 9 | #define MIN(a, b) ((a) < (b) ? (a) : (b)) 10 | #endif 11 | 12 | #define PRINTF(f, args...) printf("%s:%d: " f, __FILE__, __LINE__, ##args) 13 | 14 | #define CALL(arg) printf("%s returned %d\n", #arg, arg) 15 | 16 | int main(int argc, char **argv) 17 | { 18 | uint8_t wbuf[1024] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'}; 19 | uint8_t rbuf[1024]; 20 | 21 | tcprb_t *rb = tcprb_new(10); 22 | 23 | CALL(tcprb_pwrite(rb, wbuf, 2, 0)); 24 | CALL(tcprb_ppeek(rb, rbuf, 2, 0)); 25 | PRINTF("Read result: %c%c\n", rbuf[0], rbuf[1]); 26 | tcprb_printrb(rb); 27 | 28 | CALL(tcprb_pwrite(rb, wbuf, 2, 3)); 29 | tcprb_printrb(rb); 30 | 31 | CALL(tcprb_pwrite(rb, wbuf, 2, 2)); 32 | tcprb_printrb(rb); 33 | 34 | CALL(tcprb_pwrite(rb, wbuf, 2, 9)); 35 | tcprb_printrb(rb); 36 | 37 | CALL(tcprb_setpile(rb, 2)); 38 | tcprb_printrb(rb); 39 | 40 | CALL(tcprb_pwrite(rb, wbuf, 2, 11)); 41 | tcprb_printrb(rb); 42 | 43 | CALL(tcprb_pwrite(rb, wbuf, 3, 6)); 44 | tcprb_printrb(rb); 45 | 46 | CALL(tcprb_pwrite(rb, wbuf, 8, 4)); 47 | tcprb_printrb(rb); 48 | 49 | CALL(tcprb_ppeek(rb, rbuf, 10, 2)); 50 | PRINTF("Read result: %c%c%c%c%c%c%c%c%c%c\n", 51 | rbuf[0], rbuf[1], rbuf[2], rbuf[3], rbuf[4], 52 | rbuf[5], rbuf[6], rbuf[7], rbuf[8], rbuf[9]); 53 | 54 | CALL(tcprb_setpile(rb, 12)); 55 | CALL(tcprb_pwrite(rb, wbuf, 1, 21)); 56 | tcprb_printrb(rb); 57 | 58 | return 0; 59 | } 60 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/data_integer.c: -------------------------------------------------------------------------------- 1 | #include "array.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | static data_unset *data_integer_copy(const data_unset *s) { 8 | data_integer *src = (data_integer *)s; 9 | data_integer *ds = data_integer_init(); 10 | 11 | buffer_copy_string_buffer(ds->key, src->key); 12 | ds->is_index_key = src->is_index_key; 13 | ds->value = src->value; 14 | return (data_unset *)ds; 15 | } 16 | 17 | static void data_integer_free(data_unset *d) { 18 | data_integer *ds = (data_integer *)d; 19 | 20 | buffer_free(ds->key); 21 | 22 | free(d); 23 | } 24 | 25 | static void data_integer_reset(data_unset *d) { 26 | data_integer *ds = (data_integer *)d; 27 | 28 | /* reused integer elements */ 29 | buffer_reset(ds->key); 30 | ds->value = 0; 31 | } 32 | 33 | static int data_integer_insert_dup(data_unset *dst, data_unset *src) { 34 | UNUSED(dst); 35 | 36 | src->free(src); 37 | 38 | return 0; 39 | } 40 | 41 | static void data_integer_print(const data_unset *d, int depth) { 42 | data_integer *ds = (data_integer *)d; 43 | UNUSED(depth); 44 | 45 | fprintf(stdout, "%d", ds->value); 46 | } 47 | 48 | 49 | data_integer *data_integer_init(void) { 50 | data_integer *ds; 51 | 52 | ds = calloc(1, sizeof(*ds)); 53 | 54 | ds->key = buffer_init(); 55 | ds->value = 0; 56 | 57 | ds->copy = data_integer_copy; 58 | ds->free = data_integer_free; 59 | ds->reset = data_integer_reset; 60 | ds->insert_dup = data_integer_insert_dup; 61 | ds->print = data_integer_print; 62 | ds->type = TYPE_INTEGER; 63 | 64 | return ds; 65 | } 66 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/data_array.c: -------------------------------------------------------------------------------- 1 | #include "array.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | static data_unset *data_array_copy(const data_unset *s) { 8 | data_array *src = (data_array *)s; 9 | data_array *ds = data_array_init(); 10 | 11 | buffer_copy_string_buffer(ds->key, src->key); 12 | array_free(ds->value); 13 | ds->value = array_init_array(src->value); 14 | ds->is_index_key = src->is_index_key; 15 | return (data_unset *)ds; 16 | } 17 | 18 | static void data_array_free(data_unset *d) { 19 | data_array *ds = (data_array *)d; 20 | 21 | buffer_free(ds->key); 22 | array_free(ds->value); 23 | 24 | free(d); 25 | } 26 | 27 | static void data_array_reset(data_unset *d) { 28 | data_array *ds = (data_array *)d; 29 | 30 | /* reused array elements */ 31 | buffer_reset(ds->key); 32 | array_reset(ds->value); 33 | } 34 | 35 | static int data_array_insert_dup(data_unset *dst, data_unset *src) { 36 | UNUSED(dst); 37 | 38 | src->free(src); 39 | 40 | return 0; 41 | } 42 | 43 | static void data_array_print(const data_unset *d, int depth) { 44 | data_array *ds = (data_array *)d; 45 | 46 | array_print(ds->value, depth); 47 | } 48 | 49 | data_array *data_array_init(void) { 50 | data_array *ds; 51 | 52 | ds = calloc(1, sizeof(*ds)); 53 | 54 | ds->key = buffer_init(); 55 | ds->value = array_init(); 56 | 57 | ds->copy = data_array_copy; 58 | ds->free = data_array_free; 59 | ds->reset = data_array_reset; 60 | ds->insert_dup = data_array_insert_dup; 61 | ds->print = data_array_print; 62 | ds->type = TYPE_ARRAY; 63 | 64 | return ds; 65 | } 66 | -------------------------------------------------------------------------------- /util/include/debug.h: -------------------------------------------------------------------------------- 1 | #ifndef __DEBUG_H_ 2 | #define __DEBUG_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #define TRACE_CONFIG(f, m...) fprintf(stdout, f, ##m) 9 | 10 | #ifdef DBGERR 11 | 12 | #define TRACE_ERROR(f, m...) { \ 13 | fprintf(stdout, "[%10s:%4d] " f, __FUNCTION__, __LINE__, ##m); \ 14 | } 15 | 16 | #else 17 | 18 | #define TRACE_ERROR(f, m...) (void)0 19 | 20 | #endif /* DBGERR */ 21 | 22 | #ifdef DBGMSG 23 | 24 | #define TRACE_DBG(f, m...) {\ 25 | fprintf(stderr, "[%10s:%4d] " \ 26 | f, __FUNCTION__, __LINE__, ##m); \ 27 | } 28 | 29 | #else 30 | 31 | #define TRACE_DBG(f, m...) (void)0 32 | 33 | #endif /* DBGMSG */ 34 | 35 | #ifdef INFO 36 | 37 | #define TRACE_INFO(f, m...) { \ 38 | fprintf(stdout, "[%10s:%4d] " f,__FUNCTION__, __LINE__, ##m); \ 39 | } 40 | 41 | #else 42 | 43 | #define TRACE_INFO(f, m...) (void)0 44 | 45 | #endif /* INFO */ 46 | 47 | #ifdef EPOLL 48 | #define TRACE_EPOLL(f, m...) TRACE_FUNC("EPOLL", f, ##m) 49 | #else 50 | #define TRACE_EPOLL(f, m...) (void)0 51 | #endif 52 | 53 | #ifdef APP 54 | #define TRACE_APP(f, m...) TRACE_FUNC("APP", f, ##m) 55 | #else 56 | #define TRACE_APP(f, m...) (void)0 57 | #endif 58 | 59 | #ifdef DBGFUNC 60 | 61 | #define TRACE_FUNC(n, f, m...) { \ 62 | fprintf(stderr, "%6s: %10s:%4d] " \ 63 | f, n, __FUNCTION__, __LINE__, ##m); \ 64 | } 65 | 66 | #else 67 | 68 | #define TRACE_FUNC(f, m...) (void)0 69 | 70 | #endif /* DBGFUNC */ 71 | 72 | #endif /* __DEBUG_H_ */ 73 | -------------------------------------------------------------------------------- /dpdk-iface-kmod/Makefile: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------------------------------# 2 | ifeq ($(RTE_SDK),) 3 | $(error "Please define RTE_SDK environment variable") 4 | endif 5 | 6 | ifeq ($(RTE_TARGET),) 7 | $(error "Please define RTE_TARGET environment variable") 8 | endif 9 | #-------------------------------------------------------------------------# 10 | include $(RTE_SDK)/mk/rte.vars.mk 11 | CC=gcc 12 | obj-m=dpdk_iface.o 13 | DPDK_MACHINE_LINKER_FLAGS=$${RTE_SDK}/$${RTE_TARGET}/lib/ldflags.txt 14 | DPDK_MACHINE_LDFLAGS=$(shell cat ${DPDK_MACHINE_LINKER_FLAGS}) 15 | DPDK_INC=${RTE_SDK}/${RTE_TARGET}/include 16 | DPDK_LIB=${RTE_SDK}/${RTE_TARGET}/lib 17 | appname=dpdk_iface_main 18 | #-------------------------------------------------------------------------# 19 | ifeq ($V,) # no echo 20 | export MSG=@echo 21 | export HIDE=@ 22 | else 23 | export MSG=@\# 24 | export HIDE= 25 | endif 26 | #-------------------------------------------------------------------------# 27 | all: dpdk_iface.c $(appname) $(appname).c 28 | make -C /lib/modules/$(shell uname -r)/build/ M=$(PWD) modules 29 | 30 | $(appname): $(appname).c 31 | $(MSG) " CC $<" 32 | $(HIDE) $(CC) -g $(CFLAGS) $(appname).c -g -o $(appname) -g \ 33 | -I${DPDK_INC} -include $(DPDK_INC)/rte_config.h \ 34 | -L$(DPDK_LIB) ${DPDK_MACHINE_LDFLAGS} -lpthread 35 | 36 | clean: 37 | make -C /lib/modules/$(shell uname -r)/build/ M=$(PWD) clean 38 | $(MSG) " CLEAN $(appname)" 39 | $(HIDE) rm -rf *~ *.o *.ko dpdk_iface_main 40 | 41 | run: all 42 | sudo ./$(appname) 43 | #-------------------------------------------------------------------------# 44 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/outdated/webdav.txt: -------------------------------------------------------------------------------- 1 | ====== 2 | WebDAV 3 | ====== 4 | 5 | -------------------- 6 | Module: mod_webdav 7 | -------------------- 8 | 9 | :Author: Jan Kneschke 10 | :Date: $Date: 2004/11/03 22:26:05 $ 11 | :Revision: $Revision: 1.2 $ 12 | 13 | :abstract: 14 | WebDAV module for lighttpd 15 | 16 | .. meta:: 17 | :keywords: lighttpd, webdav 18 | 19 | .. contents:: Table of Contents 20 | 21 | Description 22 | =========== 23 | 24 | The WebDAV module is a very minimalistic implementation of RFC 2518. 25 | Minimalistic means that not all operations are implemented yet. 26 | 27 | So far we have 28 | 29 | * PROPFIND 30 | * OPTIONS 31 | * MKCOL 32 | * DELETE 33 | * PUT 34 | 35 | and the usual GET, POST, HEAD from HTTP/1.1. 36 | 37 | So far, mounting a WebDAV resource into Windows XP works and the basic litmus 38 | tests are passed. 39 | 40 | Options 41 | ======= 42 | 43 | webdav.activate 44 | If you load the webdav module, the WebDAV functionality has to be 45 | enabled for the directories you want to provide to the user. 46 | 47 | Default: disable 48 | 49 | webdav.is-readonly 50 | Only allow reading methods (GET, PROPFIND, OPTIONS) on WebDAV resources. 51 | 52 | Default: writable 53 | 54 | Examples 55 | ======== 56 | 57 | To enable WebDAV for the /dav directory, you wrap your webdav options in 58 | a conditional. You have to use the regex like below as you want to match 59 | the directory /dav and everything below it, but not e.g. /davos. :: 60 | 61 | $HTTP["url"] =~ "^/dav($|/)" { 62 | webdav.activate = "enable" 63 | webdav.is-readonly = "enable" 64 | } 65 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/mod-setenv.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | BEGIN { 3 | # add current source dir to the include-path 4 | # we need this for make distcheck 5 | (my $srcdir = $0) =~ s,/[^/]+$,/,; 6 | unshift @INC, $srcdir; 7 | } 8 | 9 | use strict; 10 | use IO::Socket; 11 | use Test::More tests => 6; 12 | use LightyTest; 13 | 14 | my $tf = LightyTest->new(); 15 | my $t; 16 | 17 | ok($tf->start_proc == 0, "Starting lighttpd") or die(); 18 | 19 | $t->{REQUEST} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'tracenv' } ]; 25 | ok($tf->handle_http($t) == 0, 'query first setenv'); 26 | 27 | $t->{REQUEST} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'setenv' } ]; 33 | ok($tf->handle_http($t) == 0, 'query second setenv'); 34 | 35 | $t->{REQUEST} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'foo' } ]; 41 | ok($tf->handle_http($t) == 0, 'query add-request-header'); 42 | 43 | $t->{REQUEST} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'BAR' => 'foo' } ]; 49 | ok($tf->handle_http($t) == 0, 'query add-response-header'); 50 | 51 | ok($tf->stop_proc == 0, "Stopping lighttpd"); 52 | 53 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/data_count.c: -------------------------------------------------------------------------------- 1 | #include "array.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | static data_unset *data_count_copy(const data_unset *s) { 8 | data_count *src = (data_count *)s; 9 | data_count *ds = data_count_init(); 10 | 11 | buffer_copy_string_buffer(ds->key, src->key); 12 | ds->count = src->count; 13 | ds->is_index_key = src->is_index_key; 14 | return (data_unset *)ds; 15 | } 16 | 17 | static void data_count_free(data_unset *d) { 18 | data_count *ds = (data_count *)d; 19 | 20 | buffer_free(ds->key); 21 | 22 | free(d); 23 | } 24 | 25 | static void data_count_reset(data_unset *d) { 26 | data_count *ds = (data_count *)d; 27 | 28 | buffer_reset(ds->key); 29 | 30 | ds->count = 0; 31 | } 32 | 33 | static int data_count_insert_dup(data_unset *dst, data_unset *src) { 34 | data_count *ds_dst = (data_count *)dst; 35 | data_count *ds_src = (data_count *)src; 36 | 37 | ds_dst->count += ds_src->count; 38 | 39 | src->free(src); 40 | 41 | return 0; 42 | } 43 | 44 | static void data_count_print(const data_unset *d, int depth) { 45 | data_count *ds = (data_count *)d; 46 | UNUSED(depth); 47 | 48 | fprintf(stdout, "count(%d)", ds->count); 49 | } 50 | 51 | 52 | data_count *data_count_init(void) { 53 | data_count *ds; 54 | 55 | ds = calloc(1, sizeof(*ds)); 56 | 57 | ds->key = buffer_init(); 58 | ds->count = 1; 59 | 60 | ds->copy = data_count_copy; 61 | ds->free = data_count_free; 62 | ds->reset = data_count_reset; 63 | ds->insert_dup = data_count_insert_dup; 64 | ds->print = data_count_print; 65 | ds->type = TYPE_COUNT; 66 | 67 | return ds; 68 | } 69 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/COPYING: -------------------------------------------------------------------------------- 1 | 2 | 3 | Copyright (c) 2004, Jan Kneschke, incremental 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | - Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | - Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | - Neither the name of the 'incremental' nor the names of its contributors may 17 | be used to endorse or promote products derived from this software without 18 | specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 24 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30 | THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | -------------------------------------------------------------------------------- /docs/Makefile.template: -------------------------------------------------------------------------------- 1 | ## TODO: Replace with your application name 2 | TARGET = (app_name) 3 | 4 | ###################################################################### 5 | # GCC and compilation options 6 | ###################################################################### 7 | GCC = gcc 8 | GCC_OPT = -m64 -Wall 9 | GCC_OPT += -DNDEBUG -O3 -g -DNETSTAT -DINFO -DDBGERR -DDBGCERR 10 | GCC_OPT += $(DBG_OPT) 11 | ifeq ($V,) # no echo 12 | export MSG=@echo 13 | export HIDE=@ 14 | else 15 | export MSG=@\# 16 | export HIDE= 17 | endif 18 | 19 | ###################################################################### 20 | # LIBRARIES AND INCLUDES 21 | ###################################################################### 22 | MTCP_FLD =../../../core 23 | MTCP_INC =-I$(MTCP_FLD)/include 24 | MTCP_TARGET = $(MTCP_FLD)/lib/libmtcp.a 25 | LIBS += -lmtcp -lssl -lcrypto -lnuma -lpthread -lrt 26 | LIB_DIR += -L$(MTCP_FLD)/lib 27 | CMN_DIR = ../common 28 | CMN_INC = -I$(CMN_DIR) 29 | UTIL_INC = -I../../util/include 30 | 31 | # I/O library parameters (DPDK) 32 | ## TODO: Add your own library complie paramters here 33 | ## (Please refer to Step 5 in /docs/WALKTHROUGH.md) 34 | 35 | ###################################################################### 36 | 37 | default: $(TARGET) 38 | 39 | $(MTCP_TARGET): 40 | cd $(MTCP_FLD)/src && make 41 | 42 | $(TARGET): $(MTCP_TARGET) $(TARGET).c $(CMN_DIR)/*.c 43 | $(MSG) " CC $<" 44 | $(HIDE) $(GCC) $(GCC_OPT) -o $@ $^ $(MTCP_INC) $(CMN_INC) $(UTIL_INC) $(LIB_DIR) $(LIBS) 45 | 46 | clean: 47 | rm -rf *~ *.o $(TARGET) logs/* 48 | 49 | cleanall: clean 50 | rm -rf Makefile 51 | 52 | 53 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/config/conf.d/dirlisting.conf: -------------------------------------------------------------------------------- 1 | ####################################################################### 2 | ## 3 | ## Dirlisting Module 4 | ## ------------------- 5 | ## 6 | ## See http://www.lighttpd.net/documentation/dirlisting.html 7 | ## 8 | 9 | ## 10 | ## Enabled Directory listing 11 | ## 12 | dir-listing.activate = "disable" 13 | 14 | ## 15 | ## Hide dot files from the listing? 16 | ## By default they are listed. 17 | ## 18 | dir-listing.hide-dotfiles = "disable" 19 | 20 | ## 21 | ## list of regular expressions. Files that match any of the specified 22 | ## regular expressions will be excluded from directory listings. 23 | ## 24 | dir-listing.exclude = ( "~$" ) 25 | 26 | ## 27 | ## set a encoding for the generated directory listing 28 | ## 29 | ## If you file-system is not using ASCII you have to set the encoding of 30 | ## the filenames as they are put into the HTML listing AS IS (with XML 31 | ## encoding) 32 | ## 33 | dir-listing.encoding = "UTF-8" 34 | 35 | ## 36 | ## Specify the url to an optional CSS file. 37 | ## 38 | #dir-listing.external-css = "/dirindex.css" 39 | 40 | ## 41 | ## Include HEADER.txt files above the directory listing. 42 | ## You can disable showing the HEADER.txt in the listing. 43 | ## 44 | dir-listing.hide-header-file = "disable" 45 | dir-listing.show-header = "disable" 46 | 47 | ## 48 | ## Include README.txt files above the directory listing. 49 | ## You can disable showing the README.txt in the listing. 50 | ## 51 | dir-listing.hide-readme-file = "disable" 52 | dir-listing.show-readme = "disable" 53 | 54 | ## 55 | ####################################################################### 56 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/outdated/ssl.txt: -------------------------------------------------------------------------------- 1 | =========== 2 | Secure HTTP 3 | =========== 4 | 5 | ------------ 6 | Module: core 7 | ------------ 8 | 9 | :Author: Jan Kneschke 10 | :Date: $Date: 2004/08/29 09:44:53 $ 11 | :Revision: $Revision: 1.2 $ 12 | 13 | :abstract: 14 | How to set up SSL in lighttpd 15 | 16 | .. meta:: 17 | :keywords: lighttpd, ssl 18 | 19 | .. contents:: Table of Contents 20 | 21 | Description 22 | =========== 23 | 24 | lighttpd supports SSLv2 and SSLv3 if it is compiled against openssl. 25 | 26 | Configuration 27 | ------------- 28 | 29 | To enable SSL for the whole server you have to provide a valid 30 | certificate and have to enable the SSL engine.:: 31 | 32 | ssl.engine = "enable" 33 | ssl.pemfile = "/path/to/server.pem" 34 | 35 | The HTTPS protocol does not allow you to use name-based virtual 36 | hosting with SSL. If you want to run multiple SSL servers with 37 | one lighttpd instance you must use IP-based virtual hosting: :: 38 | 39 | $SERVER["socket"] == "10.0.0.1:443" { 40 | ssl.engine = "enable" 41 | ssl.pemfile = "www.example.org.pem" 42 | server.name = "www.example.org" 43 | 44 | server.document-root = "/www/servers/www.example.org/pages/" 45 | } 46 | 47 | If you have a .crt and a .key file, cat them together into a 48 | single PEM file: 49 | :: 50 | 51 | $ cat host.key host.crt > host.pem 52 | 53 | 54 | Self-Signed Certificates 55 | ------------------------ 56 | 57 | A self-signed SSL certificate can be generated like this: :: 58 | 59 | $ openssl req -new -x509 \ 60 | -keyout server.pem -out server.pem \ 61 | -days 365 -nodes 62 | 63 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/data_fastcgi.c: -------------------------------------------------------------------------------- 1 | #include "array.h" 2 | #include "fastcgi.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | static data_unset *data_fastcgi_copy(const data_unset *s) { 9 | data_fastcgi *src = (data_fastcgi *)s; 10 | data_fastcgi *ds = data_fastcgi_init(); 11 | 12 | buffer_copy_string_buffer(ds->key, src->key); 13 | buffer_copy_string_buffer(ds->host, src->host); 14 | ds->is_index_key = src->is_index_key; 15 | return (data_unset *)ds; 16 | } 17 | 18 | static void data_fastcgi_free(data_unset *d) { 19 | data_fastcgi *ds = (data_fastcgi *)d; 20 | 21 | buffer_free(ds->key); 22 | buffer_free(ds->host); 23 | 24 | free(d); 25 | } 26 | 27 | static void data_fastcgi_reset(data_unset *d) { 28 | data_fastcgi *ds = (data_fastcgi *)d; 29 | 30 | buffer_reset(ds->key); 31 | buffer_reset(ds->host); 32 | 33 | } 34 | 35 | static int data_fastcgi_insert_dup(data_unset *dst, data_unset *src) { 36 | UNUSED(dst); 37 | 38 | src->free(src); 39 | 40 | return 0; 41 | } 42 | 43 | static void data_fastcgi_print(const data_unset *d, int depth) { 44 | data_fastcgi *ds = (data_fastcgi *)d; 45 | UNUSED(depth); 46 | 47 | fprintf(stdout, "fastcgi(%s)", ds->host->ptr); 48 | } 49 | 50 | 51 | data_fastcgi *data_fastcgi_init(void) { 52 | data_fastcgi *ds; 53 | 54 | ds = calloc(1, sizeof(*ds)); 55 | 56 | ds->key = buffer_init(); 57 | ds->host = buffer_init(); 58 | ds->port = 0; 59 | ds->is_disabled = 0; 60 | 61 | ds->copy = data_fastcgi_copy; 62 | ds->free = data_fastcgi_free; 63 | ds->reset = data_fastcgi_reset; 64 | ds->insert_dup = data_fastcgi_insert_dup; 65 | ds->print = data_fastcgi_print; 66 | ds->type = TYPE_FASTCGI; 67 | 68 | return ds; 69 | } 70 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | mOS source code is distributed under the Modified BSD Licence. 2 | 3 | Copyright (C) 2016 Muhammad Jamshed, Donghwi Kim, YoungGyoun Moon, 4 | Dongsu Han, KyoungSoo Park 5 | 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of the nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/md5.h: -------------------------------------------------------------------------------- 1 | /* MD5.H - header file for MD5C.C 2 | */ 3 | 4 | /* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All 5 | rights reserved. 6 | 7 | License to copy and use this software is granted provided that it 8 | is identified as the "RSA Data Security, Inc. MD5 Message-Digest 9 | Algorithm" in all material mentioning or referencing this software 10 | or this function. 11 | 12 | License is also granted to make and use derivative works provided 13 | that such works are identified as "derived from the RSA Data 14 | Security, Inc. MD5 Message-Digest Algorithm" in all material 15 | mentioning or referencing the derived work. 16 | 17 | RSA Data Security, Inc. makes no representations concerning either 18 | the merchantability of this software or the suitability of this 19 | software for any particular purpose. It is provided "as is" 20 | without express or implied warranty of any kind. 21 | 22 | These notices must be retained in any copies of any part of this 23 | documentation and/or software. 24 | */ 25 | #include 26 | #ifdef HAVE_STDINT_H 27 | # include 28 | #endif 29 | #ifdef HAVE_INTTYPES_H 30 | # include 31 | #endif 32 | 33 | #define UINT4 uint32_t 34 | #define UINT2 uint16_t 35 | #define POINTER unsigned char * 36 | 37 | /* MD5 context. */ 38 | typedef struct { 39 | UINT4 state[4]; /* state (ABCD) */ 40 | UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ 41 | unsigned char buffer[64]; /* input buffer */ 42 | } li_MD5_CTX; 43 | 44 | void li_MD5_Init (li_MD5_CTX *); 45 | void li_MD5_Update (li_MD5_CTX *, const void *, unsigned int); 46 | void li_MD5_Final (unsigned char [16], li_MD5_CTX *); 47 | -------------------------------------------------------------------------------- /core/src/include/tcp_send_buffer.h: -------------------------------------------------------------------------------- 1 | #ifndef __TCP_SEND_BUFFER_H_ 2 | #define __TCP_SEND_BUFFER_H_ 3 | 4 | #include 5 | #include 6 | 7 | /*----------------------------------------------------------------------------*/ 8 | typedef struct sb_manager* sb_manager_t; 9 | /*----------------------------------------------------------------------------*/ 10 | struct tcp_send_buffer 11 | { 12 | unsigned char *data; 13 | unsigned char *head; 14 | 15 | uint32_t head_off; 16 | uint32_t tail_off; 17 | uint32_t len; 18 | uint64_t cum_len; 19 | uint32_t size; 20 | 21 | uint32_t head_seq; 22 | uint32_t init_seq; 23 | }; 24 | /*----------------------------------------------------------------------------*/ 25 | uint32_t 26 | SBGetCurnum(sb_manager_t sbm); 27 | /*----------------------------------------------------------------------------*/ 28 | sb_manager_t 29 | SBManagerCreate(size_t chunk_size, uint8_t disable_rings, uint32_t concurrency); 30 | /*----------------------------------------------------------------------------*/ 31 | struct tcp_send_buffer * 32 | SBInit(sb_manager_t sbm, uint32_t init_seq); 33 | /*----------------------------------------------------------------------------*/ 34 | void 35 | SBFree(sb_manager_t sbm, struct tcp_send_buffer *buf); 36 | /*----------------------------------------------------------------------------*/ 37 | size_t 38 | SBPut(sb_manager_t sbm, struct tcp_send_buffer *buf, const void *data, size_t len); 39 | /*----------------------------------------------------------------------------*/ 40 | size_t 41 | SBRemove(sb_manager_t sbm, struct tcp_send_buffer *buf, size_t len); 42 | /*----------------------------------------------------------------------------*/ 43 | 44 | #endif /* __TCP_SEND_BUFFER_H_ */ 45 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/status_counter.c: -------------------------------------------------------------------------------- 1 | #include "status_counter.h" 2 | 3 | #include 4 | 5 | /** 6 | * The status array can carry all the status information you want 7 | * the key to the array is . 8 | * and the values are counters 9 | * 10 | * example: 11 | * fastcgi.backends = 10 12 | * fastcgi.active-backends = 6 13 | * fastcgi.backend..load = 24 14 | * fastcgi.backend..... 15 | * 16 | * fastcgi.backend..disconnects = ... 17 | */ 18 | 19 | data_integer *status_counter_get_counter(server *srv, const char *s, size_t len) { 20 | data_integer *di; 21 | 22 | if (NULL == (di = (data_integer *)array_get_element(srv->status, s))) { 23 | /* not found, create it */ 24 | 25 | if (NULL == (di = (data_integer *)array_get_unused_element(srv->status, TYPE_INTEGER))) { 26 | di = data_integer_init(); 27 | } 28 | buffer_copy_string_len(di->key, s, len); 29 | di->value = 0; 30 | 31 | array_insert_unique(srv->status, (data_unset *)di); 32 | } 33 | return di; 34 | } 35 | 36 | /* dummies of the statistic framework functions 37 | * they will be moved to a statistics.c later */ 38 | int status_counter_inc(server *srv, const char *s, size_t len) { 39 | data_integer *di = status_counter_get_counter(srv, s, len); 40 | 41 | di->value++; 42 | 43 | return 0; 44 | } 45 | 46 | int status_counter_dec(server *srv, const char *s, size_t len) { 47 | data_integer *di = status_counter_get_counter(srv, s, len); 48 | 49 | if (di->value > 0) di->value--; 50 | 51 | return 0; 52 | } 53 | 54 | int status_counter_set(server *srv, const char *s, size_t len, int val) { 55 | data_integer *di = status_counter_get_counter(srv, s, len); 56 | 57 | di->value = val; 58 | 59 | return 0; 60 | } 61 | 62 | -------------------------------------------------------------------------------- /core/src/include/stat.h: -------------------------------------------------------------------------------- 1 | #ifndef __STAT_H_ 2 | #define __STAT_H_ 3 | 4 | #include "io_module.h" 5 | 6 | struct run_stat 7 | { 8 | uint64_t rounds; 9 | uint64_t rounds_rx; 10 | uint64_t rounds_rx_try; 11 | uint64_t rounds_tx; 12 | uint64_t rounds_tx_try; 13 | uint64_t rounds_select; 14 | uint64_t rounds_select_rx; 15 | uint64_t rounds_select_tx; 16 | uint64_t rounds_select_intr; 17 | 18 | uint64_t rounds_accept; 19 | uint64_t rounds_read; 20 | uint64_t rounds_write; 21 | uint64_t rounds_epoll; 22 | uint64_t rounds_wndadv; 23 | 24 | uint64_t rounds_rtocheck; 25 | uint64_t rounds_twcheck; 26 | uint64_t rounds_tocheck; 27 | }; 28 | 29 | struct stat_counter 30 | { 31 | uint64_t cnt; 32 | uint64_t sum; 33 | uint64_t max; 34 | uint64_t min; 35 | }; 36 | 37 | struct time_stat 38 | { 39 | struct stat_counter round; 40 | struct stat_counter processing; 41 | struct stat_counter tcheck; 42 | struct stat_counter epoll; 43 | struct stat_counter handle; 44 | struct stat_counter xmit; 45 | struct stat_counter select; 46 | }; 47 | 48 | struct net_stat 49 | { 50 | uint64_t tx_packets[MAX_DEVICES]; 51 | uint64_t tx_bytes[MAX_DEVICES]; 52 | uint64_t tx_drops[MAX_DEVICES]; 53 | uint64_t rx_packets[MAX_DEVICES]; 54 | uint64_t rx_bytes[MAX_DEVICES]; 55 | uint64_t rx_errors[MAX_DEVICES]; 56 | }; 57 | 58 | struct bcast_stat 59 | { 60 | uint64_t cycles; 61 | uint64_t write; 62 | uint64_t read; 63 | uint64_t epoll; 64 | uint64_t wnd_adv; 65 | uint64_t ack; 66 | }; 67 | 68 | struct timeout_stat 69 | { 70 | uint64_t cycles; 71 | uint64_t rto_try; 72 | uint64_t rto; 73 | uint64_t timewait_try; 74 | uint64_t timewait; 75 | }; 76 | 77 | #ifdef NETSTAT 78 | #define STAT_COUNT(stat) stat++ 79 | #else 80 | #define STAT_COUNT(stat) 81 | #endif 82 | 83 | #endif /* __STAT_H_ */ 84 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/inet_ntop_cache.c: -------------------------------------------------------------------------------- 1 | #include "base.h" 2 | #include "inet_ntop_cache.h" 3 | #include "sys-socket.h" 4 | 5 | #include 6 | 7 | #include 8 | 9 | const char * inet_ntop_cache_get_ip(server *srv, sock_addr *addr) { 10 | #ifdef HAVE_IPV6 11 | size_t ndx = 0, i; 12 | for (i = 0; i < INET_NTOP_CACHE_MAX; i++) { 13 | if (srv->inet_ntop_cache[i].ts != 0 && srv->inet_ntop_cache[i].family == addr->plain.sa_family) { 14 | if (srv->inet_ntop_cache[i].family == AF_INET6 && 15 | 0 == memcmp(srv->inet_ntop_cache[i].addr.ipv6.s6_addr, addr->ipv6.sin6_addr.s6_addr, 16)) { 16 | /* IPv6 found in cache */ 17 | break; 18 | } else if (srv->inet_ntop_cache[i].family == AF_INET && 19 | srv->inet_ntop_cache[i].addr.ipv4.s_addr == addr->ipv4.sin_addr.s_addr) { 20 | /* IPv4 found in cache */ 21 | break; 22 | 23 | } 24 | } 25 | } 26 | 27 | if (i == INET_NTOP_CACHE_MAX) { 28 | /* not found in cache */ 29 | 30 | i = ndx; 31 | inet_ntop(addr->plain.sa_family, 32 | addr->plain.sa_family == AF_INET6 ? 33 | (const void *) &(addr->ipv6.sin6_addr) : 34 | (const void *) &(addr->ipv4.sin_addr), 35 | srv->inet_ntop_cache[i].b2, INET6_ADDRSTRLEN); 36 | 37 | srv->inet_ntop_cache[i].ts = srv->cur_ts; 38 | srv->inet_ntop_cache[i].family = addr->plain.sa_family; 39 | 40 | if (srv->inet_ntop_cache[i].family == AF_INET) { 41 | srv->inet_ntop_cache[i].addr.ipv4.s_addr = addr->ipv4.sin_addr.s_addr; 42 | } else if (srv->inet_ntop_cache[i].family == AF_INET6) { 43 | memcpy(srv->inet_ntop_cache[i].addr.ipv6.s6_addr, addr->ipv6.sin6_addr.s6_addr, 16); 44 | } 45 | } 46 | 47 | return srv->inet_ntop_cache[i].b2; 48 | #else 49 | UNUSED(srv); 50 | return inet_ntoa(addr->ipv4.sin_addr); 51 | #endif 52 | } 53 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/Makefile.am: -------------------------------------------------------------------------------- 1 | # lighttpd.conf and conformance.pl expect this directory 2 | testdir=$(srcdir)/tmp/lighttpd/ 3 | 4 | if CHECK_WITH_FASTCGI 5 | check_PROGRAMS=fcgi-auth fcgi-responder 6 | 7 | fcgi_auth_SOURCES=fcgi-auth.c 8 | fcgi_auth_LDADD=-lfcgi 9 | 10 | fcgi_responder_SOURCES=fcgi-responder.c 11 | fcgi_responder_LDADD=-lfcgi 12 | endif 13 | 14 | TESTS=\ 15 | prepare.sh \ 16 | run-tests.pl \ 17 | cleanup.sh 18 | 19 | CONFS=fastcgi-10.conf \ 20 | fastcgi-auth.conf \ 21 | fastcgi-responder.conf \ 22 | fastcgi-13.conf \ 23 | bug-06.conf \ 24 | bug-12.conf \ 25 | core-var-include.t \ 26 | var-include.conf \ 27 | var-include-sub.conf \ 28 | condition.conf \ 29 | core-condition.t \ 30 | core-request.t \ 31 | core-response.t \ 32 | core-keepalive.t \ 33 | core.t \ 34 | mod-proxy.t \ 35 | proxy.conf \ 36 | mod-secdownload.t \ 37 | mod-access.t \ 38 | mod-auth.t \ 39 | mod-cgi.t \ 40 | mod-compress.t \ 41 | mod-compress.conf \ 42 | mod-fastcgi.t \ 43 | mod-redirect.t \ 44 | mod-rewrite.t \ 45 | mod-userdir.t \ 46 | symlink.t \ 47 | request.t \ 48 | mod-ssi.t \ 49 | LightyTest.pm \ 50 | mod-setenv.t \ 51 | lowercase.t \ 52 | lowercase.conf \ 53 | cachable.t \ 54 | core-404-handler.t \ 55 | 404-handler.conf 56 | 57 | TESTS_ENVIRONMENT=$(srcdir)/wrapper.sh $(srcdir) $(top_builddir) 58 | 59 | EXTRA_DIST=wrapper.sh lighttpd.conf \ 60 | lighttpd.user \ 61 | lighttpd.htpasswd \ 62 | SConscript \ 63 | $(CONFS) \ 64 | $(TESTS) 65 | 66 | SUBDIRS=docroot 67 | 68 | leak-check: 69 | for i in $(TESTS); do \ 70 | $(srcdir)/$$i; \ 71 | echo $$?; \ 72 | done 73 | 74 | clean-local: 75 | rm -f *.out 76 | -------------------------------------------------------------------------------- /core/src/include/eventpoll.h: -------------------------------------------------------------------------------- 1 | #ifndef __EVENTPOLL_H_ 2 | #define __EVENTPOLL_H_ 3 | 4 | #include "mtcp_api.h" 5 | #include "mtcp_epoll.h" 6 | 7 | /*----------------------------------------------------------------------------*/ 8 | struct mtcp_epoll_stat 9 | { 10 | uint64_t calls; 11 | uint64_t waits; 12 | uint64_t wakes; 13 | 14 | uint64_t issued; 15 | uint64_t registered; 16 | uint64_t invalidated; 17 | uint64_t handled; 18 | }; 19 | /*----------------------------------------------------------------------------*/ 20 | struct mtcp_epoll_event_int 21 | { 22 | struct mtcp_epoll_event ev; 23 | int sockid; 24 | }; 25 | /*----------------------------------------------------------------------------*/ 26 | enum event_queue_type 27 | { 28 | USR_EVENT_QUEUE = 0, 29 | USR_SHADOW_EVENT_QUEUE = 1, 30 | MOS_EVENT_QUEUE = 2 31 | }; 32 | /*----------------------------------------------------------------------------*/ 33 | struct event_queue 34 | { 35 | struct mtcp_epoll_event_int *events; 36 | int start; // starting index 37 | int end; // ending index 38 | 39 | int size; // max size 40 | int num_events; // number of events 41 | }; 42 | /*----------------------------------------------------------------------------*/ 43 | struct mtcp_epoll 44 | { 45 | struct event_queue *usr_queue; 46 | struct event_queue *usr_shadow_queue; 47 | struct event_queue *mtcp_queue; 48 | 49 | uint8_t waiting; 50 | struct mtcp_epoll_stat stat; 51 | 52 | pthread_cond_t epoll_cond; 53 | pthread_mutex_t epoll_lock; 54 | }; 55 | /*----------------------------------------------------------------------------*/ 56 | 57 | int 58 | CloseEpollSocket(mctx_t mctx, int epid); 59 | 60 | struct event_queue * 61 | CreateEventQueue(int size); 62 | 63 | void 64 | DestroyEventQueue(struct event_queue *eq); 65 | 66 | #endif /* __EVENTPOLL_H_ */ 67 | -------------------------------------------------------------------------------- /samples/epwget/Makefile.in: -------------------------------------------------------------------------------- 1 | TARGET = epwget 2 | TARGETMP = epwget-mp 3 | 4 | ###################################################################### 5 | # GCC and compilation options 6 | ###################################################################### 7 | GCC = $(CC) 8 | GCC_OPT = -m64 -Wall -Werror -fgnu89-inline 9 | GCC_OPT += -DNDEBUG -O3 -g -DNETSTAT -DINFO -DDBGERR -DDBGCERR 10 | GCC_OPT += $(DBG_OPT) 11 | ifeq ($V,) # no echo 12 | export MSG=@echo 13 | export HIDE=@ 14 | else 15 | export MSG=@\# 16 | export HIDE= 17 | endif 18 | 19 | ###################################################################### 20 | # LIBRARIES AND INCLUDES 21 | ###################################################################### 22 | MTCP_FLD = ../../core 23 | MTCP_INC =-I$(MTCP_FLD)/include 24 | MTCP_TARGET = $(MTCP_FLD)/lib/libmtcp.a 25 | LIBS += -lmtcp -lssl -lcrypto -lnuma -lpthread -lrt 26 | LIB_DIR += -L$(MTCP_FLD)/lib 27 | CMN_DIR = ../common 28 | CMN_INC = -I$(CMN_DIR) 29 | UTIL_INC = -I../../util/include 30 | 31 | # I/O library parameter (PSIO or DPDK) 32 | __IO_LIB_ARGS 33 | 34 | ###################################################################### 35 | 36 | default: $(TARGET) $(TARGETMP) 37 | 38 | $(MTCP_TARGET): 39 | cd $(MTCP_FLD)/src && make 40 | 41 | $(TARGET): $(MTCP_TARGET) $(TARGET).c $(CMN_DIR)/*.c ../../util/http_parsing.c 42 | $(MSG) " CC $<" 43 | $(HIDE) $(GCC) $(GCC_OPT) -o $@ $^ $(MTCP_INC) $(CMN_INC) $(UTIL_INC) $(LIB_DIR) $(LIBS) 44 | 45 | $(TARGETMP): $(MTCP_TARGET) $(TARGETMP).c $(CMN_DIR)/*.c ../../util/http_parsing.c 46 | $(MSG) " CC $<" 47 | $(HIDE) $(GCC) $(GCC_OPT) -o $@ $^ $(MTCP_INC) $(CMN_INC) $(UTIL_INC) $(LIB_DIR) $(LIBS) 48 | 49 | clean: 50 | rm -rf *~ *.o $(TARGET) $(TARGETMP) logs/* 51 | 52 | cleanall: clean 53 | rm -rf Makefile 54 | 55 | 56 | -------------------------------------------------------------------------------- /samples/epserver/Makefile.in: -------------------------------------------------------------------------------- 1 | TARGET = epserver 2 | TARGETMP = epserver-mp 3 | 4 | ###################################################################### 5 | # GCC and compilation options 6 | ###################################################################### 7 | GCC = $(CC) 8 | GCC_OPT = -m64 -Wall -Werror -fgnu89-inline 9 | GCC_OPT += -DNDEBUG -O3 -g -DNETSTAT -DINFO -DDBGERR -DDBGCERR 10 | GCC_OPT += $(DBG_OPT) 11 | ifeq ($V,) # no echo 12 | export MSG=@echo 13 | export HIDE=@ 14 | else 15 | export MSG=@\# 16 | export HIDE= 17 | endif 18 | 19 | ###################################################################### 20 | # LIBRARIES AND INCLUDES 21 | ###################################################################### 22 | MTCP_FLD = ../../core 23 | MTCP_INC =-I$(MTCP_FLD)/include 24 | MTCP_TARGET = $(MTCP_FLD)/lib/libmtcp.a 25 | LIBS += -lmtcp -lssl -lcrypto -lnuma -lpthread -lrt 26 | LIB_DIR += -L$(MTCP_FLD)/lib 27 | CMN_DIR = ../common 28 | CMN_INC = -I$(CMN_DIR) 29 | UTIL_INC = -I../../util/include 30 | 31 | # I/O library parameter (PSIO or DPDK) 32 | __IO_LIB_ARGS 33 | 34 | ###################################################################### 35 | 36 | default: $(TARGET) $(TARGETMP) 37 | 38 | $(MTCP_TARGET): 39 | cd $(MTCP_FLD)/src && make 40 | 41 | $(TARGET): $(MTCP_TARGET) $(TARGET).c $(CMN_DIR)/*.c ../../util/http_parsing.c 42 | $(MSG) " CC $<" 43 | $(HIDE) $(GCC) $(GCC_OPT) -o $@ $^ $(MTCP_INC) $(CMN_INC) $(UTIL_INC) $(LIB_DIR) $(LIBS) 44 | 45 | $(TARGETMP): $(MTCP_TARGET) $(TARGETMP).c $(CMN_DIR)/*.c ../../util/http_parsing.c 46 | $(MSG) " CC $<" 47 | $(HIDE) $(GCC) $(GCC_OPT) -o $@ $^ $(MTCP_INC) $(CMN_INC) $(UTIL_INC) $(LIB_DIR) $(LIBS) 48 | 49 | clean: 50 | rm -rf *~ *.o $(TARGET) $(TARGETMP) logs/* 51 | 52 | cleanall: clean 53 | rm -rf Makefile 54 | 55 | 56 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/404-handler.conf: -------------------------------------------------------------------------------- 1 | debug.log-request-handling = "enable" 2 | debug.log-response-header = "enable" 3 | debug.log-request-header = "enable" 4 | 5 | server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" 6 | 7 | ## bind to port (default: 80) 8 | server.port = 2048 9 | 10 | ## bind to localhost (default: all interfaces) 11 | server.bind = "localhost" 12 | server.errorlog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log" 13 | server.breakagelog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log" 14 | server.name = "www.example.org" 15 | server.tag = "Apache 1.3.29" 16 | 17 | 18 | server.modules = ( 19 | "mod_fastcgi", 20 | "mod_cgi", 21 | "mod_accesslog" ) 22 | 23 | ######################## MODULE CONFIG ############################ 24 | 25 | 26 | accesslog.filename = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.access.log" 27 | 28 | mimetype.assign = ( ".html" => "text/html" ) 29 | 30 | cgi.assign = (".pl" => "/usr/bin/perl" ) 31 | 32 | # fastcgi.server += ( "/404.pl" => 33 | # ( "404-handler" => 34 | # ( 35 | # "socket" => env.SRCDIR + "/tmp/pl-404-fastcgi-1.socket", 36 | # "bin-path" => server.document-root + "/404.pl", 37 | # "max-procs" => 1, 38 | # "check-local" => "disable", 39 | # "broken-scriptfilename" => "enable", 40 | # ) 41 | # ), 42 | # ) 43 | 44 | $HTTP["url"] =~ "^/static/" { 45 | server.error-handler-404 = "/404.html" 46 | } 47 | else $HTTP["url"] =~ "." { 48 | server.error-handler-404 = "/404.pl" 49 | } 50 | -------------------------------------------------------------------------------- /docs/man/mtcp_set_uctx: -------------------------------------------------------------------------------- 1 | .TH mtcp_set_uctx 3 2017-02-02 "Linux" "mOS Library Functions Manual" 2 | .SH NAME 3 | mtcp_set_uctx \- set private per-flow user-context data 4 | .SH SYNOPSIS 5 | .B #include 6 | .sp 7 | .BI "int mtcp_set_uctx(mctx_t " mctx ", int " sockid ", void *" uctx ); 8 | 9 | .SH DESCRIPTION 10 | .BR mtcp_set_uctx () 11 | can be used to associate flow-specific monitoring data to 12 | a flow record in the application layer. The flow-specific 13 | data is stored with the socket that can referred to by the 14 | .I "sockid" 15 | argument. 16 | The private data can be stored as a void *. It is the 17 | responsibility of the user to free up the private data (if it 18 | is dynamically allocated from memory) when the flow 19 | record gets deleted from the stack (due to, e.g., connection 20 | termination). 21 | 22 | The 23 | .BR mtcp_set_uctx () 24 | call takes an additional argument named 25 | .I "mctx" 26 | that represents the per-core mTCP context in an application 27 | (see 28 | .BR mtcp_create_context() 29 | for details). 30 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 31 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 32 | .\""""".SH CONFORMING TO 33 | .\"""""POSIX.1-2001. 34 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 35 | .SH AUTHORS 36 | mOS development team 37 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 38 | .SH SEE ALSO 39 | .BR mtcp_socket (), 40 | .BR mtcp_get_uctx (), 41 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""" 42 | .SH COLOPHON 43 | This page is part of mOS release 0.3 44 | .I "docs" 45 | section. A description of the project, and information 46 | about reporting bugs, can be found at 47 | \%http://mos.kaist.edu/. 48 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""" 49 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/outdated/trigger_b4_dl.txt: -------------------------------------------------------------------------------- 1 | ======================= 2 | Trigger before Download 3 | ======================= 4 | 5 | ------------------------- 6 | Module: mod_trigger_b4_dl 7 | ------------------------- 8 | 9 | :Author: Jan Kneschke 10 | :Date: $Date: 2004/11/03 22:26:05 $ 11 | :Revision: $Revision: 1.2 $ 12 | 13 | :abstract: 14 | another anti-hot-linking module 15 | 16 | .. meta:: 17 | :keywords: lighttpd, hot-linking, deep-linking 18 | 19 | .. contents:: Table of Contents 20 | 21 | Description 22 | =========== 23 | 24 | Anti Hotlinking: 25 | 26 | * if user requests ''download-url'' directly, the request is denied and he is redirected to ''deny-url' 27 | * if user visits ''trigger-url'' before requesting ''download-url'', access is granted 28 | * if user visits ''download-url'' again after ''trigger-timeout'' has elapsed, the request is denied and he is redirected to ''deny-url'' 29 | 30 | The trigger information is either stored locally in a gdbm file or remotely in memcached. 31 | 32 | Requirements 33 | ------------ 34 | 35 | * libpcre 36 | * libgdbm or libmemcache 37 | 38 | Options 39 | ======= 40 | 41 | :: 42 | 43 | trigger-before-download.gdbm-filename = "/home/weigon/testbase/trigger.db" 44 | trigger-before-download.memcache-hosts = ( "127.0.0.1:11211" ) 45 | trigger-before-download.trigger-url = "^/trigger/" 46 | trigger-before-download.download-url = "^/download/" 47 | trigger-before-download.deny-url = "http://192.168.1.5:1025/index.html" 48 | trigger-before-download.trigger-timeout = 10 49 | 50 | If both trigger-before-download.gdbm-filename and 51 | trigger-before-download.memcache-hosts is set gdbm will take precedence. 52 | 53 | Installation 54 | ============ 55 | 56 | memcached should be started with the option -M as we don't want to remove entry if the memory is full. 57 | 58 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/initscripts/rc.lighttpd.redhat: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # lighttpd Startup script for the lighttpd server 4 | # 5 | # chkconfig: - 85 15 6 | # description: Lightning fast webserver with light system requirements 7 | # 8 | # processname: lighttpd 9 | # config: /etc/lighttpd/lighttpd.conf 10 | # config: /etc/sysconfig/lighttpd 11 | # pidfile: /var/run/lighttpd.pid 12 | # 13 | # Note: pidfile is assumed to be created 14 | # by lighttpd (config: server.pid-file). 15 | # If not, uncomment 'pidof' line. 16 | 17 | # Source function library 18 | . /etc/rc.d/init.d/functions 19 | 20 | if [ -f /etc/sysconfig/lighttpd ]; then 21 | . /etc/sysconfig/lighttpd 22 | fi 23 | 24 | if [ -z "$LIGHTTPD_CONF_PATH" ]; then 25 | LIGHTTPD_CONF_PATH="/etc/lighttpd/lighttpd.conf" 26 | fi 27 | 28 | prog="lighttpd" 29 | lighttpd="/usr/sbin/lighttpd" 30 | RETVAL=0 31 | 32 | start() { 33 | echo -n $"Starting $prog: " 34 | daemon $lighttpd -f $LIGHTTPD_CONF_PATH 35 | RETVAL=$? 36 | echo 37 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog 38 | return $RETVAL 39 | } 40 | 41 | stop() { 42 | echo -n $"Stopping $prog: " 43 | killproc $lighttpd 44 | RETVAL=$? 45 | echo 46 | [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog 47 | return $RETVAL 48 | } 49 | 50 | reload() { 51 | echo -n $"Reloading $prog: " 52 | killproc $lighttpd -HUP 53 | RETVAL=$? 54 | echo 55 | return $RETVAL 56 | } 57 | 58 | case "$1" in 59 | start) 60 | start 61 | ;; 62 | stop) 63 | stop 64 | ;; 65 | restart) 66 | stop 67 | start 68 | ;; 69 | condrestart) 70 | if [ -f /var/lock/subsys/$prog ]; then 71 | stop 72 | start 73 | fi 74 | ;; 75 | reload) 76 | reload 77 | ;; 78 | status) 79 | status $lighttpd 80 | RETVAL=$? 81 | ;; 82 | *) 83 | echo $"Usage: $0 {start|stop|restart|condrestart|reload|status}" 84 | RETVAL=1 85 | esac 86 | 87 | exit $RETVAL 88 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/outdated/Makefile.am: -------------------------------------------------------------------------------- 1 | DOCS=accesslog.txt \ 2 | authentication.txt \ 3 | cgi.txt \ 4 | compress.txt \ 5 | configuration.txt \ 6 | extforward.txt \ 7 | fastcgi-state.txt \ 8 | fastcgi.txt \ 9 | features.txt \ 10 | performance.txt \ 11 | plugins.txt \ 12 | proxy.txt \ 13 | redirect.txt \ 14 | rewrite.txt \ 15 | secdownload.txt \ 16 | security.txt \ 17 | simple-vhost.txt \ 18 | skeleton.txt \ 19 | ssi.txt \ 20 | ssl.txt \ 21 | state.txt \ 22 | rrdtool.txt \ 23 | alias.txt \ 24 | userdir.txt \ 25 | mysqlvhost.txt \ 26 | access.txt \ 27 | traffic-shaping.txt \ 28 | setenv.txt \ 29 | status.txt \ 30 | scgi.txt \ 31 | cml.txt \ 32 | trigger_b4_dl.txt \ 33 | webdav.txt \ 34 | expire.txt \ 35 | dirlisting.txt \ 36 | evhost.txt \ 37 | magnet.txt 38 | 39 | HTMLDOCS=accesslog.html \ 40 | authentication.html \ 41 | cgi.html \ 42 | compress.html \ 43 | configuration.html \ 44 | extforward.html \ 45 | fastcgi-state.html \ 46 | fastcgi.html \ 47 | features.html \ 48 | performance.html \ 49 | plugins.html \ 50 | proxy.html \ 51 | redirect.html \ 52 | rewrite.html \ 53 | secdownload.html \ 54 | security.html \ 55 | simple-vhost.html \ 56 | skeleton.html \ 57 | ssi.html \ 58 | ssl.html \ 59 | state.html \ 60 | rrdtool.html \ 61 | alias.html \ 62 | userdir.html \ 63 | mysqlvhost.html \ 64 | access.html \ 65 | traffic-shaping.html \ 66 | setenv.html \ 67 | status.html \ 68 | scgi.html \ 69 | cml.html \ 70 | trigger_b4_dl.html \ 71 | webdav.html \ 72 | expire.html \ 73 | dirlisting.html \ 74 | evhost.html \ 75 | magnet.html 76 | 77 | EXTRA_DIST= \ 78 | state.dot fastcgi-state.dot \ 79 | $(DOCS) 80 | 81 | .txt.html: 82 | rst2html $^ > $@ 83 | 84 | 85 | html-local: $(HTMLDOCS) 86 | 87 | #%.ps.gz: %.ps 88 | # gzip $^ 89 | 90 | #%.ps: %.dot 91 | # dot -Tps -o $@ $^ 92 | 93 | clean-local: 94 | rm -f *.html 95 | 96 | 97 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/joblist.c: -------------------------------------------------------------------------------- 1 | #include "base.h" 2 | #include "joblist.h" 3 | #include "log.h" 4 | 5 | #include 6 | #include 7 | 8 | int joblist_append(server *srv, connection *con) { 9 | if (con->in_joblist) return 0; 10 | 11 | if (srv->joblist->size == 0) { 12 | srv->joblist->size = 16; 13 | srv->joblist->ptr = malloc(sizeof(*srv->joblist->ptr) * srv->joblist->size); 14 | } else if (srv->joblist->used == srv->joblist->size) { 15 | srv->joblist->size += 16; 16 | srv->joblist->ptr = realloc(srv->joblist->ptr, sizeof(*srv->joblist->ptr) * srv->joblist->size); 17 | } 18 | 19 | srv->joblist->ptr[srv->joblist->used++] = con; 20 | 21 | return 0; 22 | } 23 | 24 | void joblist_free(server *srv, connections *joblist) { 25 | UNUSED(srv); 26 | 27 | free(joblist->ptr); 28 | free(joblist); 29 | } 30 | 31 | connection *fdwaitqueue_unshift(server *srv, connections *fdwaitqueue) { 32 | connection *con; 33 | UNUSED(srv); 34 | 35 | 36 | if (fdwaitqueue->used == 0) return NULL; 37 | 38 | con = fdwaitqueue->ptr[0]; 39 | 40 | memmove(fdwaitqueue->ptr, &(fdwaitqueue->ptr[1]), --fdwaitqueue->used * sizeof(*(fdwaitqueue->ptr))); 41 | 42 | return con; 43 | } 44 | 45 | int fdwaitqueue_append(server *srv, connection *con) { 46 | if (srv->fdwaitqueue->size == 0) { 47 | srv->fdwaitqueue->size = 16; 48 | srv->fdwaitqueue->ptr = malloc(sizeof(*(srv->fdwaitqueue->ptr)) * srv->fdwaitqueue->size); 49 | } else if (srv->fdwaitqueue->used == srv->fdwaitqueue->size) { 50 | srv->fdwaitqueue->size += 16; 51 | srv->fdwaitqueue->ptr = realloc(srv->fdwaitqueue->ptr, sizeof(*(srv->fdwaitqueue->ptr)) * srv->fdwaitqueue->size); 52 | } 53 | 54 | srv->fdwaitqueue->ptr[srv->fdwaitqueue->used++] = con; 55 | 56 | return 0; 57 | } 58 | 59 | void fdwaitqueue_free(server *srv, connections *fdwaitqueue) { 60 | UNUSED(srv); 61 | free(fdwaitqueue->ptr); 62 | free(fdwaitqueue); 63 | } 64 | -------------------------------------------------------------------------------- /docs/man/mtcp_settimer: -------------------------------------------------------------------------------- 1 | .TH mtcp_settimer 3 2017-02-02 "Linux" "mOS Library Functions Manual" 2 | .SH NAME 3 | mtcp_settimer \- register user's timer-based callback handler 4 | .SH SYNOPSIS 5 | .B #include 6 | .sp 7 | .BI "int mtcp_settimer(mctx_t " mctx ", int " id ", struct timeval *" timeout ", callback_t " cb ); 8 | 9 | .SH DESCRIPTION 10 | .BR mtcp_settimer () 11 | can be used to register callback handler function, 12 | .I "cb", 13 | that is invoked after a time interval of 14 | .I "timeout" 15 | microseconds. Note that this callback is a one time 16 | registration and 17 | .I "cb" 18 | (see 19 | .BR mtcp_register_callback () 20 | for definition) is called only once when 21 | .I "timeout" 22 | period expires. The 23 | .I "id" 24 | argument is a unique identifier that is passed to 25 | .I "cb" 26 | as one of the function arguments. 27 | 28 | .BR mtcp_settimer () 29 | call takes an additional argument named 30 | .I "mctx" 31 | that represents the per-core mTCP context in an application 32 | (see 33 | .BR mtcp_create_context() 34 | for details). 35 | 36 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 37 | .SH RETURN VALUE 38 | On success 0 is returned; -1 on failure. 39 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 40 | .\""""".SH CONFORMING TO 41 | .\"""""POSIX.1-2001. 42 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 43 | .SH AUTHORS 44 | mOS development team 45 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 46 | .SH SEE ALSO 47 | .BR mtcp_register_callback (), 48 | .BR mtcp_socket (), 49 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""" 50 | .SH COLOPHON 51 | This page is part of mOS release 0.3 52 | .I "docs" 53 | section. A description of the project, and information 54 | about reporting bugs, can be found at 55 | \%http://mos.kaist.edu/. 56 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""" 57 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/outdated/ssi.txt: -------------------------------------------------------------------------------- 1 | ==================== 2 | Server-Side Includes 3 | ==================== 4 | 5 | --------------- 6 | Module: mod_ssi 7 | --------------- 8 | 9 | :Author: Jan Kneschke 10 | :Date: $Date: 2004/08/29 09:44:53 $ 11 | :Revision: $Revision: 1.2 $ 12 | 13 | :abstract: 14 | The module for server-side includes provides a compatability 15 | layer for NSCA/Apache SSI. 16 | 17 | .. meta:: 18 | :keywords: lighttpd, ssi, Server-Side Includes 19 | 20 | .. contents:: Table of Contents 21 | 22 | Description 23 | =========== 24 | 25 | Configuration 26 | ------------- 27 | 28 | :: 29 | 30 | server.modules = ( ..., "mod_ssi", ... ) 31 | ssi.extension = ( ".shtml" ) 32 | 33 | Supported Options 34 | ----------------- 35 | 36 | - ```` 37 | - ```` 38 | - ```` 39 | - ```` 40 | - ```` 41 | - ```` 42 | - ```` 43 | - ```` 44 | - ```` 45 | - ```` 46 | - ```` 47 | 48 | Expression Handling 49 | ------------------- 50 | 51 | Every ''expr'' is interpreted: 52 | 53 | - logical: AND, OR, ! 54 | - compare: =, <, <=, >, =>, != 55 | - precedence: (, ) 56 | - quoted strings: 'string with a dollar: $FOO' 57 | - variable substitution: $REMOTE_ADDR 58 | - unquoted strings: string 59 | 60 | Flow Control 61 | ------------ 62 | 63 | if, elif, else and endif can only be used to insert content under special 64 | conditions. 65 | 66 | Unsupported Features 67 | -------------------- 68 | 69 | The original SSI module from NCSA and Apache provided some more options 70 | which are not supported by this module for various reasons: 71 | 72 | - exec 73 | - nested virtual 74 | - config.errmsg 75 | - echo.encoding 76 | 77 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/prepare.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if test x$srcdir = x; then 4 | srcdir=. 5 | fi 6 | 7 | if test x$top_builddir = x; then 8 | top_builddir=.. 9 | fi 10 | 11 | tmpdir=$top_builddir/tests/tmp/lighttpd 12 | 13 | # create test-framework 14 | rm -rf $tmpdir 15 | mkdir -p $tmpdir/servers/www.example.org/pages/ 16 | mkdir -p $tmpdir/servers/www.example.org/pages/dummydir/ 17 | mkdir -p $tmpdir/servers/www.example.org/pages/go/ 18 | mkdir -p $tmpdir/servers/www.example.org/pages/expire/ 19 | mkdir -p $tmpdir/servers/www.example.org/pages/indexfile/ 20 | mkdir -p $tmpdir/servers/123.example.org/pages/ 21 | mkdir -p $tmpdir/logs/ 22 | mkdir -p $tmpdir/cache/ 23 | mkdir -p $tmpdir/cache/compress/ 24 | 25 | # copy everything into the right places 26 | cp $srcdir/docroot/www/*.html \ 27 | $srcdir/docroot/www/*.php \ 28 | $srcdir/docroot/www/*.pl \ 29 | $srcdir/docroot/www/*.fcgi \ 30 | $srcdir/docroot/www/*.shtml \ 31 | $srcdir/docroot/www/*.txt $tmpdir/servers/www.example.org/pages/ 32 | cp $srcdir/docroot/www/go/*.php $tmpdir/servers/www.example.org/pages/go/ 33 | cp $srcdir/docroot/www/expire/*.txt $tmpdir/servers/www.example.org/pages/expire/ 34 | cp $srcdir/docroot/www/indexfile/*.php $tmpdir/servers/www.example.org/pages/indexfile/ 35 | cp $srcdir/docroot/123/*.txt \ 36 | $srcdir/docroot/123/*.html \ 37 | $srcdir/docroot/123/*.php \ 38 | $srcdir/docroot/123/*.bla $tmpdir/servers/123.example.org/pages/ 39 | cp $srcdir/lighttpd.user $tmpdir/ 40 | cp $srcdir/lighttpd.htpasswd $tmpdir/ 41 | cp $srcdir/var-include-sub.conf $tmpdir/../ 42 | touch $tmpdir/servers/www.example.org/pages/image.jpg \ 43 | $tmpdir/servers/www.example.org/pages/image.JPG \ 44 | $tmpdir/servers/www.example.org/pages/Foo.txt \ 45 | $tmpdir/servers/www.example.org/pages/a \ 46 | $tmpdir/servers/www.example.org/pages/index.html~ 47 | echo "12345" > $tmpdir/servers/www.example.org/pages/range.pdf 48 | 49 | printf "%-40s" "preparing infrastructure" 50 | 51 | exit 0 52 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/http_auth.h: -------------------------------------------------------------------------------- 1 | #ifndef _HTTP_AUTH_H_ 2 | #define _HTTP_AUTH_H_ 3 | 4 | #include "server.h" 5 | #include "plugin.h" 6 | 7 | #if defined(HAVE_LDAP_H) && defined(HAVE_LBER_H) && defined(HAVE_LIBLDAP) && defined(HAVE_LIBLBER) 8 | # define USE_LDAP 9 | # include 10 | #endif 11 | 12 | typedef enum { 13 | AUTH_BACKEND_UNSET, 14 | AUTH_BACKEND_PLAIN, 15 | AUTH_BACKEND_LDAP, 16 | AUTH_BACKEND_HTPASSWD, 17 | AUTH_BACKEND_HTDIGEST 18 | } auth_backend_t; 19 | 20 | typedef struct { 21 | /* auth */ 22 | array *auth_require; 23 | 24 | buffer *auth_plain_groupfile; 25 | buffer *auth_plain_userfile; 26 | 27 | buffer *auth_htdigest_userfile; 28 | buffer *auth_htpasswd_userfile; 29 | 30 | buffer *auth_backend_conf; 31 | 32 | buffer *auth_ldap_hostname; 33 | buffer *auth_ldap_basedn; 34 | buffer *auth_ldap_binddn; 35 | buffer *auth_ldap_bindpw; 36 | buffer *auth_ldap_filter; 37 | buffer *auth_ldap_cafile; 38 | unsigned short auth_ldap_starttls; 39 | unsigned short auth_ldap_allow_empty_pw; 40 | 41 | unsigned short auth_debug; 42 | 43 | /* generated */ 44 | auth_backend_t auth_backend; 45 | 46 | #ifdef USE_LDAP 47 | LDAP *ldap; 48 | 49 | buffer *ldap_filter_pre; 50 | buffer *ldap_filter_post; 51 | #endif 52 | } mod_auth_plugin_config; 53 | 54 | typedef struct { 55 | PLUGIN_DATA; 56 | buffer *tmp_buf; 57 | 58 | buffer *auth_user; 59 | 60 | #ifdef USE_LDAP 61 | buffer *ldap_filter; 62 | #endif 63 | 64 | mod_auth_plugin_config **config_storage; 65 | 66 | mod_auth_plugin_config conf, *anon_conf; /* this is only used as long as no handler_ctx is setup */ 67 | } mod_auth_plugin_data; 68 | 69 | int http_auth_basic_check(server *srv, connection *con, mod_auth_plugin_data *p, array *req, buffer *url, const char *realm_str); 70 | int http_auth_digest_check(server *srv, connection *con, mod_auth_plugin_data *p, array *req, buffer *url, const char *realm_str); 71 | int http_auth_digest_generate_nonce(server *srv, mod_auth_plugin_data *p, buffer *fn, char hh[33]); 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/core-var-include.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | BEGIN { 3 | # add current source dir to the include-path 4 | # we need this for make distcheck 5 | (my $srcdir = $0) =~ s,/[^/]+$,/,; 6 | unshift @INC, $srcdir; 7 | } 8 | 9 | use strict; 10 | use IO::Socket; 11 | use Test::More tests => 17; 12 | use LightyTest; 13 | 14 | my $tf = LightyTest->new(); 15 | my $t; 16 | 17 | $ENV{"env_test"} = "good_env"; 18 | 19 | $tf->{CONFIGFILE} = 'var-include.conf'; 20 | 21 | ok($tf->start_proc == 0, "Starting lighttpd") or die(); 22 | 23 | $t->{REQUEST} = ( "GET /index.html HTTP/1.0\r\nHost: www.example.org\r\n" ); 24 | $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => "/redirect" } ]; 25 | ok($tf->handle_http($t) == 0, 'basic test'); 26 | 27 | my $myvar = "good"; 28 | my $server_name = "test.example.org"; 29 | my $mystr = "string"; 30 | $mystr .= "_append"; 31 | my $tests = { 32 | "include" => "/good_include", 33 | "concat" => "/good_" . "concat", 34 | "servername1" => "/good_" . $server_name, 35 | "servername2" => $server_name . "/good_", 36 | "servername3" => "/good_" . $server_name . "/", 37 | "var.myvar" => "/good_var_myvar" . $myvar, 38 | "myvar" => "/good_myvar" . $myvar, 39 | "env" => "/" . $ENV{"env_test"}, 40 | 41 | "number1" => "/good_number" . "1", 42 | "number2" => "1" . "/good_number", 43 | "array_append" => "/good_array_append", 44 | "string_append" => "/good_" . $mystr, 45 | "number_append" => "/good_" . "2", 46 | 47 | "include_shell" => "/good_include_shell_" . "456" 48 | }; 49 | 50 | foreach my $test (keys %{ $tests }) { 51 | my $expect = $tests->{$test}; 52 | $t->{REQUEST} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => $expect } ]; 58 | ok($tf->handle_http($t) == 0, $test); 59 | } 60 | 61 | ok($tf->stop_proc == 0, "Stopping lighttpd"); 62 | -------------------------------------------------------------------------------- /core/src/include/bpf/nlpid.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996 3 | * Juniper Networks, Inc. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that: (1) source code distributions 7 | * retain the above copyright notice and this paragraph in its entirety, (2) 8 | * distributions including binary code include the above copyright notice and 9 | * this paragraph in its entirety in the documentation or other materials 10 | * provided with the distribution. The name of Juniper Networks may not 11 | * be used to endorse or promote products derived from this software 12 | * without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 15 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 16 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | * 18 | * @(#) $Header: /usr/cvsroot/sfeng/ims/src/libraries/daq/daq/sfbpf/nlpid.h,v 1.1 2010/04/15 19:18:35 maltizer Exp $ (Juniper) 19 | */ 20 | 21 | /* Types missing from some systems */ 22 | 23 | /* 24 | * Network layer prototocol identifiers 25 | */ 26 | #ifndef ISO8473_CLNP 27 | #define ISO8473_CLNP 0x81 28 | #endif 29 | #ifndef ISO9542_ESIS 30 | #define ISO9542_ESIS 0x82 31 | #endif 32 | #ifndef ISO9542X25_ESIS 33 | #define ISO9542X25_ESIS 0x8a 34 | #endif 35 | #ifndef ISO10589_ISIS 36 | #define ISO10589_ISIS 0x83 37 | #endif 38 | /* 39 | * this does not really belong in the nlpid.h file 40 | * however we need it for generating nice 41 | * IS-IS related BPF filters 42 | */ 43 | #define ISIS_L1_LAN_IIH 15 44 | #define ISIS_L2_LAN_IIH 16 45 | #define ISIS_PTP_IIH 17 46 | #define ISIS_L1_LSP 18 47 | #define ISIS_L2_LSP 20 48 | #define ISIS_L1_CSNP 24 49 | #define ISIS_L2_CSNP 25 50 | #define ISIS_L1_PSNP 26 51 | #define ISIS_L2_PSNP 27 52 | 53 | #ifndef ISO8878A_CONS 54 | #define ISO8878A_CONS 0x84 55 | #endif 56 | #ifndef ISO10747_IDRP 57 | #define ISO10747_IDRP 0x85 58 | #endif 59 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/distribute.sh.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | PACKAGE=@PACKAGE_TARNAME@ 3 | VERSION=@VERSION@ 4 | NAME=@PACKAGE_TARNAME@-@VERSION@ 5 | 6 | DISTDIR="/home/jan/wwwroot/servers/www.lighttpd.net/pages/download/" 7 | RPMS="/home/jan/rpmbuild/RPMS/i386/${NAME}-1.i386.rpm \ 8 | /home/jan/rpmbuild/SRPMS/${NAME}-1.src.rpm" 9 | FILES="${RPMS} ${NAME}.tar.gz \ 10 | NEWS.html \ 11 | ChangeLog \ 12 | release-news.${VERSION}.txt \ 13 | ${NAME}.tar.gz.sig" 14 | DLURL="http://www.lighttpd.net/download" 15 | pack=0 16 | echo $1 17 | case "$1" in 18 | --pack) pack=1;; 19 | esac 20 | 21 | echo ${nopack} 22 | 23 | if test x${pack} = x1; then 24 | make distcheck && rpmbuild -ta --nodeps ${NAME}.tar.gz 25 | gpg --detach-sign ${NAME}.tar.gz 26 | rpm --addsign ${RPMS} 27 | fi 28 | 29 | MD5RPM=`md5sum /home/jan/rpmbuild/RPMS/i386/${NAME}-1.i386.rpm| cut -b 1-32` 30 | MD5SRPM=`md5sum /home/jan/rpmbuild/SRPMS/${NAME}-1.src.rpm| cut -b 1-32` 31 | MD5TGZ=`md5sum ${NAME}.tar.gz| cut -b 1-32` 32 | DATE=`date +'%Y-%m-%d %H:%M'` 33 | NEWS=`cat NEWS | sed "/^- ${VERSION}/,/^-/p;d" | sed "/^- /d;/^$/d"` 34 | DLNAME="${DLURL}/${NAME}" 35 | 36 | cat > release-news.${VERSION}-mail.txt < release-news.${VERSION}.txt < NEWS.html 75 | 76 | for i in ${DISTDIR}; do 77 | cp -u ${FILES} $i 78 | done 79 | 80 | curdir=`pwd` 81 | cd ~/wwwroot/servers/www.lighttpd.net/ 82 | make put 83 | cd ${curdir} 84 | 85 | 86 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/mod-redirect.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | BEGIN { 3 | # add current source dir to the include-path 4 | # we need this for make distcheck 5 | (my $srcdir = $0) =~ s,/[^/]+$,/,; 6 | unshift @INC, $srcdir; 7 | } 8 | 9 | use strict; 10 | use IO::Socket; 11 | use Test::More tests => 7; 12 | use LightyTest; 13 | 14 | my $tf = LightyTest->new(); 15 | my $t; 16 | 17 | ok($tf->start_proc == 0, "Starting lighttpd") or die(); 18 | 19 | $t->{REQUEST} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => 'http://localhost:'.$tf->{PORT}.'/' } ]; 25 | ok($tf->handle_http($t) == 0, 'external redirect'); 26 | 27 | $t->{REQUEST} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => 'http://localhost:'.$tf->{PORT}.'/', 'Content-Length' => '0' } ]; 33 | ok($tf->handle_http($t) == 0, 'external redirect should have a Content-Length: 0'); 34 | 35 | $t->{REQUEST} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => 'http://localhost:'.$tf->{PORT}.'/zzz' } ]; 41 | ok($tf->handle_http($t) == 0, 'external redirect with cond regsub'); 42 | 43 | $t->{REQUEST} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => 'http://localhost:'.$tf->{PORT}.'/127.0.0.1' } ]; 49 | ok($tf->handle_http($t) == 0, 'external redirect with cond regsub on remoteip'); 50 | 51 | $t->{REQUEST} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => 'http://localhost:'.$tf->{PORT}.'/remoteip2' } ]; 57 | ok($tf->handle_http($t) == 0, 'external redirect with cond regsub on remoteip2'); 58 | 59 | ok($tf->stop_proc == 0, "Stopping lighttpd"); 60 | -------------------------------------------------------------------------------- /core/src/cpu.c: -------------------------------------------------------------------------------- 1 | #ifndef _GNU_SOURCE 2 | #define _GNU_SOURCE 3 | #endif 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #ifndef DISABLE_NUMA 13 | #include 14 | #endif 15 | 16 | #define MAX_FILE_NAME 1024 17 | 18 | /*----------------------------------------------------------------------------*/ 19 | int 20 | GetNumCPUs() 21 | { 22 | return sysconf(_SC_NPROCESSORS_ONLN); 23 | } 24 | /*----------------------------------------------------------------------------*/ 25 | pid_t 26 | Gettid() 27 | { 28 | return syscall(__NR_gettid); 29 | } 30 | /*----------------------------------------------------------------------------*/ 31 | int 32 | mtcp_core_affinitize(int cpu) 33 | { 34 | #ifndef DISABLE_NUMA 35 | struct bitmask *bmask; 36 | #endif /* DISABLE_NUMA */ 37 | cpu_set_t cpus; 38 | FILE *fp; 39 | char sysfname[MAX_FILE_NAME]; 40 | int phy_id; 41 | size_t n; 42 | int ret; 43 | 44 | n = GetNumCPUs(); 45 | 46 | if (cpu < 0 || cpu >= (int) n) { 47 | errno = -EINVAL; 48 | return -1; 49 | } 50 | 51 | CPU_ZERO(&cpus); 52 | CPU_SET((unsigned)cpu, &cpus); 53 | 54 | ret = sched_setaffinity(Gettid(), sizeof(cpus), &cpus); 55 | 56 | #ifndef DISABLE_NUMA 57 | if (numa_max_node() == 0) 58 | return ret; 59 | 60 | bmask = numa_bitmask_alloc(numa_max_node() + 1); 61 | assert(bmask); 62 | #endif /* DISABLE_NUMA */ 63 | 64 | /* read physical id of the core from sys information */ 65 | snprintf(sysfname, MAX_FILE_NAME - 1, 66 | "/sys/devices/system/cpu/cpu%d/topology/physical_package_id", cpu); 67 | fp = fopen(sysfname, "r"); 68 | if (!fp) { 69 | perror(sysfname); 70 | errno = EFAULT; 71 | return -1; 72 | } 73 | 74 | ret = fscanf(fp, "%d", &phy_id); 75 | if (ret != 1) { 76 | fclose(fp); 77 | perror("Fail to read core id"); 78 | errno = EFAULT; 79 | return -1; 80 | } 81 | 82 | 83 | #ifndef DISABLE_NUMA 84 | numa_bitmask_setbit(bmask, phy_id); 85 | numa_set_membind(bmask); 86 | numa_bitmask_free(bmask); 87 | #endif /* DISABLE_NUMA */ 88 | 89 | fclose(fp); 90 | 91 | return ret; 92 | } 93 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/tests/mod-secdownload.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | BEGIN { 3 | # add current source dir to the include-path 4 | # we need this for make distcheck 5 | (my $srcdir = $0) =~ s,/[^/]+$,/,; 6 | unshift @INC, $srcdir; 7 | } 8 | 9 | use strict; 10 | use IO::Socket; 11 | use Test::More tests => 7; 12 | use LightyTest; 13 | use Digest::MD5 qw(md5_hex); 14 | 15 | my $tf = LightyTest->new(); 16 | my $t; 17 | 18 | ok($tf->start_proc == 0, "Starting lighttpd") or die(); 19 | 20 | my $secret = "verysecret"; 21 | my $f = "/index.html"; 22 | my $thex = sprintf("%08x", time); 23 | my $m = md5_hex($secret.$f.$thex); 24 | 25 | $t->{REQUEST} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; 31 | 32 | ok($tf->handle_http($t) == 0, 'secdownload'); 33 | 34 | $thex = sprintf("%08x", time - 1800); 35 | $m = md5_hex($secret.$f.$thex); 36 | 37 | $t->{REQUEST} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 410 } ]; 43 | 44 | ok($tf->handle_http($t) == 0, 'secdownload - gone (timeout)'); 45 | 46 | $t->{REQUEST} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } ]; 52 | 53 | ok($tf->handle_http($t) == 0, 'secdownload - direct access'); 54 | 55 | $t->{REQUEST} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; 61 | 62 | ok($tf->handle_http($t) == 0, 'secdownload - conditional access'); 63 | 64 | 65 | $f = "/noexists"; 66 | $thex = sprintf("%08x", time); 67 | $m = md5_hex($secret.$f.$thex); 68 | 69 | $t->{REQUEST} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } ]; 75 | 76 | ok($tf->handle_http($t) == 0, 'secdownload - timeout'); 77 | 78 | ok($tf->stop_proc == 0, "Stopping lighttpd"); 79 | 80 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/doc/outdated/userdir.txt: -------------------------------------------------------------------------------- 1 | ======= 2 | userdir 3 | ======= 4 | 5 | ------------------- 6 | Module: mod_userdir 7 | ------------------- 8 | 9 | :Author: Jan Kneschke 10 | :Date: $Date: 2004/08/29 09:43:49 $ 11 | :Revision: $Revision: 1.1 $ 12 | 13 | :abstract: 14 | The userdir module ... 15 | 16 | .. meta:: 17 | :keywords: lighttpd, userdir 18 | 19 | .. contents:: Table of Contents 20 | 21 | Description 22 | =========== 23 | 24 | The userdir module provides a simple way to link user-based directories into the global namespace of the webserver. 25 | 26 | Requests in the form ``/~user/page.html`` are rewritten to take the file ``page.html`` from the home directory of the user. 27 | If ``userdir.path`` is set, the path will be appended to the home directory 28 | building the classic mapping of: :: 29 | 30 | userdir.path = "public_html" 31 | 32 | URL: http://www.example.org/~jan/index.html 33 | Path: /home/jan/public_html/ 34 | 35 | To control which users should be able to use this feature you can set a list of usernames to include or exclude. 36 | 37 | In case your mapping is independent of /etc/passwd you can use 38 | ``userdir.basepath``: :: 39 | 40 | userdir.path = "htdocs" 41 | userdir.basepath = "/var/www/users/" 42 | 43 | URL: http://www.example.org/~jan/index.html 44 | Path: /var/www/users/jan/htdocs/index.html 45 | 46 | Options 47 | ======= 48 | 49 | userdir.path (required option) 50 | usually it should be set to "public_html" to take ~/public_html/ as the document root 51 | 52 | Default: unset (mod_userdir disabled; set it to "" if you want the home directory to be the document root as it was the default before 1.4.19) 53 | Example: :: 54 | 55 | userdir.path = "public_html" 56 | 57 | userdir.exclude-user 58 | list of usernames which may not use this feature 59 | 60 | Default: empty (all users may use it) 61 | Example: :: 62 | 63 | userdir.exclude-user = ( "root", "postmaster" ) 64 | 65 | 66 | userdir.include-user 67 | if set, only users from this list may use the feature 68 | 69 | Default: empty (all users may use it) 70 | 71 | userdir.basepath 72 | if set, don't check /etc/passwd for homedir 73 | -------------------------------------------------------------------------------- /samples/lighttpd-1.4.32/src/stream.c: -------------------------------------------------------------------------------- 1 | #include "stream.h" 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | #include "sys-mmap.h" 10 | 11 | #ifndef O_BINARY 12 | # define O_BINARY 0 13 | #endif 14 | 15 | int stream_open(stream *f, buffer *fn) { 16 | struct stat st; 17 | #ifdef HAVE_MMAP 18 | int fd; 19 | #elif defined __WIN32 20 | HANDLE *fh, *mh; 21 | void *p; 22 | #endif 23 | 24 | f->start = NULL; 25 | 26 | if (-1 == stat(fn->ptr, &st)) { 27 | return -1; 28 | } 29 | 30 | f->size = st.st_size; 31 | 32 | #ifdef HAVE_MMAP 33 | if (-1 == (fd = open(fn->ptr, O_RDONLY | O_BINARY))) { 34 | return -1; 35 | } 36 | 37 | f->start = mmap(NULL, f->size, PROT_READ, MAP_SHARED, fd, 0); 38 | 39 | close(fd); 40 | 41 | if (MAP_FAILED == f->start) { 42 | return -1; 43 | } 44 | 45 | #elif defined __WIN32 46 | fh = CreateFile(fn->ptr, 47 | GENERIC_READ, 48 | FILE_SHARE_READ, 49 | NULL, 50 | OPEN_EXISTING, 51 | FILE_ATTRIBUTE_READONLY, 52 | NULL); 53 | 54 | if (!fh) return -1; 55 | 56 | mh = CreateFileMapping( fh, 57 | NULL, 58 | PAGE_READONLY, 59 | (sizeof(off_t) > 4) ? f->size >> 32 : 0, 60 | f->size & 0xffffffff, 61 | NULL); 62 | 63 | if (!mh) { 64 | /* 65 | LPVOID lpMsgBuf; 66 | FormatMessage( 67 | FORMAT_MESSAGE_ALLOCATE_BUFFER | 68 | FORMAT_MESSAGE_FROM_SYSTEM, 69 | NULL, 70 | GetLastError(), 71 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 72 | (LPTSTR) &lpMsgBuf, 73 | 0, NULL ); 74 | */ 75 | return -1; 76 | } 77 | 78 | p = MapViewOfFile(mh, 79 | FILE_MAP_READ, 80 | 0, 81 | 0, 82 | 0); 83 | CloseHandle(mh); 84 | CloseHandle(fh); 85 | 86 | f->start = p; 87 | #else 88 | # error no mmap found 89 | #endif 90 | 91 | return 0; 92 | } 93 | 94 | int stream_close(stream *f) { 95 | #ifdef HAVE_MMAP 96 | if (f->start) munmap(f->start, f->size); 97 | #elif defined(__WIN32) 98 | if (f->start) UnmapViewOfFile(f->start); 99 | #endif 100 | 101 | f->start = NULL; 102 | 103 | return 0; 104 | } 105 | -------------------------------------------------------------------------------- /.standalone-template.conf: -------------------------------------------------------------------------------- 1 | ############### MOS configuration file ############### 2 | 3 | ####################### 4 | # MOS-RELATED OPTIONS # 5 | ####################### 6 | mos { 7 | forward = __forward 8 | 9 | ####################### 10 | ##### I/O OPTIONS ##### 11 | ####################### 12 | __num_memch 13 | # devices used for MOS applications [mandatory] 14 | netdev {__devicemask 15 | } 16 | 17 | ####################### 18 | ### LOGGING OPTIONS ### 19 | ####################### 20 | # NICs to print network statistics per second 21 | # if enabled, mTCP will print xx Gbps and xx pps for RX and TX 22 | stat_print =__devicelist 23 | 24 | # A directory contains MOS system log files 25 | mos_log = logs/ 26 | 27 | ######################## 28 | ## NETWORK PARAMETERS ## 29 | ######################## 30 | # This to configure static arp table 31 | # (Destination IP address) (Destination MAC address) 32 | arp_table { 33 | } 34 | 35 | # This is to configure static routing table 36 | # (Destination address)/(Prefix) (Device name) 37 | route_table { 38 | } 39 | 40 | # This is to configure static bump-in-the-wire NIC forwarding table 41 | # DEVNIC_A DEVNIC_B ## (e.g. dpdk0 dpdk1) 42 | nic_forward_table { 43 | } 44 | 45 | ######################## 46 | ### ADVANCED OPTIONS ### 47 | ######################## 48 | # if required, uncomment the following options and change them 49 | 50 | # maximum concurrency per core [optional / default : 100000] 51 | # (MOS-specific parameter for preallocation) 52 | # max_concurrency = 100000 53 | 54 | # disable the ring buffer [optional / default : 0] 55 | # use disabled buffered managment only for standalone monitors. 56 | # end host applications always need recv buffers for TCP! 57 | # no_ring_buffers = 1 58 | 59 | # receive buffer size of sockets [optional / default : 8192] 60 | # rmem_size = 8192 61 | 62 | # send buffer size of sockets [optional / default : 8192] 63 | # wmem_size = 8192 64 | 65 | # tcp timewait seconds [optional / default : 0] 66 | # tcp_tw_interval = 30 67 | 68 | # tcp timeout seconds [optional / default : 30] 69 | # (set tcp_timeout = -1 to disable timeout checking) 70 | # tcp_timeout = 30 71 | } 72 | -------------------------------------------------------------------------------- /core/src/include/tcp_out.h: -------------------------------------------------------------------------------- 1 | #ifndef __TCP_OUT_H_ 2 | #define __TCP_OUT_H_ 3 | 4 | #include "mtcp.h" 5 | #include "tcp_stream.h" 6 | 7 | enum ack_opt 8 | { 9 | ACK_OPT_NOW, 10 | ACK_OPT_AGGREGATE, 11 | ACK_OPT_WACK 12 | }; 13 | 14 | int 15 | SendTCPPacketStandalone(struct mtcp_manager *mtcp, 16 | uint32_t saddr, uint16_t sport, uint32_t daddr, uint16_t dport, 17 | uint32_t seq, uint32_t ack_seq, uint16_t window, uint8_t flags, 18 | uint8_t *payload, uint16_t payloadlen, 19 | uint32_t cur_ts, uint32_t echo_ts, uint16_t ip_id, int8_t in_ifidx); 20 | 21 | int 22 | SendTCPPacket(struct mtcp_manager *mtcp, tcp_stream *cur_stream, 23 | uint32_t cur_ts, uint8_t flags, uint8_t *payload, uint16_t payloadlen); 24 | 25 | extern inline int 26 | WriteTCPControlList(mtcp_manager_t mtcp, 27 | struct mtcp_sender *sender, uint32_t cur_ts, int thresh); 28 | 29 | extern inline int 30 | WriteTCPDataList(mtcp_manager_t mtcp, 31 | struct mtcp_sender *sender, uint32_t cur_ts, int thresh); 32 | 33 | extern inline int 34 | WriteTCPACKList(mtcp_manager_t mtcp, 35 | struct mtcp_sender *sender, uint32_t cur_ts, int thresh); 36 | 37 | extern inline void 38 | AddtoControlList(mtcp_manager_t mtcp, tcp_stream *cur_stream, uint32_t cur_ts); 39 | 40 | extern inline void 41 | AddtoSendList(mtcp_manager_t mtcp, tcp_stream *cur_stream); 42 | 43 | extern inline void 44 | RemoveFromControlList(mtcp_manager_t mtcp, tcp_stream *cur_stream); 45 | 46 | extern inline void 47 | RemoveFromSendList(mtcp_manager_t mtcp, tcp_stream *cur_stream); 48 | 49 | extern inline void 50 | RemoveFromACKList(mtcp_manager_t mtcp, tcp_stream *cur_stream); 51 | 52 | extern inline void 53 | EnqueueACK(mtcp_manager_t mtcp, 54 | tcp_stream *cur_stream, uint32_t cur_ts, uint8_t opt); 55 | 56 | extern inline void 57 | DumpControlList(mtcp_manager_t mtcp, struct mtcp_sender *sender); 58 | 59 | void 60 | UpdatePassiveSendTCPContext(mtcp_manager_t mtcp, struct tcp_stream *cur_stream, 61 | struct pkt_ctx *pctx); 62 | 63 | void 64 | PostSendTCPAction(mtcp_manager_t mtcp, struct pkt_ctx *pctx, 65 | struct tcp_stream *recvside_stream, 66 | struct tcp_stream *sendside_stream); 67 | 68 | #endif /* __TCP_OUT_H_ */ 69 | --------------------------------------------------------------------------------