- changed debug printfs to work for i386

- restconf native centos8: fixed ssl shutdown error
- libnghttp2 older version patch
This commit is contained in:
Olof Hagsand 2021-06-26 08:36:24 +00:00
parent b31107f646
commit e451b7f43e
3 changed files with 29 additions and 11 deletions

View file

@ -396,7 +396,7 @@ restconf_evhtp_reply(restconf_conn *rc,
* [RFC7231]). * [RFC7231]).
*/ */
if (sd->sd_code != 204 && sd->sd_code > 199) 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; goto done;
/* Create reply and write headers */ /* Create reply and write headers */
if (native_send_reply(rc, sd, req) < 0) if (native_send_reply(rc, sd, req) < 0)

View file

@ -265,7 +265,7 @@ buf_write(char *buf,
} }
memcpy(dbgstr, buf, sz); memcpy(dbgstr, buf, sz);
dbgstr[sz] = '\0'; 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); free(dbgstr);
} }
while (totlen < buflen){ 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"); cprintf(cb, "HTTP/1.1 400 Bad Request\r\nConnection: close\r\n");
if (body){ if (body){
cprintf(cb, "Content-Type: %s\r\n", media); 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 else
cprintf(cb, "Content-Length: 0\r\n"); 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){ if ((n = SSL_read(rc->rc_ssl, buf, sizeof(buf))) < 0){
sslerr = SSL_get_error(rc->rc_ssl, n); 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){ switch (sslerr){
case SSL_ERROR_WANT_READ: /* 2 */ case SSL_ERROR_WANT_READ: /* 2 */
/* SSL_ERROR_WANT_READ is returned when the last operation was a read operation /* SSL_ERROR_WANT_READ is returned when the last operation was a read operation
@ -745,10 +745,10 @@ restconf_connection(int s,
continue; continue;
} }
} }
clicon_debug(1, "%s read:%ld", __FUNCTION__, n); clicon_debug(1, "%s (ssl)read:%zd", __FUNCTION__, n);
if (n == 0){ if (n == 0){
clicon_debug(1, "%s n=0 closing socket", __FUNCTION__); 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; goto done;
restconf_conn_free(rc); restconf_conn_free(rc);
rc = NULL; rc = NULL;

View file

@ -184,7 +184,7 @@ session_send_callback(nghttp2_session *session,
SSL *ssl; SSL *ssl;
int sslerr; int sslerr;
clicon_debug(1, "%s buflen:%lu", __FUNCTION__, buflen); clicon_debug(1, "%s buflen:%zu", __FUNCTION__, buflen);
s = rc->rc_s; s = rc->rc_s;
ssl = rc->rc_ssl; ssl = rc->rc_ssl;
while (totlen < buflen){ while (totlen < buflen){
@ -259,7 +259,7 @@ session_send_callback(nghttp2_session *session,
clicon_debug(1, "%s retval:%d", __FUNCTION__, retval); clicon_debug(1, "%s retval:%d", __FUNCTION__, retval);
return retval; return retval;
} }
clicon_debug(1, "%s retval:%lu", __FUNCTION__, totlen); clicon_debug(1, "%s retval:%zd", __FUNCTION__, totlen);
return totlen; return totlen;
} }
@ -379,7 +379,7 @@ restconf_sd_read(nghttp2_session *session,
#endif #endif
assert(cbuf_len(cb) > sd->sd_body_offset); assert(cbuf_len(cb) > sd->sd_body_offset);
remain = 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__, __FUNCTION__,
length, length,
cbuf_len(cb), cbuf_len(cb),
@ -395,7 +395,7 @@ restconf_sd_read(nghttp2_session *session,
} }
memcpy(buf, cbuf_get(cb) + sd->sd_body_offset, len); memcpy(buf, cbuf_get(cb) + sd->sd_body_offset, len);
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; return len;
} }
@ -483,7 +483,7 @@ http2_exec(restconf_conn *rc,
* [RFC7231]). * [RFC7231]).
*/ */
if (sd->sd_code != 204 && sd->sd_code > 199) 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; goto done;
if (sd->sd_code){ if (sd->sd_code){
if (restconf_submit_response(session, rc, stream_id, sd) < 0) if (restconf_submit_response(session, rc, stream_id, sd) < 0)
@ -835,6 +835,20 @@ on_extension_chunk_recv_callback(nghttp2_session *session,
return 0; 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. /*! Library provides the error code, and message for debugging purpose.
*/ */
static int static int
@ -849,6 +863,7 @@ error_callback2(nghttp2_session *session,
clicon_err(OE_NGHTTP2, lib_error_code, "%s", msg); clicon_err(OE_NGHTTP2, lib_error_code, "%s", msg);
return 0; return 0;
} }
#endif
/* /*
* XXX see session_recv * 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); nghttp2_session_callbacks_set_unpack_extension_callback(callbacks, unpack_extension_callback);
#endif #endif
nghttp2_session_callbacks_set_on_extension_chunk_recv_callback(callbacks, on_extension_chunk_recv_callback); 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); nghttp2_session_callbacks_set_error_callback2(callbacks, error_callback2);
#endif
/* Create session for server use, register callbacks */ /* Create session for server use, register callbacks */
if ((ngerr = nghttp2_session_server_new3(&session, callbacks, rc, NULL, NULL)) < 0){ if ((ngerr = nghttp2_session_server_new3(&session, callbacks, rc, NULL, NULL)) < 0){