eventcb for bufferevent */
| 876 | |
| 877 | /* eventcb for bufferevent */ |
| 878 | static void eventcb(struct bufferevent *bev, short events, void *ptr) { |
| 879 | http2_session_data *session_data = (http2_session_data *)ptr; |
| 880 | if (events & BEV_EVENT_CONNECTED) { |
| 881 | const unsigned char *alpn = NULL; |
| 882 | unsigned int alpnlen = 0; |
| 883 | SSL *ssl; |
| 884 | (void)bev; |
| 885 | |
| 886 | LM_INFO("%s connected\n", session_data->client_addr); |
| 887 | |
| 888 | ssl = bufferevent_openssl_get_ssl(session_data->bev); |
| 889 | |
| 890 | SSL_get0_alpn_selected(ssl, &alpn, &alpnlen); |
| 891 | |
| 892 | if (alpn == NULL || alpnlen != 2 || memcmp("h2", alpn, 2) != 0) { |
| 893 | LM_ERR("%s h2 is not negotiated\n", session_data->client_addr); |
| 894 | delete_http2_session_data(session_data); |
| 895 | return; |
| 896 | } |
| 897 | |
| 898 | initialize_nghttp2_session(session_data); |
| 899 | |
| 900 | if (send_server_connection_header(session_data) != 0 || |
| 901 | session_send(session_data) != 0) { |
| 902 | delete_http2_session_data(session_data); |
| 903 | return; |
| 904 | } |
| 905 | |
| 906 | return; |
| 907 | } |
| 908 | |
| 909 | if (events & BEV_EVENT_EOF) |
| 910 | LM_INFO("%s EOF\n", session_data->client_addr); |
| 911 | else if (events & BEV_EVENT_ERROR) |
| 912 | LM_INFO("%s network error\n", session_data->client_addr); |
| 913 | else if (events & BEV_EVENT_TIMEOUT) |
| 914 | LM_INFO("%s timeout\n", session_data->client_addr); |
| 915 | |
| 916 | delete_http2_session_data(session_data); |
| 917 | } |
| 918 | |
| 919 | /* callback for evconnlistener */ |
| 920 | static void acceptcb(struct evconnlistener *listener, int fd, |
nothing calls this directly
no test coverage detected