mirror of
https://github.com/Telecominfraproject/ols-ucentral-client.git
synced 2026-03-20 03:39:28 +00:00
Compare commits
74 Commits
next
...
v4.1.0-rc1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3c9d20d97f | ||
|
|
84789e07ce | ||
|
|
10cc5bec80 | ||
|
|
ca74a49604 | ||
|
|
fb10d141d0 | ||
|
|
176d2b9f36 | ||
|
|
41d50f4650 | ||
|
|
00ae4001e7 | ||
|
|
5936fbed88 | ||
|
|
0aea2e273c | ||
|
|
6e8ccbf40c | ||
|
|
80f01f977c | ||
|
|
145f8aba82 | ||
|
|
e53d618a33 | ||
|
|
0799cec723 | ||
|
|
24143fc5bc | ||
|
|
15b9868322 | ||
|
|
54141e0af6 | ||
|
|
9034123c2e | ||
|
|
d0189eaad6 | ||
|
|
c349f3f9a4 | ||
|
|
5832ecdf36 | ||
|
|
4911cab05e | ||
|
|
7442bb79c3 | ||
|
|
f972987312 | ||
|
|
783368dd7b | ||
|
|
dc60bab84b | ||
|
|
681efcabfc | ||
|
|
6f6bd4dfd0 | ||
|
|
04e80e1650 | ||
|
|
a8e2b18733 | ||
|
|
2e5499c375 | ||
|
|
0f64807cfb | ||
|
|
215d4dab4a | ||
|
|
e13a8fac52 | ||
|
|
049fef08d9 | ||
|
|
2bd145e09f | ||
|
|
732b4e1bc7 | ||
|
|
559776ba06 | ||
|
|
b6c03319d3 | ||
|
|
05d06592cc | ||
|
|
ebf160fa06 | ||
|
|
ace64ef341 | ||
|
|
5acd35237c | ||
|
|
d9fae8097b | ||
|
|
ee4ff0ee3a | ||
|
|
6efdcb7eb5 | ||
|
|
bca8160f67 | ||
|
|
3d2b3295e7 | ||
|
|
15e4f7a580 | ||
|
|
1afbc126fe | ||
|
|
a2c49e8ab5 | ||
|
|
2a8d2c18ce | ||
|
|
4549ef61c3 | ||
|
|
5710119746 | ||
|
|
cedf998260 | ||
|
|
963120f2b4 | ||
|
|
8b4a63fb66 | ||
|
|
60abb9a7e6 | ||
|
|
0b683379b4 | ||
|
|
a328cd6b7a | ||
|
|
7afff76db1 | ||
|
|
0d9af851b4 | ||
|
|
b8c952cf1c | ||
|
|
8636487247 | ||
|
|
ac20c4c276 | ||
|
|
ee4b0ca66b | ||
|
|
977c651079 | ||
|
|
3beb5f314b | ||
|
|
a84bfa8e04 | ||
|
|
289c74a81d | ||
|
|
be1138ebc6 | ||
|
|
764e9f93ab | ||
|
|
12117ebfc8 |
21
Dockerfile
21
Dockerfile
@@ -2,8 +2,11 @@ FROM debian:buster
|
||||
LABEL Description="Ucentral client (Build) environment"
|
||||
|
||||
ARG HOME /root
|
||||
ARG EXTERNAL_LIBS ${HOME}/ucentral-external-libs
|
||||
|
||||
ARG SCHEMA="4.1.0-rc1"
|
||||
ARG SCHEMA_VERSION="v${SCHEMA}"
|
||||
ARG SCHEMA_ZIP_FILE="${SCHEMA_VERSION}.zip"
|
||||
ARG SCHEMA_UNZIPPED="ols-ucentral-schema-${SCHEMA}"
|
||||
ARG OLS_SCHEMA_SRC="https://github.com/Telecominfraproject/ols-ucentral-schema/archive/refs/tags/${SCHEMA_ZIP_FILE}"
|
||||
SHELL ["/bin/bash", "-c"]
|
||||
|
||||
RUN apt-get update -q -y && apt-get -q -y --no-install-recommends install \
|
||||
@@ -15,19 +18,24 @@ RUN apt-get update -q -y && apt-get -q -y --no-install-recommends install \
|
||||
libcurl4-openssl-dev \
|
||||
libev-dev \
|
||||
libssl-dev \
|
||||
libnl-route-3-dev \
|
||||
libnl-3-dev \
|
||||
apt-utils \
|
||||
git \
|
||||
wget \
|
||||
autoconf \
|
||||
libtool \
|
||||
pkg-config \
|
||||
libjsoncpp-dev
|
||||
libjsoncpp-dev \
|
||||
unzip
|
||||
|
||||
RUN git config --global http.sslverify false
|
||||
RUN git clone https://github.com/DaveGamble/cJSON.git ${HOME}/ucentral-external-libs/cJSON/
|
||||
RUN git clone https://libwebsockets.org/repo/libwebsockets ${HOME}/ucentral-external-libs/libwebsockets/
|
||||
RUN git clone --recurse-submodules -b v1.50.0 --depth 1 --shallow-submodules https://github.com/grpc/grpc ${HOME}/ucentral-external-libs/grpc/
|
||||
RUN git clone --recursive --branch v7.1.4 https://github.com/zhaojh329/rtty.git ${HOME}/ucentral-external-libs/rtty/
|
||||
ADD ${OLS_SCHEMA_SRC} /tmp/
|
||||
|
||||
|
||||
# The following libs should be prebuilt in docker-build-env img to speed-up
|
||||
# recompilation of only the ucentral-client itself
|
||||
@@ -39,6 +47,8 @@ RUN cd ${HOME}/ucentral-external-libs/cJSON/ && \
|
||||
make install
|
||||
|
||||
RUN cd ${HOME}/ucentral-external-libs/libwebsockets/ && \
|
||||
git branch --all && \
|
||||
git checkout a9b8fe7ebf61b8c0e7891e06e70d558412933a33 && \
|
||||
mkdir build && \
|
||||
cd build && \
|
||||
cmake .. && \
|
||||
@@ -60,3 +70,8 @@ RUN cd ${HOME}/ucentral-external-libs/rtty/ && \
|
||||
cd build && \
|
||||
cmake .. && \
|
||||
make -j4
|
||||
|
||||
RUN unzip /tmp/${SCHEMA_ZIP_FILE} -d ${HOME}/ucentral-external-libs/
|
||||
|
||||
RUN cd ${HOME}/ucentral-external-libs/ && \
|
||||
mv ${SCHEMA_UNZIPPED} ols-ucentral-schema
|
||||
|
||||
28
LICENSE
Normal file
28
LICENSE
Normal file
@@ -0,0 +1,28 @@
|
||||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2024, Telecom Infra Project
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
8
Makefile
8
Makefile
@@ -32,6 +32,7 @@ run-host-env: build-host-env
|
||||
docker run -d -t --name ${CONTAINER_NAME} \
|
||||
-v $(realpath ./):/root/ols-nos \
|
||||
--env UCENTRAL_PLATFORM=$(UCENTRAL_PLATFORM) \
|
||||
--env PLATFORM_REVISION="$(PLATFORM_REVISION)" \
|
||||
${IMG_ID}:${IMG_TAG} \
|
||||
bash
|
||||
|
||||
@@ -49,8 +50,13 @@ build-ucentral-app: run-host-env
|
||||
@echo Running ucentralclient docker-build-env container to build ucentral-client...;
|
||||
docker exec -t ${CONTAINER_NAME} /root/ols-nos/docker-build-client.sh
|
||||
docker cp ${CONTAINER_NAME}:/root/deliverables/ src/docker/
|
||||
# copy the schema version, if it is there
|
||||
docker cp ${CONTAINER_NAME}:/root/ucentral-external-libs/ols-ucentral-schema/schema.json src/docker/ || true
|
||||
docker container stop ${CONTAINER_NAME} > /dev/null 2>&1 || true;
|
||||
docker container rm ${CONTAINER_NAME} > /dev/null 2>&1 || true;
|
||||
if [ -f version.json ]; then
|
||||
cp version.json src/docker/
|
||||
fi
|
||||
|
||||
build-ucentral-docker-img: build-ucentral-app
|
||||
pushd src
|
||||
@@ -90,6 +96,8 @@ clean:
|
||||
rm -rf src/docker/deliverables || true;
|
||||
rm -rf src/docker/lib* || true;
|
||||
rm -rf src/docker/ucentral-client || true;
|
||||
rm -rf src/docker/version.json || true;
|
||||
rm -rf src/docker/schema.json || true;
|
||||
rm -rf src/debian/ucentral-client.substvars 2>/dev/null || true;
|
||||
rm -rf src/debian/shasta-ucentral-client.debhelper.log 2>/dev/null || true;
|
||||
rm -rf src/debian/.debhelper src/debian/ucentral-client 2>/dev/null || true;
|
||||
|
||||
@@ -11,7 +11,7 @@ cfg2:
|
||||
cfg3:
|
||||
Bring ports 1 up, 2 up (Ethernet1, Ethernet2) (admin state);
|
||||
Destroy any VLAN that is not in the list (in this particular CFG - create VLAN 10,
|
||||
destroye any other, except for MGMT VLAN 1 - it's not being altered by the
|
||||
destroy any other, except for MGMT VLAN 1 - it's not being altered by the
|
||||
uCentral app itself);
|
||||
Create VLAN 10;
|
||||
Set VLAN 10 memberlist with the following ports: Ethernet1, Ethernet2;
|
||||
@@ -39,6 +39,7 @@ cfg5_poe:
|
||||
- detection mode is 4pt-dot3af;
|
||||
- power limit is 99900mW (e.g. max per port);
|
||||
- priority is LOW;
|
||||
|
||||
cfg7_ieee80211x.json:
|
||||
Following json file configures the given topology:
|
||||
+-----------------+
|
||||
@@ -64,3 +65,33 @@ cfg7_ieee80211x.json:
|
||||
to be the same for the given (10.10.20.0/24) network.
|
||||
.1x client also must have a valid credentials data (both client and radius server
|
||||
must have same clients credentials configured).
|
||||
|
||||
cfg_igmp.json:
|
||||
Configure igmp snooping and querier on VLAN 1.
|
||||
Configure igmp static groups:
|
||||
- 230.1.1.1 with egress port Ethernet1
|
||||
- 230.2.2.2 with egress ports Ethernet2 & Ethernet3
|
||||
|
||||
cfg_rpvstp.json:
|
||||
Configure VLAN 1;
|
||||
Configure VLAN 2;
|
||||
Configure rapid per-vlan STP on VLAN 1 with priority 32768;
|
||||
Disable STP on VLAN 2.
|
||||
|
||||
cfg_port_isolation.json:
|
||||
Configure port isolation with Ethernet1 as uplink and
|
||||
Ethernet2 & Ethernet3 as downlink
|
||||
|
||||
cfg_services_log.json:
|
||||
Enable syslog with these parameters:
|
||||
- remote host addr
|
||||
- remote host port
|
||||
- log severity (priority):
|
||||
* emerg: 0
|
||||
* alert: 1
|
||||
* crit: 2
|
||||
* error: 3
|
||||
* warning: 4
|
||||
* notice: 5
|
||||
* info: 6
|
||||
* debug: 7
|
||||
|
||||
@@ -1,70 +1,70 @@
|
||||
{
|
||||
"ethernet": [
|
||||
{
|
||||
"duplex": "full",
|
||||
"enabled": false,
|
||||
"speed": 1000,
|
||||
"select-ports": [
|
||||
"Ethernet0",
|
||||
"Ethernet1",
|
||||
"Ethernet2",
|
||||
"Ethernet3",
|
||||
"Ethernet4",
|
||||
"Ethernet5",
|
||||
"Ethernet6",
|
||||
"Ethernet7",
|
||||
"Ethernet8",
|
||||
"Ethernet9",
|
||||
"Ethernet10",
|
||||
"Ethernet11",
|
||||
"Ethernet12",
|
||||
"Ethernet13",
|
||||
"Ethernet14",
|
||||
"Ethernet15",
|
||||
"Ethernet16",
|
||||
"Ethernet17",
|
||||
"Ethernet18",
|
||||
"Ethernet19",
|
||||
"Ethernet20",
|
||||
"Ethernet21",
|
||||
"Ethernet22",
|
||||
"Ethernet23",
|
||||
"Ethernet24",
|
||||
"Ethernet25",
|
||||
"Ethernet26",
|
||||
"Ethernet27",
|
||||
"Ethernet28",
|
||||
"Ethernet29",
|
||||
"Ethernet30",
|
||||
"Ethernet31",
|
||||
"Ethernet32",
|
||||
"Ethernet33",
|
||||
"Ethernet34",
|
||||
"Ethernet35",
|
||||
"Ethernet36",
|
||||
"Ethernet37",
|
||||
"Ethernet38",
|
||||
"Ethernet39",
|
||||
"Ethernet40",
|
||||
"Ethernet41",
|
||||
"Ethernet42",
|
||||
"Ethernet43",
|
||||
"Ethernet44",
|
||||
"Ethernet45",
|
||||
"Ethernet46",
|
||||
"Ethernet47",
|
||||
"Ethernet48",
|
||||
"Ethernet52",
|
||||
"Ethernet56",
|
||||
"Ethernet60",
|
||||
"Ethernet64",
|
||||
"Ethernet68",
|
||||
"Ethernet72",
|
||||
"Ethernet76"
|
||||
]
|
||||
}
|
||||
],
|
||||
"interfaces": [],
|
||||
"services": {},
|
||||
"uuid": 1
|
||||
}
|
||||
{
|
||||
"ethernet": [
|
||||
{
|
||||
"duplex": "full",
|
||||
"enabled": false,
|
||||
"speed": 1000,
|
||||
"select-ports": [
|
||||
"Ethernet0",
|
||||
"Ethernet1",
|
||||
"Ethernet2",
|
||||
"Ethernet3",
|
||||
"Ethernet4",
|
||||
"Ethernet5",
|
||||
"Ethernet6",
|
||||
"Ethernet7",
|
||||
"Ethernet8",
|
||||
"Ethernet9",
|
||||
"Ethernet10",
|
||||
"Ethernet11",
|
||||
"Ethernet12",
|
||||
"Ethernet13",
|
||||
"Ethernet14",
|
||||
"Ethernet15",
|
||||
"Ethernet16",
|
||||
"Ethernet17",
|
||||
"Ethernet18",
|
||||
"Ethernet19",
|
||||
"Ethernet20",
|
||||
"Ethernet21",
|
||||
"Ethernet22",
|
||||
"Ethernet23",
|
||||
"Ethernet24",
|
||||
"Ethernet25",
|
||||
"Ethernet26",
|
||||
"Ethernet27",
|
||||
"Ethernet28",
|
||||
"Ethernet29",
|
||||
"Ethernet30",
|
||||
"Ethernet31",
|
||||
"Ethernet32",
|
||||
"Ethernet33",
|
||||
"Ethernet34",
|
||||
"Ethernet35",
|
||||
"Ethernet36",
|
||||
"Ethernet37",
|
||||
"Ethernet38",
|
||||
"Ethernet39",
|
||||
"Ethernet40",
|
||||
"Ethernet41",
|
||||
"Ethernet42",
|
||||
"Ethernet43",
|
||||
"Ethernet44",
|
||||
"Ethernet45",
|
||||
"Ethernet46",
|
||||
"Ethernet47",
|
||||
"Ethernet48",
|
||||
"Ethernet52",
|
||||
"Ethernet56",
|
||||
"Ethernet60",
|
||||
"Ethernet64",
|
||||
"Ethernet68",
|
||||
"Ethernet72",
|
||||
"Ethernet76"
|
||||
]
|
||||
}
|
||||
],
|
||||
"interfaces": [],
|
||||
"services": {},
|
||||
"uuid": 1
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
{
|
||||
"ethernet": [
|
||||
{
|
||||
"duplex": "full",
|
||||
"enabled": true,
|
||||
"speed": 1000,
|
||||
"select-ports": [
|
||||
"Ethernet1",
|
||||
"Ethernet2"
|
||||
]
|
||||
}
|
||||
],
|
||||
"interfaces": [],
|
||||
"services": {},
|
||||
"uuid": 1
|
||||
}
|
||||
{
|
||||
"ethernet": [
|
||||
{
|
||||
"duplex": "full",
|
||||
"enabled": true,
|
||||
"speed": 1000,
|
||||
"select-ports": [
|
||||
"Ethernet1",
|
||||
"Ethernet2"
|
||||
]
|
||||
}
|
||||
],
|
||||
"interfaces": [],
|
||||
"services": {},
|
||||
"uuid": 1
|
||||
}
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
{
|
||||
"ethernet": [
|
||||
{
|
||||
"duplex": "full",
|
||||
"enabled": true,
|
||||
"speed": 1000,
|
||||
"select-ports": [
|
||||
"Ethernet1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"duplex": "full",
|
||||
"enabled": false,
|
||||
"select-ports": [
|
||||
"Ethernet2"
|
||||
],
|
||||
"speed": 1000
|
||||
}
|
||||
],
|
||||
"interfaces": [],
|
||||
"services": {},
|
||||
"uuid": 2
|
||||
}
|
||||
{
|
||||
"ethernet": [
|
||||
{
|
||||
"duplex": "full",
|
||||
"enabled": true,
|
||||
"speed": 1000,
|
||||
"select-ports": [
|
||||
"Ethernet1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"duplex": "full",
|
||||
"enabled": false,
|
||||
"select-ports": [
|
||||
"Ethernet2"
|
||||
],
|
||||
"speed": 1000
|
||||
}
|
||||
],
|
||||
"interfaces": [],
|
||||
"services": {},
|
||||
"uuid": 2
|
||||
}
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
{
|
||||
"ethernet": [
|
||||
{
|
||||
"duplex": "full",
|
||||
"enabled": true,
|
||||
"speed": 1000,
|
||||
"select-ports": [
|
||||
"Ethernet1",
|
||||
"Ethernet2"
|
||||
]
|
||||
}
|
||||
],
|
||||
"interfaces": [
|
||||
{
|
||||
"vlan": {
|
||||
"id": 10,
|
||||
"proto": "802.1q"
|
||||
},
|
||||
"ethernet": [
|
||||
{
|
||||
"select-ports": [
|
||||
"Ethernet1",
|
||||
"Ethernet2"
|
||||
],
|
||||
"vlan-tag": "tagged"
|
||||
}
|
||||
],
|
||||
"name": "mgmt",
|
||||
"role": "upstream",
|
||||
"services": []
|
||||
}
|
||||
],
|
||||
"services": {},
|
||||
"uuid": 3
|
||||
}
|
||||
{
|
||||
"ethernet": [
|
||||
{
|
||||
"duplex": "full",
|
||||
"enabled": true,
|
||||
"speed": 1000,
|
||||
"select-ports": [
|
||||
"Ethernet1",
|
||||
"Ethernet2"
|
||||
]
|
||||
}
|
||||
],
|
||||
"interfaces": [
|
||||
{
|
||||
"vlan": {
|
||||
"id": 10,
|
||||
"proto": "802.1q"
|
||||
},
|
||||
"ethernet": [
|
||||
{
|
||||
"select-ports": [
|
||||
"Ethernet1",
|
||||
"Ethernet2"
|
||||
],
|
||||
"vlan-tag": "tagged"
|
||||
}
|
||||
],
|
||||
"name": "mgmt",
|
||||
"role": "upstream",
|
||||
"services": []
|
||||
}
|
||||
],
|
||||
"services": {},
|
||||
"uuid": 3
|
||||
}
|
||||
|
||||
@@ -1,51 +1,51 @@
|
||||
{
|
||||
"ethernet": [
|
||||
{
|
||||
"duplex": "full",
|
||||
"enabled": true,
|
||||
"speed": 1000,
|
||||
"select-ports": [
|
||||
"Ethernet1",
|
||||
"Ethernet2"
|
||||
]
|
||||
}
|
||||
],
|
||||
"interfaces": [
|
||||
{
|
||||
"vlan": {
|
||||
"id": 10,
|
||||
"proto": "802.1q"
|
||||
},
|
||||
"ethernet": [
|
||||
{
|
||||
"select-ports": [
|
||||
"Ethernet1"
|
||||
],
|
||||
"vlan-tag": "tagged"
|
||||
}
|
||||
],
|
||||
"name": "mgmt",
|
||||
"role": "upstream",
|
||||
"services": []
|
||||
},
|
||||
{
|
||||
"vlan": {
|
||||
"id": 100,
|
||||
"proto": "802.1q"
|
||||
},
|
||||
"ethernet": [
|
||||
{
|
||||
"select-ports": [
|
||||
"Ethernet2"
|
||||
],
|
||||
"vlan-tag": "tagged"
|
||||
}
|
||||
],
|
||||
"name": "mgmt",
|
||||
"role": "upstream",
|
||||
"services": []
|
||||
}
|
||||
],
|
||||
"services": {},
|
||||
"uuid": 3
|
||||
}
|
||||
{
|
||||
"ethernet": [
|
||||
{
|
||||
"duplex": "full",
|
||||
"enabled": true,
|
||||
"speed": 1000,
|
||||
"select-ports": [
|
||||
"Ethernet1",
|
||||
"Ethernet2"
|
||||
]
|
||||
}
|
||||
],
|
||||
"interfaces": [
|
||||
{
|
||||
"vlan": {
|
||||
"id": 10,
|
||||
"proto": "802.1q"
|
||||
},
|
||||
"ethernet": [
|
||||
{
|
||||
"select-ports": [
|
||||
"Ethernet1"
|
||||
],
|
||||
"vlan-tag": "tagged"
|
||||
}
|
||||
],
|
||||
"name": "mgmt",
|
||||
"role": "upstream",
|
||||
"services": []
|
||||
},
|
||||
{
|
||||
"vlan": {
|
||||
"id": 100,
|
||||
"proto": "802.1q"
|
||||
},
|
||||
"ethernet": [
|
||||
{
|
||||
"select-ports": [
|
||||
"Ethernet2"
|
||||
],
|
||||
"vlan-tag": "tagged"
|
||||
}
|
||||
],
|
||||
"name": "mgmt",
|
||||
"role": "upstream",
|
||||
"services": []
|
||||
}
|
||||
],
|
||||
"services": {},
|
||||
"uuid": 3
|
||||
}
|
||||
|
||||
@@ -17,7 +17,11 @@
|
||||
{
|
||||
"ipv4": {
|
||||
"addressing": "static",
|
||||
"subnet": "20.20.20.20/24",
|
||||
"subnet": [
|
||||
{
|
||||
"prefix": "20.20.20.20/24"
|
||||
}
|
||||
],
|
||||
"dhcp": {
|
||||
"relay-server": "172.20.254.8",
|
||||
"circuit-id-format": "{Name}:{VLAN-ID}"
|
||||
@@ -44,7 +48,11 @@
|
||||
{
|
||||
"ipv4": {
|
||||
"addressing": "static",
|
||||
"subnet": "30.30.30.30/24",
|
||||
"subnet": [
|
||||
{
|
||||
"prefix": "30.30.30.30/24"
|
||||
}
|
||||
],
|
||||
"dhcp": {
|
||||
"relay-server": "172.20.10.12",
|
||||
"circuit-id-format": "{Name}:{VLAN-ID}"
|
||||
@@ -71,7 +79,11 @@
|
||||
{
|
||||
"ipv4": {
|
||||
"addressing": "static",
|
||||
"subnet": "172.20.10.181/24"
|
||||
"subnet": [
|
||||
{
|
||||
"prefix": "172.20.10.181/24"
|
||||
}
|
||||
]
|
||||
},
|
||||
"vlan": {
|
||||
"id": 20,
|
||||
|
||||
@@ -50,7 +50,11 @@
|
||||
},
|
||||
"ipv4": {
|
||||
"addressing": "static",
|
||||
"subnet": "10.10.20.100/24"
|
||||
"subnet": [
|
||||
{
|
||||
"prefix": "10.10.20.100/24"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ethernet": [
|
||||
{
|
||||
@@ -70,7 +74,11 @@
|
||||
},
|
||||
"ipv4": {
|
||||
"addressing": "static",
|
||||
"subnet": "10.10.50.100/24"
|
||||
"subnet": [
|
||||
{
|
||||
"prefix": "10.10.50.100/24"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ethernet": [
|
||||
{
|
||||
|
||||
64
config-samples/cfg_igmp.json
Normal file
64
config-samples/cfg_igmp.json
Normal file
@@ -0,0 +1,64 @@
|
||||
{
|
||||
"ethernet": [
|
||||
{
|
||||
"select-ports": [
|
||||
"Ethernet*"
|
||||
],
|
||||
"speed": 1000,
|
||||
"duplex": "full",
|
||||
"enabled": true,
|
||||
"poe": {
|
||||
"admin-mode": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"interfaces": [
|
||||
{
|
||||
"vlan": {
|
||||
"id": 1,
|
||||
"proto": "802.1q"
|
||||
},
|
||||
"ethernet": [
|
||||
{
|
||||
"select-ports": [
|
||||
"Ethernet*"
|
||||
],
|
||||
"vlan-tag": "un-tagged"
|
||||
}
|
||||
],
|
||||
"ipv4": {
|
||||
"multicast": {
|
||||
"igmp": {
|
||||
"querier-enable": true,
|
||||
"query-interval": 60,
|
||||
"snooping-enable": true,
|
||||
"version": 3,
|
||||
"static-mcast-groups": [
|
||||
{
|
||||
"address": "230.1.1.1",
|
||||
"egress-ports": [
|
||||
"Ethernet1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"address": "230.2.2.2",
|
||||
"egress-ports": [
|
||||
"Ethernet2",
|
||||
"Ethernet3"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"subnet": [
|
||||
{
|
||||
"prefix": "1.1.1.1/24"
|
||||
}
|
||||
]
|
||||
},
|
||||
"role": "upstream",
|
||||
"name": "mgmt-vlan"
|
||||
}
|
||||
],
|
||||
"uuid": 1
|
||||
}
|
||||
54
config-samples/cfg_port_isolation.json
Normal file
54
config-samples/cfg_port_isolation.json
Normal file
@@ -0,0 +1,54 @@
|
||||
{
|
||||
"ethernet": [
|
||||
{
|
||||
"select-ports": [
|
||||
"Ethernet*"
|
||||
],
|
||||
"speed": 1000,
|
||||
"duplex": "full",
|
||||
"enabled": true,
|
||||
"poe": {
|
||||
"admin-mode": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"interfaces": [
|
||||
{
|
||||
"vlan": {
|
||||
"id": 1,
|
||||
"proto": "802.1q"
|
||||
},
|
||||
"ethernet": [
|
||||
{
|
||||
"select-ports": [
|
||||
"Ethernet*"
|
||||
],
|
||||
"vlan-tag": "un-tagged"
|
||||
}
|
||||
],
|
||||
"role": "upstream",
|
||||
"name": "mgmt-vlan"
|
||||
}
|
||||
],
|
||||
"switch": {
|
||||
"port-isolation": {
|
||||
"sessions": [
|
||||
{
|
||||
"id": 1,
|
||||
"uplink": {
|
||||
"interface-list": [
|
||||
"Ethernet1"
|
||||
]
|
||||
},
|
||||
"downlink": {
|
||||
"interface-list": [
|
||||
"Ethernet2",
|
||||
"Ethernet3"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"uuid": 1
|
||||
}
|
||||
66
config-samples/cfg_rpvstp.json
Normal file
66
config-samples/cfg_rpvstp.json
Normal file
@@ -0,0 +1,66 @@
|
||||
{
|
||||
"ethernet": [
|
||||
{
|
||||
"select-ports": [
|
||||
"Ethernet*"
|
||||
],
|
||||
"speed": 1000,
|
||||
"duplex": "full",
|
||||
"enabled": true,
|
||||
"poe": {
|
||||
"admin-mode": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"interfaces": [
|
||||
{
|
||||
"vlan": {
|
||||
"id": 1,
|
||||
"proto": "802.1q"
|
||||
},
|
||||
"ethernet": [
|
||||
{
|
||||
"select-ports": [
|
||||
"Ethernet*"
|
||||
],
|
||||
"vlan-tag": "un-tagged"
|
||||
}
|
||||
],
|
||||
"role": "upstream",
|
||||
"name": "mgmt-vlan"
|
||||
},
|
||||
{
|
||||
"vlan": {
|
||||
"id": 2,
|
||||
"proto": "802.1q"
|
||||
},
|
||||
"ethernet": [
|
||||
{
|
||||
"select-ports": [
|
||||
"Ethernet*"
|
||||
],
|
||||
"vlan-tag": "tagged"
|
||||
}
|
||||
],
|
||||
"role": "upstream",
|
||||
"name": "mgmt-vlan"
|
||||
}
|
||||
],
|
||||
"switch": {
|
||||
"loop-detection": {
|
||||
"protocol": "rpvstp",
|
||||
"instances": [
|
||||
{
|
||||
"id": 1,
|
||||
"enabled": true,
|
||||
"priority": 32768
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"enabled": false
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"uuid": 1
|
||||
}
|
||||
43
config-samples/cfg_services_log.json
Normal file
43
config-samples/cfg_services_log.json
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"ethernet": [
|
||||
{
|
||||
"select-ports": [
|
||||
"Ethernet*"
|
||||
],
|
||||
"speed": 1000,
|
||||
"duplex": "full",
|
||||
"enabled": true,
|
||||
"poe": {
|
||||
"admin-mode": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"interfaces": [
|
||||
{
|
||||
"vlan": {
|
||||
"id": 1,
|
||||
"proto": "802.1q"
|
||||
},
|
||||
"ethernet": [
|
||||
{
|
||||
"select-ports": [
|
||||
"Ethernet*"
|
||||
],
|
||||
"vlan-tag": "un-tagged"
|
||||
}
|
||||
],
|
||||
"role": "upstream",
|
||||
"name": "mgmt-vlan"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"log": {
|
||||
"port": 2000,
|
||||
"priority": 7,
|
||||
"size": 1000,
|
||||
"host": "192.168.1.10",
|
||||
"proto": "udp"
|
||||
}
|
||||
},
|
||||
"uuid": 1
|
||||
}
|
||||
@@ -36,6 +36,7 @@ override_dh_install:
|
||||
# home folder.
|
||||
mkdir -p ${INSTALL}/home/admin
|
||||
cp scripts/OLS_NOS_fixups.script ${INSTALL}/usr/local/lib
|
||||
cp scripts/OLS_NOS_upgrade_override.script ${INSTALL}/usr/local/lib
|
||||
cp docker-ucentral-client.gz ${INSTALL}/usr/local/lib
|
||||
# Install Vlan1 in-band management configuration
|
||||
mkdir -p ${INSTALL}/etc/network/interfaces.d/
|
||||
|
||||
@@ -21,6 +21,8 @@ COPY /ucentral-client /usr/local/bin/ucentral-client
|
||||
COPY /rtty /usr/local/bin/
|
||||
COPY /lib* /usr/local/lib/
|
||||
|
||||
COPY /version.jso[n] /etc/
|
||||
COPY /schema.jso[n] /etc/
|
||||
RUN ldconfig
|
||||
RUN ls -l /usr/local/bin/ucentral-client
|
||||
|
||||
|
||||
@@ -4,3 +4,8 @@ ntp server 1.pool.ntp.org prefer true
|
||||
ntp server 2.pool.ntp.org prefer true
|
||||
ntp server 3.pool.ntp.org prefer true
|
||||
ntp authenticate
|
||||
ip dhcp snooping
|
||||
ip dhcp snooping Vlan1
|
||||
ntp source-interface Vlan 1
|
||||
interface range Ethernet 0-100
|
||||
no ip dhcp snooping trust
|
||||
|
||||
2
src/scripts/OLS_NOS_upgrade_override.script
Normal file
2
src/scripts/OLS_NOS_upgrade_override.script
Normal file
@@ -0,0 +1,2 @@
|
||||
configure terminal
|
||||
no ip vrf mgmt
|
||||
@@ -11,6 +11,7 @@ start() {
|
||||
fi
|
||||
|
||||
cp /usr/local/lib/OLS_NOS_fixups.script /home/admin/OLS_NOS_fixups.script
|
||||
cp /usr/local/lib/OLS_NOS_upgrade_override.script /home/admin/OLS_NOS_upgrade_override.script
|
||||
|
||||
if [ $(systemctl is-active config-setup.service) == "active" ]; then
|
||||
# do nothing on service restart
|
||||
@@ -29,11 +30,23 @@ start() {
|
||||
}
|
||||
|
||||
wait() {
|
||||
test -d /var/lib/ucentral || mkdir /var/lib/ucentral
|
||||
|
||||
# Wait for at least one Vlan to be created - a signal that telemetry is up.
|
||||
# Even if vlan table is empty, private 3967 will be allocated with all
|
||||
# ports in it.
|
||||
while ! ls /sys/class/net/Vlan* &>/dev/null; do sleep 1; done
|
||||
|
||||
# Detect first boot on this version
|
||||
# Run upgrade overrides before fixups
|
||||
conf_upgrade_md5sum=$(md5sum /home/admin/OLS_NOS_upgrade_override.script | cut -d ' ' -f1)
|
||||
if test "$conf_upgrade_md5sum" != "$(test -f /var/lib/ucentral/upgrade-override.md5sum && cat /var/lib/ucentral/upgrade-override.md5sum)"; then
|
||||
sudo -u admin -- bash "sonic-cli" "/home/admin/OLS_NOS_upgrade_override.script"
|
||||
echo -n "$conf_upgrade_md5sum" >/var/lib/ucentral/upgrade-override.md5sum
|
||||
fi
|
||||
|
||||
sudo touch /etc/default/in-band-dhcp
|
||||
|
||||
# Temporary NTP fixup / WA: configure a list of default NTP servers.
|
||||
# Should mature into a default-config option to make sure board has right
|
||||
# time upon any boot (especially first time).
|
||||
@@ -48,6 +61,8 @@ wait() {
|
||||
# NOTE: alternatively we could use ifplugd. This also handle del/add scenario
|
||||
ifup Vlan1 || true
|
||||
|
||||
config vlan dhcp 1 enable
|
||||
|
||||
# There's an issue with containers starting before DNS server is configured:
|
||||
# resolf.conf file get copied from host to container upon container start.
|
||||
# This means, that if resolf.conf gets altered (on host) after container's been
|
||||
@@ -63,9 +78,19 @@ wait() {
|
||||
# This also means, that we won't start up untill this URI is accessible.
|
||||
while ! curl clientauth.one.digicert.com &>/dev/null; do sleep 1; done
|
||||
|
||||
# Enable DHCP trusting for uplink (Vlan1) iface
|
||||
# It's needed to forward DHCP Discover (and replies) from/to DHCP server
|
||||
# of (untrusted) port clients (EthernetX) of the same Vlan (Vlan1).
|
||||
# Without this fix underlying Vlan members wouldn't be able to receive
|
||||
# DHCP-lease IP
|
||||
trusted_dhcp_if=`sudo -u admin -- bash "sonic-cli" "-c" "show ip arp" | grep -Eo "Ethernet[0-9]+"`
|
||||
sudo -u admin -- "echo" "configure terminal" > /home/admin/fixup_scr.script
|
||||
sudo -u admin -- "echo" "interface $trusted_dhcp_if" >> /home/admin/fixup_scr.script
|
||||
sudo -u admin -- "echo" "ip dhcp snooping trust" >> /home/admin/fixup_scr.script
|
||||
sudo -u admin -- bash "sonic-cli" "/home/admin/fixup_scr.script"
|
||||
|
||||
# change admin password
|
||||
# NOTE: This could lead to access escalation, if you got image from running device
|
||||
test -d /var/lib/ucentral || mkdir /var/lib/ucentral
|
||||
if ! test -f /var/lib/ucentral/admin-cred.changed; then
|
||||
#ADMIN_PASSWD=`openssl rand -hex 10`
|
||||
ADMIN_PASSWD=broadcom
|
||||
|
||||
@@ -154,6 +154,11 @@
|
||||
"vlanid": "1"
|
||||
}
|
||||
},
|
||||
"VLAN_INTERFACE": {
|
||||
"Vlan1": {
|
||||
"dhcp": "enable"
|
||||
}
|
||||
},
|
||||
"VLAN_MEMBER": {
|
||||
{% for port in PORT %}
|
||||
"Vlan1|{{port}}": {
|
||||
@@ -164,11 +169,6 @@
|
||||
"INTERFACE": {
|
||||
"Vlan1": {}
|
||||
},
|
||||
"MGMT_VRF_CONFIG": {
|
||||
"vrf_global": {
|
||||
"mgmtVrfEnabled": "true"
|
||||
}
|
||||
},
|
||||
"VRF": {
|
||||
"default": {
|
||||
"enabled": "true"
|
||||
|
||||
@@ -46,16 +46,16 @@ struct ucentral_router {
|
||||
|
||||
struct ucentral_router_fib_db_apply_args {
|
||||
/* plat whould check info to determine if node channged */
|
||||
int (*upd_cb)(const struct ucentral_router_fib_node *old,
|
||||
int (*upd_cb)(const struct ucentral_router_fib_node *old_node,
|
||||
int olen,
|
||||
const struct ucentral_router_fib_node *new,
|
||||
const struct ucentral_router_fib_node *new_node,
|
||||
int nlen,
|
||||
void *arg);
|
||||
/* prefix = new, info = new */
|
||||
int (*add_cb)(const struct ucentral_router_fib_node *new,
|
||||
int (*add_cb)(const struct ucentral_router_fib_node *new_node,
|
||||
int len, void *arg);
|
||||
/* prefix = none */
|
||||
int (*del_cb)(const struct ucentral_router_fib_node *old,
|
||||
int (*del_cb)(const struct ucentral_router_fib_node *old_node,
|
||||
int len, void *arg);
|
||||
void *arg;
|
||||
};
|
||||
@@ -69,26 +69,26 @@ int ucentral_router_fib_db_append(struct ucentral_router *r,
|
||||
struct ucentral_router_fib_node *n);
|
||||
int ucentral_router_fib_key_cmp(const struct ucentral_router_fib_key *a,
|
||||
const struct ucentral_router_fib_key *b);
|
||||
bool ucentral_router_fib_info_cmp(const struct ucentral_router_fib_info *a,
|
||||
const struct ucentral_router_fib_info *b);
|
||||
int ucentral_router_fib_info_cmp(const struct ucentral_router_fib_info *a,
|
||||
const struct ucentral_router_fib_info *b);
|
||||
|
||||
#define router_db_get(R, I) (I < (R)->len ? &(R)->arr[(I)] : NULL)
|
||||
|
||||
#define for_router_db_diff_CASE_UPD(DIFF) if (!(DIFF))
|
||||
#define for_router_db_diff_CASE_DEL(DIFF) if ((DIFF) > 0)
|
||||
#define for_router_db_diff_CASE_ADD(DIFF) if ((DIFF) < 0)
|
||||
#define diff_case_upd(DIFF) (!(DIFF))
|
||||
#define diff_case_del(DIFF) ((DIFF) > 0)
|
||||
#define diff_case_add(DIFF) ((DIFF) < 0)
|
||||
#define router_db_diff_get(NEW, OLD, INEW, IOLD) \
|
||||
(IOLD) == (OLD)->len \
|
||||
? -1 \
|
||||
: (INEW) == (NEW)->len \
|
||||
? 1 \
|
||||
: ucentral_router_fib_key_cmp(&(NEW)->arr[(INEW)].key, &(OLD)->arr[(IOLD)].key)
|
||||
#define for_router_db_diff(NEW, OLD, INEW, IOLD, DIFF) \
|
||||
for ((INEW) = 0, (IOLD) = 0, (NEW)->sorted ? 0 : ucentral_router_fib_db_sort((NEW)), (OLD)->sorted ? 0 : ucentral_router_fib_db_sort((OLD)); \
|
||||
((IOLD) != (OLD)->len || (INEW) != (NEW)->len) && \
|
||||
(( \
|
||||
(DIFF) = (IOLD) == (OLD)->len ? -1 : (INEW) == (NEW)->len ? 1 : ucentral_router_fib_key_cmp(&(NEW)->arr[(INEW)].key, &(OLD)->arr[(IOLD)].key) \
|
||||
) || 1); \
|
||||
(DIFF) == 0 ? ++(INEW) && ++(IOLD) : 0, (DIFF) > 0 ? ++(IOLD) : 0, (DIFF) < 0 ? ++(INEW) : 0\
|
||||
for ((INEW) = 0, (IOLD) = 0, (DIFF) = 0; \
|
||||
\
|
||||
((IOLD) != (OLD)->len || (INEW) != (NEW)->len); \
|
||||
\
|
||||
(DIFF) == 0 ? ++(INEW) && ++(IOLD) : 0, \
|
||||
(DIFF) > 0 ? ++(IOLD) : 0, \
|
||||
(DIFF) < 0 ? ++(INEW) : 0 \
|
||||
)
|
||||
|
||||
/*
|
||||
* ((DIFF) == 0 && ++(INEW) && ++(IOLD)) || \
|
||||
* ((DIFF) > 0 && ++(IOLD)) || \
|
||||
* ((DIFF) < 0 && ++(INEW)) \
|
||||
*/
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@ extern "C" {
|
||||
#define RADIUS_CFG_DEFAULT_PRIO (1)
|
||||
#define HEALTHCHEK_MESSAGE_MAX_COUNT (10)
|
||||
#define HEALTHCHEK_MESSAGE_MAX_LEN (100)
|
||||
#define PLATFORM_MAC_STR_SIZE (18)
|
||||
#define METRICS_WIRED_CLIENTS_MAX_NUM (2000)
|
||||
|
||||
/*
|
||||
* TODO(vb) likely we need to parse interfaces in proto to understand
|
||||
@@ -39,6 +41,8 @@ extern "C" {
|
||||
*/
|
||||
#define PID_TO_NAME(p, name) sprintf(name, "Ethernet%hu", p)
|
||||
#define NAME_TO_PID(p, name) sscanf((name), "Ethernet%hu", (p))
|
||||
#define VLAN_TO_NAME(v, name) sprintf((name), "Vlan%hu", (v))
|
||||
#define NAME_TO_VLAN(v, name) sscanf((name), "Vlan%hu", (v))
|
||||
|
||||
struct plat_vlan_memberlist;
|
||||
struct plat_port_vlan;
|
||||
@@ -62,6 +66,18 @@ enum plat_ieee8021x_port_host_mode {
|
||||
PLAT_802_1X_PORT_HOST_MODE_SINGLE_HOST,
|
||||
};
|
||||
|
||||
enum plat_ieee8021x_das_auth_type {
|
||||
PLAT_802_1X_DAS_AUTH_TYPE_ANY,
|
||||
PLAT_802_1X_DAS_AUTH_TYPE_ALL,
|
||||
PLAT_802_1X_DAS_AUTH_TYPE_SESSION_KEY,
|
||||
};
|
||||
|
||||
enum plat_igmp_version {
|
||||
PLAT_IGMP_VERSION_1,
|
||||
PLAT_IGMP_VERSION_2,
|
||||
PLAT_IGMP_VERSION_3
|
||||
};
|
||||
|
||||
#define UCENTRAL_PORT_LLDP_PEER_INFO_MAX_MGMT_IPS (2)
|
||||
/* Interface LLDP peer's data, as defined in interface.lldp.yml*/
|
||||
struct plat_port_lldp_peer_info {
|
||||
@@ -75,7 +91,7 @@ struct plat_port_lldp_peer_info {
|
||||
/* The chassis name that our neighbour is announcing */
|
||||
char name[64];
|
||||
/* The chassis MAC that our neighbour is announcing */
|
||||
char mac[18];
|
||||
char mac[PLATFORM_MAC_STR_SIZE];
|
||||
/* The chassis description that our neighbour is announcing */
|
||||
char description[512];
|
||||
/* The management IPs that our neighbour is announcing */
|
||||
@@ -113,7 +129,7 @@ struct plat_poe_port_state {
|
||||
|
||||
struct plat_ieee8021x_authenticated_client_info {
|
||||
char auth_method[32];
|
||||
char mac_addr[18];
|
||||
char mac_addr[PLATFORM_MAC_STR_SIZE];
|
||||
size_t session_time;
|
||||
char username[64];
|
||||
char vlan_type[32];
|
||||
@@ -250,10 +266,27 @@ struct plat_port_l2 {
|
||||
struct plat_ipv4 ipv4;
|
||||
};
|
||||
|
||||
struct plat_igmp {
|
||||
bool exist;
|
||||
bool snooping_enabled;
|
||||
bool querier_enabled;
|
||||
bool fast_leave_enabled;
|
||||
uint32_t query_interval;
|
||||
uint32_t last_member_query_interval;
|
||||
uint32_t max_response_time;
|
||||
enum plat_igmp_version version;
|
||||
size_t num_groups;
|
||||
struct {
|
||||
struct in_addr addr;
|
||||
struct plat_ports_list *egress_ports_list;
|
||||
} *groups;
|
||||
};
|
||||
|
||||
struct plat_port_vlan {
|
||||
struct plat_vlan_memberlist *members_list_head;
|
||||
struct plat_ipv4 ipv4;
|
||||
struct plat_dhcp dhcp;
|
||||
struct plat_igmp igmp;
|
||||
uint16_t id;
|
||||
uint16_t mstp_instance;
|
||||
};
|
||||
@@ -280,6 +313,18 @@ struct plat_syslog_cfg {
|
||||
char host[SYSLOG_CFG_FIELD_STR_MAX_LEN];
|
||||
};
|
||||
|
||||
struct plat_enabled_service_cfg {
|
||||
struct {
|
||||
bool enabled;
|
||||
} ssh;
|
||||
struct telnet {
|
||||
bool enabled;
|
||||
} telnet;
|
||||
struct {
|
||||
bool enabled;
|
||||
} http;
|
||||
};
|
||||
|
||||
struct plat_rtty_cfg {
|
||||
char id[RTTY_CFG_FIELD_STR_MAX_LEN];
|
||||
char passwd[RTTY_CFG_FIELD_STR_MAX_LEN];
|
||||
@@ -322,6 +367,7 @@ struct plat_metrics_cfg {
|
||||
int lldp_enabled;
|
||||
int clients_enabled;
|
||||
size_t interval;
|
||||
unsigned max_mac_count;
|
||||
/* IE GET max length. Should be enoug. */
|
||||
char public_ip_lookup[2048];
|
||||
} state;
|
||||
@@ -334,8 +380,16 @@ struct plat_unit_poe_cfg {
|
||||
bool is_usage_threshold_set;
|
||||
};
|
||||
|
||||
struct plat_unit_system_cfg {
|
||||
char password[64];
|
||||
bool password_changed;
|
||||
};
|
||||
|
||||
struct plat_unit {
|
||||
struct plat_unit_poe_cfg poe;
|
||||
struct plat_unit_system_cfg system;
|
||||
bool mc_flood_control;
|
||||
bool querier_enable;
|
||||
};
|
||||
|
||||
enum plat_stp_mode {
|
||||
@@ -367,6 +421,31 @@ struct plat_radius_hosts_list {
|
||||
struct plat_radius_host host;
|
||||
};
|
||||
|
||||
struct plat_ieee8021x_dac_host {
|
||||
char hostname[RADIUS_CFG_HOSTNAME_STR_MAX_LEN];
|
||||
char passkey[RADIUS_CFG_PASSKEY_STR_MAX_LEN];
|
||||
};
|
||||
|
||||
struct plat_ieee8021x_dac_list {
|
||||
struct plat_ieee8021x_dac_list *next;
|
||||
struct plat_ieee8021x_dac_host host;
|
||||
};
|
||||
|
||||
struct plat_port_isolation_session_ports {
|
||||
struct plat_ports_list *ports_list;
|
||||
};
|
||||
|
||||
struct plat_port_isolation_session {
|
||||
uint64_t id;
|
||||
struct plat_port_isolation_session_ports uplink;
|
||||
struct plat_port_isolation_session_ports downlink;
|
||||
};
|
||||
|
||||
struct plat_port_isolation_cfg {
|
||||
struct plat_port_isolation_session *sessions;
|
||||
size_t sessions_num;
|
||||
};
|
||||
|
||||
struct plat_cfg {
|
||||
struct plat_unit unit;
|
||||
/* Alloc all ports, but access them only if bit is set. */
|
||||
@@ -376,6 +455,7 @@ struct plat_cfg {
|
||||
BITMAP_DECLARE(vlans_to_cfg, MAX_VLANS);
|
||||
struct plat_metrics_cfg metrics;
|
||||
struct plat_syslog_cfg *log_cfg;
|
||||
struct plat_enabled_service_cfg enabled_services_cfg;
|
||||
/* Port's interfaces (provide l2 iface w/o bridge caps) */
|
||||
struct plat_port_l2 portsl2[MAX_NUM_OF_PORTS];
|
||||
struct ucentral_router router;
|
||||
@@ -384,9 +464,24 @@ struct plat_cfg {
|
||||
/* Instance zero is for global instance (like common values in rstp) */
|
||||
struct plat_stp_instance_cfg stp_instances[MAX_VLANS];
|
||||
struct plat_radius_hosts_list *radius_hosts_list;
|
||||
bool ieee8021x_is_auth_ctrl_enabled;
|
||||
struct {
|
||||
bool is_auth_ctrl_enabled;
|
||||
bool bounce_port_ignore;
|
||||
bool disable_port_ignore;
|
||||
bool ignore_server_key;
|
||||
bool ignore_session_key;
|
||||
char server_key[RADIUS_CFG_PASSKEY_STR_MAX_LEN];
|
||||
enum plat_ieee8021x_das_auth_type das_auth_type;
|
||||
struct plat_ieee8021x_dac_list *das_dac_list;
|
||||
} ieee8021x;
|
||||
struct plat_port_isolation_cfg port_isolation_cfg;
|
||||
};
|
||||
|
||||
struct plat_learned_mac_addr {
|
||||
char port[PORT_MAX_NAME_LEN];
|
||||
int vid;
|
||||
char mac[PLATFORM_MAC_STR_SIZE];
|
||||
};
|
||||
|
||||
typedef void (*plat_alarm_cb)(struct plat_alarm *);
|
||||
|
||||
@@ -486,17 +581,60 @@ enum {
|
||||
PLAT_REBOOT_CAUSE_REBOOT_CMD,
|
||||
PLAT_REBOOT_CAUSE_POWERLOSS,
|
||||
PLAT_REBOOT_CAUSE_CRASH,
|
||||
PLAT_REBOOT_CAUSE_UNAVAILABLE,
|
||||
};
|
||||
|
||||
enum sfp_form_factor {
|
||||
UCENTRAL_SFP_FORM_FACTOR_NA = 0,
|
||||
|
||||
UCENTRAL_SFP_FORM_FACTOR_SFP,
|
||||
UCENTRAL_SFP_FORM_FACTOR_SFP_PLUS,
|
||||
UCENTRAL_SFP_FORM_FACTOR_SFP_28,
|
||||
UCENTRAL_SFP_FORM_FACTOR_SFP_DD,
|
||||
UCENTRAL_SFP_FORM_FACTOR_QSFP,
|
||||
UCENTRAL_SFP_FORM_FACTOR_QSFP_PLUS,
|
||||
UCENTRAL_SFP_FORM_FACTOR_QSFP_28,
|
||||
UCENTRAL_SFP_FORM_FACTOR_QSFP_DD
|
||||
};
|
||||
|
||||
enum sfp_link_mode {
|
||||
UCENTRAL_SFP_LINK_MODE_NA = 0,
|
||||
|
||||
UCENTRAL_SFP_LINK_MODE_1000_X,
|
||||
UCENTRAL_SFP_LINK_MODE_2500_X,
|
||||
UCENTRAL_SFP_LINK_MODE_4000_SR,
|
||||
UCENTRAL_SFP_LINK_MODE_10G_SR,
|
||||
UCENTRAL_SFP_LINK_MODE_25G_SR,
|
||||
UCENTRAL_SFP_LINK_MODE_40G_SR,
|
||||
UCENTRAL_SFP_LINK_MODE_50G_SR,
|
||||
UCENTRAL_SFP_LINK_MODE_100G_SR,
|
||||
};
|
||||
|
||||
struct plat_port_transceiver_info {
|
||||
char vendor_name[64];
|
||||
char part_number[64];
|
||||
char serial_number[64];
|
||||
char revision[64];
|
||||
enum sfp_form_factor form_factor;
|
||||
enum sfp_link_mode *supported_link_modes;
|
||||
size_t num_supported_link_modes;
|
||||
float temperature;
|
||||
float tx_optical_power;
|
||||
float rx_optical_power;
|
||||
float max_module_power;
|
||||
};
|
||||
|
||||
struct plat_port_info {
|
||||
struct plat_port_counters stats;
|
||||
struct plat_port_lldp_peer_info lldp_peer_info;
|
||||
struct plat_ieee8021x_port_info ieee8021x_info;
|
||||
struct plat_port_transceiver_info transceiver_info;
|
||||
uint32_t uptime;
|
||||
uint32_t speed;
|
||||
uint8_t carrier_up;
|
||||
uint8_t duplex;
|
||||
uint8_t has_lldp_peer_info;
|
||||
uint8_t has_transceiver_info;
|
||||
char name[PORT_MAX_NAME_LEN];
|
||||
};
|
||||
|
||||
@@ -510,6 +648,24 @@ struct plat_system_info {
|
||||
double load_average[3]; /* 1, 5, 15 minutes load average */
|
||||
};
|
||||
|
||||
struct plat_iee8021x_coa_counters {
|
||||
uint64_t coa_req_received;
|
||||
uint64_t coa_ack_sent;
|
||||
uint64_t coa_nak_sent;
|
||||
uint64_t coa_ignored;
|
||||
uint64_t coa_wrong_attr;
|
||||
uint64_t coa_wrong_attr_value;
|
||||
uint64_t coa_wrong_session_context;
|
||||
uint64_t coa_administratively_prohibited_req;
|
||||
};
|
||||
|
||||
struct plat_gw_address {
|
||||
struct in_addr ip;
|
||||
uint32_t metric;
|
||||
char port[PORT_MAX_NAME_LEN];
|
||||
char mac[PLATFORM_MAC_STR_SIZE];
|
||||
};
|
||||
|
||||
struct plat_state_info {
|
||||
struct plat_poe_state poe_state;
|
||||
struct plat_poe_port_state poe_ports_state[MAX_NUM_OF_PORTS];
|
||||
@@ -517,8 +673,15 @@ struct plat_state_info {
|
||||
|
||||
struct plat_port_info *port_info;
|
||||
int port_info_count;
|
||||
struct plat_port_vlan *vlan_info;
|
||||
size_t vlan_info_count;
|
||||
struct plat_learned_mac_addr *learned_mac_list;
|
||||
size_t learned_mac_list_size;
|
||||
struct plat_gw_address *gw_addr_list;
|
||||
size_t gw_addr_list_size;
|
||||
|
||||
struct plat_system_info system_info;
|
||||
struct plat_iee8021x_coa_counters ieee8021x_global_coa_counters;
|
||||
};
|
||||
|
||||
struct plat_upgrade_info {
|
||||
@@ -544,7 +707,14 @@ struct plat_event_callbacks {
|
||||
plat_poe_link_faultcode_cb poe_link_faultcode_cb;
|
||||
};
|
||||
|
||||
enum plat_script_type {
|
||||
PLAT_SCRIPT_TYPE_NA = 0,
|
||||
PLAT_SCRIPT_TYPE_SHELL = 1,
|
||||
PLAT_SCRIPT_TYPE_DIAGNOSTICS = 2,
|
||||
};
|
||||
|
||||
struct plat_run_script_result {
|
||||
enum plat_script_type type;
|
||||
const char *stdout_string;
|
||||
size_t stdout_string_len;
|
||||
int exit_status;
|
||||
@@ -552,7 +722,7 @@ struct plat_run_script_result {
|
||||
};
|
||||
|
||||
struct plat_run_script {
|
||||
const char *type;
|
||||
enum plat_script_type type;
|
||||
const char *script_base64;
|
||||
plat_run_script_cb cb;
|
||||
void *ctx;
|
||||
@@ -602,11 +772,10 @@ int plat_run_script(struct plat_run_script *);
|
||||
int plat_port_list_get(uint16_t list_size, struct plat_ports_list *ports);
|
||||
int plat_port_num_get(uint16_t *num_of_active_ports);
|
||||
int plat_running_img_name_get(char *str, size_t str_max_len);
|
||||
int plat_revision_get(char *str, size_t str_max_len);
|
||||
int
|
||||
plat_reboot_cause_get(struct plat_reboot_cause *cause);
|
||||
|
||||
int plat_diagnostic(char *res_path);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,12 +1,19 @@
|
||||
plat.a: plat.o
|
||||
ar crs $@ $^
|
||||
|
||||
plat.o: plat-gnma.o gnma/gnma.full.a
|
||||
plat.o: plat-gnma.o gnma/gnma.full.a netlink/netlink.full.a
|
||||
# TODO(vb) get back to this
|
||||
gcc -r -nostdlib -o $@ $^
|
||||
|
||||
gnma/gnma.full.a:
|
||||
$(MAKE) -C $(dir $@) $(notdir $@)
|
||||
|
||||
netlink/netlink.full.a:
|
||||
$(MAKE) -C $(dir $@) $(notdir $@)
|
||||
|
||||
%.o: %.c
|
||||
ifdef PLATFORM_REVISION
|
||||
gcc -c -o $@ ${CFLAGS} -I ./ -I ../../include -D PLATFORM_REVISION='"$(PLATFORM_REVISION)"' $^
|
||||
else
|
||||
gcc -c -o $@ ${CFLAGS} -I ./ -I ../../include $^
|
||||
endif
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
all: gnma.a
|
||||
|
||||
%.o: %.c
|
||||
gcc -c -o $@ ${CFLAGS} -I ./ -I../../../include $<
|
||||
gcc -c -o $@ ${CFLAGS} -I ./ -I../../../include -I../netlink $<
|
||||
|
||||
gnma.a: gnma_common.o
|
||||
ar crs $@ $^
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -7,6 +7,7 @@
|
||||
#define GNMA_RADIUS_CFG_HOSTNAME_STR_MAX_LEN (64)
|
||||
#define GNMA_RADIUS_CFG_PASSKEY_STR_MAX_LEN (64)
|
||||
|
||||
#define GNMA_OK 0
|
||||
#define GNMA_ERR_COMMON -1
|
||||
#define GNMA_ERR_OVERFLOW -2
|
||||
|
||||
@@ -26,6 +27,16 @@ struct gnma_radius_host_key {
|
||||
char hostname[GNMA_RADIUS_CFG_HOSTNAME_STR_MAX_LEN];
|
||||
};
|
||||
|
||||
struct gnma_das_dac_host_key {
|
||||
char hostname[GNMA_RADIUS_CFG_HOSTNAME_STR_MAX_LEN];
|
||||
};
|
||||
|
||||
typedef enum _gnma_das_auth_type_t {
|
||||
GNMA_802_1X_DAS_AUTH_TYPE_ANY,
|
||||
GNMA_802_1X_DAS_AUTH_TYPE_ALL,
|
||||
GNMA_802_1X_DAS_AUTH_TYPE_SESSION_KEY,
|
||||
} gnma_das_auth_type_t;
|
||||
|
||||
struct gnma_metadata {
|
||||
char platform[GNMA_METADATA_STR_MAX_LEN];
|
||||
char hwsku[GNMA_METADATA_STR_MAX_LEN];
|
||||
@@ -58,6 +69,17 @@ typedef enum _gnma_port_stat_type_t {
|
||||
|
||||
} gnma_port_stat_type_t;
|
||||
|
||||
typedef enum _gnma_ieee8021x_das_dac_stat_type_t {
|
||||
GNMA_IEEE8021X_DAS_DAC_STAT_IN_COA_PKTS,
|
||||
GNMA_IEEE8021X_DAS_DAC_STAT_OUT_COA_ACK_PKTS,
|
||||
GNMA_IEEE8021X_DAS_DAC_STAT_OUT_COA_NAK_PKTS,
|
||||
GNMA_IEEE8021X_DAS_DAC_STAT_IN_COA_IGNORED_PKTS,
|
||||
GNMA_IEEE8021X_DAS_DAC_STAT_IN_COA_WRONG_ATTR_PKTS,
|
||||
GNMA_IEEE8021X_DAS_DAC_STAT_IN_COA_WRONG_ATTR_VALUE_PKTS,
|
||||
GNMA_IEEE8021X_DAS_DAC_STAT_IN_COA_WRONG_SESSION_CONTEXT_PKTS,
|
||||
GNMA_IEEE8021X_DAS_DAC_STAT_IN_COA_ADMINISTRATIVELY_PROHIBITED_REQ_PKTS,
|
||||
} gnma_ieee8021x_das_dac_stat_type_t;
|
||||
|
||||
struct gnma_alarm {
|
||||
const char *id;
|
||||
const char *resource;
|
||||
@@ -129,7 +151,9 @@ struct gnma_route_attrs {
|
||||
} connected;
|
||||
struct {
|
||||
uint16_t vid;
|
||||
uint32_t metric;
|
||||
struct in_addr gw;
|
||||
struct gnma_port_key egress_port;
|
||||
} nexthop;
|
||||
};
|
||||
};
|
||||
@@ -256,6 +280,47 @@ struct gnma_vlan_member_bmap {
|
||||
} vlan[GNMA_MAX_VLANS];
|
||||
};
|
||||
|
||||
typedef enum _gnma_fdb_entry_type_t {
|
||||
GNMA_FDB_ENTRY_TYPE_STATIC,
|
||||
GNMA_FDB_ENTRY_TYPE_DYNAMIC,
|
||||
} gnma_fdb_entry_type_t;
|
||||
|
||||
struct gnma_fdb_entry {
|
||||
struct gnma_port_key port;
|
||||
gnma_fdb_entry_type_t type;
|
||||
int vid;
|
||||
char mac[18];
|
||||
};
|
||||
|
||||
typedef enum _gnma_igmp_version_t {
|
||||
GNMA_IGMP_VERSION_NA = 0,
|
||||
GNMA_IGMP_VERSION_1 = 1,
|
||||
GNMA_IGMP_VERSION_2 = 2,
|
||||
GNMA_IGMP_VERSION_3 = 3
|
||||
} gnma_igmp_version_t;
|
||||
|
||||
struct gnma_igmp_snoop_attr {
|
||||
bool enabled;
|
||||
bool querier_enabled;
|
||||
bool fast_leave_enabled;
|
||||
uint32_t query_interval;
|
||||
uint32_t last_member_query_interval;
|
||||
uint32_t max_response_time;
|
||||
gnma_igmp_version_t version;
|
||||
};
|
||||
|
||||
struct gnma_igmp_static_group_attr {
|
||||
struct in_addr address;
|
||||
size_t num_ports;
|
||||
struct gnma_port_key *egress_ports;
|
||||
};
|
||||
|
||||
struct gnma_vlan_ip_t {
|
||||
uint16_t vid;
|
||||
uint16_t prefixlen;
|
||||
struct in_addr address;
|
||||
};
|
||||
|
||||
int gnma_switch_create(/* TODO id */ /* TODO: attr (adr, login, psw) */);
|
||||
int gnma_port_admin_state_set(struct gnma_port_key *port_key, bool up);
|
||||
int gnma_port_speed_set(struct gnma_port_key *port_key, const char *speed);
|
||||
@@ -380,6 +445,9 @@ int gnma_route_remove(uint16_t vr_id /* 0 - default */,
|
||||
int gnma_route_list_get(uint16_t vr_id, uint32_t *list_size,
|
||||
struct gnma_ip_prefix *prefix_list,
|
||||
struct gnma_route_attrs *attr_list);
|
||||
int gnma_dyn_route_list_get(size_t *list_size,
|
||||
struct gnma_ip_prefix *prefix_list,
|
||||
struct gnma_route_attrs *attr_list);
|
||||
|
||||
int gnma_stp_mode_set(gnma_stp_mode_t mode, struct gnma_stp_attr *attr);
|
||||
int gnma_stp_mode_get(gnma_stp_mode_t *mode, struct gnma_stp_attr *attr);
|
||||
@@ -390,23 +458,53 @@ int gnma_stp_ports_enable(uint32_t list_size, struct gnma_port_key *ports_list);
|
||||
int gnma_stp_instance_set(uint16_t instance, uint16_t prio,
|
||||
uint32_t list_size, uint16_t *vid_list);
|
||||
|
||||
int gnma_stp_vids_enable(uint32_t list_size, uint16_t *vid_list);
|
||||
int gnma_stp_vids_enable_all(void);
|
||||
int gnma_stp_vids_set(uint32_t list_size, uint16_t *vid_list, bool enable);
|
||||
int gnma_stp_vids_set_all(bool enable);
|
||||
int gnma_stp_vid_set(uint16_t vid, struct gnma_stp_attr *attr);
|
||||
int gnma_stp_vid_bulk_get(struct gnma_stp_attr *list, ssize_t size);
|
||||
|
||||
int gnma_ieee8021x_system_auth_control_set(bool is_enabled);
|
||||
int gnma_ieee8021x_system_auth_control_get(bool *is_enabled);
|
||||
int gnma_ieee8021x_system_auth_clients_get(char *buf, size_t buf_size);
|
||||
int gnma_ieee8021x_das_bounce_port_ignore_set(bool bounce_port_ignore);
|
||||
int gnma_ieee8021x_das_bounce_port_ignore_get(bool *bounce_port_ignore);
|
||||
int gnma_ieee8021x_das_disable_port_ignore_set(bool disable_port_ignore);
|
||||
int gnma_ieee8021x_das_disable_port_ignore_get(bool *disable_port_ignore);
|
||||
int gnma_ieee8021x_das_ignore_server_key_set(bool ignore_server_key);
|
||||
int gnma_ieee8021x_das_ignore_server_key_get(bool *ignore_server_key);
|
||||
int gnma_ieee8021x_das_ignore_session_key_set(bool ignore_session_key);
|
||||
int gnma_ieee8021x_das_ignore_session_key_get(bool *ignore_session_key);
|
||||
int gnma_ieee8021x_das_auth_type_key_set(gnma_das_auth_type_t auth_type);
|
||||
int gnma_ieee8021x_das_auth_type_key_get(gnma_das_auth_type_t *auth_type);
|
||||
int gnma_ieee8021x_das_dac_hosts_list_get(size_t *list_size,
|
||||
struct gnma_das_dac_host_key *das_dac_keys_arr);
|
||||
int gnma_ieee8021x_das_dac_host_add(struct gnma_das_dac_host_key *key,
|
||||
const char *passkey);
|
||||
int gnma_ieee8021x_das_dac_host_remove(struct gnma_das_dac_host_key *key);
|
||||
int
|
||||
gnma_iee8021x_das_dac_global_stats_get(uint32_t num_of_counters,
|
||||
gnma_ieee8021x_das_dac_stat_type_t *counter_ids,
|
||||
uint64_t *counters);
|
||||
|
||||
int gnma_radius_hosts_list_get(size_t *list_size,
|
||||
struct gnma_radius_host_key *hosts_list);
|
||||
int gnma_radius_host_add(struct gnma_radius_host_key *key, const char *passkey,
|
||||
uint16_t auth_port, uint8_t prio);
|
||||
int gnma_radius_host_remove(struct gnma_radius_host_key *key);
|
||||
int gnma_mac_address_list_get(size_t *list_size, struct gnma_fdb_entry *list);
|
||||
int gnma_system_password_set(char *password);
|
||||
int gnma_igmp_snooping_set(uint16_t vid, struct gnma_igmp_snoop_attr *attr);
|
||||
int gnma_igmp_static_groups_set(uint16_t vid, size_t num_groups,
|
||||
struct gnma_igmp_static_group_attr *groups);
|
||||
int gnma_nei_addr_get(struct gnma_port_key *iface, struct in_addr *ip,
|
||||
char *mac, size_t buf_size);
|
||||
|
||||
int gnma_igmp_iface_groups_get(struct gnma_port_key *iface,
|
||||
char *buf, size_t *buf_size);
|
||||
|
||||
struct gnma_change *gnma_change_create(void);
|
||||
void gnma_change_destory(struct gnma_change *);
|
||||
int gnma_change_exec(struct gnma_change *);
|
||||
|
||||
int gnma_techsupport_start(char *res_path);
|
||||
int gnma_ip_iface_addr_get(struct gnma_vlan_ip_t *address_list, size_t *list_size);
|
||||
|
||||
10
src/ucentral-client/platform/brcm-sonic/netlink/Makefile
Normal file
10
src/ucentral-client/platform/brcm-sonic/netlink/Makefile
Normal file
@@ -0,0 +1,10 @@
|
||||
all: netlink.a
|
||||
|
||||
%.o: %.c
|
||||
gcc -c -o $@ ${CFLAGS} -I ./ -I/usr/include/libnl3 -lnl-3 -lnl-route-3 $<
|
||||
|
||||
netlink.a: netlink_common.o
|
||||
ar crs $@ $^
|
||||
|
||||
netlink.full.a: netlink.a
|
||||
ar crsT $@ $^
|
||||
220
src/ucentral-client/platform/brcm-sonic/netlink/netlink_common.c
Normal file
220
src/ucentral-client/platform/brcm-sonic/netlink/netlink_common.c
Normal file
@@ -0,0 +1,220 @@
|
||||
#include <sys/socket.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <unistd.h>
|
||||
#include <net/if.h>
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/route/link.h>
|
||||
#include <netlink/route/route.h>
|
||||
#include <netlink/route/addr.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <netlink_common.h>
|
||||
|
||||
#define BUFFER_SIZE 4096
|
||||
|
||||
#define likely(x) __builtin_expect(!!(x), 1)
|
||||
#define unlikely(x) __builtin_expect(!!(x), 0)
|
||||
|
||||
#define for_each_nlmsg(n, buf, len) \
|
||||
for (n = (struct nlmsghdr*)buf; \
|
||||
NLMSG_OK(n, (uint32_t)len) && n->nlmsg_type != NLMSG_DONE; \
|
||||
n = NLMSG_NEXT(n, len))
|
||||
|
||||
#define for_each_rattr(n, buf, len) \
|
||||
for (n = (struct rtattr*)buf; RTA_OK(n, len); n = RTA_NEXT(n, len))
|
||||
|
||||
|
||||
static int _nl_connect(int *sock)
|
||||
{
|
||||
int s;
|
||||
|
||||
s = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
|
||||
if (s == -1)
|
||||
return -1;
|
||||
|
||||
*sock = s;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void _nl_disconnect(int sock)
|
||||
{
|
||||
close(sock);
|
||||
}
|
||||
|
||||
static int _nl_request_ip_send(int sock)
|
||||
{
|
||||
struct sockaddr_nl sa = {.nl_family = AF_NETLINK};
|
||||
char buf[BUFFER_SIZE];
|
||||
struct ifaddrmsg *ifa;
|
||||
struct nlmsghdr *nl;
|
||||
struct msghdr msg;
|
||||
struct iovec iov;
|
||||
int res;
|
||||
|
||||
memset(&msg, 0, sizeof(msg));
|
||||
memset(buf, 0, BUFFER_SIZE);
|
||||
|
||||
nl = (struct nlmsghdr*)buf;
|
||||
nl->nlmsg_len = NLMSG_LENGTH(sizeof(struct ifaddrmsg));
|
||||
nl->nlmsg_type = RTM_GETADDR;
|
||||
nl->nlmsg_flags = NLM_F_REQUEST | NLM_F_ROOT;
|
||||
|
||||
iov.iov_base = nl;
|
||||
iov.iov_len = nl->nlmsg_len;
|
||||
|
||||
ifa = (struct ifaddrmsg*)NLMSG_DATA(nl);
|
||||
ifa->ifa_family = AF_INET; /* IPv4 */
|
||||
|
||||
msg.msg_name = &sa;
|
||||
msg.msg_namelen = sizeof(sa);
|
||||
msg.msg_iov = &iov;
|
||||
msg.msg_iovlen = 1;
|
||||
|
||||
res = sendmsg(sock, &msg, 0);
|
||||
if (res < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _nl_response_get(int sock, void *buf, size_t *len)
|
||||
{
|
||||
struct iovec iov = {.iov_base = buf, .iov_len = *len};
|
||||
struct sockaddr_nl sa = {.nl_family = AF_NETLINK};
|
||||
struct msghdr msg = {
|
||||
.msg_name = &sa,
|
||||
.msg_namelen = sizeof(sa),
|
||||
.msg_iov = &iov,
|
||||
.msg_iovlen = 1
|
||||
};
|
||||
int res;
|
||||
|
||||
res = recvmsg(sock, &msg, 0);
|
||||
if (res < 0)
|
||||
return -1;
|
||||
*len = res;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _nl_iface_addr_parse(uint32_t vid, void *buf, size_t len,
|
||||
unsigned char prefixlen, struct nl_vid_addr *addr)
|
||||
{
|
||||
struct rtattr *rta = NULL;
|
||||
|
||||
for_each_rattr(rta, buf, len) {
|
||||
if (rta->rta_type == IFA_LOCAL) {
|
||||
memcpy(&addr->address, RTA_DATA(rta), sizeof(addr->address));
|
||||
addr->vid = vid;
|
||||
addr->prefixlen = prefixlen;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _nl_response_addr_parse(void *buf,
|
||||
size_t len,
|
||||
struct nl_vid_addr *addr_list,
|
||||
size_t *list_size)
|
||||
{
|
||||
struct ifaddrmsg *iface_addr;
|
||||
struct nlmsghdr *nl = NULL;
|
||||
char ifname[IF_NAMESIZE];
|
||||
size_t num_addrs = 0;
|
||||
uint32_t vid;
|
||||
int err = 0;
|
||||
|
||||
for_each_nlmsg(nl, buf, len) {
|
||||
if (nl->nlmsg_type == NLMSG_ERROR)
|
||||
return -1;
|
||||
|
||||
if (nl->nlmsg_type != RTM_NEWADDR) /* only care for addr */
|
||||
continue;
|
||||
|
||||
iface_addr = (struct ifaddrmsg*)NLMSG_DATA(nl);
|
||||
|
||||
if (!if_indextoname(iface_addr->ifa_index, ifname))
|
||||
return -1;
|
||||
|
||||
if (sscanf(ifname, "Vlan%u", &vid) != 1)
|
||||
continue;
|
||||
|
||||
if (!addr_list || *list_size == 0) {
|
||||
num_addrs++;
|
||||
continue;
|
||||
}
|
||||
if (num_addrs > *list_size)
|
||||
return -EOVERFLOW;
|
||||
|
||||
err = _nl_iface_addr_parse(vid, IFA_RTA(iface_addr), IFA_PAYLOAD(nl),
|
||||
iface_addr->ifa_prefixlen,
|
||||
&addr_list[num_addrs++]);
|
||||
if (err)
|
||||
break;
|
||||
}
|
||||
|
||||
if (num_addrs > *list_size)
|
||||
err = -EOVERFLOW;
|
||||
*list_size = num_addrs;
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
return nl->nlmsg_type == NLMSG_DONE? -ENODATA : 0;
|
||||
}
|
||||
|
||||
int nl_get_ip_list(struct nl_vid_addr *addr_list, size_t *list_size)
|
||||
{
|
||||
size_t buf_len = BUFFER_SIZE, batch_size = 0, num_addrs = 0;
|
||||
char buf[BUFFER_SIZE];
|
||||
int sock = 0;
|
||||
int err;
|
||||
|
||||
err = _nl_connect(&sock);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = _nl_request_ip_send(sock);
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
while (1) {
|
||||
err = _nl_response_get(sock, buf, &buf_len);
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
err = _nl_response_addr_parse(buf, buf_len, NULL, &batch_size);
|
||||
if (err == -ENODATA) {
|
||||
err = 0;
|
||||
break;
|
||||
}
|
||||
if (err && err != -EOVERFLOW) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
num_addrs += batch_size;
|
||||
if (!addr_list || *list_size == 0)
|
||||
continue;
|
||||
if (num_addrs > *list_size) {
|
||||
err = -EOVERFLOW;
|
||||
break;
|
||||
}
|
||||
|
||||
err = _nl_response_addr_parse(buf, buf_len, &addr_list[num_addrs - batch_size], &batch_size);
|
||||
if (unlikely(err == -ENODATA)) {
|
||||
err = 0;
|
||||
break;
|
||||
}
|
||||
if (err)
|
||||
goto out;
|
||||
}
|
||||
if (num_addrs > *list_size)
|
||||
err = -EOVERFLOW;
|
||||
*list_size = num_addrs;
|
||||
out:
|
||||
_nl_disconnect(sock);
|
||||
return err;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef _NETLINK_COMMON
|
||||
#define _NETLINK_COMMON
|
||||
|
||||
struct nl_vid_addr {
|
||||
uint16_t vid;
|
||||
uint16_t prefixlen;
|
||||
uint32_t address;
|
||||
};
|
||||
|
||||
int nl_get_ip_list(struct nl_vid_addr *addr_list, size_t *list_size);
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
14
src/ucentral-client/platform/brcm-sonic/plat-revision.h
Normal file
14
src/ucentral-client/platform/brcm-sonic/plat-revision.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef _PLAT_REVISION
|
||||
#define _PLAT_REVISION
|
||||
|
||||
#define XSTR(x) STR(x)
|
||||
#define STR(x) #x
|
||||
|
||||
#define PLATFORM_REL_NUM 2.2
|
||||
#define PLATFORM_BUILD_NUM 5
|
||||
|
||||
#ifndef PLATFORM_REVISION
|
||||
#define PLATFORM_REVISION "Rel " XSTR(PLATFORM_REL_NUM) " build " XSTR(PLATFORM_BUILD_NUM)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -2,4 +2,8 @@ plat.a: plat-example.o
|
||||
ar crs $@ $^
|
||||
|
||||
%.o: %.c
|
||||
ifdef PLATFORM_REVISION
|
||||
gcc -c -o $@ ${CFLAGS} -I ./ -I ../../include -D PLATFORM_REVISION='"$(PLATFORM_REVISION)"' $^
|
||||
else
|
||||
gcc -c -o $@ ${CFLAGS} -I ./ -I ../../include $^
|
||||
endif
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <ucentral-platform.h>
|
||||
#include <ucentral-log.h>
|
||||
#include <plat-revision.h>
|
||||
|
||||
#define UNUSED_PARAM(param) (void)((param))
|
||||
|
||||
@@ -12,7 +13,11 @@ int plat_init(void)
|
||||
|
||||
int plat_info_get(struct plat_platform_info *info)
|
||||
{
|
||||
UNUSED_PARAM(info);
|
||||
*info = (struct plat_platform_info){0};
|
||||
snprintf(info->platform, sizeof info->platform, "%s", "Example Platform" );
|
||||
snprintf(info->hwsku, sizeof info->hwsku, "%s", "example-platform-sku");
|
||||
snprintf(info->mac, sizeof info->mac, "%s", "24:fe:9a:0f:48:f0");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -156,10 +161,45 @@ int plat_port_num_get(uint16_t *num_of_active_ports)
|
||||
UNUSED_PARAM(num_of_active_ports);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int plat_revision_get(char *str, size_t str_max_len)
|
||||
{
|
||||
snprintf(str, str_max_len, PLATFORM_REVISION);
|
||||
return 0;
|
||||
}
|
||||
int plat_reboot_cause_get(struct plat_reboot_cause *cause)
|
||||
{
|
||||
UNUSED_PARAM(cause);
|
||||
return 0;
|
||||
}
|
||||
int plat_event_subscribe(const struct plat_event_callbacks *cbs)
|
||||
{
|
||||
UNUSED_PARAM(cbs);
|
||||
return 0;
|
||||
}
|
||||
void plat_event_unsubscribe(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int plat_running_img_name_get(char *str, size_t str_max_len)
|
||||
{
|
||||
UNUSED_PARAM(str_max_len);
|
||||
UNUSED_PARAM(str);
|
||||
return 0;
|
||||
}
|
||||
int plat_metrics_save(const struct plat_metrics_cfg *cfg)
|
||||
{
|
||||
UNUSED_PARAM(cfg);
|
||||
return 0;
|
||||
}
|
||||
int plat_metrics_restore(struct plat_metrics_cfg *cfg)
|
||||
{
|
||||
UNUSED_PARAM(cfg);
|
||||
return 0;
|
||||
}
|
||||
int plat_run_script(struct plat_run_script *p)
|
||||
{
|
||||
UNUSED_PARAM(p);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef _PLAT_REVISION
|
||||
#define _PLAT_REVISION
|
||||
|
||||
#define XSTR(x) STR(x)
|
||||
#define STR(x) #x
|
||||
|
||||
#define PLATFORM_REL_NUM 3.2.0
|
||||
#define PLATFORM_BUILD_NUM 5
|
||||
|
||||
#ifndef PLATFORM_REVISION
|
||||
#define PLATFORM_REVISION "Rel " XSTR(PLATFORM_REL_NUM) " build " XSTR(PLATFORM_BUILD_NUM)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -70,12 +70,13 @@ int ucentral_router_fib_key_cmp(const struct ucentral_router_fib_key *a,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* bool result, as we have no criteria to sort this */
|
||||
bool ucentral_router_fib_info_cmp(const struct ucentral_router_fib_info *a,
|
||||
const struct ucentral_router_fib_info *b)
|
||||
int ucentral_router_fib_info_cmp(const struct ucentral_router_fib_info *a,
|
||||
const struct ucentral_router_fib_info *b)
|
||||
{
|
||||
if (a->type != b->type)
|
||||
return false;
|
||||
if (a->type > b->type)
|
||||
return 1;
|
||||
if (a->type < b->type)
|
||||
return -1;
|
||||
|
||||
switch (a->type) {
|
||||
case UCENTRAL_ROUTE_BLACKHOLE:
|
||||
@@ -83,24 +84,32 @@ bool ucentral_router_fib_info_cmp(const struct ucentral_router_fib_info *a,
|
||||
case UCENTRAL_ROUTE_UNREACHABLE:
|
||||
break;
|
||||
case UCENTRAL_ROUTE_CONNECTED:
|
||||
if (a->connected.vid != b->connected.vid)
|
||||
return false;
|
||||
if (a->connected.vid > b->connected.vid)
|
||||
return 1;
|
||||
if (a->connected.vid < b->connected.vid)
|
||||
return -1;
|
||||
break;
|
||||
case UCENTRAL_ROUTE_BROADCAST:
|
||||
if (a->broadcast.vid != b->broadcast.vid)
|
||||
return false;
|
||||
if (a->broadcast.vid > b->broadcast.vid)
|
||||
return 1;
|
||||
if (a->broadcast.vid < b->broadcast.vid)
|
||||
return -1;
|
||||
break;
|
||||
case UCENTRAL_ROUTE_NH:
|
||||
if (a->nh.vid != b->nh.vid)
|
||||
return false;
|
||||
if (a->nh.gw.s_addr != b->nh.gw.s_addr)
|
||||
return false;
|
||||
if (a->nh.vid > b->nh.vid)
|
||||
return 1;
|
||||
if (a->nh.vid < b->nh.vid)
|
||||
return -1;
|
||||
if (a->nh.gw.s_addr > b->nh.gw.s_addr)
|
||||
return 1;
|
||||
if (a->nh.gw.s_addr < b->nh.gw.s_addr)
|
||||
return -1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __fib_node_key_cmp_cb(const void *a, const void *b)
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
#include <cjson/cJSON.h>
|
||||
|
||||
#include "ucentral.h"
|
||||
#include "ucentral-json-parser.h"
|
||||
/* WA for parser issue */
|
||||
/* #include "ucentral-json-parser.h" */
|
||||
|
||||
#include <openssl/conf.h>
|
||||
#include <openssl/err.h>
|
||||
@@ -47,7 +48,6 @@ time_t conn_time;
|
||||
static int conn_successfull;
|
||||
|
||||
struct plat_metrics_cfg ucentral_metrics;
|
||||
static struct uc_json_parser parser;
|
||||
|
||||
static int interrupted;
|
||||
static pthread_t sigthread;
|
||||
@@ -67,6 +67,8 @@ lws_protocols protocols[] = {
|
||||
struct client_config client = {
|
||||
.redirector_file = "/tmp/ucentral-redirector.json",
|
||||
.redirector_file_dbg = "/tmp/firstcontact.hdr",
|
||||
.ols_schema_version_file = "/etc/schema.json",
|
||||
.ols_client_version_file = "/etc/version.json",
|
||||
.server = NULL,
|
||||
.port = 15002,
|
||||
.path = "/",
|
||||
@@ -339,6 +341,7 @@ sul_connect_attempt(struct lws_sorted_usec_list *sul)
|
||||
UC_LOG_DBG("Connected\n");
|
||||
}
|
||||
|
||||
/* WA for parser issue
|
||||
static void parse_cb(cJSON *j, void *data)
|
||||
{
|
||||
(void)data;
|
||||
@@ -350,6 +353,7 @@ static void parse_error_cb(void *data)
|
||||
(void)data;
|
||||
UC_LOG_ERR("JSON config parse failed");
|
||||
}
|
||||
*/
|
||||
|
||||
static const char *redirector_host_get(void)
|
||||
{
|
||||
@@ -424,12 +428,15 @@ callback_broker(struct lws *wsi, enum lws_callback_reasons reason,
|
||||
websocket = wsi;
|
||||
connect_send();
|
||||
conn_successfull = 1;
|
||||
uc_json_parser_init(&parser, parse_cb, parse_error_cb, 0);
|
||||
/* WA for parser issue */
|
||||
/* uc_json_parser_init(&parser, parse_cb, parse_error_cb, 0); */
|
||||
lws_callback_on_writable(websocket);
|
||||
break;
|
||||
|
||||
case LWS_CALLBACK_CLIENT_RECEIVE:
|
||||
uc_json_parser_feed(&parser, in, len);
|
||||
/* WA for parser issue */
|
||||
/* uc_json_parser_feed(&parser, in, len); */
|
||||
proto_handle((char *)in);
|
||||
break;
|
||||
|
||||
case LWS_CALLBACK_CLIENT_CONNECTION_ERROR:
|
||||
@@ -443,7 +450,8 @@ callback_broker(struct lws *wsi, enum lws_callback_reasons reason,
|
||||
/* fall through */
|
||||
case LWS_CALLBACK_CLIENT_CLOSED:
|
||||
UC_LOG_INFO("connection closed\n");
|
||||
uc_json_parser_uninit(&parser);
|
||||
/* WA for parser issue */
|
||||
/* uc_json_parser_uninit(&parser); */
|
||||
websocket = NULL;
|
||||
set_conn_time();
|
||||
vhd->client_wsi = NULL;
|
||||
@@ -683,6 +691,57 @@ static void sigthread_create(void)
|
||||
}
|
||||
}
|
||||
|
||||
static int get_updated_pass(char *pass, size_t *len) {
|
||||
char *passwd_file_path = "/var/lib/ucentral/admin-cred.buf";
|
||||
size_t password_size;
|
||||
int passwd_fd = -1;
|
||||
char password[64];
|
||||
|
||||
if (access(passwd_file_path, F_OK))
|
||||
goto out;
|
||||
|
||||
passwd_fd = open(passwd_file_path, O_RDONLY);
|
||||
if (passwd_fd < 0) {
|
||||
UC_LOG_ERR("Failed to open %s", passwd_file_path);
|
||||
goto out;
|
||||
}
|
||||
|
||||
memset(&password, 0, sizeof(password));
|
||||
password_size = read(passwd_fd, &password, sizeof(password));
|
||||
if (password_size == sizeof(password)) {
|
||||
UC_LOG_ERR("%s is too big", passwd_file_path);
|
||||
goto out_close;
|
||||
}
|
||||
|
||||
if (!password_size) {
|
||||
UC_LOG_ERR("failed to read %s", passwd_file_path);
|
||||
goto out_close;
|
||||
}
|
||||
|
||||
if (*len < password_size) {
|
||||
UC_LOG_ERR("out buffer is too small (%lu < %lu)",
|
||||
*len, password_size);
|
||||
goto out_close;
|
||||
}
|
||||
|
||||
/* remove password from buffer */
|
||||
close(passwd_fd);
|
||||
passwd_fd = -1;
|
||||
if (remove(passwd_file_path)) {
|
||||
UC_LOG_ERR("Failed to remove %s", passwd_file_path);
|
||||
goto out;
|
||||
}
|
||||
|
||||
strncpy(pass, password, password_size);
|
||||
*len = password_size;
|
||||
|
||||
return 0;
|
||||
out_close:
|
||||
close(passwd_fd);
|
||||
out:
|
||||
return -1;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE | LLL_CLIENT;
|
||||
@@ -693,6 +752,8 @@ int main(void)
|
||||
struct lws_context_creation_info info = {0};
|
||||
bool reboot_reason_sent = false;
|
||||
char *gw_host = NULL;
|
||||
size_t password_len;
|
||||
char password[64];
|
||||
struct stat st;
|
||||
int ret;
|
||||
|
||||
@@ -722,10 +783,10 @@ int main(void)
|
||||
UC_LOG_CRIT("Platform initialization failed");
|
||||
}
|
||||
|
||||
plat_running_img_name_get(client.firmware, sizeof(client.firmware));
|
||||
plat_revision_get(client.firmware, sizeof(client.firmware));
|
||||
|
||||
if ((gw_host = getenv("UC_GATEWAY_ADDRESS"))) {
|
||||
gw_host = strdup(gw_host);
|
||||
client.server = strdup(gw_host);
|
||||
} else {
|
||||
while (1) {
|
||||
if (uc_loop_interrupted_get())
|
||||
@@ -770,13 +831,20 @@ int main(void)
|
||||
}
|
||||
sigthread_context_set(context);
|
||||
|
||||
password_len = sizeof(password);
|
||||
if (get_updated_pass(password, &password_len))
|
||||
password_len = 0;
|
||||
|
||||
proto_start();
|
||||
|
||||
while (!uc_loop_interrupted_get()) {
|
||||
lws_service_tsi(context, 0, 0);
|
||||
|
||||
if (conn_successfull) {
|
||||
deviceupdate_send();
|
||||
if (password_len) {
|
||||
deviceupdate_send(password);
|
||||
password_len = 0;
|
||||
}
|
||||
if (!reboot_reason_sent) {
|
||||
device_rebootcause_send();
|
||||
reboot_reason_sent = true;
|
||||
|
||||
@@ -41,6 +41,8 @@ extern "C" {
|
||||
struct client_config {
|
||||
const char *redirector_file;
|
||||
const char *redirector_file_dbg;
|
||||
const char *ols_client_version_file;
|
||||
const char *ols_schema_version_file;
|
||||
const char *server;
|
||||
int16_t port;
|
||||
const char *path;
|
||||
@@ -60,14 +62,14 @@ extern time_t conn_time;
|
||||
extern struct plat_metrics_cfg ucentral_metrics;
|
||||
|
||||
/* proto.c */
|
||||
void proto_handle(cJSON *cmd);
|
||||
void proto_handle(char *cmd);
|
||||
void proto_cb_register_uc_send_msg(uc_send_msg_cb cb);
|
||||
void proto_cb_register_uc_connect_msg_send(uc_send_connect_msg_cb cb);
|
||||
void connect_send(void);
|
||||
void ping_send(void);
|
||||
void health_send(struct plat_health_info *);
|
||||
void state_send(struct plat_state_info *plat_state_info);
|
||||
void deviceupdate_send(void);
|
||||
void deviceupdate_send(const char *updated_pass);
|
||||
void device_rebootcause_send(void);
|
||||
void telemetry_send(struct plat_state_info *plat_state_info);
|
||||
void log_send(const char *message, int severity);
|
||||
|
||||
5
version.json
Normal file
5
version.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"major": 4,
|
||||
"minor": 1,
|
||||
"patch": 0
|
||||
}
|
||||
Reference in New Issue
Block a user