diff --git a/.gitignore b/.gitignore
index a9144d6699af12319a67e8bad5cec982f3ae6a8c..20b98c30c5b3edb0983578b0a5f74fb1c1f3025e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -171,5 +171,8 @@ local_k8s_deployment.sh
# asdf configuration
.tool-versions
+# libyang build files
+libyang/
+
# Other logs
**/logs/*.log.*
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 0c3626b2f576dae2135de2030c01ada133aa89d7..e2d653e0360b694891adc966d6d0b1124ed72ac4 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,4 +1,4 @@
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -17,10 +17,9 @@ stages:
#- dependencies
- build
- unit_test
- #- deploy
- #- end2end_test
+ - end2end_test
-# include the individual .gitlab-ci.yml of each micro-service
+# include the individual .gitlab-ci.yml of each micro-service and tests
include:
#- local: '/manifests/.gitlab-ci.yml'
- local: '/src/monitoring/.gitlab-ci.yml'
@@ -31,7 +30,8 @@ include:
- local: '/src/dbscanserving/.gitlab-ci.yml'
- local: '/src/opticalattackmitigator/.gitlab-ci.yml'
- local: '/src/opticalattackdetector/.gitlab-ci.yml'
- # - local: '/src/opticalattackmanager/.gitlab-ci.yml'
+ - local: '/src/opticalattackmanager/.gitlab-ci.yml'
+ - local: '/src/opticalcontroller/.gitlab-ci.yml'
- local: '/src/ztp/.gitlab-ci.yml'
- local: '/src/policy/.gitlab-ci.yml'
- local: '/src/forecaster/.gitlab-ci.yml'
@@ -39,8 +39,12 @@ include:
#- local: '/src/l3_distributedattackdetector/.gitlab-ci.yml'
#- local: '/src/l3_centralizedattackdetector/.gitlab-ci.yml'
#- local: '/src/l3_attackmitigator/.gitlab-ci.yml'
- #- local: '/src/slice/.gitlab-ci.yml'
+ - local: '/src/slice/.gitlab-ci.yml'
#- local: '/src/interdomain/.gitlab-ci.yml'
- local: '/src/pathcomp/.gitlab-ci.yml'
#- local: '/src/dlt/.gitlab-ci.yml'
- local: '/src/load_generator/.gitlab-ci.yml'
+ - local: '/src/bgpls_speaker/.gitlab-ci.yml'
+
+ # This should be last one: end-to-end integration tests
+ - local: '/src/tests/.gitlab-ci.yml'
diff --git a/README.md b/README.md
index 5bfb6d70d947f631e8694b3dcf6c872cf1248ea4..8825795b864938af9fd2eb67e181c719ee9fbd26 100644
--- a/README.md
+++ b/README.md
@@ -1,14 +1,25 @@
# ETSI TeraFlowSDN Controller
-[ETSI OpenSource Group for TeraFlowSDN](https://tfs.etsi.org/)
+The [ETSI Software Development Group TeraFlowSDN (SDG TFS)](https://tfs.etsi.org/) is developing an open source cloud native SDN controller enabling smart connectivity services for future networks beyond 5G.
-Former, [Teraflow H2020 project](https://teraflow-h2020.eu/) - Secured autonomic traffic management for a Tera of SDN Flows
+The project originated from "[Teraflow H2020 project](https://teraflow-h2020.eu/) - Secured autonomic traffic management for a Tera of SDN Flows", a project funded by the European Union’s Horizon 2020 Research and Innovation programme that finished on 30th June 2023.
-Branch "master" : [![pipeline status](https://labs.etsi.org/rep/tfs/controller/badges/master/pipeline.svg)](https://labs.etsi.org/rep/tfs/controller/-/commits/master) [![coverage report](https://labs.etsi.org/rep/tfs/controller/badges/master/coverage.svg)](https://labs.etsi.org/rep/tfs/controller/-/commits/master)
-Branch "develop" : [![pipeline status](https://labs.etsi.org/rep/tfs/controller/badges/develop/pipeline.svg)](https://labs.etsi.org/rep/tfs/controller/-/commits/develop) [![coverage report](https://labs.etsi.org/rep/tfs/controller/badges/develop/coverage.svg)](https://labs.etsi.org/rep/tfs/controller/-/commits/develop)
+## Available branches and releases
-# Installation Instructions and Functional Tests
-The [TeraFlowSDN Wiki](https://labs.etsi.org/rep/tfs/controller/-/wikis/home) pages include details on using the ETSI TeraFlowSDN release 2.0.
+[![Latest Release](https://labs.etsi.org/rep/tfs/controller/-/badges/release.svg)](https://labs.etsi.org/rep/tfs/controller/-/releases)
-The documentation, installation instructions, and description of the functional tests defined to enable experimentation with the ETSI TeraFlowSDN Controller can be found in the Wiki pages
+- The branch `master` ([![pipeline status](https://labs.etsi.org/rep/tfs/controller/badges/master/pipeline.svg)](https://labs.etsi.org/rep/tfs/controller/-/commits/master) [![coverage report](https://labs.etsi.org/rep/tfs/controller/badges/master/coverage.svg)](https://labs.etsi.org/rep/tfs/controller/-/commits/master)), points always to the latest stable version of the TeraFlowSDN controller.
+
+- The branches `release/X.Y.Z`, point to the code for the different release versions indicated in the branch name.
+ - Code in these branches can be considered stable, and no new features are planned.
+ - In case of bugs, point releases increasing revision number (Z) might be created.
+
+- The `develop` ([![pipeline status](https://labs.etsi.org/rep/tfs/controller/badges/develop/pipeline.svg)](https://labs.etsi.org/rep/tfs/controller/-/commits/develop) [![coverage report](https://labs.etsi.org/rep/tfs/controller/badges/develop/coverage.svg)](https://labs.etsi.org/rep/tfs/controller/-/commits/develop)) branch is the main development branch and contains the latest contributions.
+ - **Use it with care! It might not be stable.**
+ - The latest developments and contributions are added to this branch for testing and validation before reaching a release.
+
+
+## Documentation
+The [TeraFlowSDN Wiki](https://labs.etsi.org/rep/tfs/controller/-/wikis/home) pages include the main documentation for the ETSI TeraFlowSDN Controller.
+The documentation includes project documentation, installation instructions, functional tests, supported NBIs and SBIs, etc.
diff --git a/clean_testing_environment.sh b/clean_testing_environment.sh
index b9c502ade6f34e3a19ebeafa67c222b10ea3f99d..f037a2a39309abb192c36943c014c4a3b893dd98 100755
--- a/clean_testing_environment.sh
+++ b/clean_testing_environment.sh
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/common_requirements.in b/common_requirements.in
index 37b70c993e913602f9d5e509d0c887802c5d0b1e..3aa30e174f43d6f8758f49b3104a20cc8580a7ff 100644
--- a/common_requirements.in
+++ b/common_requirements.in
@@ -1,4 +1,4 @@
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/coverage/.coveragerc.template b/coverage/.coveragerc.template
index 4421399ca30027e3032001dae64e6fa0b7fa41cb..3d8065acabefc65daad28fd4bd2e166b84d11d8b 100644
--- a/coverage/.coveragerc.template
+++ b/coverage/.coveragerc.template
@@ -1,4 +1,4 @@
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/data/perf/old/MW/generate.sh b/data/perf/old/MW/generate.sh
index a7fd03b2ffc8f546e7778e77bc3197661bcb0336..ccef4e113b3216bc4e4dddcd4be793c2bba32501 100755
--- a/data/perf/old/MW/generate.sh
+++ b/data/perf/old/MW/generate.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/data/perf/old/MW/generate_plot.py b/data/perf/old/MW/generate_plot.py
index 3d2d3a77c130ab4a3aac6bb5e9fba3eab59de67a..22befef305bf33b4aa150bf60fbd39fac3c61402 100644
--- a/data/perf/old/MW/generate_plot.py
+++ b/data/perf/old/MW/generate_plot.py
@@ -1,4 +1,4 @@
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/data/perf/old/OpenConfig/generate.sh b/data/perf/old/OpenConfig/generate.sh
index 6a6123bab2c2a1d0f475a0503a0af8d1612e7cac..5147d49626143919814a6184e02cbabdaf32b5cf 100755
--- a/data/perf/old/OpenConfig/generate.sh
+++ b/data/perf/old/OpenConfig/generate.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/data/perf/old/OpenConfig/generate_plot.py b/data/perf/old/OpenConfig/generate_plot.py
index 63166d7ac67802d1dcd37fafa6299cb6af898c8e..8d50ab81fd41d5dc8963aa3a9dc317bd3487fd54 100644
--- a/data/perf/old/OpenConfig/generate_plot.py
+++ b/data/perf/old/OpenConfig/generate_plot.py
@@ -1,4 +1,4 @@
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/data/perf/old/TE/te-cdf.py b/data/perf/old/TE/te-cdf.py
index fdcc1f679e7f5c3c1523ee1edaaa260727d72884..a3e7cc53006f5b1f513ee2b3b23938d33cb93fcd 100644
--- a/data/perf/old/TE/te-cdf.py
+++ b/data/perf/old/TE/te-cdf.py
@@ -1,4 +1,4 @@
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/data/perf/old/XR/generate.sh b/data/perf/old/XR/generate.sh
index a2663295956aa20e4ed4f10a32a4f56f0df6fe29..d5b70476331f3a3e6ffcaa77cd3f2ef68008bc67 100755
--- a/data/perf/old/XR/generate.sh
+++ b/data/perf/old/XR/generate.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/data/perf/old/XR/generate_plot.py b/data/perf/old/XR/generate_plot.py
index d9cf628a1fd1608b5d312ebb443714a980040790..f27c37e53a287d90c209620282a25d5f92152f1e 100644
--- a/data/perf/old/XR/generate_plot.py
+++ b/data/perf/old/XR/generate_plot.py
@@ -1,4 +1,4 @@
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/data/perf/old/emulated/generate.sh b/data/perf/old/emulated/generate.sh
index c6140652514a8f35e01d7e788668d8c94e9aa064..7b978c1fd4f2962693926f9cf443a6d03ee17161 100755
--- a/data/perf/old/emulated/generate.sh
+++ b/data/perf/old/emulated/generate.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/data/perf/old/emulated/generate_plot.py b/data/perf/old/emulated/generate_plot.py
index 0f74bc401a518b706e9d17ab18a0e501edb7edcd..d049386c3cf010ae53e8f2a91a8354bdd54f910b 100644
--- a/data/perf/old/emulated/generate_plot.py
+++ b/data/perf/old/emulated/generate_plot.py
@@ -1,4 +1,4 @@
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/deploy/all.sh b/deploy/all.sh
index 7760d9dcd6366a5887edbedb285e59ef2ec97d81..332eb6ac65b62e21d0ce2276e7639fdcfde008d4 100755
--- a/deploy/all.sh
+++ b/deploy/all.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/deploy/component.sh b/deploy/component.sh
index e2648818684f672c41cca19a7ac1281b797f4382..89d2383d7c62393753de27abf9d0a15f67066c76 100755
--- a/deploy/component.sh
+++ b/deploy/component.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -40,6 +40,21 @@ export TFS_GRAFANA_PASSWORD=${TFS_GRAFANA_PASSWORD:-"admin123+"}
# Automated steps start here
########################################################################################################################
+DOCKER_BUILD="docker build"
+DOCKER_MAJOR_VERSION=$(docker --version | grep -o -E "Docker version [0-9]+\." | grep -o -E "[0-9]+" | cut -c 1-3)
+if [[ $DOCKER_MAJOR_VERSION -ge 23 ]]; then
+ # If Docker version >= 23, build command was migrated to docker-buildx
+ # In Ubuntu, in practice, means to install package docker-buildx together with docker.io
+ # Check if docker-buildx plugin is installed
+ docker buildx version 1>/dev/null 2>/dev/null
+ if [[ $? -ne 0 ]]; then
+ echo "Docker buildx command is not installed. Check: https://docs.docker.com/build/architecture/#install-buildx"
+ echo "If you installed docker through APT package docker.io, consider installing also package docker-buildx"
+ exit 1;
+ fi
+ DOCKER_BUILD="docker buildx build"
+fi
+
# Constants
GITLAB_REPO_URL="labs.etsi.org:5050/tfs/controller"
TMP_FOLDER="./tmp"
@@ -60,17 +75,17 @@ for COMPONENT in $TFS_COMPONENTS; do
BUILD_LOG="$TMP_LOGS_FOLDER/build_${COMPONENT}.log"
if [ "$COMPONENT" == "ztp" ] || [ "$COMPONENT" == "policy" ]; then
- docker build -t "$IMAGE_NAME" -f ./src/"$COMPONENT"/Dockerfile ./src/"$COMPONENT"/ > "$BUILD_LOG"
+ $DOCKER_BUILD -t "$IMAGE_NAME" -f ./src/"$COMPONENT"/Dockerfile ./src/"$COMPONENT"/ > "$BUILD_LOG"
elif [ "$COMPONENT" == "pathcomp" ]; then
BUILD_LOG="$TMP_LOGS_FOLDER/build_${COMPONENT}-frontend.log"
- docker build -t "$COMPONENT-frontend:$TFS_IMAGE_TAG" -f ./src/"$COMPONENT"/frontend/Dockerfile . >> "$BUILD_LOG"
+ $DOCKER_BUILD -t "$COMPONENT-frontend:$TFS_IMAGE_TAG" -f ./src/"$COMPONENT"/frontend/Dockerfile . >> "$BUILD_LOG"
BUILD_LOG="$TMP_LOGS_FOLDER/build_${COMPONENT}-backend.log"
- docker build -t "$COMPONENT-backend:$TFS_IMAGE_TAG" -f ./src/"$COMPONENT"/backend/Dockerfile . >> "$BUILD_LOG"
+ $DOCKER_BUILD -t "$COMPONENT-backend:$TFS_IMAGE_TAG" -f ./src/"$COMPONENT"/backend/Dockerfile . >> "$BUILD_LOG"
# next command is redundant, but helpful to keep cache updated between rebuilds
- docker build -t "$COMPONENT-backend:$TFS_IMAGE_TAG-builder" --target builder -f ./src/"$COMPONENT"/backend/Dockerfile . >> "$BUILD_LOG"
+ $DOCKER_BUILD -t "$COMPONENT-backend:$TFS_IMAGE_TAG-builder" --target builder -f ./src/"$COMPONENT"/backend/Dockerfile . >> "$BUILD_LOG"
else
- docker build -t "$IMAGE_NAME" -f ./src/"$COMPONENT"/Dockerfile . > "$BUILD_LOG"
+ $DOCKER_BUILD -t "$IMAGE_NAME" -f ./src/"$COMPONENT"/Dockerfile . > "$BUILD_LOG"
fi
if [ -n "$TFS_REGISTRY_IMAGES" ]; then
diff --git a/deploy/crdb.sh b/deploy/crdb.sh
index 5d87adf60bbb3303e9abe9cc17c4a68cbe295370..c979ad4f2c18861c6a93b6b04e5d8e3e71aae41e 100755
--- a/deploy/crdb.sh
+++ b/deploy/crdb.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -158,9 +158,19 @@ function crdb_undeploy_single() {
function crdb_drop_database_single() {
echo "Drop database if exists"
- CRDB_PORT_SQL=$(kubectl --namespace ${CRDB_NAMESPACE} get service cockroachdb-public -o 'jsonpath={.spec.ports[?(@.name=="sql")].port}')
- CRDB_CLIENT_URL="postgresql://${CRDB_USERNAME}:${CRDB_PASSWORD}@cockroachdb-0:${CRDB_PORT_SQL}/defaultdb?sslmode=require"
- kubectl exec -it --namespace ${CRDB_NAMESPACE} cockroachdb-0 -- \
+
+ if [[ -z "${GITLAB_CI}" ]]; then
+ #kubectl --namespace ${CRDB_NAMESPACE} get service cockroachdb-public -o yaml
+ CRDB_HOST=$(kubectl --namespace ${CRDB_NAMESPACE} get service cockroachdb-public -o 'jsonpath={.spec.clusterIP}')
+ CRDB_PORT=$(kubectl --namespace ${CRDB_NAMESPACE} get service cockroachdb-public -o 'jsonpath={.spec.ports[?(@.name=="sql")].port}')
+ else
+ CRDB_HOST="127.0.0.1"
+ CRDB_PORT=${CRDB_EXT_PORT_SQL}
+ fi
+
+ CRDB_CLIENT_URL="postgresql://${CRDB_USERNAME}:${CRDB_PASSWORD}@${CRDB_HOST}:${CRDB_PORT}/defaultdb?sslmode=require"
+ echo "CRDB_CLIENT_URL=${CRDB_CLIENT_URL}"
+ kubectl exec -i --namespace ${CRDB_NAMESPACE} cockroachdb-0 -- \
./cockroach sql --certs-dir=/cockroach/cockroach-certs --url=${CRDB_CLIENT_URL} \
--execute "DROP DATABASE IF EXISTS ${CRDB_DATABASE};"
echo
@@ -343,7 +353,7 @@ function crdb_undeploy_cluster() {
function crdb_drop_database_cluster() {
echo "Drop database if exists"
- kubectl exec -it --namespace ${CRDB_NAMESPACE} cockroachdb-client-secure -- \
+ kubectl exec -i --namespace ${CRDB_NAMESPACE} cockroachdb-client-secure -- \
./cockroach sql --certs-dir=/cockroach/cockroach-certs --host=cockroachdb-public --execute \
"DROP DATABASE IF EXISTS ${CRDB_DATABASE};"
echo
diff --git a/deploy/expose_dashboard.sh b/deploy/expose_dashboard.sh
index d42a340ac18f50a93fd42bbfc03f40176a0ec9d6..7180c4ca5c1147c27bd5a6a8f7aded9b2fcbd24e 100755
--- a/deploy/expose_dashboard.sh
+++ b/deploy/expose_dashboard.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/deploy/mock_blockchain.sh b/deploy/mock_blockchain.sh
index 74d62cd526a38298c8f197fedf0c0169dbb8efca..fafa435b10f7c027e088435997ec01ebf1858d0f 100755
--- a/deploy/mock_blockchain.sh
+++ b/deploy/mock_blockchain.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -58,9 +58,24 @@ echo "Processing '$COMPONENT' component..."
IMAGE_NAME="$COMPONENT:$IMAGE_TAG"
IMAGE_URL=$(echo "$REGISTRY_IMAGE/$IMAGE_NAME" | sed 's,//,/,g' | sed 's,http:/,,g')
+DOCKER_BUILD="docker build"
+DOCKER_MAJOR_VERSION=$(docker --version | grep -o -E "Docker version [0-9]+\." | grep -o -E "[0-9]+" | cut -c 1-3)
+if [[ $DOCKER_MAJOR_VERSION -ge 23 ]]; then
+ # If Docker version >= 23, build command was migrated to docker-buildx
+ # In Ubuntu, in practice, means to install package docker-buildx together with docker.io
+ # Check if docker-buildx plugin is installed
+ docker buildx version 1>/dev/null 2>/dev/null
+ if [[ $? -ne 0 ]]; then
+ echo "Docker buildx command is not installed. Check: https://docs.docker.com/build/architecture/#install-buildx"
+ echo "If you installed docker through APT package docker.io, consider installing also package docker-buildx"
+ exit 1;
+ fi
+ DOCKER_BUILD="docker buildx build"
+fi
+
echo " Building Docker image..."
BUILD_LOG="$TMP_LOGS_FOLDER/build_${COMPONENT}.log"
-docker build -t "$IMAGE_NAME" -f ./src/dlt/mock_blockchain/Dockerfile . > "$BUILD_LOG"
+$DOCKER_BUILD -t "$IMAGE_NAME" -f ./src/dlt/mock_blockchain/Dockerfile . > "$BUILD_LOG"
if [ -n "$REGISTRY_IMAGE" ]; then
echo " Pushing Docker image to '$REGISTRY_IMAGE'..."
diff --git a/deploy/nats.sh b/deploy/nats.sh
index b730cec4af66920e5a7d8a2235e63beff70e8694..366270a6915a1eef969846446ecc9152c3fa9531 100755
--- a/deploy/nats.sh
+++ b/deploy/nats.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -47,6 +47,10 @@ function nats_deploy_single() {
helm3 repo add nats https://nats-io.github.io/k8s/helm/charts/
echo
+ echo "Upgrade NATS Helm Chart"
+ helm3 repo update nats
+ echo
+
echo "Install NATS (single-node)"
echo ">>> Checking if NATS is deployed..."
if kubectl get --namespace ${NATS_NAMESPACE} statefulset/${NATS_NAMESPACE} &> /dev/null; then
@@ -81,6 +85,10 @@ function nats_deploy_single() {
echo "NATS Port Mapping"
echo ">>> Expose NATS Client port (4222->${NATS_EXT_PORT_CLIENT})"
NATS_PORT_CLIENT=$(kubectl --namespace ${NATS_NAMESPACE} get service ${NATS_NAMESPACE} -o 'jsonpath={.spec.ports[?(@.name=="client")].port}')
+ if [ -z "$NATS_PORT_CLIENT" ]; then
+ # NATS charts updated and port name changed from "client" to "nats"; fix to support new name and enable backward compatibility
+ NATS_PORT_CLIENT=$(kubectl --namespace ${NATS_NAMESPACE} get service ${NATS_NAMESPACE} -o 'jsonpath={.spec.ports[?(@.name=="nats")].port}')
+ fi
PATCH='{"data": {"'${NATS_EXT_PORT_CLIENT}'": "'${NATS_NAMESPACE}'/'${NATS_NAMESPACE}':'${NATS_PORT_CLIENT}'"}}'
kubectl patch configmap nginx-ingress-tcp-microk8s-conf --namespace ingress --patch "${PATCH}"
diff --git a/deploy/qdb.sh b/deploy/qdb.sh
index e930b5a6cfdba8897ec138e97e3115da8917554f..acbcfd4f96ccbd2b09d5d82f66a1bf801a710780 100755
--- a/deploy/qdb.sh
+++ b/deploy/qdb.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -160,10 +160,17 @@ function qdb_undeploy() {
}
function qdb_drop_tables() {
- QDB_HOST=$(kubectl --namespace ${QDB_NAMESPACE} get service questdb-public -o 'jsonpath={.spec.clusterIP}')
- QDB_PORT=$(kubectl --namespace ${QDB_NAMESPACE} get service questdb-public -o 'jsonpath={.spec.ports[?(@.name=="http")].port}')
-
echo "Drop tables, if exist"
+
+ if [[ -z "${GITLAB_CI}" ]]; then
+ #kubectl --namespace ${QDB_NAMESPACE} get service questdb-public -o yaml
+ QDB_HOST=$(kubectl --namespace ${QDB_NAMESPACE} get service questdb-public -o 'jsonpath={.spec.clusterIP}')
+ QDB_PORT=$(kubectl --namespace ${QDB_NAMESPACE} get service questdb-public -o 'jsonpath={.spec.ports[?(@.name=="http")].port}')
+ else
+ QDB_HOST="127.0.0.1"
+ QDB_PORT=${QDB_EXT_PORT_HTTP}
+ fi
+
curl "http://${QDB_HOST}:${QDB_PORT}/exec?fmt=json&query=DROP+TABLE+IF+EXISTS+${QDB_TABLE_MONITORING_KPIS}+;"
echo
curl "http://${QDB_HOST}:${QDB_PORT}/exec?fmt=json&query=DROP+TABLE+IF+EXISTS+${QDB_TABLE_SLICE_GROUPS}+;"
diff --git a/deploy/show.sh b/deploy/show.sh
index a4084ac65402c7987504fbcacdf6aa5b44029fc4..4fa1ce3a6dac5194e967ccbe0826a6ed9a64e3f8 100755
--- a/deploy/show.sh
+++ b/deploy/show.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/deploy/tfs.sh b/deploy/tfs.sh
index 41dcdc2a6c75846757de709ee2880c42e3eac42d..e93cb35442bca4aa555d0589df4fc90391d9376a 100755
--- a/deploy/tfs.sh
+++ b/deploy/tfs.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -150,6 +150,10 @@ printf "\n"
echo "Create secret with NATS data"
NATS_CLIENT_PORT=$(kubectl --namespace ${NATS_NAMESPACE} get service ${NATS_NAMESPACE} -o 'jsonpath={.spec.ports[?(@.name=="client")].port}')
+if [ -z "$NATS_CLIENT_PORT" ]; then
+ # NATS charts updated and port name changed from "client" to "nats"; fix to support new name and enable backward compatibility
+ NATS_CLIENT_PORT=$(kubectl --namespace ${NATS_NAMESPACE} get service ${NATS_NAMESPACE} -o 'jsonpath={.spec.ports[?(@.name=="nats")].port}')
+fi
kubectl create secret generic nats-data --namespace ${TFS_K8S_NAMESPACE} --type='Opaque' \
--from-literal=NATS_NAMESPACE=${NATS_NAMESPACE} \
--from-literal=NATS_CLIENT_PORT=${NATS_CLIENT_PORT}
@@ -297,8 +301,13 @@ for COMPONENT in $TFS_COMPONENTS; do
VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}-gateway:" "$MANIFEST" | cut -d ":" -f4)
sed -E -i "s#image: $GITLAB_REPO_URL/$COMPONENT-gateway:${VERSION}#image: $IMAGE_URL#g" "$MANIFEST"
else
- IMAGE_URL=$(echo "$TFS_REGISTRY_IMAGES/$COMPONENT:$TFS_IMAGE_TAG" | sed 's,//,/,g' | sed 's,http:/,,g')
- VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}:" "$MANIFEST" | cut -d ":" -f4)
+ if [ "$TFS_SKIP_BUILD" != "YES" ]; then
+ IMAGE_URL=$(echo "$TFS_REGISTRY_IMAGES/$COMPONENT:$TFS_IMAGE_TAG" | sed 's,//,/,g' | sed 's,http:/,,g')
+ VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}:" "$MANIFEST" | cut -d ":" -f4)
+ else
+ VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}:" "$MANIFEST" | cut -d ":" -f4)
+ IMAGE_URL=$(echo "$TFS_REGISTRY_IMAGES/$COMPONENT:$VERSION" | sed 's,//,/,g' | sed 's,http:/,,g')
+ fi
sed -E -i "s#image: $GITLAB_REPO_URL/$COMPONENT:${VERSION}#image: $IMAGE_URL#g" "$MANIFEST"
fi
@@ -362,7 +371,13 @@ for COMPONENT in $TFS_COMPONENTS; do
echo "Waiting for '$COMPONENT' component..."
COMPONENT_OBJNAME=$(echo "${COMPONENT}" | sed "s/\_/-/")
kubectl wait --namespace $TFS_K8S_NAMESPACE \
- --for='condition=available' --timeout=300s deployment/${COMPONENT_OBJNAME}service
+ --for='condition=available' --timeout=90s deployment/${COMPONENT_OBJNAME}service
+ WAIT_EXIT_CODE=$?
+ if [[ $WAIT_EXIT_CODE != 0 ]]; then
+ echo " Failed to deploy '${COMPONENT}' component, exit code '${WAIT_EXIT_CODE}', exiting..."
+ kubectl logs --namespace $TFS_K8S_NAMESPACE deployment/${COMPONENT_OBJNAME}service --all-containers=true
+ exit $WAIT_EXIT_CODE
+ fi
printf "\n"
done
@@ -572,3 +587,9 @@ if [[ "$TFS_COMPONENTS" == *"monitoring"* ]] && [[ "$TFS_COMPONENTS" == *"webui"
printf "\n\n"
fi
+
+if [ "$DOCKER_BUILD" == "docker buildx build" ]; then
+ echo "Pruning Docker Buildx Cache..."
+ docker buildx prune --force
+ printf "\n\n"
+fi
diff --git a/hackfest/containerlab/tfs-scenario.clab.yml b/hackfest/containerlab/tfs-scenario.clab.yml
index df197ebea70906874515240f18d2f06c4c307c88..f79378757827ff706be849b03277b947ee85f7fb 100644
--- a/hackfest/containerlab/tfs-scenario.clab.yml
+++ b/hackfest/containerlab/tfs-scenario.clab.yml
@@ -1,4 +1,4 @@
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/hackfest/gnmi/srlinux.clab.yml b/hackfest/gnmi/srlinux.clab.yml
index a589292ac5b58664646ab7d3cccebfd62c28a540..6cfeb6108cd88cb52bd5925a374ea8c6724f4c69 100644
--- a/hackfest/gnmi/srlinux.clab.yml
+++ b/hackfest/gnmi/srlinux.clab.yml
@@ -1,4 +1,4 @@
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/hackfest/grpc/connection.proto b/hackfest/grpc/connection.proto
index 0e8522768614ec4c698b87647118101ae0479aaa..0da1059f3d65357f520b5123cc29d4c6230e8388 100644
--- a/hackfest/grpc/connection.proto
+++ b/hackfest/grpc/connection.proto
@@ -1,4 +1,4 @@
-// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+// Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
diff --git a/hackfest/grpc/connection/create.py b/hackfest/grpc/connection/create.py
index 7d134105d04b155abc2d3d4ad3e4efeef085c81a..9e32dd8d4e3c89555c039d417b5aab2f6d9ef321 100644
--- a/hackfest/grpc/connection/create.py
+++ b/hackfest/grpc/connection/create.py
@@ -1,5 +1,5 @@
#! /usr/bin/env python3
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/hackfest/grpc/connection/list.py b/hackfest/grpc/connection/list.py
index 5b1926d3cac8dbdf00d889726b1638e0a70ad6b2..e852b69b7cee16e02ca2021db83bbc11cd9c7538 100644
--- a/hackfest/grpc/connection/list.py
+++ b/hackfest/grpc/connection/list.py
@@ -1,5 +1,5 @@
#! /usr/bin/env python3
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/hackfest/grpc/connectionService.proto b/hackfest/grpc/connectionService.proto
index 8f6b5a6e781ba074239bfdbc2d05bea638b153a3..0a80f2c1a49056ce76766e720b427283fd63969d 100644
--- a/hackfest/grpc/connectionService.proto
+++ b/hackfest/grpc/connectionService.proto
@@ -1,4 +1,4 @@
-// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+// Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
diff --git a/hackfest/grpc/connectionService/connectionService_client.py b/hackfest/grpc/connectionService/connectionService_client.py
index e5c1bf48186b4c5e7e3425e3601e32642e7d2fcc..2ed97ae97c4ef50c036635f8d5fb5812ad92c5b5 100644
--- a/hackfest/grpc/connectionService/connectionService_client.py
+++ b/hackfest/grpc/connectionService/connectionService_client.py
@@ -1,4 +1,4 @@
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/hackfest/grpc/connectionService/connectionService_server.py b/hackfest/grpc/connectionService/connectionService_server.py
index f1632db90cd6d7dbfd186fe3c4bad9da32195b28..ff991f44c16ac12ec7042f922dc9558ec08fcfbe 100644
--- a/hackfest/grpc/connectionService/connectionService_server.py
+++ b/hackfest/grpc/connectionService/connectionService_server.py
@@ -1,4 +1,4 @@
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/hackfest/grpc/connectionServiceWithNotif.proto b/hackfest/grpc/connectionServiceWithNotif.proto
index f2f5b17e317cd5c15461979cf2cf20462d3d72de..778203e2619aa938194107d855ea4949fdf550da 100644
--- a/hackfest/grpc/connectionServiceWithNotif.proto
+++ b/hackfest/grpc/connectionServiceWithNotif.proto
@@ -1,4 +1,4 @@
-// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+// Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
diff --git a/hackfest/grpc/connectionServiceWithNotif/connectionServiceWithNotif_client.py b/hackfest/grpc/connectionServiceWithNotif/connectionServiceWithNotif_client.py
index 9518bf743221c0a2e2c1191be063aafff8eaccb5..2503f424f4dd3445d91c82daa235f4677e6f910a 100644
--- a/hackfest/grpc/connectionServiceWithNotif/connectionServiceWithNotif_client.py
+++ b/hackfest/grpc/connectionServiceWithNotif/connectionServiceWithNotif_client.py
@@ -1,4 +1,4 @@
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/hackfest/grpc/connectionServiceWithNotif/connectionServiceWithNotif_server.py b/hackfest/grpc/connectionServiceWithNotif/connectionServiceWithNotif_server.py
index 922f91837bc013f038985cbb0ef44aa234556696..d5c413064968c9ef30e015cf818e66066d45ceb9 100644
--- a/hackfest/grpc/connectionServiceWithNotif/connectionServiceWithNotif_server.py
+++ b/hackfest/grpc/connectionServiceWithNotif/connectionServiceWithNotif_server.py
@@ -1,4 +1,4 @@
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/hackfest/grpc/topologyService.proto b/hackfest/grpc/topologyService.proto
index 775e45addedd8fd30c888ddcd7f3de92a9b66a4b..6a38bf9c7dd1762743eda91b01c639f9bc5ae3ab 100644
--- a/hackfest/grpc/topologyService.proto
+++ b/hackfest/grpc/topologyService.proto
@@ -1,4 +1,4 @@
-// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+// Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
diff --git a/hackfest/grpc/topologyService/topologyService_client.py b/hackfest/grpc/topologyService/topologyService_client.py
index ef628183bed45452f191fc3be07a87db97ed6650..aa1ffc2bf6269ebd7495c9f01438cfc73315c687 100644
--- a/hackfest/grpc/topologyService/topologyService_client.py
+++ b/hackfest/grpc/topologyService/topologyService_client.py
@@ -1,4 +1,4 @@
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/hackfest/grpc/topologyService/topologyService_server.py b/hackfest/grpc/topologyService/topologyService_server.py
index ff1c80e82a9bf3404c6e9da9b3c0f7c534d01889..dfd62aa13adf189c10477840c747fb34b610d5fc 100644
--- a/hackfest/grpc/topologyService/topologyService_server.py
+++ b/hackfest/grpc/topologyService/topologyService_server.py
@@ -1,4 +1,4 @@
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/hackfest/kafka/pub.py b/hackfest/kafka/pub.py
index e80dd5db82632b9ef17e7fdf017b8964ab357623..77564dfcb710677ecbd8fa9b2cbe8e6145c5baac 100644
--- a/hackfest/kafka/pub.py
+++ b/hackfest/kafka/pub.py
@@ -1,4 +1,4 @@
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/hackfest/kafka/sub.py b/hackfest/kafka/sub.py
index 233b9f9d0c8b4a4a744859beeaff0141c04e0560..2253c64674ce421d288344315649fbee64058432 100644
--- a/hackfest/kafka/sub.py
+++ b/hackfest/kafka/sub.py
@@ -1,4 +1,4 @@
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/hackfest/mock_osm/MockOSM.py b/hackfest/mock_osm/MockOSM.py
index 338db0e19becc8a9dd277beec7f3b4ceb2e765a3..7ced57d3efa64038d09f5cea21fb7098b8ceb2ba 100644
--- a/hackfest/mock_osm/MockOSM.py
+++ b/hackfest/mock_osm/MockOSM.py
@@ -1,4 +1,4 @@
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/hackfest/mock_osm/__init__.py b/hackfest/mock_osm/__init__.py
index 1549d9811aa5d1c193a44ad45d0d7773236c0612..3ee6f7071f145e06c3aeaefc09a43ccd88e619e3 100644
--- a/hackfest/mock_osm/__init__.py
+++ b/hackfest/mock_osm/__init__.py
@@ -1,4 +1,4 @@
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/hackfest/mock_osm/__main__.py b/hackfest/mock_osm/__main__.py
index 4ed25eaedbf4eba1f04ea41c72a751ecd7d6380b..48866fb2db7ac92c37f57561abc58c2d45df810a 100644
--- a/hackfest/mock_osm/__main__.py
+++ b/hackfest/mock_osm/__main__.py
@@ -1,4 +1,4 @@
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/hackfest/netconf-oc/device_definition.py b/hackfest/netconf-oc/device_definition.py
index 6e737f55675e811ebdd96a4d7471f1b4438c8e52..ecd3dd6ce5a7091d5223153ddd0f6e3cca7fc39d 100644
--- a/hackfest/netconf-oc/device_definition.py
+++ b/hackfest/netconf-oc/device_definition.py
@@ -1,4 +1,4 @@
-# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/hackfest/netconf-oc/interfaces.xml b/hackfest/netconf-oc/interfaces.xml
index c47fc44e3ba9ea0290823eb42feaa444d6179526..f04504bd408a7735ccdaa55c63c85ba25a7bde2d 100644
--- a/hackfest/netconf-oc/interfaces.xml
+++ b/hackfest/netconf-oc/interfaces.xml
@@ -1,6 +1,6 @@
dst: %s", link_id_src)
+ context_client.close()
+ return Empty()
diff --git a/src/bgpls_speaker/service/__init__.py b/src/bgpls_speaker/service/__init__.py
new file mode 100644
index 0000000000000000000000000000000000000000..839e45e3b646bc60de7edd81fcfb91b7b38feadf
--- /dev/null
+++ b/src/bgpls_speaker/service/__init__.py
@@ -0,0 +1,13 @@
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
+#
+# Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+#
+# 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.
\ No newline at end of file
diff --git a/src/bgpls_speaker/service/__main__.py b/src/bgpls_speaker/service/__main__.py
new file mode 100644
index 0000000000000000000000000000000000000000..564711b3b2766ddd79f555679d9eea94e718a85a
--- /dev/null
+++ b/src/bgpls_speaker/service/__main__.py
@@ -0,0 +1,63 @@
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
+#
+# Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+#
+# 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.
+
+import logging, signal, sys, threading
+from prometheus_client import start_http_server
+from common.Settings import get_log_level, get_metrics_port
+from .tools.DiscoveredDBManager import DiscoveredDBManager
+from .BgplsService import BgplsService
+from .tools.GrpcServer import GrpcServer
+
+terminate = threading.Event()
+LOGGER : logging.Logger = None
+_ONE_DAY_IN_SECONDS = 60 * 60 * 24
+
+def signal_handler(signal, frame):
+ LOGGER.warning('Terminate signal received')
+ LOGGER.warning(signal)
+ terminate.set()
+
+def main():
+ global LOGGER
+
+ log_level = get_log_level()
+ logging.basicConfig(level=log_level, format="[%(asctime)s] %(levelname)s:%(name)s:%(message)s")
+ LOGGER = logging.getLogger(__name__)
+ signal.signal(signal.SIGINT, signal_handler)
+ signal.signal(signal.SIGTERM, signal_handler)
+
+ LOGGER.info('Starting...')
+
+ # Start metrics server
+ metrics_port = get_metrics_port()
+ start_http_server(metrics_port)
+ # One common database for all bgpls_speakers connection
+ DB=DiscoveredDBManager()
+
+ speaker_server = GrpcServer(DB)
+ speaker_server.Connect()
+
+ grpc_service = BgplsService(DB,speaker_server)
+ grpc_service.start()
+
+ # Wait for termination signal
+ while not terminate.wait(timeout=0.1): pass
+ LOGGER.info('Terminating...')
+ speaker_server.terminateGrpcServer()
+ grpc_service.stop()
+ LOGGER.info('Bye')
+ return 0
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/src/bgpls_speaker/service/java/BGP4Parameters_3.xml b/src/bgpls_speaker/service/java/BGP4Parameters_3.xml
new file mode 100644
index 0000000000000000000000000000000000000000..b945caa8307e89447a8ec1230d440e9dab6a43c4
--- /dev/null
+++ b/src/bgpls_speaker/service/java/BGP4Parameters_3.xml
@@ -0,0 +1,65 @@
+
+
+
+
+ 12179
+ 7.7.7.7
+
+ 1112
+
+
+ 10.95.90.43
+ false
+ true
+ 179
+
+
+
+ BGP4Parser2.log
+ BGP4Client2.log
+ BGP4Server2.log
+
+ true
+
+ 40000
+ true
+
+
+ 180
+
+ 4
+
+ 65006
+
+
+
+ false
+
+ true
+
+ fromBGP
+
+
+
+
+
+ 0.0.0.0
+
\ No newline at end of file
diff --git a/src/bgpls_speaker/service/java/exec_speakear_java.sh b/src/bgpls_speaker/service/java/exec_speakear_java.sh
new file mode 100644
index 0000000000000000000000000000000000000000..4e38174fb070070106a8f0f7951d72ffb3f93fa0
--- /dev/null
+++ b/src/bgpls_speaker/service/java/exec_speakear_java.sh
@@ -0,0 +1,19 @@
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
+#
+# Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+#
+# 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.
+
+#!/bin/bash
+cd netphony-topology/
+"/home/ubuntu/downloads/apache-maven-3.8.8/bin/mvn" clean package -P bgp-ls-speaker assembly:single -DskipTests
+cd ..
+sudo java -jar netphony-topology/target/bgp-ls-speaker-jar-with-dependencies.jar BGP4Parameters_3.xml
\ No newline at end of file
diff --git a/src/bgpls_speaker/service/java/netphony-topology/.settings/org.eclipse.jdt.core.prefs b/src/bgpls_speaker/service/java/netphony-topology/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000000000000000000000000000000000000..cb635b1c2a6bee7b1279cac6db56bd9ee2f6c271
--- /dev/null
+++ b/src/bgpls_speaker/service/java/netphony-topology/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
+org.eclipse.jdt.core.compiler.release=disabled
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/src/bgpls_speaker/service/java/netphony-topology/BGP4Parameters_3.xml b/src/bgpls_speaker/service/java/netphony-topology/BGP4Parameters_3.xml
new file mode 100644
index 0000000000000000000000000000000000000000..50dce7ed17613cd9fa4d8f612751e4c045b30cab
--- /dev/null
+++ b/src/bgpls_speaker/service/java/netphony-topology/BGP4Parameters_3.xml
@@ -0,0 +1,65 @@
+
+
+
+
+ 12179
+ 7.7.7.7
+
+ 1112
+
+
+ 10.95.90.43
+ false
+ true
+ 179
+
+
+
+ BGP4Parser2.log
+ BGP4Client2.log
+ BGP4Server2.log
+
+ true
+
+ 40000
+ true
+
+
+ 180
+
+ 4
+
+ 100
+
+
+
+ false
+
+ true
+
+ fromBGP
+
+
+
+
+
+ 0.0.0.0
+
\ No newline at end of file
diff --git a/src/bgpls_speaker/service/java/netphony-topology/CHANGELOG b/src/bgpls_speaker/service/java/netphony-topology/CHANGELOG
new file mode 100644
index 0000000000000000000000000000000000000000..01a2b22efe4a23f2381d01d8b295dc34d8a7fda5
--- /dev/null
+++ b/src/bgpls_speaker/service/java/netphony-topology/CHANGELOG
@@ -0,0 +1,50 @@
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
+
+# Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+
+# 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.
+
+v1.3.3
+- Topology Module added
+- Topology Module: Export via RESCONF with COP model
+- Topology Module: Export via RESTCONF with IETF model (nodes only)
+- Topology Module: Export via UNIFY model
+- Topology Module: Import via XML
+- Topology Module: Import/Export via BGP-LS
+v1.3.2
+- Supports network-protocols 1.3.2
+- Update to support reading multiple AS_PATH
+- Apache 2.0 license
+- Moved to slf4j logging framework
+- Added method to pass multiple TEDs from en external program
+- Added docker support in travis
+v1.3
+- Compile with networking-protocols v1.3.0 (available in maven central)
+- JUnit Test upgrade to check intraTEDBs after sending
+- Added functionality: read multiple intraTEDBs from xml file
+- Added support to draft-previdi-idr-bgpls-te-metric-extensions-00
+v1.2.2
+- Added travis integration
+- Javadoc errors fixed
+- Ready to meet maven central requirements
+- Compile with networking-protocols v1.2.3 (available in maven central)
+v1.2.1
+- Compile with networking-protocols v1.2.1
+v1.2
+- JUnit Test added
+- Bugfixes
+- Reduced number of logs
+- Updated README with explanation of parameters
+v1.1.1
+- Added configuration instructions of the standalone BGP Peer
+- Added dependencies to pom.xml
+v1.1.0
+First Public Release
diff --git a/src/bgpls_speaker/service/java/netphony-topology/LICENSE b/src/bgpls_speaker/service/java/netphony-topology/LICENSE
new file mode 100644
index 0000000000000000000000000000000000000000..d645695673349e3947e8e5ae42332d0ac3164cd7
--- /dev/null
+++ b/src/bgpls_speaker/service/java/netphony-topology/LICENSE
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+
+ 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.
diff --git a/src/bgpls_speaker/service/java/netphony-topology/VERSION b/src/bgpls_speaker/service/java/netphony-topology/VERSION
new file mode 100644
index 0000000000000000000000000000000000000000..31e5c843497c24df077777c05af122d8b3a60ddb
--- /dev/null
+++ b/src/bgpls_speaker/service/java/netphony-topology/VERSION
@@ -0,0 +1 @@
+1.3.3
diff --git a/src/bgpls_speaker/service/java/netphony-topology/doc/Examples.md b/src/bgpls_speaker/service/java/netphony-topology/doc/Examples.md
new file mode 100644
index 0000000000000000000000000000000000000000..88f7a7bd5c7a268857a7a4ec2642c388daf715d3
--- /dev/null
+++ b/src/bgpls_speaker/service/java/netphony-topology/doc/Examples.md
@@ -0,0 +1,133 @@
+
+
+#Examples
+
+##Topology Module Examples
+
+Two sets of basic configuration files are here included with Topology Module software: the setup for running three TM within the same machine (configuration A) and the setup for running three TM in three dedicated machines (configuration B). In both cases three example network topologies are provided to represent the abstract topology of 2 end-point providers and 1 transit provider.
+
+### Example TM1: 1 Way Test in the same virtual machine, BPG-LS Plugin and UNIFY Export.
+
+The setup has been provided just for testing purpose and configures 3 TADS in the same machine to perform unidirectional information exchange.
+
+![1WayTest](figures/1wayTest.png?raw=true "Test with 3 TM")
+
+The reference files, including Topology Module configuration, BGP-LS Plugin configuration and abstracted topologies are copiend in the folder target/conf1wayTest after the maven installation. Be sure to compile also the Topology Module as indicated in README.md.
+
+To execute TM1 run:
+ ```bash
+ sudo java -Dlog4j.configurationFile=target/log4j2.xml -jar target/topology-1.3.3-shaded.jar target/conf1wayTest/TM1.xml
+ ```
+
+To execute TM2 run:
+ ```bash
+ sudo java -Dlog4j.configurationFile=target/log4j2.xml -jar target/topology-1.3.3-shaded.jar target/conf1wayTest/TM2.xml
+ ```
+
+To execute TM3 run:
+ ```bash
+ sudo java -Dlog4j.configurationFile=target/log4j2.xml -jar target/topology-1.3.3-shaded.jar target/conf1wayTest/TM3.xml
+ ```
+
+To verify the retrieved information:
+ ```bash
+curl http://localhost:8087/restconf/data/virtualizer/ | python -m json.tool
+ ```
+[for TADS2]
+ ```bash
+curl http://localhost:8088/restconf/data/virtualizer/ | python -m json.tool
+ ```
+[for TADS3]
+ ```bash
+curl http://localhost:8089/restconf/data/virtualizer/ | python -m json.tool
+ ```
+
+### Example TM2: 2 Way Test in the different virtual machines, BPG-LS Plugin and UNIFY Export.
+The setup has been provided as reference configuration for the configuration of 3 TM in dedicated machines to perform bidirectional exchange of information
+![1WayTest](figures/2wayTest.png?raw=true "Test with 3 TM in 3 different machines")
+The reference files, including Topology Module configuration, BGP-LS Plugin configuration and abstracted topologies are in
+ ```bash
+target/conf2waysReal
+ ```
+Before running the reference scenario be sure to complete the IP configuration in the 3 modules, in fact, according to previous description, minor ad-hoc changes are needed.
+
+In the Topology Module configuration files (TM*.xml):
+• set the IP address used for the BGP-LS communication as Identifier
+
+In the BGP-LS Plugin configuration (BGPLS*_2way.xml):
+• set the IP address used for the BGP-LS communication as BGPIdentifier
+• configure the peers as needed (IP address and port)
+
+[where * = 1,2,3]
+
+To execute TADS1 in machine 1 run:
+ ```bash
+ sudo java -Dlog4j.configurationFile=target/log4j2.xml -jar target/topology-1.3.3-shaded.jar target/conf1wayTest/TM1.xml
+ ```
+
+To execute TADS1 in machine 2 run:
+ ```bash
+ sudo java -Dlog4j.configurationFile=target/log4j2.xml -jar target/topology-1.3.3-shaded.jar target/conf1wayTest/TM2.xml
+ ```
+
+To execute TADS1 in machine 3 run:
+ ```bash
+ sudo java -Dlog4j.configurationFile=target/log4j2.xml -jar target/topology-1.3.3-shaded.jar target/conf1wayTest/TM3.xml
+ ```
+
+To verify the retrieved information:
+[for TADS2, in machine 1]
+ ```bash
+curl http://localhost:8088/restconf/data/virtualizer/ | python -m json.tool
+ ```
+[for TADS2, in machine 2]
+ ```bash
+>curl http://localhost:8088/restconf/data/virtualizer/ | python -m json.tool
+ ```
+[for TADS3, in machine 3]
+ ```bash
+>curl http://localhost:8088/restconf/data/virtualizer/ | python -m json.tool
+ ```
+### Topology module with BGP-LS and COP plugins and BGP-LS speaker
+
+In this example there are 2 BGP-LS speakers, one acting as sender of topology, and the other as consumer. A small topology is loaded from an xml file in BGP-LS Speaker #1. This topology is sent to BGP-LS Speaker #2.
+ ```bash
+TBD
+ ```
+### Topology module with BGP-LS and COP plugins and Topology module with BGP-LS speaker
+
+In this example there are 2 BGP-LS speakers, one acting as sender of topology, and the other as consumer. A small topology is loaded from an xml file in BGP-LS Speaker #1. This topology is sent to BGP-LS Speaker #2.
+ ```bash
+TBD
+ ```
+## BGP-LS Speaker Examples
+
+### BPP-LS Speaker Example 1
+
+In this example there are 2 BGP-LS speakers, one acting as sender of topology, and the other as consumer. A small topology is loaded from an xml file in BGP-LS Speaker #1. This topology is sent to BGP-LS Speaker #2.
+To launch BGP-LS Speaker #1:
+ ```bash
+sudo java -Dlog4j.configurationFile=target/log4j2.xml -jar target/bgp-ls-speaker-jar-with-dependencies.jar target/bgpls_example1/BGP4Parameters_1.xml
+ ```
+ BGP-LS Speaker #2:
+ ```bash
+sudo java -Dlog4j.configurationFile=target/log4j2.xml -jar target/bgp-ls-speaker-jar-with-dependencies.jar target/bgpls_example1/BGP4Parameters_2.xml
+ ```
+To verify the retrieved information:
+ ```bash
+telnet localhost 1112
+show topology
+ ```
+Then, the topology is printed on screen.
diff --git a/src/bgpls_speaker/service/java/netphony-topology/doc/TAPIExample.md b/src/bgpls_speaker/service/java/netphony-topology/doc/TAPIExample.md
new file mode 100644
index 0000000000000000000000000000000000000000..9b0c48c8ed24fe8ca5c06f118b3d440653c686e5
--- /dev/null
+++ b/src/bgpls_speaker/service/java/netphony-topology/doc/TAPIExample.md
@@ -0,0 +1,27 @@
+
+
+# Example 1: TM with XML Plugin and TAPI Plugin
+- First of all, compile the full-jar if you have not done so
+```bash
+ mvn package -P generate-full-jar
+```
+Execute the server
+```bash
+sudo java -Dlog4j.configurationFile=target/examples/log4j2.xml -jar target/topology-1.3.4-SNAPSHOT-shaded.jar target/TM_TAPI_example1/TMConfTAPI.xml
+```
+Make the query
+```bash
+curl http://localhost:8089/config/context/topology -X GET -i -H "Content-Type: application/json" -H "Accept: application/json"
+```
diff --git a/src/bgpls_speaker/service/java/netphony-topology/doc/TopologyFileDescription.md b/src/bgpls_speaker/service/java/netphony-topology/doc/TopologyFileDescription.md
new file mode 100644
index 0000000000000000000000000000000000000000..452050b65106b8393ac8a7df98ea472b7705e608
--- /dev/null
+++ b/src/bgpls_speaker/service/java/netphony-topology/doc/TopologyFileDescription.md
@@ -0,0 +1,127 @@
+
+
+# Topology XML File
+
+This section describes the topology file format, used by the TADS to load the abstracted view of the local provider.
+
+The reference file for this description is
+
+```
+target/conf1wayTest/network1.xml
+```
+
+The main tag of the file is **network** that can include multiple **domains**, each domain represents a provider.
+
+```xml
+
+
+
+
+
+
+```
+
+In this case the network topology includes two providers.
+
+The first part of the each domain contains some general information:
+
+ - **domain_id**: the AS number of the domain represented in IPv4 format
+ - the **reachability_entry**: that summarizes the prefix network for the provider (IPv4 network prefix and mask)
+ - **it_resources**: here the information related to overall IT resources availability is described considering
+ - **controller_it**: the entry point for 5GEx orchestration
+ - **cpu**: overall available CPUs
+ - **mem**: overall available memory
+ - **storage**: overall available storage
+
+```xml
+0.0.0.1
+
+ 172.16.101.0
+ 24
+
+
+ https://openstack.5Gex.com/url
+ 100
+ 100Gbyte
+ 100Tbyte
+
+```
+
+Then the file is organized considering a list of nodes and a list unidirectional links.
+
+Each node is represented with a tag **node** and is identified with an IPv4 id called **router_id**
+
+```xml
+
+ 172.16.101.101
+
+
+ 172.16.101.102
+
+
+ 172.16.101.103
+
+
+ 172.16.101.104
+
+```
+
+In the reference case 4 nodes are considered.
+Each link is identified by the tag **edge**.
+The link description include:
+
+
+ - **source**: the source node of the link, identified with the pair **router_id** and interface id, **if_id**
+ - **destination**: the destination node of the link, identified with the pair router_id and interface
+ - **TE parameters**: several possibilities are available, in the considered example the focus was on
+ - unidirectional link delay
+ - minimum experienced delay
+ - maximum experienced delay
+
+```xml
+
+
+
+ 172.16.101.104
+ 1
+
+ 99
+
+ 23
+ 250
+
+
+
+```
+
+For setting up default TE parameters for all the network links, the **edgeCommon** tag is used.
+
+```xml
+
+ 99
+
+ 23
+ 43
+
+ 1
+ 102
+ 802
+ 500
+ 436
+
+```
diff --git a/src/bgpls_speaker/service/java/netphony-topology/doc/figures/1wayTest.png b/src/bgpls_speaker/service/java/netphony-topology/doc/figures/1wayTest.png
new file mode 100644
index 0000000000000000000000000000000000000000..021dd3ee5c6dff653af4131f8060e0b7cac88f1d
Binary files /dev/null and b/src/bgpls_speaker/service/java/netphony-topology/doc/figures/1wayTest.png differ
diff --git a/src/bgpls_speaker/service/java/netphony-topology/doc/figures/2wayTest.png b/src/bgpls_speaker/service/java/netphony-topology/doc/figures/2wayTest.png
new file mode 100644
index 0000000000000000000000000000000000000000..4800df6d96874c480059be8cc905e753b8614f2b
Binary files /dev/null and b/src/bgpls_speaker/service/java/netphony-topology/doc/figures/2wayTest.png differ
diff --git a/src/bgpls_speaker/service/java/netphony-topology/log4j2.xml b/src/bgpls_speaker/service/java/netphony-topology/log4j2.xml
new file mode 100644
index 0000000000000000000000000000000000000000..47cf97472ebc0ab692e33da88c70a762c1bb429c
--- /dev/null
+++ b/src/bgpls_speaker/service/java/netphony-topology/log4j2.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/bgpls_speaker/service/java/netphony-topology/pom.xml b/src/bgpls_speaker/service/java/netphony-topology/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..0b83a126198f9b5a082bedac224f01ffe486e059
--- /dev/null
+++ b/src/bgpls_speaker/service/java/netphony-topology/pom.xml
@@ -0,0 +1,497 @@
+
+
+ 4.0.0
+ es.tid.netphony
+ topology
+ 1.4.0-SNAPSHOT
+ jar
+ Netphony TED and BGP-LS peer
+ Traffic Engineering Database, BGP-LS peer, Topology Module
+ http://telefonicaid.github.io/netphony-topology/
+
+
+ Apache License 2.0
+ http://www.apache.org/licenses/LICENSE-2.0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ com.sun.jersey
+ jersey-json
+ ${jersey-version}
+
+
+
+ org.slf4j
+ slf4j-api
+ ${slf4j-version}
+
+
+
+ org.slf4j
+ slf4j-simple
+ ${slf4j-version}
+
+
+ es.tid.netphony
+ network-protocols
+ 1.4.1
+
+
+
+
+ org.jgrapht
+ jgrapht-core
+ ${jgrapht-core-version}
+
+
+ com.google.code.gson
+ gson
+ 2.2.2
+
+
+ com.googlecode.json-simple
+ json-simple
+ 1.1.1
+
+
+ com.metaparadigm
+ json-rpc
+ 1.0
+
+
+ redis.clients
+ jedis
+ 2.1.0
+
+
+
+ com.fasterxml.jackson.core
+ jackson-core
+ ${jackson-version}
+
+
+ com.fasterxml.jackson.core
+ jackson-annotations
+ ${jackson-version}
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ ${jackson-version}
+
+
+ com.fasterxml.jackson.datatype
+ jackson-datatype-joda
+ ${jackson-datatype-joda-version}
+
+
+
+ joda-time
+ joda-time
+ ${jodatime-version}
+
+
+
+
+ io.grpc
+ grpc-netty-shaded
+ ${grpc-protobuf-version}
+
+
+ io.grpc
+ grpc-protobuf
+ ${grpc-protobuf-version}
+
+
+ io.grpc
+ grpc-stub
+ ${grpc-stub-version}
+
+
+ javax.annotation
+ javax.annotation-api
+ ${javax-annotation-api-version}
+
+
+
+ com.google.guava
+ guava
+ 31.1-jre
+
+
+
+
+
+ Telefonica I+D
+ oscar.gonzalezdedios@telefonica.com
+ Telefonica I+D
+ https://www.tid.es
+
+
+
+ scm:git:git@github.com:telefonicaid/netphony-topology.git
+ scm:git:git@github.com:telefonicaid/netphony-topology.git
+ git@github.com:telefonicaid/netphony-topology.git
+
+
+
+
+ oss.sonatype.org-snapshot
+ http://oss.sonatype.org/content/repositories/snapshots
+
+ false
+
+
+ true
+
+
+
+
+
+ ossrh
+ https://oss.sonatype.org/content/repositories/snapshots
+
+
+ ossrh
+ https://oss.sonatype.org/service/local/staging/deploy/maven2/
+
+
+
+ ${basedir}/src/main/java
+
+
+ kr.motd.maven
+ os-maven-plugin
+ 1.6.2
+
+
+
+
+
+ org.xolstice.maven.plugins
+ protobuf-maven-plugin
+ 0.6.1
+
+ com.google.protobuf:protoc:3.9.0:exe:${os.detected.classifier}
+ grpc-java
+ io.grpc:protoc-gen-grpc-java:1.24.0:exe:${os.detected.classifier}
+
+
+
+
+ compile
+ compile-custom
+
+
+
+
+
+ maven-compiler-plugin
+ 3.8.1
+
+
+ 8
+ UTF-8
+
+
+
+ maven-resources-plugin
+ 2.6
+
+ UTF-8
+
+
+
+ copy-resources
+ validate
+
+ copy-resources
+
+
+ ${basedir}/target
+
+
+ ${basedir}/src/main/resources
+ true
+
+
+ ${basedir}/src/main/sample-config-files
+ true
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+ 2.2.1
+
+
+ attach-sources
+
+ jar-no-fork
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 3.1.0
+
+
+
+ true
+ lib/
+ eu.teraflow.tid.bgp4Peer.peer.BGPPeerMain
+
+
+
+
+
+
+
+
+ deploy-maven-central
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ 2.9.1
+
+ -Xdoclint:none
+
+
+
+ attach-javadocs
+
+ jar
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-gpg-plugin
+ 1.6
+
+
+ sign-artifacts
+ verify
+
+ sign
+
+
+
+
+
+
+
+
+ bgp-ls-speaker
+
+
+ org.apache.logging.log4j
+ log4j-slf4j-impl
+ 2.5
+
+
+ org.apache.logging.log4j
+ log4j-api
+ 2.5
+
+
+ org.apache.logging.log4j
+ log4j-core
+ 2.5
+
+
+ io.netty
+ netty-transport-native-epoll
+ 4.1.77.Final
+ linux-x86_64
+
+
+
+
+
+ maven-assembly-plugin
+ 3.3.0
+
+
+ jar-with-dependencies
+
+ bgp-ls-speaker
+
+
+ eu.teraflow.tid.bgp4Peer.peer.BGPPeerMain
+
+
+
+
+
+
+
+
+ generate-javadoc
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+
+ false
+
+ 2.9.1
+
+
+ attach-javadocs
+
+ jar
+
+
+
+
+
+
+
+
+ integration-test
+
+
+
+ org.apache.maven.plugins
+ maven-failsafe-plugin
+ 2.13
+
+
+ integration-test
+
+ integration-test
+
+
+
+ verify
+
+ verify
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.19.1
+
+ true
+
+
+
+
+
+
+
+ generate-full-jar
+
+
+ org.apache.logging.log4j
+ log4j-slf4j-impl
+ 2.5
+
+
+ org.apache.logging.log4j
+ log4j-api
+ 2.5
+
+
+ org.apache.logging.log4j
+ log4j-core
+ 2.5
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 2.4.3
+
+
+ package
+
+ shade
+
+
+ true
+
+
+ *:*
+
+
+
+ false
+
+
+
+ eu.teraflow.tid.bgp.bgp4Peer.peer.BGPPeerMain
+
+
+
+
+
+
+ make-assembly
+ package
+
+ single
+
+
+
+
+
+
+
+
+
+
+ 1.19.4
+ 2.0.6
+ 4.8.1
+ 2.5
+ 2.4.2
+ 2.3
+ 2.19.1
+ 0.9.1
+ 1.3.2
+ 1.24.0
+ 1.46.0
+ 2.1.5
+
+
diff --git a/src/bgpls_speaker/service/java/netphony-topology/src/main/java/eu/teraflow/tid/bgp4Peer/bgp4session/BGP4PeerInitiatedSession.java b/src/bgpls_speaker/service/java/netphony-topology/src/main/java/eu/teraflow/tid/bgp4Peer/bgp4session/BGP4PeerInitiatedSession.java
new file mode 100644
index 0000000000000000000000000000000000000000..9651d78761d267fdb10bcb1994aa0a90d9c17cf8
--- /dev/null
+++ b/src/bgpls_speaker/service/java/netphony-topology/src/main/java/eu/teraflow/tid/bgp4Peer/bgp4session/BGP4PeerInitiatedSession.java
@@ -0,0 +1,188 @@
+// Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
+
+// Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+
+// 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.
+
+package eu.teraflow.tid.bgp4Peer.bgp4session;
+
+import es.tid.bgp.bgp4.messages.BGP4Message;
+import es.tid.bgp.bgp4.messages.BGP4MessageTypes;
+import es.tid.bgp.bgp4.messages.BGP4Update;
+import eu.teraflow.tid.bgp4Peer.peer.BGP4Exception;
+import eu.teraflow.tid.bgp4Peer.updateTEDB.UpdateDispatcher;
+
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.net.Inet4Address;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.net.SocketException;
+import java.util.Timer;
+
+/**
+ * BGP4 session server
+ *
+ * @author mcs
+ *
+ */
+public class BGP4PeerInitiatedSession extends GenericBGP4Session{
+ /**
+ * Class to dispatch the BGP4 update messages.
+ * If a BGP5 update message is received, it is stored in a queue of UpdateDispatcher.
+ */
+ private UpdateDispatcher updateDispatcher;
+
+
+ /**
+ * Constructor of the BGP4 Session
+ * @param s Socket of the BGP4Peer-BGP4Peer Communication
+ * @param bgp4SessionsInformation bgp4SessionsInformation
+ * @param updateDispatcher updateDispatcher
+ * @param holdTime holdTime
+ * @param BGPIdentifier BGPIdentifier
+ * @param version version
+ * @param myAutonomousSystem myAutonomousSystem
+ * @param noDelay noDelay
+ * @param keepAliveTimer keepAliveTimer
+ */
+ public BGP4PeerInitiatedSession(Socket s, BGP4SessionsInformation bgp4SessionsInformation, UpdateDispatcher updateDispatcher,int holdTime,Inet4Address BGPIdentifier,int version,int myAutonomousSystem,boolean noDelay,int keepAliveTimer ){
+ super(bgp4SessionsInformation, holdTime, BGPIdentifier, version, myAutonomousSystem,keepAliveTimer);
+
+ this.setFSMstate(BGP4StateSession.BGP4_STATE_IDLE);
+ log=LoggerFactory.getLogger("BGP4Server");
+ log.debug("New BGP4Session: "+s);
+ this.socket = s;
+ try {
+ s.setTcpNoDelay(noDelay);
+ } catch (SocketException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ this.newSessionId();
+
+ this.remotePeerIP =(Inet4Address) ((InetSocketAddress) socket.getRemoteSocketAddress()).getAddress();
+
+
+ timer=new Timer();
+ this.updateDispatcher = updateDispatcher;
+ //this.keepAliveLocal=params.getKeepAliveTimer();
+ //this.deadTimerLocal=params.getDeadTimer();
+ }
+
+
+
+ /**
+ * Initiates a Session the BGP-4 Peers
+ */
+ public void run() {
+ try {
+ initializeBGP4Session();
+ } catch (BGP4Exception e2) {
+ // TODO Auto-generated catch block
+ try {
+ this.socket.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return;
+ }
+ log.info("BGP4 Session established with peer "+this.remotePeerIP);
+ this.deadTimerT=new DeadTimerThread(this, this.holdTime);
+ startDeadTimer();
+ this.keepAliveT=new KeepAliveThread(out, this.keepAliveTimer);
+ startKeepAlive();
+
+ //Listen to new messages
+ try{
+ while(this.FSMstate==BGP4StateSession.BGP4_STATE_SESSION_UP) {
+ try {
+ this.msg = readBGP4Msg(in);//Read a new message
+
+ }catch (IOException e){
+ cancelDeadTimer();
+ cancelKeepAlive();
+ timer.cancel();
+ try {
+ in.close();
+ out.close();
+ } catch (Exception e1) {
+ log.warn("Exception Closing BGP4 Session with "+this.remotePeerIP);
+ }
+ log.debug("Finishing BGP4 Session with "+this.remotePeerIP);
+ return;
+ }
+ if (this.msg != null) {//If null, it is not a valid PCEP message
+ boolean bgp4Msg = true;//By now, we assume a valid PCEP message has arrived
+ //Depending on the type a different action is performed
+ switch(BGP4Message.getMessageType(this.msg)) {
+
+ case BGP4MessageTypes.MESSAGE_OPEN:
+ log.debug("OPEN message received");
+ //After the session has been started, ignore subsequent OPEN messages
+ log.warn("OPEN message ignored");
+ break;
+
+ case BGP4MessageTypes.MESSAGE_KEEPALIVE:
+ log.debug("KEEPALIVE message received from "+this.remotePeerIP);
+ //The Keepalive message allows to reset the deadtimer
+ break;
+
+ case BGP4MessageTypes.MESSAGE_NOTIFICATION:
+ log.info("NOTIFICATION message from "+this.remotePeerIP);
+ break;
+
+ case BGP4MessageTypes.MESSAGE_UPDATE:
+ log.debug("UPDATE message from "+this.remotePeerIP);
+ BGP4Update bgp4Update = new BGP4Update(msg);
+ log.debug(bgp4Update.toString());
+ bgp4Update.setLearntFrom(this.getRemotePeerIP().toString());
+ updateDispatcher.dispatchRequests(bgp4Update);
+ break;
+
+ default:
+ log.warn("ERROR: unexpected message from "+this.remotePeerIP);
+ bgp4Msg = false;
+ }
+
+ if (bgp4Msg) {
+ //Reseting Dead Timer as BGP4 Session Message has arrived
+ resetDeadTimer();
+ }
+ }
+ }
+ }finally{
+ log.error("BGP4 session with peer "+this.remotePeerIP+" has been closed");
+ cancelDeadTimer();
+ cancelKeepAlive();
+ this.FSMstate=BGP4StateSession.BGP4_STATE_IDLE;
+ endSession();
+ }
+ }
+
+ @Override
+ public void close() {
+ // TODO Auto-generated method stub
+
+ }
+
+
+
+ @Override
+ protected void endSession() {
+ // TODO Auto-generated method stub
+ log.debug("Ending session with id "+this.getSessionId()+" from peer "+this.remotePeerIP);
+ BGP4SessionsInformation.deleteSession(this.getSessionId());
+ }
+
+}
diff --git a/src/bgpls_speaker/service/java/netphony-topology/src/main/java/eu/teraflow/tid/bgp4Peer/bgp4session/BGP4Session.java b/src/bgpls_speaker/service/java/netphony-topology/src/main/java/eu/teraflow/tid/bgp4Peer/bgp4session/BGP4Session.java
new file mode 100644
index 0000000000000000000000000000000000000000..0c1a656c4b2f74c63ffc09143ec93a274116d5f1
--- /dev/null
+++ b/src/bgpls_speaker/service/java/netphony-topology/src/main/java/eu/teraflow/tid/bgp4Peer/bgp4session/BGP4Session.java
@@ -0,0 +1,44 @@
+// Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
+
+// Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+
+// 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.
+
+package eu.teraflow.tid.bgp4Peer.bgp4session;
+
+import es.tid.bgp.bgp4.messages.BGP4Message;
+
+
+/**
+ * BGP Session Interface
+ *
+ * @author mcs
+ *
+ */
+public interface BGP4Session {
+ /**
+ * Send close message and finish the BGP Session
+ */
+ public void close(/*int reason*/);
+ /**
+ * Finish the BGP Session abruptly,
+ */
+ public void killSession();
+
+ /**
+ * Encodes and sends BGP Message
+ * If the message is bad encoded, the session is closed
+ * @param message BGP4 Message
+ */
+ public void sendBGP4Message(BGP4Message message);
+
+
+}
diff --git a/src/bgpls_speaker/service/java/netphony-topology/src/main/java/eu/teraflow/tid/bgp4Peer/bgp4session/BGP4SessionClient.java b/src/bgpls_speaker/service/java/netphony-topology/src/main/java/eu/teraflow/tid/bgp4Peer/bgp4session/BGP4SessionClient.java
new file mode 100644
index 0000000000000000000000000000000000000000..b96359b6cb00fae27e50ac08b7e3fe07772275eb
--- /dev/null
+++ b/src/bgpls_speaker/service/java/netphony-topology/src/main/java/eu/teraflow/tid/bgp4Peer/bgp4session/BGP4SessionClient.java
@@ -0,0 +1,222 @@
+// Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
+
+// Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+
+// 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.
+
+package eu.teraflow.tid.bgp4Peer.bgp4session;
+
+import es.tid.bgp.bgp4.messages.BGP4Message;
+import es.tid.bgp.bgp4.messages.BGP4MessageTypes;
+import es.tid.bgp.bgp4.messages.BGP4Update;
+import eu.teraflow.tid.bgp4Peer.peer.BGP4Exception;
+import eu.teraflow.tid.bgp4Peer.updateTEDB.UpdateDispatcher;
+
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.net.Inet4Address;
+import java.net.Socket;
+import java.util.Timer;
+/**
+ * Client session
+ *
+ * @author mcs
+ *
+ */
+public class BGP4SessionClient extends GenericBGP4Session{
+ /**
+ * Peer BGP port to which the session is connected
+ */
+ private int peerBGP_port;
+ /**
+ * Delay
+ */
+
+
+ private boolean no_delay=true;
+ private String localBGP4Address;
+ private int localBGP4Port;
+ /**
+ * Class to dispatch the BGP4 update messages.
+ * If a BGP5 update message is received, it is stored in a queue of UpdateDispatcher.
+ */
+ private UpdateDispatcher updateDispatcher;
+
+ public BGP4SessionClient(BGP4SessionsInformation bgp4SessionsInformation,UpdateDispatcher updateDispatcher, Inet4Address peerBGP_IPaddress, int peerBGP_port, int holdTime,Inet4Address BGPIdentifier,int version,int myAutonomousSystem, String localBGP4Address, int localBGP4Port,int keepAliveTimer){
+ super(bgp4SessionsInformation, holdTime, BGPIdentifier, version, myAutonomousSystem,keepAliveTimer);
+ timer=new Timer();
+ log = LoggerFactory.getLogger("BGP4Client");
+ this.peerBGP_port = peerBGP_port;
+ this.updateDispatcher=updateDispatcher;
+ this.localBGP4Address=localBGP4Address;
+ this.localBGP4Port=localBGP4Port;
+ this.remotePeerIP = peerBGP_IPaddress;
+ }
+ /**
+ * Initiates a Session between the local BGP Peer and the remote BGP Peer
+ */
+ public void run() {
+
+ log.info("Opening new BGP4 Session with host "+ this.remotePeerIP.getHostAddress() + " on port " + this.peerBGP_port);
+ log.debug("Do we want to update from peer?" + updateFrom);
+ log.debug("Do we want to send to peer?" + sendTo);
+ try {
+ Inet4Address addr = (Inet4Address) Inet4Address.getByName(localBGP4Address);
+ Inet4Address addrPeer = remotePeerIP;
+ socket = new Socket(addrPeer, peerBGP_port, addr, 0);
+ if (no_delay){
+ this.socket.setTcpNoDelay(true);
+ log.debug("No delay activated");
+ }
+
+ } catch (IOException e) {
+ log.info("Connection refused trying to connect " + remotePeerIP.getHostAddress() + " on port " + peerBGP_port);
+ //As there is not yet a session added (it is added in the beginning of initializeBGP4Session());
+ //endSession();
+ return;
+ }
+
+ try {
+ initializeBGP4Session();
+ log.info("BGP4 Session established with peer "+this.remotePeerIP);
+ this.keepAliveT= new KeepAliveThread(this.getOut(),this.keepAliveTimer);
+ keepAliveT.start();
+ } catch (BGP4Exception e2) {
+ // TODO Auto-generated catch block
+ e2.printStackTrace();
+ log.debug("Session with "+this.remotePeerIP+" already exists: "+e2.getMessage());
+ try {
+ socket.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ log.error("Problem closing socket "+e.getMessage());
+ }
+ return;
+ }
+
+
+
+
+ try{
+ while(this.FSMstate==BGP4StateSession.BGP4_STATE_SESSION_UP) {
+ try {
+
+ this.msg = readBGP4Msg(in);//Read a new message
+
+ }catch (IOException e){
+ cancelDeadTimer();
+ cancelKeepAlive();
+ timer.cancel();
+ try {
+ in.close();
+ out.close();
+ } catch (Exception e1) {
+ log.warn("problem closing sockets");
+ }
+ log.debug("Finishing BGP4 Session abruptly!");
+ return;
+ }
+ if (this.msg != null) {//If null, it is not a valid PCEP message
+ boolean bgp4Msg = true;//By now, we assume a valid PCEP message has arrived
+ //Depending on the type a different action is performed
+ switch(BGP4Message.getMessageType(this.msg)) {
+
+ case BGP4MessageTypes.MESSAGE_OPEN:
+ log.debug("BGP OPEN message received from "+this.remotePeerIP);
+ //After the session has been started, ignore subsequent OPEN messages
+ log.warn("OPEN message ignored");
+ break;
+
+ case BGP4MessageTypes.MESSAGE_KEEPALIVE:
+ log.debug("BGP KEEPALIVE message received from "+this.remotePeerIP);
+ //The Keepalive message allows to reset the deadtimer
+ break;
+
+ case BGP4MessageTypes.MESSAGE_NOTIFICATION:
+ log.debug("BGP NOTIFICATION message received from "+this.remotePeerIP);
+ break;
+
+ case BGP4MessageTypes.MESSAGE_UPDATE:
+ log.debug("BGP UPDATE message received from "+this.remotePeerIP);
+ if(this.getUpdateFrom()){
+ BGP4Update bgp4Update = new BGP4Update(msg);
+ log.debug(bgp4Update.toString());
+ bgp4Update.setLearntFrom(this.remotePeerIP.getHostAddress() );
+ updateDispatcher.dispatchRequests(bgp4Update);
+ }
+ else
+ log.debug("Update message from " + this.remotePeerIP + " discarded");
+ break;
+
+ default:
+ log.warn("ERROR: unexpected message received");
+ bgp4Msg = false;
+ }
+
+ if (bgp4Msg) {
+ //Reseting Dead Timer as BGP4 Session Message has arrived
+ resetDeadTimer();
+ }
+ }
+ }
+ }finally{
+ //log.error("SESSION "+ internalSessionID+" IS KILLED");
+ log.info("BGP4 session with peer "+this.remotePeerIP+" has been closed");
+ cancelDeadTimer();
+ cancelKeepAlive();
+ this.FSMstate=BGP4StateSession.BGP4_STATE_IDLE;
+ endSession();
+ }
+ }
+
+
+ public int getPeerBGP_port() {
+ return peerBGP_port;
+ }
+ public void setPeerBGP_port(int peerBGP_port) {
+ this.peerBGP_port = peerBGP_port;
+ }
+ public Boolean getUpdateFrom() {
+ return updateFrom;
+ }
+ public void setUpdateFrom(Boolean updateFrom) {
+ this.updateFrom = updateFrom;
+ }
+ public Boolean getSendTo() {
+ return sendTo;
+ }
+ public void setSendTo(Boolean sendTo) {
+ this.sendTo = sendTo;
+ }
+ public boolean isNo_delay() {
+ return no_delay;
+ }
+ public void setNo_delay(boolean no_delay) {
+ this.no_delay = no_delay;
+ }
+
+
+ @Override
+ public void close() {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ @Override
+ protected void endSession() {
+ // TODO Auto-generated method stub
+ log.debug("Ending session with id "+this.getSessionId());
+ this.BGP4SessionsInformation.deleteSession(this.getSessionId());
+ }
+
+}
diff --git a/src/bgpls_speaker/service/java/netphony-topology/src/main/java/eu/teraflow/tid/bgp4Peer/bgp4session/BGP4SessionExistsException.java b/src/bgpls_speaker/service/java/netphony-topology/src/main/java/eu/teraflow/tid/bgp4Peer/bgp4session/BGP4SessionExistsException.java
new file mode 100644
index 0000000000000000000000000000000000000000..4f6f4af856ad4293d5c999cc2cc8cde6203b60f0
--- /dev/null
+++ b/src/bgpls_speaker/service/java/netphony-topology/src/main/java/eu/teraflow/tid/bgp4Peer/bgp4session/BGP4SessionExistsException.java
@@ -0,0 +1,24 @@
+// Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
+
+// Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+
+// 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.
+
+package eu.teraflow.tid.bgp4Peer.bgp4session;
+
+public class BGP4SessionExistsException extends Exception {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+}
diff --git a/src/bgpls_speaker/service/java/netphony-topology/src/main/java/eu/teraflow/tid/bgp4Peer/bgp4session/BGP4SessionsInformation.java b/src/bgpls_speaker/service/java/netphony-topology/src/main/java/eu/teraflow/tid/bgp4Peer/bgp4session/BGP4SessionsInformation.java
new file mode 100644
index 0000000000000000000000000000000000000000..963406700f327ec47eb213ec943f29476714f76c
--- /dev/null
+++ b/src/bgpls_speaker/service/java/netphony-topology/src/main/java/eu/teraflow/tid/bgp4Peer/bgp4session/BGP4SessionsInformation.java
@@ -0,0 +1,146 @@
+// Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
+
+// Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+
+// 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.
+
+package eu.teraflow.tid.bgp4Peer.bgp4session;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import eu.teraflow.tid.bgp4Peer.peer.BGP4Exception;
+
+import java.io.DataOutputStream;
+import java.net.Inet4Address;
+import java.util.Enumeration;
+import java.util.Hashtable;
+
+
+/**
+ * Class where the oppened BGP4 sessions are stored.
+ *
+ * @author mcs
+ *
+ */
+public class BGP4SessionsInformation {
+ public Hashtable sessionList;
+ public Hashtable sessionListByPeerIP;
+ private boolean isTest = false;
+ Logger log;
+ //FIXME: ya lo tenemos a trav�s de la lista de sesiones
+ DataOutputStream out;
+
+ public BGP4SessionsInformation(){
+ sessionList=new Hashtable();
+ sessionListByPeerIP=new Hashtable();
+ log = LoggerFactory.getLogger("BGP4Parser");
+ }
+
+ public BGP4SessionsInformation(boolean test){
+ sessionList=new Hashtable();
+ sessionListByPeerIP=new Hashtable();
+ log = LoggerFactory.getLogger("BGP4Parser");
+ isTest= test;
+ }
+
+
+ public synchronized void notifySessionStart(Inet4Address addr) throws BGP4SessionExistsException{
+ if (sessionListByPeerIP.containsKey(addr)){
+ throw new BGP4SessionExistsException();
+ }
+ }
+
+ public synchronized void addSession(long sessionId, GenericBGP4Session session) throws BGP4Exception{
+ Enumeration sessions = sessionList.elements();
+ log.debug("Looking to add session with id "+sessionId+" --> "+session.toString());
+
+ //Check if there is already a session with the remote peer.
+ //Only one session allowed with each remote peer
+ GenericBGP4Session existingSession=sessionListByPeerIP.get(session.remotePeerIP);
+ if(isTest){
+ //If there is no existing session with the peer
+ sessionList.put(new Long(sessionId),session);
+ sessionListByPeerIP.put(session.getPeerIP() , session);
+ log.debug("Registering new session with Peer "+session.getPeerIP() +" with ID "+sessionId);
+ }
+ else{
+ if (existingSession!=null){
+ log.debug("Session with id "+existingSession.getSessionId()+" against "+session.remotePeerIP.getHostAddress()+" already exists");
+ throw new BGP4Exception();//si no existe throw new BGP4Exception();
+ }
+
+ //If there is no existing session with the peer
+ sessionList.put(new Long(sessionId),session);
+ sessionListByPeerIP.put(session.getPeerIP() , session);
+ log.debug("Registering new session with Peer "+session.getPeerIP() +" with ID "+sessionId);
+
+ }
+
+ }
+
+ public synchronized void deleteSession(long sessionId){
+ GenericBGP4Session ses=sessionList.get(sessionId);
+ if (ses!=null) {
+ Inet4Address ip=sessionList.get(sessionId).getPeerIP();
+ sessionList.remove(new Long(sessionId));
+ sessionListByPeerIP.remove(ses.getPeerIP());
+ log.debug("Deleted Session with id "+sessionId +" with peer "+ses.getPeerIP().getHostAddress());
+ }else {
+ log.info("SESSION WAS NOT REGISTERED NULL");
+ }
+
+
+ }
+
+ @Override
+ public String toString() {
+ StringBuffer sb=new StringBuffer(2000);
+ int counter = 1;
+ Enumeration sessions = sessionList.elements();
+
+ //Comprobar si ya existe la session con ese peer
+ while (sessions.hasMoreElements()){
+ sb.append("Session number "+(counter++)+"\n");
+ sb.append(sessions.nextElement().toString()+"\n");
+
+ }
+ return sb.toString();
+ }
+
+ public String printSession(long sessionId){
+ GenericBGP4Session ses=sessionList.get(new Long(sessionId));
+ if (ses!=null){
+ return ses.toString();
+ }else {
+ return "session "+sessionId+" does not exist";
+ }
+ }
+
+
+
+ public DataOutputStream getOut() {
+ return out;
+ }
+
+ public void setOut(DataOutputStream out) {
+ this.out = out;
+ }
+
+ public Hashtable getSessionList() {
+ return sessionList;
+ }
+ public void setSessionList(Hashtable sessionList) {
+ this.sessionList = sessionList;
+ }
+
+
+}
diff --git a/src/bgpls_speaker/service/java/netphony-topology/src/main/java/eu/teraflow/tid/bgp4Peer/bgp4session/BGP4StateSession.java b/src/bgpls_speaker/service/java/netphony-topology/src/main/java/eu/teraflow/tid/bgp4Peer/bgp4session/BGP4StateSession.java
new file mode 100644
index 0000000000000000000000000000000000000000..5a1a5119a6fc213c0c923673dd6dbdaa108b755c
--- /dev/null
+++ b/src/bgpls_speaker/service/java/netphony-topology/src/main/java/eu/teraflow/tid/bgp4Peer/bgp4session/BGP4StateSession.java
@@ -0,0 +1,28 @@
+// Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
+
+// Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+
+// 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.
+
+package eu.teraflow.tid.bgp4Peer.bgp4session;
+/**
+ * The state session attribute indicates the current state of the BGP
+ FSM
+ * @author mcs
+ *
+ */
+public class BGP4StateSession {
+ public static final int BGP4_STATE_IDLE=0;
+ public static final int BGP4_STATE_TCP_PENDING=1;
+ public static final int BGP4_STATE_OPEN_WAIT=2;
+ public static final int BGP4_STATE_KEEP_WAIT=3;
+ public static final int BGP4_STATE_SESSION_UP=4;
+}
diff --git a/src/bgpls_speaker/service/java/netphony-topology/src/main/java/eu/teraflow/tid/bgp4Peer/bgp4session/ConnectRetryTimer.java b/src/bgpls_speaker/service/java/netphony-topology/src/main/java/eu/teraflow/tid/bgp4Peer/bgp4session/ConnectRetryTimer.java
new file mode 100644
index 0000000000000000000000000000000000000000..0eba7b30963ec9254ba8b892a057b6d4996513a5
--- /dev/null
+++ b/src/bgpls_speaker/service/java/netphony-topology/src/main/java/eu/teraflow/tid/bgp4Peer/bgp4session/ConnectRetryTimer.java
@@ -0,0 +1,30 @@
+// Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
+
+// Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+
+// 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.
+
+package eu.teraflow.tid.bgp4Peer.bgp4session;
+
+import java.util.TimerTask;
+
+public class ConnectRetryTimer extends TimerTask {
+ int initialValue;
+ ConnectRetryTimer(int initialValue){
+ this.initialValue=initialValue;
+ }
+ @Override
+ public void run() {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/src/bgpls_speaker/service/java/netphony-topology/src/main/java/eu/teraflow/tid/bgp4Peer/bgp4session/DeadTimerThread.java b/src/bgpls_speaker/service/java/netphony-topology/src/main/java/eu/teraflow/tid/bgp4Peer/bgp4session/DeadTimerThread.java
new file mode 100644
index 0000000000000000000000000000000000000000..ee9dd662320914cec0afb7fff9ebed74a4f06756
--- /dev/null
+++ b/src/bgpls_speaker/service/java/netphony-topology/src/main/java/eu/teraflow/tid/bgp4Peer/bgp4session/DeadTimerThread.java
@@ -0,0 +1,72 @@
+// Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
+
+// Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+
+// 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.
+
+package eu.teraflow.tid.bgp4Peer.bgp4session;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * BGP4 DeadTimer management Thread
+ *
+ */
+public class DeadTimerThread extends Thread {
+
+
+ private BGP4Session bgp4Session = null;
+ private int deadTimer = 0;
+ private Logger log;
+ private boolean running;
+
+ public DeadTimerThread(BGP4Session p, int d) {
+ this.deadTimer = d;
+ this.bgp4Session = p;
+ log=LoggerFactory.getLogger("BGP4Server");
+ }
+
+ public void run() {
+ running=true;
+ while (running) {
+ try {
+ sleep(deadTimer * 1000);
+ /*
+ * Time's over, close PCEP Session
+ */
+ log.warn("DeadTimer OVER");
+ this.bgp4Session.close(/*ObjectParameters.REASON_DEADTIMER*/);
+ return;
+ } catch (InterruptedException e) {
+ //return;
+ if (running==false){
+ log.debug("Ending DeadTimerThread");
+ return;
+ }
+ else {
+ log.debug("Reseting Dead Timer");
+ }
+ } catch (Exception e) {
+ //FIXME: Ver que hacer aqui, por ahora, solo saco un log
+ log.warn("Unhandled exception: " + e.getMessage());
+ }
+
+ }
+
+
+ }
+
+ public void stopRunning(){
+ running=false;
+ }
+}
diff --git a/src/bgpls_speaker/service/java/netphony-topology/src/main/java/eu/teraflow/tid/bgp4Peer/bgp4session/GenericBGP4Session.java b/src/bgpls_speaker/service/java/netphony-topology/src/main/java/eu/teraflow/tid/bgp4Peer/bgp4session/GenericBGP4Session.java
new file mode 100644
index 0000000000000000000000000000000000000000..c42423affbb415a40e6697a56285e9f77f55c59c
--- /dev/null
+++ b/src/bgpls_speaker/service/java/netphony-topology/src/main/java/eu/teraflow/tid/bgp4Peer/bgp4session/GenericBGP4Session.java
@@ -0,0 +1,908 @@
+// Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
+
+// Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+
+// 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.
+
+package eu.teraflow.tid.bgp4Peer.bgp4session;
+
+import es.tid.bgp.bgp4.messages.BGP4Keepalive;
+import es.tid.bgp.bgp4.messages.BGP4Message;
+import es.tid.bgp.bgp4.messages.BGP4MessageTypes;
+import es.tid.bgp.bgp4.messages.BGP4Open;
+import es.tid.bgp.bgp4.open.BGP4CapabilitiesOptionalParameter;
+import es.tid.bgp.bgp4.open.BGP4OctetsASByteCapabilityAdvertisement;
+import es.tid.bgp.bgp4.open.MultiprotocolExtensionCapabilityAdvertisement;
+import es.tid.bgp.bgp4.update.fields.pathAttributes.AFICodes;
+import es.tid.bgp.bgp4.update.fields.pathAttributes.SAFICodes;
+import eu.teraflow.tid.bgp4Peer.peer.BGP4Exception;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.net.Inet4Address;
+import java.net.Socket;
+import java.util.Timer;
+
+
+/**
+ * Generic BGP4 Session.
+ * Implements the basics of a BGP4 Session
+ * Any particular session must inherit this one
+ *
+ * @author ogondio
+ *
+ */
+public abstract class GenericBGP4Session extends Thread implements BGP4Session {
+
+ /**
+ * PCEP Session Manager
+ */
+ protected BGP4SessionsInformation BGP4SessionsInformation;
+
+ /**
+ * Thread to send periodic Keepalives
+ */
+ protected KeepAliveThread keepAliveT = null;
+
+ /**
+ * Value of the Keepalive timer set by the Local PCE. Used to send keepalives
+ */
+
+ protected int keepAliveLocal;
+
+ /**
+ * Value of the Keepalive timer of the peer PCC. It is not used in the server!!!
+ */
+ protected int keepAlivePeer;
+
+ /**
+ * Thread to check if the connection is still alive.
+ * If in this time the PCE has not received anything, it closes the session
+ * It is set by the PCC (in this case, the remote peer)
+ */
+ protected DeadTimerThread deadTimerT = null;
+
+ /**
+ * Value of the deadtimer that the PCC sends. It is used in the PCC in the thread
+ */
+ protected int deadTimerPeer;
+
+ /**
+ * Socket of the communication between BGP peers
+ */
+ protected Socket socket = null;
+
+ /**
+ * Remote Peer IP Address
+ * Obtained from the socket for convenience
+ */
+ protected Inet4Address remotePeerIP=null;
+
+ /**
+ * DataOutputStream to send messages to the peer
+ */
+ protected DataOutputStream out=null;
+
+
+
+ /**
+ * DataInputStream to receive messages from PCC
+ */
+ protected DataInputStream in=null;//
+ /**
+ * Queue to send the Computing Path Requests
+ */
+ //protected RequestQueueSend req;
+
+ /**
+ * Logger to write the Parent PCE server log
+ */
+ protected Logger log;
+
+ /**
+ * Timer to schedule KeepWait and OpenWait Timers
+ */
+ protected Timer timer;
+
+ /**
+ * Finite State Machine of the PCEP protocol
+ */
+ protected int FSMstate;
+
+ /**
+ * Remote Domain ID
+ * null if not sent
+ */
+ protected Inet4Address remoteDomainId=null;
+
+ /**
+ * Remote List of OF Codes
+ * If sent by the peer PCE
+ */
+ //private LinkedList remoteOfCodes;//FIME: What do we do with them?
+
+ /**
+ * RemoteOK: a boolean that is set to 1 if the system has received an
+ acceptable Open message.
+ */
+ private boolean remoteOK=false;
+
+ /**
+ *
+ */
+ private boolean localOK=false;
+
+ /**
+ *
+ */
+ private int openRetry=0;
+
+ /**
+ * Byte array to store the last PCEP message read.
+ */
+ protected byte[] msg = null;
+
+ /**
+ * Initial number of the session ID (internal use only)
+ */
+ public static long sessionIdCounter=0;
+
+ /**
+ *
+ */
+ protected Boolean updateFrom;
+ protected boolean sendTo;
+
+ /**
+ * Session ID (internal use only)
+ */
+ private long sessionId;
+ /**************** PARAMETROS DE LA SESION ********************/
+ private int ConnectRetryCounter=0;
+ private ConnectRetryTimer connectRetryTimer = null;
+ private int connectRetryTime; //FIXME: esto aun no se que es.
+
+ /**************PARAMETROS OPEN MESSAGE************************/
+ protected int holdTime;
+ /**
+ * Time between sending keepalives
+ */
+ protected int keepAliveTimer;
+ /**
+ * IP address that is assigned to that BGP speaker
+ */
+ protected Inet4Address BGPIdentifier;
+ /**
+ * Autonomous System number of the sender
+ */
+ protected int myAutonomousSystem;
+ /**
+ * version indicates the protocol version number of the message
+ * it must be 4
+ */
+ protected int version;
+
+
+ public GenericBGP4Session(BGP4SessionsInformation bgp4SessionsInformation,int holdTime,Inet4Address BGPIdentifier,int version,int myAutonomousSystem,int mykeepAliveTimer) {
+ log=LoggerFactory.getLogger("BGP4Parser");
+ this.BGP4SessionsInformation=bgp4SessionsInformation;
+ this.holdTime=holdTime;
+ this.BGPIdentifier=BGPIdentifier;
+ this.version = version;
+ this.myAutonomousSystem=myAutonomousSystem;
+ this.keepAliveTimer = mykeepAliveTimer;
+ this.newSessionId();
+
+ }
+
+ /**
+ * Read PCE message from TCP stream
+ * @param in InputStream
+ * @return byte array with a BGP4 Message
+ * @throws IOException Execption thrown trying to read message
+ */
+ protected byte[] readBGP4Msg(DataInputStream in) throws IOException{
+ byte[] ret = null;
+
+ byte[] hdr = new byte[BGP4Message.getBGPHeaderLength()];
+ byte[] temp = null;
+ boolean endHdr = false;
+ int r = 0;
+ int length = 0;
+ boolean endMsg = false;
+ int offset = 0;
+
+ while (!endMsg) {
+ try {
+ if (endHdr) {
+ r = in.read(temp, offset, 1);
+ }
+ else {
+ r = in.read(hdr, offset, 1);
+ }
+ } catch (IOException e){
+ log.warn("Error reading data: "+ e.getMessage());
+ throw e;
+ }catch (Exception e) {
+ log.warn("readMsg Oops: " + e.getMessage());
+ throw new IOException();
+ }
+
+ if (r > 0) {
+ if (offset == BGP4Message.getBGPMarkerLength()) {
+ length = ((int)hdr[offset]&0xFF) << 8;
+ }
+ if (offset == BGP4Message.getBGPMarkerLength() + 1) {
+ length = length | (((int)hdr[offset]&0xFF));
+ temp = new byte[length];
+ endHdr = true;
+ System.arraycopy(hdr, 0, temp, 0, BGP4Message.getBGPHeaderLength());
+ }
+ if ((length > 0) && (offset == length - 1)) {
+ endMsg = true;
+ }
+ offset++;
+ }
+ else if (r==-1){
+ log.debug("End of stream has been reached");
+ throw new IOException();
+ }
+ }
+ if (length > 0) {
+ ret = new byte[length];
+ System.arraycopy(temp, 0, ret, 0, length);
+ }
+ return ret;
+ }
+
+ /**
+ * Read PCE message from TCP stream
+ * @param in InputStream
+ * @return byte array with a BGP4 Message
+ * @throws IOException Execption thrown trying to read message
+ */
+ protected byte[] readMsgOptimized(DataInputStream in) throws IOException{
+ byte[] ret = null;
+
+ byte[] hdr = new byte[4];
+ byte[] temp = null;
+ boolean endHdr = false;
+ int r = 0;
+ int length = 0;
+ boolean endMsg = false;
+ int offset = 0;
+
+
+ while (!endMsg) {
+ try {
+ if (endHdr) {
+ //log.info("Vamos a leer datos ");
+ r = in.read(temp, offset, length-offset);
+ if (r>0){
+ if ((offset+r)>=length){
+ //log.info("Bien ");
+ endMsg=true;
+ }else {
+ offset=offset+r;
+ }
+
+ }
+ else if (r<0){
+ log.error("End of stream has been reached reading data");
+ throw new IOException();
+ }
+ }
+ else {
+ //log.info("Vamos a leer la cabecera ");
+ r = in.read(hdr, offset, 4-offset);
+ if (r < 0) {
+ log.error("End of stream has been reached reading header");
+ throw new IOException();
+ }else if (r >0){
+ if ((offset+r)>=4){
+ length = ( (hdr[offset+2]&0xFF) << 8) | ((hdr[offset+3]&0xFF));
+ offset=4;
+ temp = new byte[length];
+ endHdr = true;
+ System.arraycopy(hdr, 0, temp, 0, 4);
+ if (length==4){
+ endMsg=true;
+ }
+ }else {
+ offset=offset+r;
+ }
+
+ }
+
+ }
+ } catch (IOException e){
+ log.error("Error reading data: "+ e.getMessage());
+ throw e;
+ }catch (Exception e) {
+ log.error("readMsg Oops: " + e.getMessage());
+ log.error("Failure reason : "+e.getStackTrace());
+ throw new IOException();
+ }
+
+ }
+ if (length > 0) {
+ ret = new byte[length];
+ System.arraycopy(temp, 0, ret, 0, length);
+ }
+ return ret;
+ }
+
+
+ // /**
+ // *