aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / native / net / aienos_report.h
| 1 | /* aienos_report.h -- a machine's boot report as UDP broadcast datagrams, so |
| 2 | * the owner does not have to photograph the screen. Same wire format as the |
| 3 | * iMac report (native/kernel/x86/report_x86.c), with the first word as a |
| 4 | * parameter: each datagram goes from 0.0.0.0:PORT to 255.255.255.255:PORT in |
| 5 | * an Ethernet broadcast frame (TTL 1, nothing to configure or answer) and |
| 6 | * starts with one header line |
| 7 | * "<TAG> v=1 run=<16 hex> part=<i>/<n> bytes=<total>\n" |
| 8 | * followed by bytes [i*CHUNK, i*CHUNK + CHUNK) of the report. |
| 9 | * Pure functions: no device, no clock, no heap. */ |
| 10 | #ifndef AIENOS_NET_REPORT_H |
| 11 | #define AIENOS_NET_REPORT_H |
| 12 | #include <stddef.h> |
| 13 | #include <stdint.h> |
| 14 | |
| 15 | #define NET_REPORT_PORT 47031u /* UDP, source and destination (the iMac's port) */ |
| 16 | #define NET_REPORT_CHUNK 1024u /* report bytes per datagram */ |
| 17 | #define NET_REPORT_MAX 65536u /* largest report */ |
| 18 | #define NET_REPORT_TAG_SPARK "AIENUX-SPARK-REPORT" |
| 19 | #define NET_REPORT_TAG_MAX 32u |
| 20 | |
| 21 | typedef struct { |
| 22 | uint64_t run; |
| 23 | unsigned part, parts; |
| 24 | size_t total; /* report bytes in all parts */ |
| 25 | size_t offset; /* where this part's data goes */ |
| 26 | const uint8_t *data; /* view into the frame */ |
| 27 | size_t len; |
| 28 | } net_report_part; |
| 29 | |
| 30 | /* Datagrams needed for a report of len bytes; 0 when len is 0 or too big. */ |
| 31 | unsigned net_report_parts(size_t len); |
| 32 | /* Ethernet frame (no FCS) carrying part `part` of the report, broadcast from |
| 33 | * `mac`. Bytes written, 0 on a bad argument or a buffer too small. */ |
| 34 | size_t net_report_frame(const char *tag, const uint8_t mac[6], uint64_t run, const char *log, size_t len, |
| 35 | unsigned part, uint8_t *out, size_t cap); |
| 36 | /* Parse one received Ethernet frame. 0 and *out filled when it is a part of |
| 37 | * a `tag` report whose header, ports, checksums and lengths all agree; |
| 38 | * negative otherwise. */ |
| 39 | int net_report_parse(const char *tag, const uint8_t *frame, size_t n, net_report_part *out); |
| 40 | #endif |