diff --git a/apps/restconf/restconf_evhtp.c b/apps/restconf/restconf_evhtp.c index b69eba42..49245afd 100644 --- a/apps/restconf/restconf_evhtp.c +++ b/apps/restconf/restconf_evhtp.c @@ -396,7 +396,7 @@ restconf_evhtp_reply(restconf_conn *rc, * [RFC7231]). */ if (sd->sd_code != 204 && sd->sd_code > 199) - if (restconf_reply_header(sd, "Content-Length", "%lu", sd->sd_body_len) < 0) + if (restconf_reply_header(sd, "Content-Length", "%zu", sd->sd_body_len) < 0) goto done; /* Create reply and write headers */ if (native_send_reply(rc, sd, req) < 0) diff --git a/apps/restconf/restconf_main_native.c b/apps/restconf/restconf_main_native.c index 5e7551f2..4bbe7b47 100644 --- a/apps/restconf/restconf_main_native.c +++ b/apps/restconf/restconf_main_native.c @@ -265,7 +265,7 @@ buf_write(char *buf, } memcpy(dbgstr, buf, sz); dbgstr[sz] = '\0'; - clicon_debug(1, "%s buflen:%lu buf:%s", __FUNCTION__, buflen, dbgstr); + clicon_debug(1, "%s buflen:%zu buf:%s", __FUNCTION__, buflen, dbgstr); free(dbgstr); } while (totlen < buflen){ @@ -641,7 +641,7 @@ send_badrequest(clicon_handle h, cprintf(cb, "HTTP/1.1 400 Bad Request\r\nConnection: close\r\n"); if (body){ cprintf(cb, "Content-Type: %s\r\n", media); - cprintf(cb, "Content-Length: %lu\r\n", strlen(body)); + cprintf(cb, "Content-Length: %u\r\n", strlen(body)); } else cprintf(cb, "Content-Length: 0\r\n"); @@ -703,7 +703,7 @@ restconf_connection(int s, */ if ((n = SSL_read(rc->rc_ssl, buf, sizeof(buf))) < 0){ sslerr = SSL_get_error(rc->rc_ssl, n); - clicon_debug(1, "%s SSL_read() n:%ld errno:%d sslerr:%d", __FUNCTION__, n, errno, sslerr); + clicon_debug(1, "%s SSL_read() n:%zd errno:%d sslerr:%d", __FUNCTION__, n, errno, sslerr); switch (sslerr){ case SSL_ERROR_WANT_READ: /* 2 */ /* SSL_ERROR_WANT_READ is returned when the last operation was a read operation @@ -745,10 +745,10 @@ restconf_connection(int s, continue; } } - clicon_debug(1, "%s read:%ld", __FUNCTION__, n); + clicon_debug(1, "%s (ssl)read:%zd", __FUNCTION__, n); if (n == 0){ clicon_debug(1, "%s n=0 closing socket", __FUNCTION__); - if (restconf_close_ssl_socket(rc, 1) < 0) + if (restconf_close_ssl_socket(rc, 0) < 0) goto done; restconf_conn_free(rc); rc = NULL; diff --git a/apps/restconf/restconf_nghttp2.c b/apps/restconf/restconf_nghttp2.c index 7f963c51..698e1a6e 100644 --- a/apps/restconf/restconf_nghttp2.c +++ b/apps/restconf/restconf_nghttp2.c @@ -184,7 +184,7 @@ session_send_callback(nghttp2_session *session, SSL *ssl; int sslerr; - clicon_debug(1, "%s buflen:%lu", __FUNCTION__, buflen); + clicon_debug(1, "%s buflen:%zu", __FUNCTION__, buflen); s = rc->rc_s; ssl = rc->rc_ssl; while (totlen < buflen){ @@ -259,7 +259,7 @@ session_send_callback(nghttp2_session *session, clicon_debug(1, "%s retval:%d", __FUNCTION__, retval); return retval; } - clicon_debug(1, "%s retval:%lu", __FUNCTION__, totlen); + clicon_debug(1, "%s retval:%zd", __FUNCTION__, totlen); return totlen; } @@ -379,7 +379,7 @@ restconf_sd_read(nghttp2_session *session, #endif assert(cbuf_len(cb) > sd->sd_body_offset); remain = cbuf_len(cb) - sd->sd_body_offset; - clicon_debug(1, "%s length:%lu totlen:%d, offset:%lu remain:%lu", + clicon_debug(1, "%s length:%zu totlen:%d, offset:%zu remain:%zu", __FUNCTION__, length, cbuf_len(cb), @@ -395,7 +395,7 @@ restconf_sd_read(nghttp2_session *session, } memcpy(buf, cbuf_get(cb) + sd->sd_body_offset, len); sd->sd_body_offset += len; - clicon_debug(1, "%s retval:%lu", __FUNCTION__, len); + clicon_debug(1, "%s retval:%zu", __FUNCTION__, len); return len; } @@ -483,7 +483,7 @@ http2_exec(restconf_conn *rc, * [RFC7231]). */ if (sd->sd_code != 204 && sd->sd_code > 199) - if (restconf_reply_header(sd, "Content-Length", "%lu", sd->sd_body_len) < 0) + if (restconf_reply_header(sd, "Content-Length", "%zu", sd->sd_body_len) < 0) goto done; if (sd->sd_code){ if (restconf_submit_response(session, rc, stream_id, sd) < 0) @@ -835,6 +835,20 @@ on_extension_chunk_recv_callback(nghttp2_session *session, return 0; } +/*! Library provides the error code, and message for debugging purpose. + */ +static int +error_callback(nghttp2_session *session, + const char *msg, + size_t len, + void *user_data) +{ + // restconf_conn *rc = (restconf_conn *)user_data; + clicon_debug(1, "%s", __FUNCTION__); + return 0; +} + +#if (NGHTTP2_VERSION_NUM > 0x011201) /* Unsure of version number */ /*! Library provides the error code, and message for debugging purpose. */ static int @@ -849,6 +863,7 @@ error_callback2(nghttp2_session *session, clicon_err(OE_NGHTTP2, lib_error_code, "%s", msg); return 0; } +#endif /* * XXX see session_recv @@ -944,7 +959,10 @@ http2_session_init(restconf_conn *rc) nghttp2_session_callbacks_set_unpack_extension_callback(callbacks, unpack_extension_callback); #endif nghttp2_session_callbacks_set_on_extension_chunk_recv_callback(callbacks, on_extension_chunk_recv_callback); + nghttp2_session_callbacks_set_error_callback(callbacks, error_callback); +#if (NGHTTP2_VERSION_NUM > 0x011201) /* Unsure of version number */ nghttp2_session_callbacks_set_error_callback2(callbacks, error_callback2); +#endif /* Create session for server use, register callbacks */ if ((ngerr = nghttp2_session_server_new3(&session, callbacks, rc, NULL, NULL)) < 0){