X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvcl%2Fvppcom.c;h=05b84d4674bdabb571f845ae9f090bc73a20fb4e;hb=dd92bdeb0735dac940d32f651c0b0b9ed65a6d7d;hp=8476ea44d6839faa0d055957b980d6d91856d853;hpb=3f245e687c6bd837dcf7c6734aeed788bdbb4220;p=vpp.git diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c index 8476ea44d68..05b84d4674b 100644 --- a/src/vcl/vppcom.c +++ b/src/vcl/vppcom.c @@ -411,6 +411,7 @@ vcl_session_connected_handler (vcl_worker_t * wrk, format_session_error, mp->retval); session->session_state = VCL_STATE_DETACHED; session->vpp_handle = VCL_INVALID_SESSION_HANDLE; + session->vpp_error = mp->retval; return session_index; } @@ -1398,6 +1399,7 @@ vppcom_session_create (u8 proto, u8 is_nonblocking) session->session_state = VCL_STATE_CLOSED; session->vpp_handle = ~0; session->is_dgram = vcl_proto_is_dgram (proto); + session->vpp_error = SESSION_E_NONE; if (is_nonblocking) vcl_session_set_attr (session, VCL_SESS_ATTR_NONBLOCK); @@ -4420,6 +4422,10 @@ vppcom_retval_str (int retval) st = "VPPCOM_ETIMEDOUT"; break; + case VPPCOM_EADDRINUSE: + st = "VPPCOM_EADDRINUSE"; + break; + default: st = "UNKNOWN_STATE"; break; @@ -4446,6 +4452,32 @@ vppcom_del_cert_key_pair (uint32_t ckpair_index) return vcl_bapi_del_cert_key_pair (ckpair_index); } +int +vppcom_session_get_error (uint32_t session_handle) +{ + vcl_worker_t *wrk = vcl_worker_get_current (); + vcl_session_t *session = 0; + + session = vcl_session_get_w_handle (wrk, session_handle); + if (!session) + return VPPCOM_EBADFD; + + if (PREDICT_FALSE (session->flags & VCL_SESSION_F_IS_VEP)) + { + VWRN ("epoll session %u! will not have connect", session->session_index); + return VPPCOM_EBADFD; + } + + if (session->vpp_error == SESSION_E_PORTINUSE) + return VPPCOM_EADDRINUSE; + else if (session->vpp_error == SESSION_E_REFUSED) + return VPPCOM_ECONNREFUSED; + else if (session->vpp_error != SESSION_E_NONE) + return VPPCOM_EFAULT; + else + return VPPCOM_OK; +} + /* * fd.io coding-style-patch-verification: ON *