Add ssh connect function for M-plane
This commit is contained in:
@@ -26,6 +26,7 @@ target_compile_definitions(oran_fhlib_5g_mplane PRIVATE OAI_MPLANE)
|
||||
|
||||
target_sources(oran_fhlib_5g_mplane PRIVATE
|
||||
init-mplane.c
|
||||
connect-mplane.c
|
||||
)
|
||||
|
||||
pkg_check_modules(libyang REQUIRED libyang)
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
#include "connect-mplane.h"
|
||||
#include "common/utils/assertions.h"
|
||||
|
||||
#include <libyang/libyang.h>
|
||||
#include <nc_client.h>
|
||||
|
||||
static int my_auth_hostkey_check(const char *hostname, ssh_session session, void *priv)
|
||||
{
|
||||
(void)hostname;
|
||||
(void)session;
|
||||
(void)priv;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool connect_mplane(ru_session_t *ru_session)
|
||||
{
|
||||
int port = NC_PORT_SSH;
|
||||
char *user = "oranbenetel";
|
||||
|
||||
nc_client_ssh_set_username(user);
|
||||
|
||||
nc_client_ssh_set_auth_pref(NC_SSH_AUTH_PUBLICKEY, 1); // ssh-key identification
|
||||
nc_client_ssh_set_auth_pref(NC_SSH_AUTH_PASSWORD, -1);
|
||||
nc_client_ssh_set_auth_pref(NC_SSH_AUTH_INTERACTIVE, -1);
|
||||
|
||||
nc_client_ssh_set_auth_hostkey_check_clb(my_auth_hostkey_check, "DATA"); // host-key identification
|
||||
|
||||
MP_LOG_I("RPC request to RU \"%s\" = <connect> with username \"%s\" and port ID \"%d\".\n", ru_session->ru_ip_add, user, port);
|
||||
ru_session->session = nc_connect_ssh(ru_session->ru_ip_add, port, NULL);
|
||||
AssertError(ru_session->session != NULL, return false, "[MPLANE] RU IP address %s unreachable. Maybe M-plane is disabled on the RU?\n", ru_session->ru_ip_add);
|
||||
|
||||
MP_LOG_I("Successfuly connected to RU \"%s\" with username \"%s\" and port ID \"%d\".\n", ru_session->ru_ip_add, user, port);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
#ifndef CONNECT_MPLANE_H
|
||||
#define CONNECT_MPLANE_H
|
||||
|
||||
#include "ru-mplane-api.h"
|
||||
|
||||
bool connect_mplane(ru_session_t *ru_session);
|
||||
|
||||
#endif /* CONNECT_MPLANE_H */
|
||||
@@ -41,6 +41,7 @@
|
||||
|
||||
#ifdef OAI_MPLANE
|
||||
#include "mplane/init-mplane.h"
|
||||
#include "mplane/connect-mplane.h"
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
@@ -293,6 +294,15 @@ __attribute__((__visibility__("default"))) int transport_init(openair0_device *d
|
||||
ru_session_list_t ru_session_list = {0};
|
||||
success = init_mplane(&ru_session_list);
|
||||
AssertFatal(success, "[MPLANE] Cannot initialize M-plane.\n");
|
||||
|
||||
bool ru_configured[ru_session_list.num_rus];
|
||||
for (size_t i = 0; i < ru_session_list.num_rus; i++) {
|
||||
ru_session_t *ru_session = &ru_session_list.ru_session[i];
|
||||
ru_configured[i] = connect_mplane(ru_session);
|
||||
if (!ru_configured[i]) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#else
|
||||
success = get_xran_config(openair0_cfg, &fh_init, fh_config);
|
||||
AssertFatal(success, "cannot get configuration for xran\n");
|
||||
|
||||
Reference in New Issue
Block a user