diff options
author | dzwdz | 2022-08-20 15:05:19 +0200 |
---|---|---|
committer | dzwdz | 2022-08-20 15:05:19 +0200 |
commit | 7519e57749e176be60b7185d7bbdc298b1744c3c (patch) | |
tree | f320249b75a90a016451acab06c09dbcefdbc89a /src/user/app/ethdump/proto.h | |
parent | f22f019aeba00ccb3cc35fe763c3e87bf5690040 (diff) |
user/ethdump: UDP support
Diffstat (limited to 'src/user/app/ethdump/proto.h')
-rw-r--r-- | src/user/app/ethdump/proto.h | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/user/app/ethdump/proto.h b/src/user/app/ethdump/proto.h index 21057a2..9bd6936 100644 --- a/src/user/app/ethdump/proto.h +++ b/src/user/app/ethdump/proto.h @@ -1,5 +1,6 @@ #pragma once #include <camellia/types.h> +#include <stdbool.h> #include <stdint.h> typedef uint8_t mac_t[6]; @@ -26,6 +27,7 @@ struct ipv4 { struct ethernet e; uint32_t src, dst; uint8_t proto; + uint8_t *header; size_t hlen; }; struct icmp { @@ -34,20 +36,19 @@ struct icmp { }; -/* NOT THREADSAFE, YET USED FROM THREADS +/* NOT THREADSAFE, YET USED FROM CONCURRENT THREADS * will break if i implement a scheduler*/ -struct queue_entry { +struct ethq { + struct ethq *next; handle_t h; - struct queue_entry *next; }; -extern struct queue_entry *ether_queue; - +extern struct ethq *ether_queue; void arp_parse(const uint8_t *buf, size_t len); void icmp_parse(const uint8_t *buf, size_t len, struct ipv4 ip); uint8_t *icmp_start(size_t len, struct icmp i); -void icmp_finish(uint8_t *pkt); +void icmp_finish(uint8_t *pkt, size_t len); void ipv4_parse(const uint8_t *buf, size_t len, struct ethernet ether); uint8_t *ipv4_start(size_t len, struct ipv4 ip); @@ -56,3 +57,15 @@ void ipv4_finish(uint8_t *pkt); void ether_parse(const uint8_t *buf, size_t len); uint8_t *ether_start(size_t len, struct ethernet ether); void ether_finish(uint8_t *pkt); + +struct udp_conn; +void udp_parse(const uint8_t *buf, size_t len, struct ipv4 ip); +/* calls callback once, after a client connects. */ +void udp_listen(uint16_t port, + void (*on_conn)(struct udp_conn *, void *carg), + void (*on_recv)(const void *, size_t, void *carg), + void *carg); +// TODO udp_onclosed +void udpc_send(struct udp_conn *, const void *buf, size_t len); +/* frees */ +void udpc_close(struct udp_conn *); |