osmo-v5/src/v5x_le_provisioning.c

91 lines
3.3 KiB
C

/* (C) 2022 by Andreas Eversberg <jolly@eversberg.eu>
*
* All Rights Reserved
*
* SPDX-License-Identifier: GPL-2.0+
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#include <unistd.h>
#include <stdint.h>
#include <errno.h>
#include "v5x_internal.h"
#include "v5x_protocol.h"
#include "v5x_le_ctrl_fsm.h"
#include "v5x_le_provisioning.h"
#include "logging.h"
/* ITU-T G.964 Section 14.5 V5.1-re-provisioning procedures */
/* This is incomplete and very minimal */
void v5x_le_provisioning_init(void)
{
LOGP(DV5PROV, LOGL_NOTICE, "Using V5x provisioning\n");
}
/* messages from common control layer */
void v5x_le_provisioning_rcv(struct v5x_interface *v5if, uint8_t cfi, uint8_t variant, uint8_t rej_cause,
uint32_t interface_id)
{
LOGP(DV5PROV, LOGL_DEBUG, "Received common control message from control protocol. "
"(cfi = %d, variant = %d, rej_cause = %d, interface_id = %d)\n", cfi, variant, rej_cause, interface_id);
switch (cfi) {
case V5X_CTRL_ID_REQUEST_VARIANT_AND_INTERFACE_ID:
LOGP(DV5PROV, LOGL_INFO, "AN requests variant and interface ID, replying.\n");
v5x_le_ctrl_common_snd(v5if, V5X_CTRL_ID_VARIANT_AND_INTERFACE_ID, NULL, &v5if->variant, &v5if->id);
break;
case V5X_CTRL_ID_RESTART_REQUEST:
LOGP(DV5PROV, LOGL_INFO, "AN requests restart, replying.\n");
v5x_le_ctrl_common_snd(v5if, V5X_CTRL_ID_RESTART_COMPLETE, NULL, NULL, NULL);
break;
case V5X_CTRL_ID_VARIANT_AND_INTERFACE_ID:
LOGP(DV5PROV, LOGL_INFO, "AN replies variant and interface ID. (variant = %d, interface_id = %d)\n",
variant, interface_id);
if (variant != v5if->variant)
LOGP(DV5PROV, LOGL_ERROR, "Variant does not match: AN(%d) != LE(%d)\n", variant, v5if->variant);
if (interface_id != v5if->id) {
LOGP(DV5PROV, LOGL_ERROR, "Interface ID does not match: AN(%d) != LE(%d)\n", variant,
v5if->variant);
}
break;
case V5X_CTRL_ID_RESTART_COMPLETE:
LOGP(DV5PROV, LOGL_INFO, "AN replies restart.\n");
break;
default:
LOGP(DV5PROV, LOGL_NOTICE, "Ignoring common control message with cfi = %d\n", cfi);
}
}
/* perform provisioning */
void v5x_le_provisioning_start(struct v5x_interface *v5if)
{
/* ask for variant and interface ID */
LOGP(DV5PROV, LOGL_INFO, "Requesting variant and interface ID.\n");
v5x_le_ctrl_common_snd(v5if, V5X_CTRL_ID_REQUEST_VARIANT_AND_INTERFACE_ID, NULL, NULL, NULL);
#if 0
Do not send a restart, because it will make Fastlink reset the link after two minutes.
Also port states will not be indicted. (blocked/unblocked)
/* request a restart */
LOGP(DV5PROV, LOGL_INFO, "Requesting restart.\n");
v51_snd_ctrl_common(v5if, V51_CTRL_ID_RESTART_REQUEST, NULL, NULL, NULL);
#endif
}