http_tcp_core.h
来自「AMLOGIC DPF source code」· C头文件 代码 · 共 172 行
H
172 行
/*******************************************************************
*
* Copyright C 2004 by Amlogic, Inc. All Rights Reserved.
*
* Description: HTTP TCP declarations
*
* Created: Mon Oct 18 20:30:03 2004, Eric Knudstrup
*
*******************************************************************/
#ifndef HTTP_TCP_CORE_H
#define HTTP_TCP_CORE_H
/**
* @file http_tcp_core.h
* HTTP TCP core routines. Provided by http_core.lib
*/
/** @defgroup http_tcp_core HTTP TCP connection functions and data structures.
* @ingroup Network
*/
/*@{*/
/*
* When HTTPClientState is modified
* http_state_str[] in http_tcp_core.c also needs to be changed.
*/
/**
* HTTP client states.
*/
typedef enum {
HTTP_CONN_ALLOCATED, /**< Memory Allocated */
HTTP_CONN_CONNECTING, /**< TCP connection in progess */
HTTP_CONN_CONNECTED, /**< TCP connection made */
HTTP_CONN_SENDING, /**< Request in progress */
HTTP_CONN_CLOSED, /**< Connection closed */
HTTP_CONN_ERROR, /**< An error occured with the connection */
HTTP_CONN_TIMEOUT, /**< Connection timed out */
} HTTPTCPState_t ;
typedef struct _http_tcp_con_s HTTPTcpConnection_t;
typedef void (*HTTPCompleteCb) (HTTPTcpConnection_t *client, HTTPInputMessage_t *response);
/**
* Callback for a new TCP server connection. Can be used
* to allow the application to create a new context.
*/
typedef void (*HTTPAcceptCb_t) (HTTPTcpConnection_t *server);
/**
* Callback to let owner of HTTPTcpConnection_t know that the message
* has been sent.
*/
typedef void (*HTTPSentCb_t) (HTTPTcpConnection_t *server);
/*;emacs generated header for file http_tcp_core.c. Global function declarations only. */
/**
* Begin sending request. http_output_complete() must be called first.
* If the HTTP client connection hasn't been made, an attempt will be made
* to reconnect to the server.
*
* @returns ERR_OK on success, ERR_USE if there is already a request
* in progress.
*/
extern err_t
http_tcp_send(HTTPTcpConnection_t *conn, HTTPOutputMessage_t *message);
/**
* Returns the client's parser
*/
extern HTTPParser *
http_tcp_parser(HTTPTcpConnection_t *conn);
/**
* Set the HTTPTcpConnection_t's sent callback.
*/
extern void
http_set_sent_cb(HTTPTcpConnection_t *conn, HTTPSentCb_t sent_cb);
/**
* Create an HTTP server.
*
* @param [in] complete_cb Function pointer to a completion callback.
* @param [in] accept_cb Callback for accept event.
* @param [in] sent_cb Callback for message sent notification.
* @param [in] parser Flavor of HTTP Parser to use.
* @param [in] user_context User context
* @param [in] port TCP port to bind to.
*
* @returns A pointer to an HTTPTcpConnection_t if successful, NULL if
* the memory allocation failed.
*/
extern HTTPTcpConnection_t *
http_tcp_server_create(HTTPCompleteCb complete_cb,
HTTPAcceptCb_t accept_cb,
HTTPSentCb_t sent_cb,
HTTPParser *parser,
void *user_context, u16_t port);
/**
* Create an HTTP TCP connection.
*
* @param [in] complete_cb Function pointer to a completion callback.
* @param [in] parser Flavor of HTTP Parser to use.
* @param [in] user_context User context
* @param [in] ipaddr IP Address to connect to.
* @param [in] port TCP port to connect to.
*
* @returns A pointer to an HTTPTcpConnection_t if successful, NULL if
* the memory allocation failed.
*/
extern HTTPTcpConnection_t *
http_tcp_client_create(HTTPCompleteCb complete_cb,
HTTPParser *parser,
void *user_context,
struct ip_addr *ipaddr,
uint16_t port);
/**
* Destroy connection. Nothing in this session is valid after calling this
* function.
* @param [in] conn HTTPTcpConnection_t to delete.
* @ingroup http_tcp_core
*/
extern void
http_tcp_destroy(HTTPTcpConnection_t *conn);
/**
* Close the underlying TCP connection. The \a HTTPTcpConnection_t
* is still valid.
*/
extern void
http_disconnect(HTTPTcpConnection_t *conn);
/**
* If the application has overrun its buffer, then we may need to tell the
* TCP connection to push more data up as well as increase the TCP receive window.
*/
extern void
http_tcp_poke(HTTPTcpConnection_t *conn);
/**
* Retrieve current connection state.
*
* @param [in] conn HTTPTcpConnection_t to operate on.
*
* @returns Current HTTPTCPState_t.
*/
extern HTTPTCPState_t
http_get_state(HTTPTcpConnection_t *conn);
/**
* Retrieves user_context passed in for creation for this connection
*/
extern void *
http_user_context(HTTPTcpConnection_t *conn);
/**
* If the connection was trying to fill the output
* pipe and had to pause for asynchronous data it
* will have to be restarted with this function.
*/
extern void
http_tcp_output_continue(HTTPTcpConnection_t *conn);
/*;end emacs generated header for file http_tcp_core.c. Global function declarations only. */
#endif
/*@}*/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?