The Pubnub C-core library. It's home is on https://github.com/pubnub/c_core, this is a copy
Dependents: Pubnub_c_core_mbed2_pal Pubnub_c_core_mbed2_pal Pubnub_c_core_mbed2_pal2
pubnub_netcore.h@0:d13755cfb705, 2016-11-10 (annotated)
- Committer:
- sveljko
- Date:
- Thu Nov 10 22:20:11 2016 +0000
- Revision:
- 0:d13755cfb705
Initial commit of Pubnub C-core
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sveljko | 0:d13755cfb705 | 1 | /* -*- c-file-style:"stroustrup"; indent-tabs-mode: nil -*- */ |
sveljko | 0:d13755cfb705 | 2 | #if !defined INC_PUBNUB_NETCORE |
sveljko | 0:d13755cfb705 | 3 | #define INC_PUBNUB_NETCORE |
sveljko | 0:d13755cfb705 | 4 | |
sveljko | 0:d13755cfb705 | 5 | /** @file pubnub_netcore.h |
sveljko | 0:d13755cfb705 | 6 | |
sveljko | 0:d13755cfb705 | 7 | This is the interface of the Pubnub C-core network module. |
sveljko | 0:d13755cfb705 | 8 | It is internal, users should not include this or use any |
sveljko | 0:d13755cfb705 | 9 | of its definitions. |
sveljko | 0:d13755cfb705 | 10 | */ |
sveljko | 0:d13755cfb705 | 11 | |
sveljko | 0:d13755cfb705 | 12 | |
sveljko | 0:d13755cfb705 | 13 | /** States of a context */ |
sveljko | 0:d13755cfb705 | 14 | enum pubnub_state { |
sveljko | 0:d13755cfb705 | 15 | /** Context not allocated */ |
sveljko | 0:d13755cfb705 | 16 | PBS_NULL, |
sveljko | 0:d13755cfb705 | 17 | /** No transaction ongoing */ |
sveljko | 0:d13755cfb705 | 18 | PBS_IDLE, |
sveljko | 0:d13755cfb705 | 19 | /** Ready to start a transaction */ |
sveljko | 0:d13755cfb705 | 20 | PBS_READY, |
sveljko | 0:d13755cfb705 | 21 | /** Waiting for sending a DNS request */ |
sveljko | 0:d13755cfb705 | 22 | PBS_WAIT_DNS_SEND, |
sveljko | 0:d13755cfb705 | 23 | /** Waiting for DNS resolution (response) */ |
sveljko | 0:d13755cfb705 | 24 | PBS_WAIT_DNS_RCV, |
sveljko | 0:d13755cfb705 | 25 | /** Waiting for TCP connection establishment */ |
sveljko | 0:d13755cfb705 | 26 | PBS_WAIT_CONNECT, |
sveljko | 0:d13755cfb705 | 27 | /** TCP connected, can start */ |
sveljko | 0:d13755cfb705 | 28 | PBS_CONNECTED, |
sveljko | 0:d13755cfb705 | 29 | /** Sending HTTP "GET" */ |
sveljko | 0:d13755cfb705 | 30 | PBS_TX_GET, |
sveljko | 0:d13755cfb705 | 31 | /** Sending the path (part of the URL) */ |
sveljko | 0:d13755cfb705 | 32 | PBS_TX_PATH, |
sveljko | 0:d13755cfb705 | 33 | /** Sending the scheme (part of the URL - the `http:` part) - |
sveljko | 0:d13755cfb705 | 34 | utilized when using the "HTTP GET" proxy */ |
sveljko | 0:d13755cfb705 | 35 | PBS_TX_SCHEME, |
sveljko | 0:d13755cfb705 | 36 | /** Sending the host (part of the URL - the `www.pubnub.com` part) |
sveljko | 0:d13755cfb705 | 37 | - utilized when using the "HTTP GET" proxy */ |
sveljko | 0:d13755cfb705 | 38 | PBS_TX_HOST, |
sveljko | 0:d13755cfb705 | 39 | /** Sending the "port number" (part of the URL - the `:80` part) - |
sveljko | 0:d13755cfb705 | 40 | utilized when using the "HTTP CONNECT" proxy */ |
sveljko | 0:d13755cfb705 | 41 | PBS_TX_PORT_NUM, |
sveljko | 0:d13755cfb705 | 42 | /** Sending the HTTP version */ |
sveljko | 0:d13755cfb705 | 43 | PBS_TX_VER, |
sveljko | 0:d13755cfb705 | 44 | /** Sending the DNS name (part of the URL) */ |
sveljko | 0:d13755cfb705 | 45 | PBS_TX_ORIGIN, |
sveljko | 0:d13755cfb705 | 46 | /** Sending the rest of the HTTP headers */ |
sveljko | 0:d13755cfb705 | 47 | PBS_TX_FIN_HEAD, |
sveljko | 0:d13755cfb705 | 48 | /** Waiting for HTTP version in response */ |
sveljko | 0:d13755cfb705 | 49 | PBS_RX_HTTP_VER, |
sveljko | 0:d13755cfb705 | 50 | /** Reading the HTTP response headers */ |
sveljko | 0:d13755cfb705 | 51 | PBS_RX_HEADERS, |
sveljko | 0:d13755cfb705 | 52 | /** Reading one HTTP response header line */ |
sveljko | 0:d13755cfb705 | 53 | PBS_RX_HEADER_LINE, |
sveljko | 0:d13755cfb705 | 54 | /** Reading the HTTP response body */ |
sveljko | 0:d13755cfb705 | 55 | PBS_RX_BODY, |
sveljko | 0:d13755cfb705 | 56 | /** Waiting for new data in HTTP response body */ |
sveljko | 0:d13755cfb705 | 57 | PBS_RX_BODY_WAIT, |
sveljko | 0:d13755cfb705 | 58 | /** Reading the length of the chunk in HTTP chunked response body */ |
sveljko | 0:d13755cfb705 | 59 | PBS_RX_CHUNK_LEN, |
sveljko | 0:d13755cfb705 | 60 | /** Waiting to receive whole line of the chunk length*/ |
sveljko | 0:d13755cfb705 | 61 | PBS_RX_CHUNK_LEN_LINE, |
sveljko | 0:d13755cfb705 | 62 | /** Reading the chunk in HTTP chunked response body */ |
sveljko | 0:d13755cfb705 | 63 | PBS_RX_BODY_CHUNK, |
sveljko | 0:d13755cfb705 | 64 | /** Waiting for new data in HTTP chunked response body */ |
sveljko | 0:d13755cfb705 | 65 | PBS_RX_BODY_CHUNK_WAIT, |
sveljko | 0:d13755cfb705 | 66 | /** Waiting for the TCP connection to close */ |
sveljko | 0:d13755cfb705 | 67 | PBS_WAIT_CLOSE, |
sveljko | 0:d13755cfb705 | 68 | /** Waiting to cancel (close before the end of transaction) the |
sveljko | 0:d13755cfb705 | 69 | * TCP connection (in some TCP/IP implementations, we don't want to |
sveljko | 0:d13755cfb705 | 70 | * cancel right away, but wait). |
sveljko | 0:d13755cfb705 | 71 | */ |
sveljko | 0:d13755cfb705 | 72 | PBS_WAIT_CANCEL, |
sveljko | 0:d13755cfb705 | 73 | /* Waiting for a cancelled TCP connection to close */ |
sveljko | 0:d13755cfb705 | 74 | PBS_WAIT_CANCEL_CLOSE |
sveljko | 0:d13755cfb705 | 75 | }; |
sveljko | 0:d13755cfb705 | 76 | |
sveljko | 0:d13755cfb705 | 77 | |
sveljko | 0:d13755cfb705 | 78 | struct pubnub_; |
sveljko | 0:d13755cfb705 | 79 | |
sveljko | 0:d13755cfb705 | 80 | /** The Finite State Machine (FSM) of the net-core module. It's |
sveljko | 0:d13755cfb705 | 81 | "universal", in the sense that it is portable to all platforms, |
sveljko | 0:d13755cfb705 | 82 | with the porting being done by implementing some functions it |
sveljko | 0:d13755cfb705 | 83 | needs in the PAL (Platform Abstraction Layer). |
sveljko | 0:d13755cfb705 | 84 | */ |
sveljko | 0:d13755cfb705 | 85 | int pbnc_fsm(struct pubnub_ *pb); |
sveljko | 0:d13755cfb705 | 86 | |
sveljko | 0:d13755cfb705 | 87 | |
sveljko | 0:d13755cfb705 | 88 | /** Issues a stop command to the FSM of the net-core module. The |
sveljko | 0:d13755cfb705 | 89 | FSM will close a connection (if it is already open) and then |
sveljko | 0:d13755cfb705 | 90 | inform the user of the outcome (as specified) when it is called. |
sveljko | 0:d13755cfb705 | 91 | |
sveljko | 0:d13755cfb705 | 92 | @note This function will _not_ call pbnc_fsm(). |
sveljko | 0:d13755cfb705 | 93 | */ |
sveljko | 0:d13755cfb705 | 94 | void pbnc_stop(struct pubnub_ *pb, enum pubnub_res outcome_to_report); |
sveljko | 0:d13755cfb705 | 95 | |
sveljko | 0:d13755cfb705 | 96 | |
sveljko | 0:d13755cfb705 | 97 | #endif /* !defined INC_PUBNUB_NETCORE */ |