struct uh_connection: New api: get_addr

Return the host byte order address

Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
main
Jianhui Zhao 2020-10-14 20:48:15 +08:00
parent d4b34049bc
commit f621c51888
2 changed files with 7 additions and 0 deletions

View File

@ -175,6 +175,11 @@ static void conn_redirect(struct uh_connection *conn, int code, const char *loca
conn_done(conn);
}
static uint32_t conn_get_addr(struct uh_connection *conn)
{
return ntohl(conn->addr.sin_addr.s_addr);
}
static enum http_method conn_get_method(struct uh_connection *conn)
{
return conn->parser.method;
@ -605,6 +610,7 @@ struct uh_connection *uh_new_connection(struct uh_server *srv, int sock, struct
conn->chunk_vprintf = conn_chunk_vprintf;
conn->chunk_end = conn_chunk_end;
conn->get_addr = conn_get_addr;
conn->get_method = conn_get_method;
conn->get_method_str = conn_get_method_str;
conn->get_path = conn_get_path;

View File

@ -108,6 +108,7 @@ struct uh_connection {
void (*chunk_printf)(struct uh_connection *conn, const char *format, ...);
void (*chunk_vprintf)(struct uh_connection *conn, const char *format, va_list arg);
void (*chunk_end)(struct uh_connection *conn);
uint32_t (*get_addr)(struct uh_connection *conn);
enum http_method (*get_method)(struct uh_connection *conn);
const char *(*get_method_str)(struct uh_connection *conn);
struct uh_str (*get_path)(struct uh_connection *conn);