Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
downdemo committed Jul 29, 2024
1 parent 8b10e95 commit d744ebd
Show file tree
Hide file tree
Showing 44 changed files with 3,234 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/pipeline-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: SNET-CI

on:
push:
branches: [master, release/**]
pull_request:
branches: [master, release/**]

env:
BUILD_TYPE: Release

jobs:
run-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}

- name: install gcc
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
sudo apt update
sudo apt install -y gcc-11 g++-11 gcc-12 g++-12 gcc-13 g++-13
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 1
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 1
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 1
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 1
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 1
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 1
- name: check compiler versions
run: |
g++-11 --version
g++-12 --version
g++-13 --version
- name: build with gcc 11
run: |
sudo update-alternatives --set gcc /usr/bin/gcc-11
sudo update-alternatives --set g++ /usr/bin/g++-11
make -j BUILD_TYPE=${BUILD_TYPE}
ls lib
ls bin
- name: build with gcc 12
run: |
sudo update-alternatives --set gcc /usr/bin/gcc-12
sudo update-alternatives --set g++ /usr/bin/g++-12
make -j BUILD_TYPE=${BUILD_TYPE}
ls lib
ls bin
- name: build with gcc 13
run: |
sudo update-alternatives --set gcc /usr/bin/gcc-13
sudo update-alternatives --set g++ /usr/bin/g++-13
make -j BUILD_TYPE=${BUILD_TYPE}
ls lib
ls bin
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.vscode
build
debug
lib
bin
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
language: cpp
dist: jammy
script:
- make
73 changes: 73 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
$(shell if [ -e lib ]; then rm -rf lib; fi; mkdir lib)
$(shell if [ -e bin ]; then rm -rf bin; fi; mkdir bin)
CXX = g++
CXXFLAGS = -std=c++20 -Wall
LDFLAGS = -Isrc -Llib -lsnet -lpthread -Wl,-rpath=lib
BUILD_TYPE=Release

ifeq ($(BUILD_TYPE), Release)
CXXFLAGS += -O2 -DNDEBUG
else
CXXFLAGS += -O0 -g
endif

all: libsnet.so \
test_epoll_connection \
test_epoll_ping_pong \
test_epoll_timer \
test_poll_connection \
test_poll_ping_pong \
test_poll_timer \
test_select_connection \
test_select_ping_pong \
test_select_timer \
test_tcp_connection \
test_tcp_ping_pong \
test_udp_recv \
test_tcp_connection_fork \

libsnet.so: src/net/*.cpp
$(CXX) $(CXXFLAGS) -shared -fpic -Isrc src/net/*.cpp -o lib/libsnet.so

test_epoll_connection: test/test_epoll_connection.cpp libsnet.so
$(CXX) $(CXXFLAGS) test/test_epoll_connection.cpp $(LDFLAGS) -o bin/test_epoll_connection

test_epoll_ping_pong: test/test_epoll_ping_pong.cpp libsnet.so
$(CXX) $(CXXFLAGS) test/test_epoll_ping_pong.cpp $(LDFLAGS) -o bin/test_epoll_ping_pong

test_epoll_timer: test/test_epoll_timer.cpp libsnet.so
$(CXX) $(CXXFLAGS) test/test_epoll_timer.cpp $(LDFLAGS) -o bin/test_epoll_timer

test_poll_connection: test/test_poll_connection.cpp libsnet.so
$(CXX) $(CXXFLAGS) test/test_poll_connection.cpp $(LDFLAGS) -o bin/test_poll_connection

test_poll_ping_pong: test/test_poll_ping_pong.cpp libsnet.so
$(CXX) $(CXXFLAGS) test/test_poll_ping_pong.cpp $(LDFLAGS) -o bin/test_poll_ping_pong

test_poll_timer: test/test_poll_timer.cpp libsnet.so
$(CXX) $(CXXFLAGS) test/test_poll_timer.cpp $(LDFLAGS) -o bin/test_poll_timer

test_select_connection: test/test_select_connection.cpp libsnet.so
$(CXX) $(CXXFLAGS) test/test_select_connection.cpp $(LDFLAGS) -o bin/test_select_connection

test_select_ping_pong: test/test_select_ping_pong.cpp libsnet.so
$(CXX) $(CXXFLAGS) test/test_select_ping_pong.cpp $(LDFLAGS) -o bin/test_select_ping_pong

test_select_timer: test/test_select_timer.cpp libsnet.so
$(CXX) $(CXXFLAGS) test/test_select_timer.cpp $(LDFLAGS) -o bin/test_select_timer

test_tcp_connection: test/test_tcp_connection.cpp libsnet.so
$(CXX) $(CXXFLAGS) test/test_tcp_connection.cpp $(LDFLAGS) -o bin/test_tcp_connection

test_tcp_ping_pong: test/test_tcp_ping_pong.cpp libsnet.so
$(CXX) $(CXXFLAGS) test/test_tcp_ping_pong.cpp $(LDFLAGS) -o bin/test_tcp_ping_pong

test_udp_recv: test/test_udp_recv.cpp libsnet.so
$(CXX) $(CXXFLAGS) test/test_udp_recv.cpp $(LDFLAGS) -o bin/test_udp_recv

test_tcp_connection_fork: test/test_tcp_connection_fork.cpp libsnet.so
$(CXX) $(CXXFLAGS) test/test_tcp_connection_fork.cpp $(LDFLAGS) -o bin/test_tcp_connection_fork

clean:
rm -rf lib
rm -rf bin
67 changes: 67 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
![Supported Platforms](https://img.shields.io/badge/platform-Linux-red.svg)
[![SNET-CI](https://github.com/downdemo/SNET/actions/workflows/pipeline-ci.yml/badge.svg)](https://github.com/downdemo/SNET/actions/workflows/pipeline-ci.yml)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/downdemo/SNET/blob/master/LICENSE)

## Documentation

* [tcpdump](docs/tcpdump.md)
* [Network I/O mode](docs/network_io_mode.md)
* [Socket API](docs/socket_api.md)
* [I/O multiplexing API](docs/io_multiplexing_api.md)

## Build

```sh
make
```

## [RFC](https://www.rfc-editor.org/)

* Ethernet: [RFC 894, A Standard for the Transmission of IP Datagrams over Ethernet Networks](https://www.rfc-editor.org/rfc/rfc894.html)
* ARP: [RFC 826, An Ethernet Address Resolution Protocol](https://www.rfc-editor.org/rfc/rfc826.html)
* PPP: [RFC 1661, The Point-to-Point Protocol (PPP)](https://www.rfc-editor.org/rfc/rfc1661.html)
* PPPoE: [RFC 2516, A Method for Transmitting PPP Over Ethernet (PPPoE)](https://www.rfc-editor.org/rfc/rfc2516.html)
* ICMPv4: [RFC 792, INTERNET CONTROL MESSAGE PROTOCOL](https://www.rfc-editor.org/rfc/rfc792.html)
* ICMPv6: [RFC 2463, Internet Control Message Protocol (ICMPv6)](https://www.rfc-editor.org/rfc/rfc2463.html)
* IPv4: [RFC 791, INTERNET PROTOCOL](https://www.rfc-editor.org/rfc/rfc791.html)
* IPv6: [RFC 8200, Internet Protocol, Version 6 (IPv6) Specification](https://www.rfc-editor.org/rfc/rfc8200.html)
* IANA IPv4 Address Space Registry: [RFC 1466, Guidelines for Management of IP Address Space](https://www.rfc-editor.org/rfc/rfc1466.html)
* Private IPv4 addresses: [RFC 1918, Address Allocation for Private Internets](https://www.rfc-editor.org/rfc/rfc1918.html)
* Private IPv6 addresses: [RFC 4193, Unique Local IPv6 Unicast Addresses](https://www.rfc-editor.org/rfc/rfc4193.html)
* NAT: [RFC 2663, IP Network Address Translator (NAT) Terminology and Considerations](https://www.rfc-editor.org/rfc/rfc2663.html)
* IGMPv3: [RFC 3376, Internet Group Management Protocol, Version 3](https://www.rfc-editor.org/rfc/rfc3376.html)
* IPSec: [RFC 2401, Security Architecture for the Internet Protocol](https://www.rfc-editor.org/rfc/rfc2401.html)
* PPTP: [RFC 2637, Point-to-Point Tunneling Protocol (PPTP)](https://www.rfc-editor.org/rfc/rfc2637.html)
* L2TP: [RFC 2661, Layer Two Tunneling Protocol "L2TP"](https://www.rfc-editor.org/rfc/rfc2661.html)
* TCP: [RFC 793, TRANSMISSION CONTROL PROTOCOL](https://www.rfc-editor.org/rfc/rfc793.html)
* TCP Extensions: [RFC 1323, TCP Extensions for High Performance](https://www.rfc-editor.org/rfc/rfc1323.html)
* UDP: [RFC 768, User Datagram Protocol](https://www.rfc-editor.org/rfc/rfc768.html)
* SOCKS5: [RFC 1928, SOCKS Protocol Version 5](https://www.rfc-editor.org/rfc/rfc1928.html)
* PNG: [RFC 2083, PNG (Portable Network Graphics) Specification Version 1.0](https://www.rfc-editor.org/rfc/rfc2083.html)
* JSON: [RFC 7159, The JavaScript Object Notation (JSON) Data Interchange Format](https://www.rfc-editor.org/rfc/rfc7159.html)
* SIP: [RFC 3261, SIP: Session Initiation Protocol](https://www.rfc-editor.org/rfc/rfc3261.html)
* RTP: [RFC 3550, RTP: A Transport Protocol for Real-Time Applications](https://www.rfc-editor.org/rfc/rfc3550.html)
* SSL: [RFC 6101, The Secure Sockets Layer (SSL) Protocol Version 3.0](https://www.rfc-editor.org/rfc/rfc6101.html)
* TLS 1.3: [RFC 8446, The Transport Layer Security (TLS) Protocol Version 1.3](https://www.rfc-editor.org/rfc/rfc8446.html)
* X.509: [RFC 8017, Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile](https://www.rfc-editor.org/rfc/rfc5280.html)
* PKCS #1: [RFC 8017, PKCS #1: RSA Cryptography Specifications Version 2.2](https://www.rfc-editor.org/rfc/rfc8017.html)
* PKCS #8: [RFC 5208, Public-Key Cryptography Standards (PKCS) #8: Private-Key Information Syntax Specification Version 1.2](https://www.rfc-editor.org/rfc/rfc5208.html)
* PKCS #12: [RFC 7972, PKCS #12: Personal Information Exchange Syntax v1.1](https://www.rfc-editor.org/rfc/rfc7292.html)
* HTTP/1.1: [RFC 7230, Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing](https://www.rfc-editor.org/rfc/rfc7230.html)
* HTTP/2: [RFC 7540, Hypertext Transfer Protocol Version 2 (HTTP/2)](https://www.rfc-editor.org/rfc/rfc7540.html)
* HTTP/3: [RFC 9114, HTTP/3](https://www.rfc-editor.org/rfc/rfc9114.html)
* QUIC: [RFC 9000, QUIC: A UDP-Based Multiplexed and Secure Transport](https://www.rfc-editor.org/rfc/rfc9000.html)
* HTTPS: [RFC 2818, HTTP Over TLS](https://www.rfc-editor.org/rfc/rfc2818.html)
* WebSocket: [RFC 6455, The WebSocket Protocol](https://www.rfc-editor.org/rfc/rfc6455.html)
* TELNET: [RFC 854, TELNET PROTOCOL SPECIFICATION](https://www.rfc-editor.org/rfc/rfc854.html)
* SSH: [RFC 4254, The Secure Shell (SSH) Connection Protocol](https://www.rfc-editor.org/rfc/rfc4254.html)
* DNS: [RFC 1034, DOMAIN NAMES](https://www.rfc-editor.org/rfc/rfc1034.html)
* DHCP: [RFC 2131, Dynamic Host Configuration Protocol](https://www.rfc-editor.org/rfc/rfc2131.html)
* NTP: [RFC 1305, Network Time Protocol (Version 3)](https://www.rfc-editor.org/rfc/rfc1305.html)
* TZif: [RFC 8536, The Time Zone Information Format (TZif)](https://www.rfc-editor.org/rfc/rfc8536.html)
* FTP: [RFC 959, FILE TRANSFER PROTOCOL (FTP)](https://www.rfc-editor.org/rfc/rfc959.html)
* NFSv4.2: [RFC 7862, Network File System (NFS) Version 4 Minor Version 2 Protocol](https://www.rfc-editor.org/rfc/rfc7862.html)
* NNTP: [RFC 977, Network News Transfer Protocol](https://www.rfc-editor.org/rfc/rfc977.html)
* POP3: [RFC 1939, Post Office Protocol - Version 3](https://www.rfc-editor.org/rfc/rfc1939.html)
* IMAP4: [RFC 1730, INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4](https://www.rfc-editor.org/rfc/rfc1730.html)
* SMTP: [RFC 2821, Simple Mail Transfer Protocol](https://www.rfc-editor.org/rfc/rfc2821.html)
1 change: 1 addition & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
theme: jekyll-theme-hacker
67 changes: 67 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
![Supported Platforms](https://img.shields.io/badge/platform-Linux-red.svg)
[![SNET-CI](https://github.com/downdemo/SNET/actions/workflows/pipeline-ci.yml/badge.svg)](https://github.com/downdemo/SNET/actions/workflows/pipeline-ci.yml)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/downdemo/SNET/blob/master/LICENSE)

## Documentation

* [tcpdump](tcpdump.html)
* [Network I/O mode](network_io_mode.html)
* [Socket API](socket_api.html)
* [I/O multiplexing API](io_multiplexing_api.html)

## Build

```sh
make
```

## [RFC](https://www.rfc-editor.org/)

* Ethernet: [RFC 894, A Standard for the Transmission of IP Datagrams over Ethernet Networks](https://www.rfc-editor.org/rfc/rfc894.html)
* ARP: [RFC 826, An Ethernet Address Resolution Protocol](https://www.rfc-editor.org/rfc/rfc826.html)
* PPP: [RFC 1661, The Point-to-Point Protocol (PPP)](https://www.rfc-editor.org/rfc/rfc1661.html)
* PPPoE: [RFC 2516, A Method for Transmitting PPP Over Ethernet (PPPoE)](https://www.rfc-editor.org/rfc/rfc2516.html)
* ICMPv4: [RFC 792, INTERNET CONTROL MESSAGE PROTOCOL](https://www.rfc-editor.org/rfc/rfc792.html)
* ICMPv6: [RFC 2463, Internet Control Message Protocol (ICMPv6)](https://www.rfc-editor.org/rfc/rfc2463.html)
* IPv4: [RFC 791, INTERNET PROTOCOL](https://www.rfc-editor.org/rfc/rfc791.html)
* IPv6: [RFC 8200, Internet Protocol, Version 6 (IPv6) Specification](https://www.rfc-editor.org/rfc/rfc8200.html)
* IANA IPv4 Address Space Registry: [RFC 1466, Guidelines for Management of IP Address Space](https://www.rfc-editor.org/rfc/rfc1466.html)
* Private IPv4 addresses: [RFC 1918, Address Allocation for Private Internets](https://www.rfc-editor.org/rfc/rfc1918.html)
* Private IPv6 addresses: [RFC 4193, Unique Local IPv6 Unicast Addresses](https://www.rfc-editor.org/rfc/rfc4193.html)
* NAT: [RFC 2663, IP Network Address Translator (NAT) Terminology and Considerations](https://www.rfc-editor.org/rfc/rfc2663.html)
* IGMPv3: [RFC 3376, Internet Group Management Protocol, Version 3](https://www.rfc-editor.org/rfc/rfc3376.html)
* IPSec: [RFC 2401, Security Architecture for the Internet Protocol](https://www.rfc-editor.org/rfc/rfc2401.html)
* PPTP: [RFC 2637, Point-to-Point Tunneling Protocol (PPTP)](https://www.rfc-editor.org/rfc/rfc2637.html)
* L2TP: [RFC 2661, Layer Two Tunneling Protocol "L2TP"](https://www.rfc-editor.org/rfc/rfc2661.html)
* TCP: [RFC 793, TRANSMISSION CONTROL PROTOCOL](https://www.rfc-editor.org/rfc/rfc793.html)
* TCP Extensions: [RFC 1323, TCP Extensions for High Performance](https://www.rfc-editor.org/rfc/rfc1323.html)
* UDP: [RFC 768, User Datagram Protocol](https://www.rfc-editor.org/rfc/rfc768.html)
* SOCKS5: [RFC 1928, SOCKS Protocol Version 5](https://www.rfc-editor.org/rfc/rfc1928.html)
* PNG: [RFC 2083, PNG (Portable Network Graphics) Specification Version 1.0](https://www.rfc-editor.org/rfc/rfc2083.html)
* JSON: [RFC 7159, The JavaScript Object Notation (JSON) Data Interchange Format](https://www.rfc-editor.org/rfc/rfc7159.html)
* SIP: [RFC 3261, SIP: Session Initiation Protocol](https://www.rfc-editor.org/rfc/rfc3261.html)
* RTP: [RFC 3550, RTP: A Transport Protocol for Real-Time Applications](https://www.rfc-editor.org/rfc/rfc3550.html)
* SSL: [RFC 6101, The Secure Sockets Layer (SSL) Protocol Version 3.0](https://www.rfc-editor.org/rfc/rfc6101.html)
* TLS 1.3: [RFC 8446, The Transport Layer Security (TLS) Protocol Version 1.3](https://www.rfc-editor.org/rfc/rfc8446.html)
* X.509: [RFC 8017, Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile](https://www.rfc-editor.org/rfc/rfc5280.html)
* PKCS #1: [RFC 8017, PKCS #1: RSA Cryptography Specifications Version 2.2](https://www.rfc-editor.org/rfc/rfc8017.html)
* PKCS #8: [RFC 5208, Public-Key Cryptography Standards (PKCS) #8: Private-Key Information Syntax Specification Version 1.2](https://www.rfc-editor.org/rfc/rfc5208.html)
* PKCS #12: [RFC 7972, PKCS #12: Personal Information Exchange Syntax v1.1](https://www.rfc-editor.org/rfc/rfc7292.html)
* HTTP/1.1: [RFC 7230, Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing](https://www.rfc-editor.org/rfc/rfc7230.html)
* HTTP/2: [RFC 7540, Hypertext Transfer Protocol Version 2 (HTTP/2)](https://www.rfc-editor.org/rfc/rfc7540.html)
* HTTP/3: [RFC 9114, HTTP/3](https://www.rfc-editor.org/rfc/rfc9114.html)
* QUIC: [RFC 9000, QUIC: A UDP-Based Multiplexed and Secure Transport](https://www.rfc-editor.org/rfc/rfc9000.html)
* HTTPS: [RFC 2818, HTTP Over TLS](https://www.rfc-editor.org/rfc/rfc2818.html)
* WebSocket: [RFC 6455, The WebSocket Protocol](https://www.rfc-editor.org/rfc/rfc6455.html)
* TELNET: [RFC 854, TELNET PROTOCOL SPECIFICATION](https://www.rfc-editor.org/rfc/rfc854.html)
* SSH: [RFC 4254, The Secure Shell (SSH) Connection Protocol](https://www.rfc-editor.org/rfc/rfc4254.html)
* DNS: [RFC 1034, DOMAIN NAMES](https://www.rfc-editor.org/rfc/rfc1034.html)
* DHCP: [RFC 2131, Dynamic Host Configuration Protocol](https://www.rfc-editor.org/rfc/rfc2131.html)
* NTP: [RFC 1305, Network Time Protocol (Version 3)](https://www.rfc-editor.org/rfc/rfc1305.html)
* TZif: [RFC 8536, The Time Zone Information Format (TZif)](https://www.rfc-editor.org/rfc/rfc8536.html)
* FTP: [RFC 959, FILE TRANSFER PROTOCOL (FTP)](https://www.rfc-editor.org/rfc/rfc959.html)
* NFSv4.2: [RFC 7862, Network File System (NFS) Version 4 Minor Version 2 Protocol](https://www.rfc-editor.org/rfc/rfc7862.html)
* NNTP: [RFC 977, Network News Transfer Protocol](https://www.rfc-editor.org/rfc/rfc977.html)
* POP3: [RFC 1939, Post Office Protocol - Version 3](https://www.rfc-editor.org/rfc/rfc1939.html)
* IMAP4: [RFC 1730, INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4](https://www.rfc-editor.org/rfc/rfc1730.html)
* SMTP: [RFC 2821, Simple Mail Transfer Protocol](https://www.rfc-editor.org/rfc/rfc2821.html)
Loading

0 comments on commit d744ebd

Please sign in to comment.