Internal API for handling CoAP proxies.
More...
|
void | coap_proxy_cleanup (coap_context_t *context) |
| Close down proxy tracking, releasing any memory used.
|
|
int | coap_proxy_check_timeouts (coap_context_t *context, coap_tick_t now, coap_tick_t *tim_rem) |
| Idle timeout inactive proxy sessions as well as return in tim_rem the time to remaining to timeout the inactive proxy.
|
|
int | coap_proxy_remove_association (coap_session_t *session, int send_failure) |
| Remove the upstream proxy connection from list for session.
|
|
int | coap_proxy_forward_request_lkd (coap_session_t *session, const coap_pdu_t *request, coap_pdu_t *response, coap_resource_t *resource, coap_cache_key_t *cache_key, coap_proxy_server_list_t *server_list) |
| Forward incoming request upstream to the next proxy/server.
|
|
coap_response_t | coap_proxy_forward_response_lkd (coap_session_t *session, const coap_pdu_t *received, coap_cache_key_t **cache_key) |
| Forward the returning response back to the appropriate client.
|
|
coap_session_t * | coap_new_client_session_proxy_lkd (coap_context_t *context, coap_proxy_server_list_t *server_list) |
| Creates a new client session to use the proxy logic going to the defined upstream server.
|
|
coap_mid_t | coap_proxy_local_write (coap_session_t *session, coap_pdu_t *pdu) |
|
struct coap_proxy_req_t * | coap_proxy_map_outgoing_request (coap_session_t *ongoing, const coap_pdu_t *received, coap_proxy_list_t **proxy_entry) |
|
Internal API for handling CoAP proxies.
◆ coap_proxy_req_t
◆ coap_new_client_session_proxy_lkd()
Creates a new client session to use the proxy logic going to the defined upstream server.
Note: This function must be called in the locked state,
Note: If server_list contains more than one server, the first server is not always chosen.
Note: server_list
must exist for the duration of the returned session as it is used for every coap_send() or coap_send_recv().
Note: Unless coap_send_recv() is used, the response is sent to the handler defined by coap_register_response_handler(), not to the handler defined by coap_register_proxy_response_handler().
- Parameters
-
context | The CoAP context. |
server_list | The upstream server list to connect to. |
- Returns
- A new CoAP session or NULL if failed. Call coap_session_release() to free.
◆ coap_proxy_check_timeouts()
Idle timeout inactive proxy sessions as well as return in tim_rem
the time to remaining to timeout the inactive proxy.
- Parameters
-
context | Context to check against. |
now | Current time in ticks. |
tim_rem | Where to update timeout time to the next expiry. |
- Returns
- Return 1 if there is a future expire time, else 0.
◆ coap_proxy_cleanup()
Close down proxy tracking, releasing any memory used.
- Parameters
-
context | The current CoAP context. |
◆ coap_proxy_forward_request_lkd()
Forward incoming request upstream to the next proxy/server.
Possible scenarios: Acting as a reverse proxy - connect to defined internal server (possibly round robin load balancing over multiple servers). Acting as a forward proxy - connect to host defined in Proxy-Uri or Proxy-Scheme with Uri-Host (and maybe Uri-Port). Acting as a relay proxy - connect to defined upstream server (possibly round robin load balancing over multiple servers).
A request that should go direct to this server is not supported here.
Note: This function must be called in the locked state,
- Parameters
-
session | The client session. |
request | The client's request PDU. |
response | The response PDU that will get sent back to the client. |
resource | The resource associated with this request. |
cache_key | A cache key generated from the request PDU or NULL. |
server_list | The upstream server list to connect to. |
- Returns
1
if success, or 0
if failure (response
code set to appropriate value).
◆ coap_proxy_forward_response_lkd()
Forward the returning response back to the appropriate client.
Note: This function must be called in the locked state,
- Parameters
-
session | The session handling the response. |
received | The received PDU. |
cache_key | Updated with the cache key pointer provided to coap_proxy_forward_request_lkd(). The caller should delete this cach key (unless the client request set up an Observe and there will be unsolicited responses). |
- Returns
- One of COAP_RESPONSE_FAIL or COAP_RESPONSE_OK.
◆ coap_proxy_local_write()
◆ coap_proxy_map_outgoing_request()
◆ coap_proxy_remove_association()
int coap_proxy_remove_association |
( |
coap_session_t * |
session, |
|
|
int |
send_failure |
|
) |
| |
Remove the upstream proxy connection from list for session.
- Parameters
-
session | Either incoming or ongoiing session. |
send_failure | Indicate to incoming session proxy issues. |
- Returns
- Return 1 if proxy_entry deleted.