doc: update README and LICENSE

This commit is contained in:
lohhiiccc 2026-03-19 01:45:21 +01:00
parent 18432a527c
commit afe7e53e5b
2 changed files with 94 additions and 5 deletions

View file

@ -631,7 +631,7 @@ to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
ft_ping - TODO
net-tools - ICMPv4 network utilities
Copyright (C) 2026
This program is free software: you can redistribute it and/or modify

View file

@ -1,10 +1,99 @@
# ft_ping
# net-tools
TODO
A collection of ICMPv4 network utilities as an alternative to standard
system commands (ping, ...).
### Code Style
## Code Style
TODO
- Allman braces: opening and closing braces each on their own line
- Yoda conditions: constant on the left (e.g. 0 == val, NULL != ptr)
- C99 compliant
- Tabs only, width 4
- snake_case for functions and variables, SCREAMING_SNAKE_CASE for macros
- System includes, then a blank line, then local includes
- Variable declarations aligned with tabs within the function body
- Static helper functions are forward-declared at the top of the file and
defined after the main public function
- Function definitions (not forward declarations or prototypes) have a newline
between the return type and the function name
- Line continuations are indented 2 tabs past the base scope indentation
## Dependencies
- clang (C99)
- make
- bash (configure script)
- POSIX-compliant OS
- libc
For tests only:
- criterion
## Binaries
### ft_ping
Alternative to inetutils ping. Sends ICMPv4 ECHO_REQUEST packets to network
hosts and reports RTT statistics. Requires root (raw socket).
```
ft_ping - Send ICMP ECHO_REQUEST to network hosts
Usage: ft_ping [options] <destination>
Options:
-h, --help Display this help and exit
-V, --version Display version information and exit
-v, --verbose Verbose output
-q, --quiet Quiet mode (only show summary)
-c, --count <NUM> Stop after sending N packets
-i, --interval <SEC> Wait N seconds between packets
-t, --ttl <TTL> Set Time To Live
-s, --size <SIZE> Packet size in bytes
-W, --timeout <SEC> Timeout for replies in seconds
-w, --deadline <SEC> Exit after N seconds regardless of packets sent/received
-f, --flood Flood mode
-M, --dont-fragment Set the Don't Fragment bit
```
## Modules
### libicmp
Handles everything ICMP at the socket level: open a raw socket, build and
send echo requests, receive and parse replies. No loop, no display. Just a
clean interface over the kernel socket.
### src/cli
Shared CLI parsing layer used by all binaries. Provides a generic getopt
wrapper and primitive parsers (int, float) that each binary plugs into.
### src/<binary>/cli
Per-binary argument parsing. Defines the accepted options, validates them,
and fills the binary-specific config struct.
### src/ping/core
Drives the ping session for one destination. ping_run() creates the socket
and calls ping_one() for each destination. ping_one() sets up state, runs
the loop, and prints the summary. ping_loop() uses select() to wait for
packets and reacts to send/stop flags. ping_send_one() builds the payload
and calls libicmp. ping_callback() handles incoming replies and errors.
### src/ping/scheduler
Manages timing and signals. Installs SIGALRM (triggers send) and SIGINT
(triggers stop). Arms a one-shot timer via setitimer() after each send.
Signal handlers only write a flag -- the loop does the actual work.
### src/ping/tracker
A 128-slot circular buffer indexed by (seq % 128). Records when each
packet was sent and marks it when a reply arrives. Used to compute RTT
and detect duplicates.
### src/ping/stats
Accumulates RTT samples (min, max, sum, sum of squares) in nanoseconds.
Computes min/avg/max/mdev in milliseconds on demand.
### src/ping/output
All user-facing output: the opening line, per-packet lines, ICMP error
messages, the final statistics summary, and flood mode dots.
## License