Skip to content

Commit a3a321f

Browse files
committed
Initial import from internal tree
0 parents  commit a3a321f

File tree

15 files changed

+480
-0
lines changed

15 files changed

+480
-0
lines changed

.clang-format

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
BasedOnStyle: Chromium
2+
Language: Cpp
3+
MaxEmptyLinesToKeep: 3
4+
IndentCaseLabels: false
5+
AllowShortIfStatementsOnASingleLine: false
6+
AllowShortCaseLabelsOnASingleLine: false
7+
AllowShortLoopsOnASingleLine: false
8+
DerivePointerAlignment: false
9+
PointerAlignment: Right
10+
SpaceAfterCStyleCast: true
11+
TabWidth: 4
12+
UseTab: Never
13+
IndentWidth: 4
14+
BreakBeforeBraces: Linux
15+
AccessModifierOffset: -4
16+
ForEachMacros:
17+
- foreach
18+
- Q_FOREACH
19+
- BOOST_FOREACH
20+
- list_for_each
21+
- list_for_each_safe
22+
- list_for_each_entry
23+
- list_for_each_entry_safe
24+
- hlist_for_each_entry
25+
- rb_list_foreach
26+
- rb_list_foreach_safe
27+
- vec_foreach

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# kernel module compile output
2+
*.ko.cmd
3+
*.o.cmd
4+
.tmp_versions
5+
*.symvers
6+
*.mod.c
7+
*.mod.o
8+
*.order
9+
*.o
10+
*.ko
11+
12+
# Other
13+
http_parser.c
14+
http_parser.h

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (C) 2020 National Cheng Kung University, Taiwan.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
CFILES = main.c http_server.c http_parser.c
2+
3+
obj-m += khttpd.o
4+
khttpd-objs := $(CFILES:.c=.o)
5+
6+
all: http_parser.c
7+
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
8+
9+
clean:
10+
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
11+
12+
http_parser.c:
13+
wget https://raw.githubusercontent.com/nodejs/http-parser/master/http_parser.c
14+
sed -i 's/#include <assert.h>/#include "compat\/assert.h"/' $@
15+
sed -i 's/#include <stddef.h>/#include "compat\/stddef.h"/' $@
16+
sed -i 's/#include <ctype.h>/#include "compat\/ctype.h"/' $@
17+
sed -i 's/#include <string.h>/#include "compat\/string.h"/' $@
18+
sed -i 's/#include <limits.h>/#include "compat\/limits.h"/' $@
19+
wget https://raw.githubusercontent.com/nodejs/http-parser/master/http_parser.h
20+
sed -i 's/#include <stddef.h>/#include "compat\/stddef.h"/' http_parser.h
21+
sed -i 's/#include <stdint.h>/#include "compat\/stdint.h"/' http_parser.h
22+
23+
distclean: clean
24+
$(RM) http_parser.c http_parser.h

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# khttpd
2+
3+
`khttpd` is an experimental HTTP server implemented as Linux kernel module.
4+
The server defaults to port 8081 but this can be easily configured using command line arguments to the LKM.
5+
6+
## TODO
7+
* Request queue and/or cache
8+
* Slab cache
9+
* Kthread pool
10+
* Dynamic framework
11+
* Reverse proxy
12+
13+
## License
14+
15+
`khttpdc`is released under the MIT License. Use of this source code is governed by
16+
a MIT License that can be found in the LICENSE file.
17+

common.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#ifndef KHTTPD_COMMON_H
2+
#define KHTTPD_COMMON_H
3+
4+
#include "http_parser.h"
5+
#include "http_server.h"
6+
7+
#define MODULE_NAME "khttpd"
8+
9+
#endif

compat/assert.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef COMPAT_ASSERT_H
2+
#define COMPAT_ASSERT_H
3+
4+
static inline void assert(int x) {};
5+
6+
#endif

compat/ctype.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* Dummy */

compat/limits.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* Dummy */

compat/stddef.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#include <linux/types.h>
2+
#include <linux/kernel.h>

0 commit comments

Comments
 (0)