The stack surface of the platform, over idemIP: the protocore_net_* names that the transport calls. More...
#include <stddef.h>#include <stdint.h>#include "embed_compiler_directives.h"#include "embed_types.h"Go to the source code of this file.
Classes | |
| struct | protocore_net_ip |
| struct | protocore_pbuf |
| struct | StackNetConnectWait |
| struct | protocore_pcb |
| struct | protocore_udp_pcb |
| struct | protocore_net_call |
| The record that a call of the stack carries, as the transport embeds it. More... | |
Typedefs | |
| typedef struct protocore_pbuf | protocore_pbuf |
| typedef struct protocore_pcb | protocore_pcb |
| typedef struct protocore_udp_pcb | protocore_udp_pcb |
| typedef protocore_net_err(* | protocore_net_recv_fn) (void *, protocore_pcb *, protocore_pbuf *, protocore_net_err) |
| typedef protocore_net_err(* | protocore_net_sent_fn) (void *, protocore_pcb *, uint16_t) |
| typedef protocore_net_err(* | protocore_net_accept_fn) (void *, protocore_pcb *, protocore_net_err) |
| typedef protocore_net_err(* | protocore_net_connect_fn) (void *, protocore_pcb *, protocore_net_err) |
| typedef void(* | protocore_net_err_fn) (void *, protocore_net_err) |
| typedef void(* | protocore_net_udp_recv_fn) (void *, protocore_udp_pcb *, protocore_pbuf *, const protocore_net_ip *, uint16_t) |
| typedef struct protocore_net_call | protocore_net_call |
| The record that a call of the stack carries, as the transport embeds it. | |
| typedef void(* | protocore_net_dns_found_fn) (const char *, const protocore_net_ip *, void *) |
| The callback of a name that the resolver of the stack found, with a NULL address for none. | |
Functions | |
| uint32_t | protocore_net_ip4_u32 (const protocore_net_ip *a) |
The IPv4 address of a as the word that lwIP keeps: the four octets in network order in memory. | |
| void | protocore_net_ip4_set (protocore_net_ip *a, uint8_t b0, uint8_t b1, uint8_t b2, uint8_t b3) |
Set a to the IPv4 address b0.b1.b2.b3. | |
| int | protocore_net_ip4_is_multicast (const protocore_net_ip *a) |
1 when a is an IPv4 host group, 224.0.0.0/4. | |
| int | protocore_net_ip_parse (const char *s, protocore_net_ip *out) |
Parse the dotted quad s into out. 1 on success, and 0 otherwise. | |
| char * | protocore_net_ip_print (const protocore_net_ip *a, char *buf, int cap) |
The dotted quad of a in buf, of cap octets. | |
| protocore_pbuf * | protocore_net_pbuf_alloc (int layer, uint16_t len, int type) |
A packet buffer of len octets from the pool, or NULL when the pool is spent. | |
| uint8_t | protocore_net_pbuf_free (const protocore_pbuf *p) |
| Give a packet buffer back to the pool. | |
| uint16_t | protocore_net_pbuf_copy (const protocore_pbuf *p, void *dst, uint16_t len, uint16_t off) |
Copy at most len octets of p, from off, to dst. The octets copied. | |
| protocore_pcb * | protocore_net_new (int type) |
| protocore_net_err | protocore_net_bind (protocore_pcb *p, const protocore_net_ip *a, uint16_t port) |
| protocore_pcb * | protocore_net_listen (protocore_pcb *p, uint8_t backlog) |
| protocore_net_err | protocore_net_connect (protocore_pcb *p, const protocore_net_ip *a, uint16_t port, protocore_net_connect_fn connected) |
| protocore_net_err | protocore_net_close (protocore_pcb *p) |
| void | protocore_net_abort (protocore_pcb *p) |
| void | protocore_net_arg (protocore_pcb *p, void *arg) |
| void | protocore_net_on_recv (protocore_pcb *p, protocore_net_recv_fn fn) |
| void | protocore_net_on_sent (protocore_pcb *p, protocore_net_sent_fn fn) |
| void | protocore_net_on_accept (protocore_pcb *p, protocore_net_accept_fn fn) |
| void | protocore_net_on_err (protocore_pcb *p, protocore_net_err_fn fn) |
| protocore_net_err | protocore_net_write (protocore_pcb *p, const void *data, uint16_t len, uint8_t flags) |
| protocore_net_err | protocore_net_output (const protocore_pcb *p) |
| void | protocore_net_recved (const protocore_pcb *p, uint16_t len) |
| uint16_t | protocore_net_sndbuf (const protocore_pcb *p) |
| void | protocore_net_nagle_disable (const protocore_pcb *p) |
| void | protocore_net_rcv_wnd_update (const protocore_pcb *p, uint16_t len) |
| void | protocore_net_opt_set (void *p, uint32_t opt) |
| protocore_udp_pcb * | protocore_net_udp_new (void) |
| protocore_net_err | protocore_net_udp_bind (protocore_udp_pcb *p, const protocore_net_ip *a, uint16_t port) |
| void | protocore_net_udp_recv (protocore_udp_pcb *p, protocore_net_udp_recv_fn fn, void *arg) |
| protocore_net_err | protocore_net_udp_sendto (const protocore_udp_pcb *p, const protocore_pbuf *b, const protocore_net_ip *a, uint16_t port) |
| void | protocore_net_udp_remove (protocore_udp_pcb *p) |
| protocore_net_err | protocore_net_igmp_join (const protocore_net_ip *nif, const protocore_net_ip *grp) |
| protocore_net_err | protocore_net_igmp_leave (const protocore_net_ip *nif, const protocore_net_ip *grp) |
| protocore_net_err | protocore_net_call_marshal (protocore_net_err(*fn)(protocore_net_call *), protocore_net_call *c) |
Run fn on c under the lock of the stack, and return what it returns. | |
| protocore_net_err | protocore_net_dns_resolve (const char *host, protocore_net_ip *addr, protocore_net_dns_found_fn found, void *arg) |
Resolve host to addr, as dns_gethostbyname of lwIP does. | |
| void | protocore_stack_net_pass (uint32_t now_ms, uint32_t random_word) |
| One pass of the stack, under its lock: the units of idemIP, then each event of the TCP as a callback. | |
| int | protocore_stack_net_start (void) |
| Start the task of the stack, which runs protocore_stack_net_pass once each tick of the platform. | |
| void | protocore_stack_net_udp_input (const uint8_t *frame, uint16_t entry, size_t ip_off, size_t payload_off, size_t payload_len) |
| One UDP datagram that Dispatch delivered to a UdpPcb entry, to the callback of its control block. | |
Variables | |
| EMBED_BEGIN_DECLS typedef int8_t | protocore_net_err |
| The result of a call of the stack, as lwIP numbers it. | |
| const protocore_net_ip | protocore_stack_net_any |
| The any address, which a bind takes for each local address. | |
The stack surface of the platform, over idemIP: the protocore_net_* names that the transport calls.
With PROTOCORE_ENABLE_IDEMIP, the platform header takes these declarations in place of those of lwIP. The names, the types and the callbacks are those of the raw API of lwIP, so that the transport above runs as it does over lwIP. The stack module of the network layer answers each call: stack.c runs the units of idemIP, stack_tcp.c holds each TCP connection, and stack_net.c maps the raw API onto both.
Each call runs under the lock of the stack. protocore_net_call_marshal takes the lock and runs its function in the thread of the caller. A callback runs in the pass of the stack, which holds the lock already.
The platform header reaches this one before protocore_config.h defines anything. It thus reads embedded_types alone.
Definition in file stack_net.h.
| #define PROTOCORE_NET_OK 0 |
Definition at line 38 of file stack_net.h.
| #define PROTOCORE_NET_ERR_MEM (-1) |
Definition at line 39 of file stack_net.h.
| #define PROTOCORE_NET_ERR_BUF (-2) |
Definition at line 40 of file stack_net.h.
| #define PROTOCORE_NET_ERR_VAL (-6) |
Definition at line 41 of file stack_net.h.
| #define PROTOCORE_NET_ERR_USE (-8) |
Definition at line 42 of file stack_net.h.
| #define PROTOCORE_NET_ERR_CONN (-11) |
Definition at line 43 of file stack_net.h.
| #define PROTOCORE_NET_ERR_ABRT (-13) |
Definition at line 44 of file stack_net.h.
| #define PROTOCORE_NET_ERR_RST (-14) |
Definition at line 45 of file stack_net.h.
| #define PROTOCORE_NET_ERR_CLSD (-15) |
Definition at line 46 of file stack_net.h.
| #define PROTOCORE_NET_ERR_ARG (-16) |
Definition at line 47 of file stack_net.h.
| #define PROTOCORE_NET_ERR_INPROGRESS (-5) |
Definition at line 48 of file stack_net.h.
| #define PROTOCORE_NET_TYPE_ANY 0 |
Definition at line 52 of file stack_net.h.
| #define PROTOCORE_NET_TYPE_V4 4 |
Definition at line 53 of file stack_net.h.
| #define PROTOCORE_NET_TYPE_V6 6 |
Definition at line 54 of file stack_net.h.
| #define PROTOCORE_NET_HAS_IGMP 1 |
Definition at line 55 of file stack_net.h.
| #define PROTOCORE_NET_HAS_IPV6 0 |
Definition at line 56 of file stack_net.h.
| #define PROTOCORE_NET_ADDR_ANY (&protocore_stack_net_any) |
Definition at line 72 of file stack_net.h.
| #define PROTOCORE_NET_ADDR_ANY4 (&protocore_stack_net_any) |
Definition at line 73 of file stack_net.h.
| #define PROTOCORE_NET_ADDR_ANY4_P (&protocore_stack_net_any) |
Definition at line 74 of file stack_net.h.
| #define protocore_net_ip_is_v4 | ( | a | ) |
Definition at line 76 of file stack_net.h.
| #define protocore_net_ip_is_v6 | ( | a | ) |
Definition at line 77 of file stack_net.h.
| #define protocore_net_ip_as_v4 | ( | a | ) |
Definition at line 78 of file stack_net.h.
| #define protocore_net_ip_as_v6 | ( | a | ) |
Definition at line 79 of file stack_net.h.
| #define protocore_net_ip6_bytes | ( | a | ) |
Definition at line 80 of file stack_net.h.
| #define protocore_net_ip6_wbytes | ( | a | ) |
Definition at line 81 of file stack_net.h.
| #define protocore_net_ip6_mark | ( | a | ) |
Definition at line 82 of file stack_net.h.
| #define PROTOCORE_NET_PBUF_TRANSPORT 0 |
Definition at line 97 of file stack_net.h.
| #define PROTOCORE_NET_PBUF_RAM 0 |
Definition at line 98 of file stack_net.h.
| #define PROTOCORE_NET_WRITE_COPY 0x01 |
Definition at line 125 of file stack_net.h.
| #define PROTOCORE_NET_OPT_REUSEADDR 0x04 |
Definition at line 126 of file stack_net.h.
| #define PROTOCORE_STACK_NET_NONE 0xFFu |
The entry index that names none.
Definition at line 201 of file stack_net.h.
| typedef struct protocore_pbuf protocore_pbuf |
| typedef struct protocore_pcb protocore_pcb |
Definition at line 128 of file stack_net.h.
| typedef struct protocore_udp_pcb protocore_udp_pcb |
Definition at line 129 of file stack_net.h.
| typedef protocore_net_err(* protocore_net_recv_fn) (void *, protocore_pcb *, protocore_pbuf *, protocore_net_err) |
Definition at line 130 of file stack_net.h.
| typedef protocore_net_err(* protocore_net_sent_fn) (void *, protocore_pcb *, uint16_t) |
Definition at line 131 of file stack_net.h.
| typedef protocore_net_err(* protocore_net_accept_fn) (void *, protocore_pcb *, protocore_net_err) |
Definition at line 132 of file stack_net.h.
| typedef protocore_net_err(* protocore_net_connect_fn) (void *, protocore_pcb *, protocore_net_err) |
Definition at line 133 of file stack_net.h.
| typedef void(* protocore_net_err_fn) (void *, protocore_net_err) |
Definition at line 134 of file stack_net.h.
| typedef void(* protocore_net_udp_recv_fn) (void *, protocore_udp_pcb *, protocore_pbuf *, const protocore_net_ip *, uint16_t) |
Definition at line 135 of file stack_net.h.
| typedef struct protocore_net_call protocore_net_call |
The record that a call of the stack carries, as the transport embeds it.
| typedef void(* protocore_net_dns_found_fn) (const char *, const protocore_net_ip *, void *) |
The callback of a name that the resolver of the stack found, with a NULL address for none.
Definition at line 272 of file stack_net.h.
| uint32_t protocore_net_ip4_u32 | ( | const protocore_net_ip * | a | ) |
The IPv4 address of a as the word that lwIP keeps: the four octets in network order in memory.
| void protocore_net_ip4_set | ( | protocore_net_ip * | a, |
| uint8_t | b0, | ||
| uint8_t | b1, | ||
| uint8_t | b2, | ||
| uint8_t | b3 ) |
Set a to the IPv4 address b0.b1.b2.b3.
| int protocore_net_ip4_is_multicast | ( | const protocore_net_ip * | a | ) |
1 when a is an IPv4 host group, 224.0.0.0/4.
| int protocore_net_ip_parse | ( | const char * | s, |
| protocore_net_ip * | out ) |
Parse the dotted quad s into out. 1 on success, and 0 otherwise.
| char * protocore_net_ip_print | ( | const protocore_net_ip * | a, |
| char * | buf, | ||
| int | cap ) |
The dotted quad of a in buf, of cap octets.
| protocore_pbuf * protocore_net_pbuf_alloc | ( | int | layer, |
| uint16_t | len, | ||
| int | type ) |
A packet buffer of len octets from the pool, or NULL when the pool is spent.
| uint8_t protocore_net_pbuf_free | ( | const protocore_pbuf * | p | ) |
Give a packet buffer back to the pool.
| uint16_t protocore_net_pbuf_copy | ( | const protocore_pbuf * | p, |
| void * | dst, | ||
| uint16_t | len, | ||
| uint16_t | off ) |
Copy at most len octets of p, from off, to dst. The octets copied.
| protocore_pcb * protocore_net_new | ( | int | type | ) |
| protocore_net_err protocore_net_bind | ( | protocore_pcb * | p, |
| const protocore_net_ip * | a, | ||
| uint16_t | port ) |
References protocore_net_err.
| protocore_pcb * protocore_net_listen | ( | protocore_pcb * | p, |
| uint8_t | backlog ) |
| protocore_net_err protocore_net_connect | ( | protocore_pcb * | p, |
| const protocore_net_ip * | a, | ||
| uint16_t | port, | ||
| protocore_net_connect_fn | connected ) |
References protocore_net_err.
| protocore_net_err protocore_net_close | ( | protocore_pcb * | p | ) |
References protocore_net_err.
| void protocore_net_abort | ( | protocore_pcb * | p | ) |
| void protocore_net_arg | ( | protocore_pcb * | p, |
| void * | arg ) |
| void protocore_net_on_recv | ( | protocore_pcb * | p, |
| protocore_net_recv_fn | fn ) |
| void protocore_net_on_sent | ( | protocore_pcb * | p, |
| protocore_net_sent_fn | fn ) |
| void protocore_net_on_accept | ( | protocore_pcb * | p, |
| protocore_net_accept_fn | fn ) |
| void protocore_net_on_err | ( | protocore_pcb * | p, |
| protocore_net_err_fn | fn ) |
| protocore_net_err protocore_net_write | ( | protocore_pcb * | p, |
| const void * | data, | ||
| uint16_t | len, | ||
| uint8_t | flags ) |
References protocore_net_err.
| protocore_net_err protocore_net_output | ( | const protocore_pcb * | p | ) |
References protocore_net_err.
| void protocore_net_recved | ( | const protocore_pcb * | p, |
| uint16_t | len ) |
| uint16_t protocore_net_sndbuf | ( | const protocore_pcb * | p | ) |
| void protocore_net_nagle_disable | ( | const protocore_pcb * | p | ) |
| void protocore_net_rcv_wnd_update | ( | const protocore_pcb * | p, |
| uint16_t | len ) |
| void protocore_net_opt_set | ( | void * | p, |
| uint32_t | opt ) |
| protocore_udp_pcb * protocore_net_udp_new | ( | void | ) |
| protocore_net_err protocore_net_udp_bind | ( | protocore_udp_pcb * | p, |
| const protocore_net_ip * | a, | ||
| uint16_t | port ) |
References protocore_net_err.
| void protocore_net_udp_recv | ( | protocore_udp_pcb * | p, |
| protocore_net_udp_recv_fn | fn, | ||
| void * | arg ) |
| protocore_net_err protocore_net_udp_sendto | ( | const protocore_udp_pcb * | p, |
| const protocore_pbuf * | b, | ||
| const protocore_net_ip * | a, | ||
| uint16_t | port ) |
References protocore_net_err.
| void protocore_net_udp_remove | ( | protocore_udp_pcb * | p | ) |
| protocore_net_err protocore_net_igmp_join | ( | const protocore_net_ip * | nif, |
| const protocore_net_ip * | grp ) |
References protocore_net_err.
| protocore_net_err protocore_net_igmp_leave | ( | const protocore_net_ip * | nif, |
| const protocore_net_ip * | grp ) |
References protocore_net_err.
| protocore_net_err protocore_net_call_marshal | ( | protocore_net_err(* | fn )(protocore_net_call *), |
| protocore_net_call * | c ) |
Run fn on c under the lock of the stack, and return what it returns.
References protocore_net_err.
| protocore_net_err protocore_net_dns_resolve | ( | const char * | host, |
| protocore_net_ip * | addr, | ||
| protocore_net_dns_found_fn | found, | ||
| void * | arg ) |
Resolve host to addr, as dns_gethostbyname of lwIP does.
A dotted quad completes in the call, with PROTOCORE_NET_OK. The stack has no resolver of its own, so each other name gets PROTOCORE_NET_ERR_VAL.
References protocore_net_err.
| void protocore_stack_net_pass | ( | uint32_t | now_ms, |
| uint32_t | random_word ) |
One pass of the stack, under its lock: the units of idemIP, then each event of the TCP as a callback.
| now_ms | the monotonic millisecond count of the caller |
| random_word | a random word for this pass |
| int protocore_stack_net_start | ( | void | ) |
Start the task of the stack, which runs protocore_stack_net_pass once each tick of the platform.
The task has the place of the tcpip thread of lwIP. Call it once, after Stack.start, Stack.bind and Stack.set_addr4. A second call does nothing.
| void protocore_stack_net_udp_input | ( | const uint8_t * | frame, |
| uint16_t | entry, | ||
| size_t | ip_off, | ||
| size_t | payload_off, | ||
| size_t | payload_len ) |
One UDP datagram that Dispatch delivered to a UdpPcb entry, to the callback of its control block.
| frame | the received frame |
| entry | the UdpPcb entry that the datagram matched |
| ip_off | the octets from the frame to the IPv4 header |
| payload_off | the octets from the frame to the UDP header |
| payload_len | the octets of the UDP header and its data |
| EMBED_BEGIN_DECLS typedef int8_t protocore_net_err |
The result of a call of the stack, as lwIP numbers it.
Definition at line 37 of file stack_net.h.
Referenced by listener_accept_cb(), lowlevel_err_cb(), lowlevel_recv_cb(), lowlevel_sent_cb(), protocore_net_bind(), protocore_net_call_marshal(), protocore_net_close(), protocore_net_connect(), protocore_net_dns_resolve(), protocore_net_igmp_join(), protocore_net_igmp_leave(), protocore_net_output(), protocore_net_udp_bind(), protocore_net_udp_sendto(), and protocore_net_write().
|
extern |
The any address, which a bind takes for each local address.