mirror of
https://github.com/Telecominfraproject/ols-ucentral-client.git
synced 2026-03-20 03:39:28 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7df000f08c |
19
Dockerfile
19
Dockerfile
@@ -2,11 +2,8 @@ FROM debian:buster
|
||||
LABEL Description="Ucentral client (Build) environment"
|
||||
|
||||
ARG HOME /root
|
||||
ARG SCHEMA="3.2.7"
|
||||
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}"
|
||||
ARG EXTERNAL_LIBS ${HOME}/ucentral-external-libs
|
||||
|
||||
SHELL ["/bin/bash", "-c"]
|
||||
|
||||
RUN apt-get update -q -y && apt-get -q -y --no-install-recommends install \
|
||||
@@ -18,24 +15,19 @@ 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 \
|
||||
unzip
|
||||
libjsoncpp-dev
|
||||
|
||||
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
|
||||
@@ -68,8 +60,3 @@ 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
28
LICENSE
@@ -1,28 +0,0 @@
|
||||
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.
|
||||
24
Makefile
24
Makefile
@@ -7,7 +7,8 @@ IMG_ID := "ucentral-client-build-env"
|
||||
IMG_TAG := $(shell cat Dockerfile | sha1sum | awk '{print substr($$1,0,11);}')
|
||||
CONTAINER_NAME := "ucentral_client_build_env"
|
||||
|
||||
.PHONY: all clean build-host-env build-final-deb build-ucentral-docker-img run-host-env run-ucentral-docker-img
|
||||
.PHONY: all clean build-host-env build-final-deb build-ucentral-docker-img run-host-env run-ucentral-docker-img \
|
||||
plat-ec plat-ec-clean
|
||||
|
||||
all: build-host-env build-ucentral-app build-ucentral-docker-img build-final-deb
|
||||
|
||||
@@ -32,7 +33,6 @@ 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
|
||||
|
||||
@@ -50,13 +50,8 @@ 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
|
||||
@@ -86,6 +81,9 @@ build-final-deb: build-ucentral-docker-img
|
||||
@echo
|
||||
@echo "ucentral client deb pkg is available under ./output/ dir"
|
||||
|
||||
plat-ec:
|
||||
src/ec-private/build.sh
|
||||
|
||||
clean:
|
||||
docker container stop ${CONTAINER_NAME} > /dev/null 2>&1 || true;
|
||||
docker container rm ${CONTAINER_NAME} > /dev/null 2>&1 || true;
|
||||
@@ -96,11 +94,19 @@ 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;
|
||||
rm -rf src/debian/shasta-ucentral-client* 2>/dev/null || true;
|
||||
rm -rf src/debian/debhelper-build-stamp* 2>/dev/null || true;
|
||||
rm -rf src/debian/files shasta_1.0_amd64.changes shasta_1.0_amd64.buildinfo 2>/dev/null || true;
|
||||
|
||||
plat-ec-clean:
|
||||
rm -rf src/ec-private/cjson
|
||||
rm -rf src/ec-private/curl
|
||||
rm -rf src/ec-private/libwebsockets
|
||||
rm -rf src/ec-private/openssl
|
||||
rm -rf src/ec-private/openssl
|
||||
rm -rf src/ec-private/ecapi/build
|
||||
rm -rf src/ec-private/ucentral
|
||||
rm -rf output
|
||||
|
||||
@@ -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,
|
||||
destroy any other, except for MGMT VLAN 1 - it's not being altered by the
|
||||
destroye 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,7 +39,6 @@ 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:
|
||||
+-----------------+
|
||||
@@ -65,33 +64,3 @@ 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,11 +17,7 @@
|
||||
{
|
||||
"ipv4": {
|
||||
"addressing": "static",
|
||||
"subnet": [
|
||||
{
|
||||
"prefix": "20.20.20.20/24"
|
||||
}
|
||||
],
|
||||
"subnet": "20.20.20.20/24",
|
||||
"dhcp": {
|
||||
"relay-server": "172.20.254.8",
|
||||
"circuit-id-format": "{Name}:{VLAN-ID}"
|
||||
@@ -48,11 +44,7 @@
|
||||
{
|
||||
"ipv4": {
|
||||
"addressing": "static",
|
||||
"subnet": [
|
||||
{
|
||||
"prefix": "30.30.30.30/24"
|
||||
}
|
||||
],
|
||||
"subnet": "30.30.30.30/24",
|
||||
"dhcp": {
|
||||
"relay-server": "172.20.10.12",
|
||||
"circuit-id-format": "{Name}:{VLAN-ID}"
|
||||
@@ -79,11 +71,7 @@
|
||||
{
|
||||
"ipv4": {
|
||||
"addressing": "static",
|
||||
"subnet": [
|
||||
{
|
||||
"prefix": "172.20.10.181/24"
|
||||
}
|
||||
]
|
||||
"subnet": "172.20.10.181/24"
|
||||
},
|
||||
"vlan": {
|
||||
"id": 20,
|
||||
|
||||
@@ -50,11 +50,7 @@
|
||||
},
|
||||
"ipv4": {
|
||||
"addressing": "static",
|
||||
"subnet": [
|
||||
{
|
||||
"prefix": "10.10.20.100/24"
|
||||
}
|
||||
]
|
||||
"subnet": "10.10.20.100/24"
|
||||
},
|
||||
"ethernet": [
|
||||
{
|
||||
@@ -74,11 +70,7 @@
|
||||
},
|
||||
"ipv4": {
|
||||
"addressing": "static",
|
||||
"subnet": [
|
||||
{
|
||||
"prefix": "10.10.50.100/24"
|
||||
}
|
||||
]
|
||||
"subnet": "10.10.50.100/24"
|
||||
},
|
||||
"ethernet": [
|
||||
{
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
{
|
||||
"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
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
{
|
||||
"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
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
{
|
||||
"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
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
{
|
||||
"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,7 +36,6 @@ 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,8 +21,6 @@ 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
|
||||
|
||||
|
||||
33
src/ec-private/README.md
Executable file
33
src/ec-private/README.md
Executable file
@@ -0,0 +1,33 @@
|
||||
# Ucentral for EC
|
||||
|
||||
Ucentral solution for EC is made of the following parts:
|
||||
* `ecapi`: a library to communicate with EC via SNMP
|
||||
|
||||
# Compiling
|
||||
|
||||
## EC Build for Target Device
|
||||
|
||||
First build the full EC image for your target device:
|
||||
* `cd EC_VOB/project_build_environment/<target device>`
|
||||
* `./make_all`
|
||||
|
||||
If this is successful, you can proceed to the next step.
|
||||
|
||||
## Build Environment
|
||||
|
||||
To successfully build required components the build environments variables must be prepared:
|
||||
* `cd EC_VOB/project_build_environment/<target device>`
|
||||
* `cd utils`
|
||||
* `. build_env_init`
|
||||
|
||||
## Building All Components
|
||||
|
||||
Presumably you have checked out the [ols-ucentral-src]:
|
||||
* `cd [ols-ucentral-src]`
|
||||
* Run `make plat-ec`, which should successfully compile all components
|
||||
|
||||
## Creating EC Firmware with Ucentral
|
||||
|
||||
After building everything up:
|
||||
* Check the `output` directory, it should contain all required binaries in appropriate subdirectories
|
||||
* Copy over these directories to your `EC_VOB/project_build_environment/<target device>/user/thirdpty/ucentral`
|
||||
BIN
src/ec-private/archive/cJSON-1.7.15.tar.gz
Executable file
BIN
src/ec-private/archive/cJSON-1.7.15.tar.gz
Executable file
Binary file not shown.
BIN
src/ec-private/archive/curl-7.83.1.tar.xz
Executable file
BIN
src/ec-private/archive/curl-7.83.1.tar.xz
Executable file
Binary file not shown.
BIN
src/ec-private/archive/libwebsockets-4.1.4.tar.gz
Executable file
BIN
src/ec-private/archive/libwebsockets-4.1.4.tar.gz
Executable file
Binary file not shown.
BIN
src/ec-private/archive/openssl-1.1.1q.tar.gz
Executable file
BIN
src/ec-private/archive/openssl-1.1.1q.tar.gz
Executable file
Binary file not shown.
141
src/ec-private/build.sh
Executable file
141
src/ec-private/build.sh
Executable file
@@ -0,0 +1,141 @@
|
||||
#!/bin/bash
|
||||
UCENTRAL_DIR=${PWD}
|
||||
EC_BUILD_DIR=${PWD}/src/ec-private
|
||||
OUT_DIR=${UCENTRAL_DIR}/output
|
||||
BIN_DIR=${OUT_DIR}/usr/sbin
|
||||
LIB_DIR=${OUT_DIR}/lib
|
||||
|
||||
LIB_OPENSSL=openssl-1.1.1q
|
||||
LIB_WEBSOCKETS=libwebsockets-4.1.4
|
||||
LIB_CURL=curl-7.83.1
|
||||
LIB_CJSON=cJSON-1.7.15
|
||||
|
||||
echo "+++++++++++++++++ check EC build environment +++++++++++++++++"
|
||||
if [ ! "${PROJECT_NAME}" ] || [ ! "${SOURCE_PATH}" ]; then
|
||||
echo "Error! Please source 'build_env_init' for your build environment."
|
||||
exit
|
||||
fi
|
||||
|
||||
cp -af ${UCENTRAL_DIR}/src/ucentral-client/* ${EC_BUILD_DIR}/ucentral-client
|
||||
|
||||
rm -rf ${OUT_DIR}
|
||||
|
||||
if [ ! -d output ]; then
|
||||
mkdir -p ${BIN_DIR}
|
||||
mkdir -p ${LIB_DIR}
|
||||
fi
|
||||
|
||||
C_COMPILER="${TOOLCHAIN_PATH}/${CROSS_COMPILE}gcc ."
|
||||
|
||||
echo "+++++++++++++++++ openssl +++++++++++++++++"
|
||||
cd ${EC_BUILD_DIR}
|
||||
if [ ! -d openssl ]; then
|
||||
tar -xf ./archive/${LIB_OPENSSL}.tar.gz
|
||||
mv ${LIB_OPENSSL} openssl
|
||||
fi
|
||||
|
||||
model_name=${D_MODEL_NAME}
|
||||
|
||||
if [ "$model_name" == 'ECS4130_AC5' ]; then
|
||||
platform=linux-aarch64
|
||||
elif [ "$model_name" == 'ECS4125_10P' ]; then
|
||||
platform=linux-mips32
|
||||
else
|
||||
echo "Error! The model ${model_name} is not in the support lists, please check."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd openssl
|
||||
./Configure ${platform} --cross-compile-prefix=${CROSS_COMPILE} no-idea no-mdc2 no-rc5 no-ssl2 no-ssl3
|
||||
make -j${nproc}
|
||||
|
||||
if [ "$?" -eq "0" ]; then
|
||||
cp -af libssl.so.1.1 libcrypto.so.1.1 ${LIB_DIR}
|
||||
fi
|
||||
|
||||
echo "+++++++++++++++++ libwebsockets +++++++++++++++++"
|
||||
cd ${EC_BUILD_DIR}
|
||||
if [ ! -d libwebsockets ]; then
|
||||
tar -xf ./archive/${LIB_WEBSOCKETS}.tar.gz
|
||||
mv ${LIB_WEBSOCKETS} libwebsockets
|
||||
patch -s -N -p1 -d libwebsockets/lib < ./patch/libwebsockets/${LIB_WEBSOCKETS}.patch
|
||||
fi
|
||||
|
||||
cd libwebsockets
|
||||
cmake \
|
||||
-DOPENSSL_ROOT_DIR=${EC_BUILD_DIR}/openssl \
|
||||
-DCMAKE_C_COMPILER=${C_COMPILER}
|
||||
make -j${nproc}
|
||||
|
||||
if [ "$?" -eq "0" ]; then
|
||||
cp -af lib/libwebsockets.so.17 ${LIB_DIR}
|
||||
fi
|
||||
|
||||
echo "+++++++++++++++++ curl +++++++++++++++++"
|
||||
cd ${EC_BUILD_DIR}
|
||||
|
||||
if [ ! -d curl ]; then
|
||||
tar -xf ./archive/${LIB_CURL}.tar.xz
|
||||
mv ${LIB_CURL} curl
|
||||
patch -s -N -p1 -d curl < ./patch/curl/${LIB_CURL}.patch
|
||||
fi
|
||||
|
||||
cd curl
|
||||
cmake -DCMAKE_C_COMPILER=${C_COMPILER} -DCMAKE_SHARED_LINKER_FLAGS=-L${EC_BUILD_DIR}/openssl
|
||||
make
|
||||
|
||||
if [ "$?" -eq "0" ]; then
|
||||
cp -af ./lib/libcurl.so ${LIB_DIR}
|
||||
cp -af ./src/curl ${BIN_DIR}
|
||||
fi
|
||||
|
||||
echo "+++++++++++++++++ cjson +++++++++++++++++"
|
||||
cd ${EC_BUILD_DIR}
|
||||
|
||||
if [ ! -d cjson ]; then
|
||||
tar -xf ./archive/${LIB_CJSON}.tar.gz
|
||||
mv ${LIB_CJSON} cjson
|
||||
fi
|
||||
|
||||
cd cjson
|
||||
cmake -DCMAKE_C_COMPILER=${C_COMPILER}
|
||||
make
|
||||
|
||||
if [ "$?" -eq "0" ]; then
|
||||
cp -af ./libcjson.so.1.7.15 ${LIB_DIR}
|
||||
cd ${LIB_DIR}
|
||||
mv libcjson.so.1.7.15 libcjson.so.1
|
||||
fi
|
||||
|
||||
echo "+++++++++++++++++ ecapi +++++++++++++++++"
|
||||
cd ${EC_BUILD_DIR}/ecapi
|
||||
mkdir ${EC_BUILD_DIR}/ecapi/build
|
||||
cd ${EC_BUILD_DIR}/ecapi/build
|
||||
|
||||
cmake -DCMAKE_C_COMPILER=${C_COMPILER} ..
|
||||
make
|
||||
|
||||
if [ "$?" -eq "0" ]; then
|
||||
cp -af libecapi.so ${LIB_DIR}
|
||||
fi
|
||||
|
||||
echo "+++++++++++++++++ ucentral-client +++++++++++++++++"
|
||||
if [ ! -d ucentral ]; then
|
||||
mkdir -p ${EC_BUILD_DIR}/ucentral
|
||||
fi
|
||||
|
||||
cp -af ${UCENTRAL_DIR}/src/ucentral-client ${EC_BUILD_DIR}/ucentral/ucentral-client
|
||||
cp -af ${EC_BUILD_DIR}/patch/ucentral/* ${EC_BUILD_DIR}/ucentral
|
||||
mkdir -p ${EC_BUILD_DIR}/ucentral/build
|
||||
cd ${EC_BUILD_DIR}/ucentral/build
|
||||
|
||||
cmake -DCMAKE_C_COMPILER=${C_COMPILER} ..
|
||||
make
|
||||
|
||||
if [ "$?" -eq "0" ]; then
|
||||
cp -af ucentral-client ${BIN_DIR}
|
||||
fi
|
||||
|
||||
echo "+++++++++++++++++ Strip target binaries +++++++++++++++++"
|
||||
${TOOLCHAIN_PATH}/${CROSS_COMPILE}strip ${BIN_DIR}/*
|
||||
${TOOLCHAIN_PATH}/${CROSS_COMPILE}strip ${LIB_DIR}/*
|
||||
31
src/ec-private/ecapi/CMakeLists.txt
Executable file
31
src/ec-private/ecapi/CMakeLists.txt
Executable file
@@ -0,0 +1,31 @@
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
|
||||
PROJECT(ecapi C)
|
||||
ADD_DEFINITIONS(-Os -ggdb -Wall -Werror --std=gnu99 -Wmissing-declarations)
|
||||
|
||||
SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
|
||||
INCLUDE_DIRECTORIES($ENV{SOURCE_PATH}/sysinclude)
|
||||
INCLUDE_DIRECTORIES($ENV{SOURCE_PATH}/sysinclude/mibconstants)
|
||||
INCLUDE_DIRECTORIES($ENV{SOURCE_PATH}/sysinclude/oem/$ENV{PROJECT_NAME})
|
||||
|
||||
INCLUDE_DIRECTORIES($ENV{PROJECT_PATH}/user/thirdpty/lua/net-snmp-5.4.4/include)
|
||||
INCLUDE_DIRECTORIES($ENV{PROJECT_PATH}/user/thirdpty/lua/net-snmp-5.4.4/agent/mibgroup)
|
||||
#LINK_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src/snmp)
|
||||
|
||||
|
||||
FIND_LIBRARY(netsnmp_library netsnmp $ENV{PROJECT_PATH}/user/thirdpty/lua/net-snmp-5.4.4/snmplib/.libs)
|
||||
#INCLUDE (CheckSymbolExists)
|
||||
#CHECK_SYMBOL_EXISTS(SYS_getrandom syscall.h getrandom)
|
||||
|
||||
if ($ENV{D_MODEL_NAME} STREQUAL ECS4130_AC5)
|
||||
add_definitions(-DENDIANNESS_ADJUST)
|
||||
endif()
|
||||
|
||||
INCLUDE(snmp/CMakeLists.txt)
|
||||
INCLUDE(generic/CMakeLists.txt)
|
||||
|
||||
ADD_LIBRARY(ecapi SHARED ${LIB_SOURCES})
|
||||
TARGET_LINK_LIBRARIES(ecapi ${netsnmp_library})
|
||||
3
src/ec-private/ecapi/generic/CMakeLists.txt
Executable file
3
src/ec-private/ecapi/generic/CMakeLists.txt
Executable file
@@ -0,0 +1,3 @@
|
||||
list(APPEND LIB_SOURCES
|
||||
${CMAKE_CURRENT_LIST_DIR}/api_print.c
|
||||
)
|
||||
27
src/ec-private/ecapi/generic/api_print.c
Executable file
27
src/ec-private/ecapi/generic/api_print.c
Executable file
@@ -0,0 +1,27 @@
|
||||
// #include <stdarg.h>
|
||||
|
||||
#include "api_print.h"
|
||||
|
||||
static bool debug_on = false;
|
||||
|
||||
void print_set_debug(bool on) {
|
||||
debug_on = on;
|
||||
}
|
||||
|
||||
bool print_is_debug(void) {
|
||||
return debug_on;
|
||||
}
|
||||
/*
|
||||
void print_debug(char *fmt, ...) {
|
||||
if (print_is_debug()) {
|
||||
va_list args; va_start(args, fmt);
|
||||
vfprintf(stdout, fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
}
|
||||
|
||||
void print_err(char *fmt, ...) {
|
||||
va_list args; va_start(args, fmt);
|
||||
vfprintf(stderr, fmt, args);
|
||||
va_end(args);
|
||||
}*/
|
||||
40
src/ec-private/ecapi/include/api_config.h
Executable file
40
src/ec-private/ecapi/include/api_config.h
Executable file
@@ -0,0 +1,40 @@
|
||||
#ifndef API_CONFIG_H
|
||||
#define API_CONFIG_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef enum {
|
||||
DPX_HALF = 0,
|
||||
DPX_FULL,
|
||||
} duplex_t;
|
||||
|
||||
typedef enum {
|
||||
M_NONE = 1,
|
||||
M_SFP_FORCED_1000 = 7,
|
||||
M_SFP_FORCED_10G = 8,
|
||||
} media_t;
|
||||
|
||||
typedef enum {
|
||||
VL_NONE = 0,
|
||||
VL_TAGGED,
|
||||
VL_UNTAGGED,
|
||||
VL_FORBIDDEN
|
||||
} vlan_membership_t;
|
||||
|
||||
void *open_config_transaction();
|
||||
void commit_config_transaction(void *tr);
|
||||
|
||||
void add_eth_speed(void *tr, uint16_t eth_num, uint32_t speed, duplex_t duplex);
|
||||
void add_eth_media(void *tr, uint16_t eth_num, media_t media);
|
||||
|
||||
void add_l2_vlan(void *tr, uint16_t vlan_id,
|
||||
uint16_t *tagged_members, // NULL terminated array / NULL if not required
|
||||
uint16_t *un_tagged_members, // NULL terminated array / NULL if not required
|
||||
uint16_t *forbidden_members, // NULL terminated array / NULL if not required
|
||||
uint16_t *pvid_ports // NULL terminated array / NULL if not required
|
||||
);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
8
src/ec-private/ecapi/include/api_consts.h
Executable file
8
src/ec-private/ecapi/include/api_consts.h
Executable file
@@ -0,0 +1,8 @@
|
||||
#ifndef API_CONSTS_H
|
||||
#define API_CONSTS_H
|
||||
|
||||
#define STATUS_SUCCESS 0
|
||||
#define STATUS_ERROR 1
|
||||
#define STATUS_TIMEOUT 2
|
||||
|
||||
#endif
|
||||
15
src/ec-private/ecapi/include/api_device.h
Executable file
15
src/ec-private/ecapi/include/api_device.h
Executable file
@@ -0,0 +1,15 @@
|
||||
#ifndef API_DEVICEID_H
|
||||
#define API_DEVICEID_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "api_consts.h"
|
||||
|
||||
int dev_get_main_mac(char *mac, int mac_len);
|
||||
int dev_get_serial(char *serial, int serial_len);
|
||||
int dev_get_fw_version(char *fw, int fw_len);
|
||||
int dev_get_uptime(uint32_t *up);
|
||||
int dev_get_vlan_list(int *vlan_arr, int *num);
|
||||
int dev_get_vlan_mask_len(int *len);
|
||||
int dev_get_poe_port_num(int *num);
|
||||
int dev_get_port_capabilities_val_len(int *len);
|
||||
#endif
|
||||
13
src/ec-private/ecapi/include/api_print.h
Executable file
13
src/ec-private/ecapi/include/api_print.h
Executable file
@@ -0,0 +1,13 @@
|
||||
#ifndef API_PRINT_H
|
||||
#define API_PRINT_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
void print_set_debug(bool on);
|
||||
bool print_is_debug(void);
|
||||
|
||||
#define print_debug(...) if (print_is_debug()) { fprintf(stdout, __VA_ARGS__); }
|
||||
#define print_err(...) fprintf(stderr, __VA_ARGS__)
|
||||
|
||||
#endif
|
||||
9
src/ec-private/ecapi/include/api_session.h
Executable file
9
src/ec-private/ecapi/include/api_session.h
Executable file
@@ -0,0 +1,9 @@
|
||||
#ifndef API_SESSION_H
|
||||
#define API_SESSION_H
|
||||
|
||||
#include "api_consts.h"
|
||||
|
||||
int session_start(void);
|
||||
void session_close(void);
|
||||
|
||||
#endif
|
||||
36
src/ec-private/ecapi/include/api_stats.h
Executable file
36
src/ec-private/ecapi/include/api_stats.h
Executable file
@@ -0,0 +1,36 @@
|
||||
#ifndef API_STATS_H
|
||||
#define API_STATS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "api_consts.h"
|
||||
|
||||
#define IF_LOCATION_SIZE 16
|
||||
#define IF_NAME_SIZE 32
|
||||
|
||||
typedef struct {
|
||||
uint32_t collisions;
|
||||
uint64_t multicast ;
|
||||
uint64_t rx_bytes;
|
||||
uint32_t rx_dropped;
|
||||
uint32_t rx_errors;
|
||||
uint64_t rx_packets;
|
||||
uint64_t tx_bytes;
|
||||
uint32_t tx_dropped;
|
||||
uint32_t tx_errors;
|
||||
uint64_t tx_packets;
|
||||
} counters_t;
|
||||
|
||||
typedef struct {
|
||||
char location[IF_LOCATION_SIZE];
|
||||
char name[IF_NAME_SIZE];
|
||||
uint32_t uptime;
|
||||
uint32_t speed_dpx_status;
|
||||
counters_t counters;
|
||||
} interface_t;
|
||||
|
||||
int get_ethernet_count(int *eth_count);
|
||||
int get_ethernet_stats(interface_t *eths, int eth_count);
|
||||
int get_vlans(uint16_t **vlans, int *vlan_count);
|
||||
|
||||
#endif
|
||||
41
src/ec-private/ecapi/include/oid_define.h
Executable file
41
src/ec-private/ecapi/include/oid_define.h
Executable file
@@ -0,0 +1,41 @@
|
||||
#ifndef OID_DEFINE_H
|
||||
#define OID_DEFINE_H
|
||||
|
||||
#include <sys_adpt.h>
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
#include <net-snmp/net-snmp-includes.h>
|
||||
|
||||
const static oid O_MAIN_MAC[] = { SYS_ADPT_PRIVATEMIB_OID, 1, 5, 6, 1, 0 };
|
||||
const static oid O_SERIAL[] = { SYS_ADPT_PRIVATEMIB_OID, 1, 1, 3, 1, 10, 1 };
|
||||
const static oid O_OPCODE_VERSION[] = { SYS_ADPT_PRIVATEMIB_OID, 1, 1, 5, 4, 0 };
|
||||
const static oid O_SYS_UPTIME[] = { 1, 3, 6, 1, 2, 1, 1, 3, 0 };
|
||||
const static oid O_VLAN_STATUS[] = { 1, 3, 6, 1, 2, 1, 17, 7, 1, 4, 3, 1, 5};
|
||||
const static oid O_POE_PORT_ENABLE[] ={1, 3, 6, 1, 2, 1, 105, 1, 1, 1, 3, 1};
|
||||
const static oid O_PORT_CPAPBILITIES[] = { SYS_ADPT_PRIVATEMIB_OID, 1, 2, 1, 1, 6, 1 };
|
||||
|
||||
#define O_FACTORY_DEFAULT SYSTEM_OID"1.24.2.1.1.4.1.70.97.99.116.111.114.121.95.68.101.102.97.117.108.116.95.67.111.110.102.105.103.46.99.102.103"
|
||||
#define O_FW_UPGRADE_MGMT SYSTEM_OID"1.24.6.1.0"
|
||||
#define O_DEVICE_MODEL SYSTEM_OID"1.1.5.1.0"
|
||||
#define O_DEVICE_COMPANY SYSTEM_OID"1.1.5.2.0"
|
||||
#define O_STR_POE_PORT_ENABLE "1.3.6.1.2.1.105.1.1.1.3.1"
|
||||
#define O_STR_POE_MAX_POWER SYSTEM_OID"1.28.6.1.13.1"
|
||||
#define O_STR_POE_USAGE_THRESHOLD "1.3.6.1.2.1.105.1.3.1.1.5.1"
|
||||
#define O_STR_IF_ADMIN_STATUS "1.3.6.1.2.1.2.2.1.7"
|
||||
#define O_STR_PORT_CPAPBILITIES SYSTEM_OID"1.2.1.1.6"
|
||||
#define O_STR_PVID "1.3.6.1.2.1.17.7.1.4.5.1.1"
|
||||
#define O_STR_VLAN_NAME "1.3.6.1.2.1.17.7.1.4.3.1.1"
|
||||
#define O_STR_VLAN_EGRESS "1.3.6.1.2.1.17.7.1.4.3.1.2"
|
||||
#define O_STR_VLAN_STATUS "1.3.6.1.2.1.17.7.1.4.3.1.5"
|
||||
#define O_STR_VLAN_UNTAGGED "1.3.6.1.2.1.17.7.1.4.3.1.4"
|
||||
#define O_STR_COPY_SRC_TYPE SYSTEM_OID"1.24.1.1.0"
|
||||
#define O_STR_COPY_DST_TYPE SYSTEM_OID"1.24.1.3.0"
|
||||
#define O_STR_COPY_DST_NAME SYSTEM_OID"1.24.1.4.0"
|
||||
#define O_STR_COPY_FILE_TYPE SYSTEM_OID"1.24.1.5.0"
|
||||
#define O_STR_COPY_ACTION SYSTEM_OID"1.24.1.8.0"
|
||||
#define O_NTP_STATUS SYSTEM_OID"1.23.5.1.0"
|
||||
#define O_SNTP_STATUS SYSTEM_OID"1.23.1.1.0"
|
||||
#define O_SNTP_INTERVAL SYSTEM_OID"1.23.1.3.0"
|
||||
#define O_SNTP_SERVER_TYPE SYSTEM_OID"1.23.1.4.1.4"
|
||||
#define O_SNTP_SERVER_ADDR SYSTEM_OID"1.23.1.4.1.5"
|
||||
|
||||
#endif
|
||||
25
src/ec-private/ecapi/include/snmp_helper.h
Executable file
25
src/ec-private/ecapi/include/snmp_helper.h
Executable file
@@ -0,0 +1,25 @@
|
||||
#ifndef SNMP_HELPER_H
|
||||
#define SNMP_HELPER_H
|
||||
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
#include <net-snmp/net-snmp-includes.h>
|
||||
#include "oid_define.h"
|
||||
|
||||
int snmph_session_start(void);
|
||||
void snmph_session_close(void);
|
||||
|
||||
int snmph_get(const oid *req_oid, size_t req_oid_len, struct snmp_pdu **response);
|
||||
int snmph_get_argstr(const char *oid_str, struct snmp_pdu **response);
|
||||
int snmph_get_single_string(const oid *req_oid, size_t req_oid_len, char *buf, int buf_len);
|
||||
int snmph_get_bulk(const oid *req_oid, size_t req_oid_len, int max, struct snmp_pdu **response);
|
||||
int snmph_set(const char *oid_str, char type, char *value);
|
||||
int snmph_set_array(const char *oid_str, char type, const u_char *value, size_t len);
|
||||
int snmph_walk(const char *oid_str, void *buf, int *num);
|
||||
|
||||
enum snmp_walk_node {
|
||||
SNMP_WALK_NODE_NONE,
|
||||
SNMP_WALK_NODE_VLAN_STATUS,
|
||||
SNMP_WALK_NODE_POE_PORT_ENABLE,
|
||||
};
|
||||
|
||||
#endif
|
||||
7
src/ec-private/ecapi/snmp/CMakeLists.txt
Executable file
7
src/ec-private/ecapi/snmp/CMakeLists.txt
Executable file
@@ -0,0 +1,7 @@
|
||||
list(APPEND LIB_SOURCES
|
||||
${CMAKE_CURRENT_LIST_DIR}/device.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/helper.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/session.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/stats.c
|
||||
)
|
||||
|
||||
96
src/ec-private/ecapi/snmp/device.c
Executable file
96
src/ec-private/ecapi/snmp/device.c
Executable file
@@ -0,0 +1,96 @@
|
||||
#include <sys_adpt.h>
|
||||
|
||||
#include "api_device.h"
|
||||
#include "snmp_helper.h"
|
||||
|
||||
int dev_get_main_mac(char *mac, int mac_len) {
|
||||
int status = snmph_get_single_string(O_MAIN_MAC, OID_LENGTH(O_MAIN_MAC), mac, mac_len);
|
||||
|
||||
if (status != STAT_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
int i = 0, j = 2;
|
||||
|
||||
for (i = 3; i < 17; i += 3) {
|
||||
mac[j++] = mac[i];
|
||||
mac[j++] = mac[i + 1];
|
||||
}
|
||||
|
||||
mac[12] = 0;
|
||||
|
||||
char *c;
|
||||
|
||||
for (c = mac; *c; c++) {
|
||||
if (*c >= 'A' && *c <= 'Z') {
|
||||
*c += 32;
|
||||
}
|
||||
}
|
||||
|
||||
return STAT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int dev_get_serial(char *serial, int serial_len) {
|
||||
return snmph_get_single_string(O_SERIAL, OID_LENGTH(O_SERIAL), serial, serial_len);
|
||||
}
|
||||
|
||||
int dev_get_fw_version(char *fw, int fw_len) {
|
||||
return snmph_get_single_string(O_OPCODE_VERSION, OID_LENGTH(O_OPCODE_VERSION), fw, fw_len);
|
||||
}
|
||||
|
||||
int dev_get_uptime(uint32_t *up) {
|
||||
struct snmp_pdu *response = NULL;
|
||||
int status = snmph_get(O_SYS_UPTIME, OID_LENGTH(O_SYS_UPTIME), &response);
|
||||
|
||||
if (status != STATUS_SUCCESS) return status;
|
||||
|
||||
|
||||
*up = (uint32_t) (response->variables->val.integer[0] / 100 + 0.5);
|
||||
snmp_free_pdu(response);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
int dev_get_vlan_list(int *vlan_arr, int *num) {
|
||||
int status;
|
||||
|
||||
status = snmph_walk(O_STR_VLAN_STATUS, vlan_arr, num);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int dev_get_vlan_mask_len(int *len) {
|
||||
char oidstr[MAX_OID_LEN];
|
||||
struct snmp_pdu *response;
|
||||
|
||||
sprintf(oidstr, "%s.%d", O_STR_VLAN_EGRESS, 1);
|
||||
int status = snmph_get_argstr(oidstr, &response);
|
||||
|
||||
if (status != STAT_SUCCESS) {
|
||||
fprintf(stderr, "Could not retrieve vlan mask length.\n");
|
||||
return status;
|
||||
}
|
||||
|
||||
*len = response->variables->val_len;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
int dev_get_poe_port_num(int *num) {
|
||||
int status;
|
||||
|
||||
status = snmph_walk(O_STR_POE_PORT_ENABLE, 0, num);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int dev_get_port_capabilities_val_len(int *len) {
|
||||
int status;
|
||||
struct snmp_pdu *response = NULL;
|
||||
|
||||
status = snmph_get(O_PORT_CPAPBILITIES, OID_LENGTH(O_PORT_CPAPBILITIES), &response);
|
||||
if (status == STATUS_SUCCESS)
|
||||
*len = response->variables->val_len;
|
||||
snmp_free_pdu(response);
|
||||
return status;
|
||||
}
|
||||
340
src/ec-private/ecapi/snmp/helper.c
Executable file
340
src/ec-private/ecapi/snmp/helper.c
Executable file
@@ -0,0 +1,340 @@
|
||||
/* MODULE NAME: snmp_helper.c
|
||||
* PURPOSE:
|
||||
* for ucentral middleware process.
|
||||
*
|
||||
* NOTES:
|
||||
*
|
||||
* REASON:
|
||||
* Description:
|
||||
* HISTORY
|
||||
* 2023/02/03 - Saulius P., Created
|
||||
*
|
||||
* Copyright(C) Accton Corporation, 2023
|
||||
*/
|
||||
/* INCLUDE FILE DECLARATIONS
|
||||
*/
|
||||
#include <math.h>
|
||||
#include "snmp_helper.h"
|
||||
#include "api_print.h"
|
||||
|
||||
static struct snmp_session session, *ss;
|
||||
|
||||
int snmph_session_start(void) {
|
||||
init_snmp("ucmw_snmp");
|
||||
snmp_sess_init( &session );
|
||||
|
||||
session.peername = "127.0.0.1";
|
||||
session.version = SNMP_VERSION_2c;
|
||||
session.community = (unsigned char*)"private";
|
||||
session.community_len = strlen((char*)session.community);
|
||||
|
||||
ss = snmp_open(&session);
|
||||
|
||||
if (ss) {
|
||||
return STAT_SUCCESS;
|
||||
} else {
|
||||
return STAT_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
int snmph_set(const char *oid_str, char type, char *value) {
|
||||
netsnmp_pdu *pdu, *response = NULL;
|
||||
size_t name_length;
|
||||
oid name[MAX_OID_LEN];
|
||||
int status, exitval = 0;
|
||||
|
||||
pdu = snmp_pdu_create(SNMP_MSG_SET);
|
||||
name_length = MAX_OID_LEN;
|
||||
if (snmp_parse_oid(oid_str, name, &name_length) == NULL){
|
||||
snmp_perror(oid_str);
|
||||
return -1;
|
||||
} else{
|
||||
if (snmp_add_var(pdu, name, name_length, type, value)) {
|
||||
snmp_perror(oid_str);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
status = snmp_synch_response(ss, pdu, &response);
|
||||
if (status == STAT_SUCCESS) {
|
||||
if (response->errstat != SNMP_ERR_NOERROR) {
|
||||
fprintf(stderr, "Error in packet.\nReason: %s\n",
|
||||
snmp_errstring(response->errstat));
|
||||
exitval = 2;
|
||||
}
|
||||
} else if (status == STAT_TIMEOUT) {
|
||||
fprintf(stderr, "Timeout: No Response from %s\n",
|
||||
session.peername);
|
||||
exitval = 1;
|
||||
} else { /* status == STAT_ERROR */
|
||||
snmp_sess_perror("snmpset", ss);
|
||||
exitval = 1;
|
||||
}
|
||||
|
||||
if (response)
|
||||
snmp_free_pdu(response);
|
||||
|
||||
return exitval;
|
||||
}
|
||||
|
||||
int snmph_set_array(const char *oid_str, char type, const u_char *value, size_t len) {
|
||||
netsnmp_pdu *pdu, *response = NULL;
|
||||
size_t name_length;
|
||||
oid name[MAX_OID_LEN];
|
||||
int status, exitval = 0;
|
||||
|
||||
pdu = snmp_pdu_create(SNMP_MSG_SET);
|
||||
name_length = MAX_OID_LEN;
|
||||
if (snmp_parse_oid(oid_str, name, &name_length) == NULL){
|
||||
snmp_perror(oid_str);
|
||||
return -1;
|
||||
} else{
|
||||
if (!snmp_pdu_add_variable(pdu, name, name_length, type, value, len)) {
|
||||
snmp_perror(oid_str);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
status = snmp_synch_response(ss, pdu, &response);
|
||||
if (status == STAT_SUCCESS) {
|
||||
if (response->errstat != SNMP_ERR_NOERROR) {
|
||||
fprintf(stderr, "Error in packet.\nReason: %s\n",
|
||||
snmp_errstring(response->errstat));
|
||||
exitval = 2;
|
||||
}
|
||||
} else if (status == STAT_TIMEOUT) {
|
||||
fprintf(stderr, "Timeout: No Response from %s\n",
|
||||
session.peername);
|
||||
exitval = 1;
|
||||
} else { /* status == STAT_ERROR */
|
||||
snmp_sess_perror("snmpset", ss);
|
||||
exitval = 1;
|
||||
}
|
||||
|
||||
if (response)
|
||||
snmp_free_pdu(response);
|
||||
|
||||
return exitval;
|
||||
}
|
||||
|
||||
int snmph_get(const oid *req_oid, size_t req_oid_len, struct snmp_pdu **response) {
|
||||
struct snmp_pdu *request = snmp_pdu_create(SNMP_MSG_GET);
|
||||
snmp_add_null_var(request, req_oid, req_oid_len);
|
||||
|
||||
int status = snmp_synch_response(ss, request, response);
|
||||
|
||||
if (*response && (*response)->errstat != SNMP_ERR_NOERROR) {
|
||||
print_err("Error 1, response with error: %d, %ld\n", status, (*response)->errstat);
|
||||
snmp_free_pdu(*response);
|
||||
return STAT_ERROR;
|
||||
}
|
||||
|
||||
if (!(*response)) {
|
||||
print_err("Error 2: empty SNMP response\n");
|
||||
return STAT_ERROR;
|
||||
}
|
||||
|
||||
if (status != STAT_SUCCESS) {
|
||||
print_err("Error 3: bad response status: %d\n", status);
|
||||
snmp_free_pdu(*response);
|
||||
}
|
||||
|
||||
if (!(*response)->variables) {
|
||||
print_err("Error 4: empty variable list in response\n");
|
||||
snmp_free_pdu(*response);
|
||||
return STAT_ERROR;
|
||||
}
|
||||
|
||||
print_debug("Default return: %d\n", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
int snmph_get_argstr(const char *oid_str, struct snmp_pdu **response) {
|
||||
oid name[MAX_OID_LEN];
|
||||
size_t name_length = MAX_OID_LEN;
|
||||
|
||||
if (snmp_parse_oid(oid_str, name, &name_length) == NULL) {
|
||||
snmp_perror(oid_str);
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct snmp_pdu *request = snmp_pdu_create(SNMP_MSG_GET);
|
||||
snmp_add_null_var(request, name, name_length);
|
||||
|
||||
int status = snmp_synch_response(ss, request, response);
|
||||
|
||||
if (*response && (*response)->errstat != SNMP_ERR_NOERROR) {
|
||||
print_err("Error 1, response with error: %d, %ld\n", status, (*response)->errstat);
|
||||
snmp_free_pdu(*response);
|
||||
return STAT_ERROR;
|
||||
}
|
||||
|
||||
if (!(*response)) {
|
||||
print_err("Error 2: empty SNMP response\n");
|
||||
return STAT_ERROR;
|
||||
}
|
||||
|
||||
if (status != STAT_SUCCESS) {
|
||||
print_err("Error 3: bad response status: %d\n", status);
|
||||
snmp_free_pdu(*response);
|
||||
}
|
||||
|
||||
if (!(*response)->variables) {
|
||||
print_err("Error 4: empty variable list in response\n");
|
||||
snmp_free_pdu(*response);
|
||||
return STAT_ERROR;
|
||||
}
|
||||
|
||||
print_debug("Default return: %d\n", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
int snmph_get_single_string(const oid *req_oid, size_t req_oid_len, char *buf, int buf_len) {
|
||||
struct snmp_pdu *response = NULL;
|
||||
int status = snmph_get(req_oid, req_oid_len, &response);
|
||||
|
||||
if (status != STAT_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
memset(buf, 0, buf_len);
|
||||
strncpy(buf, (char*)response->variables->val.string, (int) fmin(buf_len, response->variables->val_len));
|
||||
|
||||
// if (response)
|
||||
snmp_free_pdu(response);
|
||||
|
||||
return STAT_SUCCESS;
|
||||
}
|
||||
|
||||
int snmph_get_bulk(const oid *req_oid, size_t req_oid_len, int max, struct snmp_pdu **response) {
|
||||
struct snmp_pdu *request = snmp_pdu_create(SNMP_MSG_GETBULK);
|
||||
request->non_repeaters = 0;
|
||||
request->max_repetitions = max;
|
||||
snmp_add_null_var(request, req_oid, req_oid_len);
|
||||
|
||||
int status = snmp_synch_response(ss, request, response);
|
||||
|
||||
// printf("Bulk status: %d\n", status);
|
||||
|
||||
if (status == 1) {
|
||||
snmp_sess_perror("snmpbulkget", ss);
|
||||
}
|
||||
|
||||
if (*response && (*response)->errstat != SNMP_ERR_NOERROR) {
|
||||
print_err("Error 1, bulk response error: %d, %ld\n", status, (*response)->errstat);
|
||||
snmp_free_pdu(*response);
|
||||
return STAT_ERROR;
|
||||
}
|
||||
|
||||
if (!(*response)) {
|
||||
print_err("Error 2: empty bulk response\n");
|
||||
return STAT_ERROR;
|
||||
}
|
||||
|
||||
if (status != STAT_SUCCESS) {
|
||||
print_err("Error 3, bad bulk status: %d\n", status);
|
||||
snmp_free_pdu(*response);
|
||||
}
|
||||
|
||||
if (!(*response)->variables) {
|
||||
print_err("Error 4, empty bulk variables\n");
|
||||
snmp_free_pdu(*response);
|
||||
return STAT_ERROR;
|
||||
}
|
||||
|
||||
print_debug("Default bulk return: %d\n", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
int snmph_walk(const char *oid_str, void *buf, int *num) {
|
||||
netsnmp_pdu *pdu, *response = NULL;
|
||||
netsnmp_variable_list *vars;
|
||||
oid name[MAX_OID_LEN];
|
||||
size_t name_length = MAX_OID_LEN;
|
||||
int running = 1;
|
||||
int status = 0;
|
||||
enum snmp_walk_node node = SNMP_WALK_NODE_NONE;
|
||||
|
||||
if (snmp_parse_oid(oid_str, name, &name_length) == NULL) {
|
||||
snmp_perror(oid_str);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!strcmp(oid_str, O_STR_VLAN_STATUS))
|
||||
node = SNMP_WALK_NODE_VLAN_STATUS;
|
||||
else if (!strcmp(oid_str, O_STR_POE_PORT_ENABLE))
|
||||
node = SNMP_WALK_NODE_POE_PORT_ENABLE;
|
||||
|
||||
*num = 0;
|
||||
|
||||
while (running) {
|
||||
/*
|
||||
* create PDU for GETNEXT request and add object name to request
|
||||
*/
|
||||
pdu = snmp_pdu_create(SNMP_MSG_GETNEXT);
|
||||
snmp_add_null_var(pdu, name, name_length);
|
||||
|
||||
/*
|
||||
* do the request
|
||||
*/
|
||||
status = snmp_synch_response(ss, pdu, &response);
|
||||
|
||||
if (status == STAT_SUCCESS) {
|
||||
if (response->errstat == SNMP_ERR_NOERROR) {
|
||||
/*
|
||||
* check resulting variables
|
||||
*/
|
||||
for (vars = response->variables; vars;
|
||||
vars = vars->next_variable) {
|
||||
|
||||
if (node == SNMP_WALK_NODE_VLAN_STATUS)
|
||||
{
|
||||
if ((vars->name[12]==O_VLAN_STATUS[12]) && (vars->name_length==(OID_LENGTH(O_VLAN_STATUS)+1)))
|
||||
{
|
||||
((int*)buf)[(*num)++] = vars->name[13];
|
||||
}
|
||||
else
|
||||
running = 0;
|
||||
}
|
||||
else if (node == SNMP_WALK_NODE_POE_PORT_ENABLE)
|
||||
{
|
||||
if ((vars->name[10]==O_POE_PORT_ENABLE[10]) && (vars->name_length==(OID_LENGTH(O_POE_PORT_ENABLE)+1)))
|
||||
{
|
||||
(*num)++;
|
||||
}
|
||||
else
|
||||
running = 0;
|
||||
}
|
||||
else
|
||||
running = 0;
|
||||
|
||||
memmove((char *) name, (char *) vars->name, vars->name_length * sizeof(oid));
|
||||
name_length = vars->name_length;
|
||||
|
||||
//print_variable(vars->name, vars->name_length, vars);
|
||||
}
|
||||
} else {
|
||||
running = 0;
|
||||
}
|
||||
} else if (status == STAT_TIMEOUT) {
|
||||
fprintf(stderr, "Timeout: No Response from %s\n",
|
||||
session.peername);
|
||||
running = 0;
|
||||
status = 1;
|
||||
|
||||
} else { /* status == STAT_ERROR */
|
||||
snmp_sess_perror("snmpwalk", ss);
|
||||
running = 0;
|
||||
status = 1;
|
||||
}
|
||||
if (response)
|
||||
snmp_free_pdu(response);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
void snmph_session_close(void) {
|
||||
snmp_close(ss);
|
||||
}
|
||||
|
||||
10
src/ec-private/ecapi/snmp/session.c
Executable file
10
src/ec-private/ecapi/snmp/session.c
Executable file
@@ -0,0 +1,10 @@
|
||||
#include "api_session.h"
|
||||
#include "snmp_helper.h"
|
||||
|
||||
int session_start() {
|
||||
return snmph_session_start();
|
||||
}
|
||||
|
||||
void session_close() {
|
||||
snmph_session_close();
|
||||
}
|
||||
250
src/ec-private/ecapi/snmp/stats.c
Executable file
250
src/ec-private/ecapi/snmp/stats.c
Executable file
@@ -0,0 +1,250 @@
|
||||
#include <sys_adpt.h>
|
||||
|
||||
#include "api_device.h"
|
||||
#include "api_stats.h"
|
||||
|
||||
#include "snmp_helper.h"
|
||||
|
||||
#include "if-mib/ifTable/ifTable_constants.h"
|
||||
|
||||
const static oid O_IF_COUNT[] = { 1, 3, 6, 1, 2, 1, 2, 1, 0 };
|
||||
const static oid O_IF_TYPE[] = { 1, 3, 6, 1, 2, 1, 2, 2, 1, 3 };
|
||||
// const static oid O_IF_LAST_CHANGE[] = { 1, 3, 6, 1, 2, 1, 2, 2, 1, 9 };
|
||||
const static oid O_IF_UPTIME[] = { SYS_ADPT_PRIVATEMIB_OID, 1, 2, 1, 1, 19 };
|
||||
const static oid O_SPEED_DPX_STATUS[] = { SYS_ADPT_PRIVATEMIB_OID, 1, 2, 1, 1, 8 };
|
||||
const static oid OID_IF_NAME[] = { SYS_ADPT_PRIVATEMIB_OID, 1, 2, 1, 1, 2 };
|
||||
|
||||
const static oid O_IF_RX_BYTES_64[] = { 1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 6 };
|
||||
const static oid O_IF_RX_DISCARD_PKTS[] = { 1, 3, 6, 1, 2, 1, 2, 2, 1, 13 };
|
||||
const static oid O_IF_RX_ERROR_PKTS[] = { 1, 3, 6, 1, 2, 1, 2, 2, 1, 14 };
|
||||
const static oid O_IF_RX_U_PKTS_64[] = { 1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 7 }; // Unicast packets
|
||||
const static oid O_IF_RX_MUL_PKTS_64[] = { 1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 8 }; // Multicast packets
|
||||
const static oid O_IF_RX_BR_PKTS_64[] = { 1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 9 };
|
||||
|
||||
const static oid O_IF_TX_BYTES_64[] = { 1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 10 };
|
||||
const static oid O_IF_TX_DISCARD_PKTS[] = { 1, 3, 6, 1, 2, 1, 2, 2, 1, 19 };
|
||||
const static oid O_IF_TX_ERROR_PKTS[] = { 1, 3, 6, 1, 2, 1, 2, 2, 1, 20 };
|
||||
const static oid O_IF_TX_U_PKTS_64[] = { 1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 11 }; // Unicast packets
|
||||
const static oid O_IF_TX_MUL_PKTS_64[] = { 1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 12 }; // Multicast packets
|
||||
const static oid O_IF_TX_BR_PKTS_64[] = { 1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 13 };
|
||||
|
||||
int get_ethernet_count(int *eth_count) {
|
||||
struct snmp_pdu *response;
|
||||
|
||||
// printf("Try to retrieve IF count...\n");
|
||||
|
||||
int status = snmph_get(O_IF_COUNT, OID_LENGTH(O_IF_COUNT), &response);
|
||||
|
||||
// printf("Retrieved: %d\n", status);
|
||||
|
||||
if (status != STAT_SUCCESS) {
|
||||
// printf("Could not retrieve interfaces count\n");
|
||||
return status;
|
||||
}
|
||||
|
||||
// printf("Interfaces: %ld\n", response->variables->val.integer[0]);
|
||||
long int max_if = response->variables->val.integer[0];
|
||||
|
||||
snmp_free_pdu(response);
|
||||
|
||||
struct variable_list *vars;
|
||||
|
||||
status = snmph_get_bulk(O_IF_TYPE, OID_LENGTH(O_IF_TYPE), max_if, &response);
|
||||
|
||||
if (status != STAT_SUCCESS) {
|
||||
// printf("Could not retrieve types\n");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
*eth_count = 0;
|
||||
|
||||
for(vars = response->variables; vars; vars = vars->next_variable) {
|
||||
// print_variable(vars->name, vars->name_length, vars);
|
||||
|
||||
if (vars->val.integer[0] == IANAIFTYPE_ETHERNETCSMACD) {
|
||||
(*eth_count)++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
snmp_free_pdu(response);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static int fill_ethernet_stats_32(const oid *req_oid, size_t req_oid_len, int max, uint32_t *val, bool aggregate) {
|
||||
struct snmp_pdu *response;
|
||||
struct variable_list *vars;
|
||||
int status = snmph_get_bulk(req_oid, req_oid_len, max, &response);
|
||||
|
||||
if (status != STATUS_SUCCESS) return status;
|
||||
|
||||
uint32_t *addr = val;
|
||||
uint32_t local_val = 0;
|
||||
|
||||
int i = 0;
|
||||
|
||||
for(vars = response->variables; vars; vars = vars->next_variable) {
|
||||
memcpy(&local_val, &vars->val.integer[0], sizeof(uint32_t));
|
||||
|
||||
addr = (uint32_t *) ((char *) val + (sizeof(interface_t) * (i++)));
|
||||
|
||||
if (aggregate) {
|
||||
*addr += local_val;
|
||||
} else {
|
||||
*addr = local_val;
|
||||
}
|
||||
// addr = (uint32_t *) ((char *) addr + sizeof(interface_t));
|
||||
}
|
||||
|
||||
snmp_free_pdu(response);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static int fill_ethernet_stats_64(const oid *req_oid, size_t req_oid_len, int max, uint64_t *val, bool aggregate) {
|
||||
struct snmp_pdu *response;
|
||||
struct variable_list *vars;
|
||||
int status = snmph_get_bulk(req_oid, req_oid_len, max, &response);
|
||||
|
||||
if (status != STATUS_SUCCESS) return status;
|
||||
|
||||
uint64_t *addr = val;
|
||||
uint64_t local_val = 0;
|
||||
|
||||
int i = 0;
|
||||
|
||||
for(vars = response->variables; vars; vars = vars->next_variable) {
|
||||
#ifdef ENDIANNESS_ADJUST
|
||||
memcpy(&local_val, &vars->val.counter64[0].low, sizeof(uint64_t));
|
||||
#else
|
||||
memcpy(&local_val, &vars->val.counter64[0], sizeof(uint64_t));
|
||||
#endif
|
||||
addr = (uint64_t *) ((char *) val + (sizeof(interface_t) * (i++)));
|
||||
if (aggregate) {
|
||||
*addr += local_val;
|
||||
} else {
|
||||
*addr = local_val;
|
||||
}
|
||||
// addr = (uint64_t *) ((char *) addr + sizeof(interface_t));
|
||||
}
|
||||
|
||||
snmp_free_pdu(response);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
int get_ethernet_stats(interface_t *eths, int eth_count) {
|
||||
uint32_t uptime;
|
||||
|
||||
if (dev_get_uptime(&uptime) != STATUS_SUCCESS) return STATUS_ERROR;
|
||||
/***************** Interface uptime *****************/
|
||||
if (fill_ethernet_stats_32(O_IF_UPTIME, OID_LENGTH(O_IF_UPTIME), eth_count, ðs[0].uptime, false) != STATUS_SUCCESS) return STATUS_ERROR;
|
||||
if (fill_ethernet_stats_32(O_SPEED_DPX_STATUS, OID_LENGTH(O_SPEED_DPX_STATUS), eth_count, ðs[0].speed_dpx_status, false) != STATUS_SUCCESS) return STATUS_ERROR;
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < eth_count; i++) {
|
||||
if (eths[i].uptime) {
|
||||
eths[i].uptime /= 100;// uptime - (eths[i].uptime / 100);
|
||||
}
|
||||
|
||||
snprintf(eths[i].location, IF_LOCATION_SIZE, "%d", i);
|
||||
}
|
||||
|
||||
struct snmp_pdu *response;
|
||||
struct variable_list *vars;
|
||||
int status = snmph_get_bulk(OID_IF_NAME, OID_LENGTH(OID_IF_NAME), eth_count, &response);
|
||||
|
||||
if (status != STATUS_SUCCESS) return status;
|
||||
|
||||
i = 0;
|
||||
for(vars = response->variables; vars || i < eth_count; vars = vars->next_variable) {
|
||||
strncpy(eths[i].name, (char *)vars->val.string, IF_NAME_SIZE > vars->val_len ? vars->val_len : IF_NAME_SIZE);
|
||||
i++;
|
||||
}
|
||||
|
||||
snmp_free_pdu(response);
|
||||
|
||||
/***************** Bytes (octets) *****************/
|
||||
if (fill_ethernet_stats_64(O_IF_RX_BYTES_64, OID_LENGTH(O_IF_RX_BYTES_64), eth_count, ðs[0].counters.rx_bytes, false) != STATUS_SUCCESS) return STATUS_ERROR;
|
||||
if (fill_ethernet_stats_64(O_IF_TX_BYTES_64, OID_LENGTH(O_IF_TX_BYTES_64), eth_count, ðs[0].counters.tx_bytes, false) != STATUS_SUCCESS) return STATUS_ERROR;
|
||||
|
||||
/***************** Packets *****************/
|
||||
if (fill_ethernet_stats_64(O_IF_RX_MUL_PKTS_64, OID_LENGTH(O_IF_RX_MUL_PKTS_64), eth_count, ðs[0].counters.rx_packets, false) != STATUS_SUCCESS) return STATUS_ERROR;
|
||||
if (fill_ethernet_stats_64(O_IF_TX_MUL_PKTS_64, OID_LENGTH(O_IF_TX_MUL_PKTS_64), eth_count, ðs[0].counters.tx_packets, false) != STATUS_SUCCESS) return STATUS_ERROR;
|
||||
|
||||
// "Multicast is the sum of rx+tx multicast packets"
|
||||
for (i = 0; i < eth_count; i++) {
|
||||
eths[i].counters.multicast = eths[i].counters.rx_packets + eths[i].counters.tx_packets;
|
||||
}
|
||||
|
||||
// All packets is a sum (aggregate == true) of unicast, multicast and broadcast packets
|
||||
if (fill_ethernet_stats_64(O_IF_RX_U_PKTS_64, OID_LENGTH(O_IF_RX_U_PKTS_64), eth_count, ðs[0].counters.rx_packets, true) != STATUS_SUCCESS) return STATUS_ERROR;
|
||||
if (fill_ethernet_stats_64(O_IF_RX_BR_PKTS_64, OID_LENGTH(O_IF_RX_BR_PKTS_64), eth_count, ðs[0].counters.rx_packets, true) != STATUS_SUCCESS) return STATUS_ERROR;
|
||||
|
||||
if (fill_ethernet_stats_64(O_IF_TX_U_PKTS_64, OID_LENGTH(O_IF_TX_U_PKTS_64), eth_count, ðs[0].counters.tx_packets, true) != STATUS_SUCCESS) return STATUS_ERROR;
|
||||
if (fill_ethernet_stats_64(O_IF_TX_BR_PKTS_64, OID_LENGTH(O_IF_TX_BR_PKTS_64), eth_count, ðs[0].counters.tx_packets, true) != STATUS_SUCCESS) return STATUS_ERROR;
|
||||
|
||||
|
||||
/***************** Errors *****************/
|
||||
if (fill_ethernet_stats_32(O_IF_RX_ERROR_PKTS, OID_LENGTH(O_IF_RX_ERROR_PKTS), eth_count, ðs[0].counters.rx_errors, false) != STATUS_SUCCESS) return STATUS_ERROR;
|
||||
if (fill_ethernet_stats_32(O_IF_TX_ERROR_PKTS, OID_LENGTH(O_IF_TX_ERROR_PKTS), eth_count, ðs[0].counters.tx_errors, false) != STATUS_SUCCESS) return STATUS_ERROR;
|
||||
|
||||
/***************** Dropped *****************/
|
||||
if (fill_ethernet_stats_32(O_IF_RX_DISCARD_PKTS, OID_LENGTH(O_IF_RX_DISCARD_PKTS), eth_count, ðs[0].counters.rx_dropped, false) != STATUS_SUCCESS) return STATUS_ERROR;
|
||||
if (fill_ethernet_stats_32(O_IF_TX_DISCARD_PKTS, OID_LENGTH(O_IF_TX_DISCARD_PKTS), eth_count, ðs[0].counters.tx_dropped, false) != STATUS_SUCCESS) return STATUS_ERROR;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
int get_vlans(uint16_t **vlans, int *vlan_count) {
|
||||
struct snmp_pdu *response;
|
||||
struct variable_list *vars;
|
||||
|
||||
// printf("Try to retrieve IF count...\n");
|
||||
|
||||
int status = snmph_get(O_IF_COUNT, OID_LENGTH(O_IF_COUNT), &response);
|
||||
|
||||
// printf("Retrieved: %d\n", status);
|
||||
|
||||
if (status != STAT_SUCCESS) {
|
||||
printf("Could not retrieve interfaces count\n");
|
||||
return status;
|
||||
}
|
||||
|
||||
// printf("Interfaces: %ld\n", response->variables->val.integer[0]);
|
||||
long int max_if = response->variables->val.integer[0];
|
||||
|
||||
status = snmph_get_bulk(O_IF_TYPE, OID_LENGTH(O_IF_TYPE), max_if, &response);
|
||||
|
||||
if (status != STAT_SUCCESS) {
|
||||
// printf("VLANS: could not retrieve types\n");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
*vlan_count = 0;
|
||||
|
||||
for(vars = response->variables; vars; vars = vars->next_variable) {
|
||||
// print_variable(vars->name, vars->name_length, vars);
|
||||
|
||||
if (vars->val.integer[0] == IANAIFTYPE_L2VLAN || vars->val.integer[0] == IANAIFTYPE_L3IPVLAN) {
|
||||
// printf("Found VLAN: %d\n", (int) vars->name[vars->name_length - 1]);
|
||||
(*vlan_count)++;
|
||||
}
|
||||
}
|
||||
|
||||
(*vlans) = malloc(sizeof(uint16_t) * (*vlan_count));
|
||||
|
||||
int i = 0;
|
||||
|
||||
for(vars = response->variables; vars; vars = vars->next_variable) {
|
||||
// print_variable(vars->name, vars->name_length, vars);
|
||||
|
||||
if (vars->val.integer[0] == IANAIFTYPE_L2VLAN || vars->val.integer[0] == IANAIFTYPE_L3IPVLAN) {
|
||||
(*vlans)[i++] = (uint16_t) ((int) vars->name[vars->name_length - 1] - 1000);
|
||||
}
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
78
src/ec-private/patch/curl/curl-7.83.1.patch
Executable file
78
src/ec-private/patch/curl/curl-7.83.1.patch
Executable file
@@ -0,0 +1,78 @@
|
||||
diff -Nuar a/CMakeLists.txt b/CMakeLists.txt
|
||||
--- a/CMakeLists.txt 2023-07-21 09:53:57.450424222 +0800
|
||||
+++ b/CMakeLists.txt 2023-07-21 11:36:15.395258277 +0800
|
||||
@@ -1,4 +1,4 @@
|
||||
-#***************************************************************************
|
||||
+#***************************************************************************
|
||||
# _ _ ____ _
|
||||
# Project ___| | | | _ \| |
|
||||
# / __| | | | |_) | |
|
||||
@@ -185,9 +185,9 @@
|
||||
mark_as_advanced(CURL_DISABLE_HTTP_AUTH)
|
||||
option(CURL_DISABLE_IMAP "disables IMAP" OFF)
|
||||
mark_as_advanced(CURL_DISABLE_IMAP)
|
||||
-option(CURL_DISABLE_LDAP "disables LDAP" OFF)
|
||||
+option(CURL_DISABLE_LDAP "disables LDAP" ON)
|
||||
mark_as_advanced(CURL_DISABLE_LDAP)
|
||||
-option(CURL_DISABLE_LDAPS "disables LDAPS" OFF)
|
||||
+option(CURL_DISABLE_LDAPS "disables LDAPS" ON)
|
||||
mark_as_advanced(CURL_DISABLE_LDAPS)
|
||||
option(CURL_DISABLE_LIBCURL_OPTION "disables --libcurl option from the curl tool" OFF)
|
||||
mark_as_advanced(CURL_DISABLE_LIBCURL_OPTION)
|
||||
@@ -433,7 +433,7 @@
|
||||
endif()
|
||||
|
||||
if(CURL_USE_OPENSSL)
|
||||
- find_package(OpenSSL REQUIRED)
|
||||
+ #find_package(OpenSSL REQUIRED)
|
||||
set(SSL_ENABLED ON)
|
||||
set(USE_OPENSSL ON)
|
||||
|
||||
@@ -441,7 +441,7 @@
|
||||
# version of CMake. This allows our dependents to get our dependencies
|
||||
# transitively.
|
||||
if(NOT CMAKE_VERSION VERSION_LESS 3.4)
|
||||
- list(APPEND CURL_LIBS OpenSSL::SSL OpenSSL::Crypto)
|
||||
+ #list(APPEND CURL_LIBS OpenSSL::SSL OpenSSL::Crypto)
|
||||
else()
|
||||
list(APPEND CURL_LIBS ${OPENSSL_LIBRARIES})
|
||||
include_directories(${OPENSSL_INCLUDE_DIR})
|
||||
@@ -595,7 +595,7 @@
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES})
|
||||
check_library_exists_concat(${CMAKE_LDAP_LIB} ldap_init HAVE_LIBLDAP)
|
||||
check_library_exists_concat(${CMAKE_LBER_LIB} ber_init HAVE_LIBLBER)
|
||||
-
|
||||
+
|
||||
set(CMAKE_REQUIRED_INCLUDES_BAK ${CMAKE_REQUIRED_INCLUDES})
|
||||
set(CMAKE_LDAP_INCLUDE_DIR "" CACHE STRING "Path to LDAP include directory")
|
||||
if(CMAKE_LDAP_INCLUDE_DIR)
|
||||
@@ -1369,12 +1369,16 @@
|
||||
add_subdirectory(docs)
|
||||
endif()
|
||||
|
||||
+INCLUDE_DIRECTORIES(../openssl/include)
|
||||
+FIND_LIBRARY(openssl ssl ../openssl)
|
||||
+
|
||||
add_subdirectory(lib)
|
||||
|
||||
if(BUILD_CURL_EXE)
|
||||
add_subdirectory(src)
|
||||
endif()
|
||||
|
||||
+
|
||||
cmake_dependent_option(BUILD_TESTING "Build tests"
|
||||
ON "PERL_FOUND;NOT CURL_DISABLE_TESTS"
|
||||
OFF)
|
||||
diff -Nuar a/src/CMakeLists.txt b/src/CMakeLists.txt
|
||||
--- a/src/CMakeLists.txt 2023-07-21 13:47:10.160906907 +0800
|
||||
+++ b/src/CMakeLists.txt 2023-07-21 13:49:45.205682320 +0800
|
||||
@@ -98,6 +98,9 @@
|
||||
|
||||
#Build curl executable
|
||||
target_link_libraries(${EXE_NAME} libcurl ${CURL_LIBS})
|
||||
+target_link_libraries(${EXE_NAME} -lssl)
|
||||
+target_link_libraries(${EXE_NAME} -lcrypto)
|
||||
+target_link_libraries(${EXE_NAME} ${CMAKE_SHARED_LINKER_FLAGS})
|
||||
|
||||
################################################################################
|
||||
|
||||
14
src/ec-private/patch/libwebsockets/libwebsockets-4.1.4.patch
Executable file
14
src/ec-private/patch/libwebsockets/libwebsockets-4.1.4.patch
Executable file
@@ -0,0 +1,14 @@
|
||||
--- a/CMakeLists.txt 2020-10-26 04:31:31.000000000 -0700
|
||||
+++ b/CMakeLists.txt 2023-04-10 20:15:13.399705011 -0700
|
||||
@@ -102,8 +102,9 @@
|
||||
|
||||
|
||||
# ideally we want to use pipe2()
|
||||
-
|
||||
-CHECK_C_SOURCE_COMPILES("#define _GNU_SOURCE\n#include <unistd.h>\nint main(void) {int fd[2];\n return pipe2(fd, 0);\n}\n" LWS_HAVE_PIPE2)
|
||||
+# jacky
|
||||
+# comment out this line, use pipe() instead of pipe2()
|
||||
+#CHECK_C_SOURCE_COMPILES("#define _GNU_SOURCE\n#include <unistd.h>\nint main(void) {int fd[2];\n return pipe2(fd, 0);\n}\n" LWS_HAVE_PIPE2)
|
||||
|
||||
# tcp keepalive needs this on linux to work practically... but it only exists
|
||||
# after kernel 2.6.37
|
||||
49
src/ec-private/patch/ucentral/CMakeLists.txt
Executable file
49
src/ec-private/patch/ucentral/CMakeLists.txt
Executable file
@@ -0,0 +1,49 @@
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
|
||||
PROJECT(ucentral-client C)
|
||||
SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-Wl,--copy-dt-needed-entries")
|
||||
SET(LDFLAGS -fopenmp -Wl,--copy-dt-needed-entries)
|
||||
|
||||
INCLUDE_DIRECTORIES(src/include)
|
||||
INCLUDE_DIRECTORIES(../)
|
||||
INCLUDE_DIRECTORIES(../curl/include)
|
||||
INCLUDE_DIRECTORIES(../libwebsockets/include)
|
||||
INCLUDE_DIRECTORIES(../openssl/include)
|
||||
INCLUDE_DIRECTORIES(ucentral-client/include)
|
||||
INCLUDE_DIRECTORIES(ucentral-client)
|
||||
|
||||
INCLUDE_DIRECTORIES(src/include)
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_LIST_DIR}/../ecapi/include)
|
||||
INCLUDE_DIRECTORIES($ENV{SOURCE_PATH}/sysinclude)
|
||||
INCLUDE_DIRECTORIES($ENV{SOURCE_PATH}/sysinclude/mibconstants)
|
||||
INCLUDE_DIRECTORIES($ENV{SOURCE_PATH}/sysinclude/oem/$ENV{PROJECT_NAME})
|
||||
INCLUDE_DIRECTORIES($ENV{PROJECT_PATH}/user/thirdpty/lua/net-snmp-5.4.4/include)
|
||||
|
||||
add_definitions(-DPLAT_EC)
|
||||
|
||||
if ($ENV{D_MODEL_NAME} STREQUAL ECS4130_AC5)
|
||||
add_definitions(-DENDIANNESS_ADJUST)
|
||||
add_definitions(-DNOT_SUPPORT_CAP_2500)
|
||||
add_definitions(-DNOT_SUPPORT_NTP_DOMAIN_NAME)
|
||||
add_definitions(-DSYSTEM_OID="1.3.6.1.4.1.259.10.1.55.")
|
||||
elseif ($ENV{D_MODEL_NAME} STREQUAL ECS4125_10P)
|
||||
add_definitions(-DSYSTEM_OID="1.3.6.1.4.1.259.10.1.57.")
|
||||
else()
|
||||
message(FATAL_ERROR "not support $ENV{D_MODEL_NAME}")
|
||||
endif()
|
||||
|
||||
INCLUDE(ucentral-client/CMakeLists.txt)
|
||||
INCLUDE(ucentral-client/platform/ec/CMakeLists.txt)
|
||||
|
||||
FIND_LIBRARY(cjson cjson ../cjson)
|
||||
FIND_LIBRARY(curl curl ../curl/lib)
|
||||
FIND_LIBRARY(openssl ssl ../openssl)
|
||||
FIND_LIBRARY(websockets websockets ../libwebsockets/lib)
|
||||
FIND_LIBRARY(crypto crypto ../openssl)
|
||||
|
||||
FIND_LIBRARY(ecapi_library ecapi ../ecapi/build)
|
||||
FIND_LIBRARY(netsnmp_library netsnmp $ENV{PROJECT_PATH}/user/thirdpty/lua/net-snmp-5.4.4/snmplib/.libs)
|
||||
|
||||
ADD_EXECUTABLE(ucentral-client ${UC_SOURCES} ${PLAT_SOURCES})
|
||||
|
||||
TARGET_LINK_LIBRARIES(ucentral-client ${cjson} ${curl} ${openssl} ${crypto} ${websockets} ${netsnmp_library} ${ecapi_library})
|
||||
9
src/ec-private/patch/ucentral/ucentral-client/CMakeLists.txt
Executable file
9
src/ec-private/patch/ucentral/ucentral-client/CMakeLists.txt
Executable file
@@ -0,0 +1,9 @@
|
||||
|
||||
list(APPEND UC_SOURCES
|
||||
${CMAKE_CURRENT_LIST_DIR}/proto.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/router-utils.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/ucentral-json-parser.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/ucentral-log.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/ucentral-client.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/inet_net_pton.c
|
||||
)
|
||||
200
src/ec-private/patch/ucentral/ucentral-client/inet_net_pton.c
Executable file
200
src/ec-private/patch/ucentral/ucentral-client/inet_net_pton.c
Executable file
@@ -0,0 +1,200 @@
|
||||
/*
|
||||
* Copyright (c) 1996,1999 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef SPRINTF_CHAR
|
||||
# define SPRINTF(x) strlen(sprintf/**/x)
|
||||
#else
|
||||
# define SPRINTF(x) ((size_t)sprintf x)
|
||||
#endif
|
||||
|
||||
static int inet_net_pton_ipv4 (const char *src, u_char *dst,
|
||||
size_t size) __THROW;
|
||||
|
||||
# define __rawmemchr strchr
|
||||
|
||||
/*
|
||||
* static int
|
||||
* inet_net_pton(af, src, dst, size)
|
||||
* convert network number from presentation to network format.
|
||||
* accepts hex octets, hex strings, decimal octets, and /CIDR.
|
||||
* "size" is in bytes and describes "dst".
|
||||
* return:
|
||||
* number of bits, either imputed classfully or specified with /CIDR,
|
||||
* or -1 if some failure occurred (check errno). ENOENT means it was
|
||||
* not a valid network specification.
|
||||
* author:
|
||||
* Paul Vixie (ISC), June 1996
|
||||
*/
|
||||
int
|
||||
inet_net_pton (int af, const char *src, void *dst, size_t size)
|
||||
{
|
||||
switch (af) {
|
||||
case AF_INET:
|
||||
return (inet_net_pton_ipv4(src, dst, size));
|
||||
default:
|
||||
//__set_errno (EAFNOSUPPORT);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* static int
|
||||
* inet_net_pton_ipv4(src, dst, size)
|
||||
* convert IPv4 network number from presentation to network format.
|
||||
* accepts hex octets, hex strings, decimal octets, and /CIDR.
|
||||
* "size" is in bytes and describes "dst".
|
||||
* return:
|
||||
* number of bits, either imputed classfully or specified with /CIDR,
|
||||
* or -1 if some failure occurred (check errno). ENOENT means it was
|
||||
* not an IPv4 network specification.
|
||||
* note:
|
||||
* network byte order assumed. this means 192.5.5.240/28 has
|
||||
* 0b11110000 in its fourth octet.
|
||||
* author:
|
||||
* Paul Vixie (ISC), June 1996
|
||||
*/
|
||||
static int
|
||||
inet_net_pton_ipv4 (const char *src, u_char *dst, size_t size)
|
||||
{
|
||||
static const char xdigits[] = "0123456789abcdef";
|
||||
int n, ch, tmp, dirty, bits;
|
||||
const u_char *odst = dst;
|
||||
|
||||
ch = *src++;
|
||||
if (ch == '0' && (src[0] == 'x' || src[0] == 'X')
|
||||
&& isascii(src[1]) && isxdigit(src[1])) {
|
||||
/* Hexadecimal: Eat nybble string. */
|
||||
if (size <= 0)
|
||||
goto emsgsize;
|
||||
dirty = 0;
|
||||
tmp = 0; /* To calm down gcc. */
|
||||
src++; /* skip x or X. */
|
||||
while (isxdigit((ch = *src++))) {
|
||||
ch = _tolower(ch);
|
||||
n = (const char *) __rawmemchr(xdigits, ch) - xdigits;
|
||||
assert(n >= 0 && n <= 15);
|
||||
if (dirty == 0)
|
||||
tmp = n;
|
||||
else
|
||||
tmp = (tmp << 4) | n;
|
||||
if (++dirty == 2) {
|
||||
if (size-- <= 0)
|
||||
goto emsgsize;
|
||||
*dst++ = (u_char) tmp;
|
||||
dirty = 0;
|
||||
}
|
||||
}
|
||||
if (dirty) { /* Odd trailing nybble? */
|
||||
if (size-- <= 0)
|
||||
goto emsgsize;
|
||||
*dst++ = (u_char) (tmp << 4);
|
||||
}
|
||||
} else if (isascii(ch) && isdigit(ch)) {
|
||||
/* Decimal: eat dotted digit string. */
|
||||
for (;;) {
|
||||
tmp = 0;
|
||||
do {
|
||||
n = ((const char *) __rawmemchr(xdigits, ch)
|
||||
- xdigits);
|
||||
assert(n >= 0 && n <= 9);
|
||||
tmp *= 10;
|
||||
tmp += n;
|
||||
if (tmp > 255)
|
||||
goto enoent;
|
||||
} while (isascii((ch = *src++)) && isdigit(ch));
|
||||
if (size-- <= 0)
|
||||
goto emsgsize;
|
||||
*dst++ = (u_char) tmp;
|
||||
if (ch == '\0' || ch == '/')
|
||||
break;
|
||||
if (ch != '.')
|
||||
goto enoent;
|
||||
ch = *src++;
|
||||
if (!isascii(ch) || !isdigit(ch))
|
||||
goto enoent;
|
||||
}
|
||||
} else
|
||||
goto enoent;
|
||||
|
||||
bits = -1;
|
||||
if (ch == '/' && isascii(src[0]) && isdigit(src[0]) && dst > odst) {
|
||||
/* CIDR width specifier. Nothing can follow it. */
|
||||
ch = *src++; /* Skip over the /. */
|
||||
bits = 0;
|
||||
do {
|
||||
n = (const char *) __rawmemchr(xdigits, ch) - xdigits;
|
||||
assert(n >= 0 && n <= 9);
|
||||
bits *= 10;
|
||||
bits += n;
|
||||
} while (isascii((ch = *src++)) && isdigit(ch));
|
||||
if (ch != '\0')
|
||||
goto enoent;
|
||||
if (bits > 32)
|
||||
goto emsgsize;
|
||||
}
|
||||
|
||||
/* Firey death and destruction unless we prefetched EOS. */
|
||||
if (ch != '\0')
|
||||
goto enoent;
|
||||
|
||||
/* If nothing was written to the destination, we found no address. */
|
||||
if (dst == odst)
|
||||
goto enoent;
|
||||
/* If no CIDR spec was given, infer width from net class. */
|
||||
if (bits == -1) {
|
||||
if (*odst >= 240) /* Class E */
|
||||
bits = 32;
|
||||
else if (*odst >= 224) /* Class D */
|
||||
bits = 4;
|
||||
else if (*odst >= 192) /* Class C */
|
||||
bits = 24;
|
||||
else if (*odst >= 128) /* Class B */
|
||||
bits = 16;
|
||||
else /* Class A */
|
||||
bits = 8;
|
||||
/* If imputed mask is narrower than specified octets, widen. */
|
||||
if (bits >= 8 && bits < ((dst - odst) * 8))
|
||||
bits = (dst - odst) * 8;
|
||||
}
|
||||
/* Extend network to cover the actual mask. */
|
||||
while (bits > ((dst - odst) * 8)) {
|
||||
if (size-- <= 0)
|
||||
goto emsgsize;
|
||||
*dst++ = '\0';
|
||||
}
|
||||
return (bits);
|
||||
|
||||
enoent:
|
||||
//__set_errno (ENOENT);
|
||||
return (-1);
|
||||
|
||||
emsgsize:
|
||||
//__set_errno (EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
@@ -4,8 +4,3 @@ 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
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
configure terminal
|
||||
no ip vrf mgmt
|
||||
@@ -11,7 +11,6 @@ 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
|
||||
@@ -30,23 +29,11 @@ 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).
|
||||
@@ -61,8 +48,6 @@ 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
|
||||
@@ -78,19 +63,9 @@ 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,11 +154,6 @@
|
||||
"vlanid": "1"
|
||||
}
|
||||
},
|
||||
"VLAN_INTERFACE": {
|
||||
"Vlan1": {
|
||||
"dhcp": "enable"
|
||||
}
|
||||
},
|
||||
"VLAN_MEMBER": {
|
||||
{% for port in PORT %}
|
||||
"Vlan1|{{port}}": {
|
||||
@@ -169,6 +164,11 @@
|
||||
"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_node,
|
||||
int (*upd_cb)(const struct ucentral_router_fib_node *old,
|
||||
int olen,
|
||||
const struct ucentral_router_fib_node *new_node,
|
||||
const struct ucentral_router_fib_node *new,
|
||||
int nlen,
|
||||
void *arg);
|
||||
/* prefix = new, info = new */
|
||||
int (*add_cb)(const struct ucentral_router_fib_node *new_node,
|
||||
int (*add_cb)(const struct ucentral_router_fib_node *new,
|
||||
int len, void *arg);
|
||||
/* prefix = none */
|
||||
int (*del_cb)(const struct ucentral_router_fib_node *old_node,
|
||||
int (*del_cb)(const struct ucentral_router_fib_node *old,
|
||||
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);
|
||||
int ucentral_router_fib_info_cmp(const struct ucentral_router_fib_info *a,
|
||||
const struct ucentral_router_fib_info *b);
|
||||
bool 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 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_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 for_router_db_diff(NEW, OLD, INEW, IOLD, DIFF) \
|
||||
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 \
|
||||
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\
|
||||
)
|
||||
|
||||
/*
|
||||
* ((DIFF) == 0 && ++(INEW) && ++(IOLD)) || \
|
||||
* ((DIFF) > 0 && ++(IOLD)) || \
|
||||
* ((DIFF) < 0 && ++(INEW)) \
|
||||
*/
|
||||
|
||||
|
||||
@@ -28,6 +28,37 @@ void uc_log_send_cb_register(void (*cb)(const char *, int sv));
|
||||
void uc_log_severity_set(enum uc_log_component c, int sv);
|
||||
void uc_log(enum uc_log_component c, int sv, const char *fmt, ...);
|
||||
|
||||
#ifdef PLAT_EC
|
||||
#define UC_LOG_INFO(...) \
|
||||
do { \
|
||||
syslog(LOG_INFO, __VA_ARGS__); \
|
||||
uc_log(UC_LOG_COMPONENT, UC_LOG_SV_INFO, __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#define UC_LOG_DBG(FMT, ...) \
|
||||
do { \
|
||||
syslog(LOG_DEBUG, "%s:%u: " FMT, __func__, \
|
||||
(unsigned)__LINE__, ##__VA_ARGS__); \
|
||||
uc_log(UC_LOG_COMPONENT, UC_LOG_SV_DEBUG, \
|
||||
FMT, ##__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#define UC_LOG_ERR(FMT, ...) \
|
||||
do { \
|
||||
syslog(LOG_ERR, "%s:%u: " FMT, __func__, \
|
||||
(unsigned)__LINE__, ##__VA_ARGS__); \
|
||||
uc_log(UC_LOG_COMPONENT, UC_LOG_SV_ERR, \
|
||||
FMT, ##__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#define UC_LOG_CRIT(FMT, ...) \
|
||||
do { \
|
||||
syslog(LOG_CRIT, "%s:%u: " FMT, __func__, \
|
||||
(unsigned)__LINE__, ##__VA_ARGS__); \
|
||||
uc_log(UC_LOG_COMPONENT, UC_LOG_SV_CRIT, \
|
||||
FMT, ##__VA_ARGS__); \
|
||||
} while (0)
|
||||
#else
|
||||
#define UC_LOG_INFO(...) \
|
||||
do { \
|
||||
syslog(LOG_INFO, __VA_ARGS__); \
|
||||
@@ -57,5 +88,6 @@ void uc_log(enum uc_log_component c, int sv, const char *fmt, ...);
|
||||
uc_log(UC_LOG_COMPONENT, UC_LOG_SV_CRIT, \
|
||||
FMT __VA_OPT__(, ) __VA_ARGS__); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,6 +22,9 @@ extern "C" {
|
||||
#define MAX_NUM_OF_PORTS (100)
|
||||
|
||||
#define PORT_MAX_NAME_LEN (32)
|
||||
#ifdef PLAT_EC
|
||||
#define VLAN_MAX_NAME_LEN PORT_MAX_NAME_LEN
|
||||
#endif
|
||||
#define RTTY_CFG_FIELD_STR_MAX_LEN (64)
|
||||
#define PLATFORM_INFO_STR_MAX_LEN (96)
|
||||
#define SYSLOG_CFG_FIELD_STR_MAX_LEN (64)
|
||||
@@ -31,8 +34,6 @@ 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
|
||||
@@ -41,8 +42,6 @@ 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;
|
||||
@@ -66,18 +65,6 @@ 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 {
|
||||
@@ -91,7 +78,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[PLATFORM_MAC_STR_SIZE];
|
||||
char mac[18];
|
||||
/* The chassis description that our neighbour is announcing */
|
||||
char description[512];
|
||||
/* The management IPs that our neighbour is announcing */
|
||||
@@ -129,7 +116,7 @@ struct plat_poe_port_state {
|
||||
|
||||
struct plat_ieee8021x_authenticated_client_info {
|
||||
char auth_method[32];
|
||||
char mac_addr[PLATFORM_MAC_STR_SIZE];
|
||||
char mac_addr[18];
|
||||
size_t session_time;
|
||||
char username[64];
|
||||
char vlan_type[32];
|
||||
@@ -266,29 +253,15 @@ 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;
|
||||
#ifdef PLAT_EC
|
||||
char name[VLAN_MAX_NAME_LEN];
|
||||
#endif
|
||||
};
|
||||
|
||||
struct plat_vlans_list {
|
||||
@@ -302,6 +275,9 @@ struct plat_vlan_memberlist {
|
||||
uint16_t fp_id;
|
||||
} port;
|
||||
bool tagged;
|
||||
#ifdef PLAT_EC
|
||||
bool pvid;
|
||||
#endif
|
||||
struct plat_vlan_memberlist *next;
|
||||
};
|
||||
|
||||
@@ -313,18 +289,6 @@ 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];
|
||||
@@ -367,7 +331,6 @@ 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;
|
||||
@@ -380,16 +343,8 @@ 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 {
|
||||
@@ -421,31 +376,6 @@ 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. */
|
||||
@@ -455,7 +385,6 @@ 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;
|
||||
@@ -464,24 +393,9 @@ 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;
|
||||
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;
|
||||
bool ieee8021x_is_auth_ctrl_enabled;
|
||||
};
|
||||
|
||||
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 *);
|
||||
|
||||
@@ -543,6 +457,9 @@ typedef void (*plat_run_script_cb)(int err, struct plat_run_script_result *,
|
||||
void *ctx);
|
||||
|
||||
enum {
|
||||
#ifdef PLAT_EC
|
||||
UCENTRAL_PORT_SPEED_NONE,
|
||||
#endif
|
||||
UCENTRAL_PORT_SPEED_10_E,
|
||||
UCENTRAL_PORT_SPEED_100_E,
|
||||
UCENTRAL_PORT_SPEED_1000_E,
|
||||
@@ -555,6 +472,9 @@ enum {
|
||||
};
|
||||
|
||||
enum {
|
||||
#ifdef PLAT_EC
|
||||
UCENTRAL_PORT_DUPLEX_NONE,
|
||||
#endif
|
||||
UCENTRAL_PORT_DUPLEX_HALF_E,
|
||||
UCENTRAL_PORT_DUPLEX_FULL_E,
|
||||
};
|
||||
@@ -581,60 +501,17 @@ 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];
|
||||
};
|
||||
|
||||
@@ -648,24 +525,6 @@ 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];
|
||||
@@ -673,15 +532,8 @@ 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 {
|
||||
@@ -707,14 +559,7 @@ 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;
|
||||
@@ -722,7 +567,7 @@ struct plat_run_script_result {
|
||||
};
|
||||
|
||||
struct plat_run_script {
|
||||
enum plat_script_type type;
|
||||
const char *type;
|
||||
const char *script_base64;
|
||||
plat_run_script_cb cb;
|
||||
void *ctx;
|
||||
@@ -741,7 +586,11 @@ int plat_metrics_save(const struct plat_metrics_cfg *cfg);
|
||||
int plat_metrics_restore(struct plat_metrics_cfg *cfg);
|
||||
int plat_saved_config_id_get(uint64_t *id);
|
||||
void plat_config_destroy(struct plat_cfg *cfg);
|
||||
#ifdef PLAT_EC
|
||||
int plat_factory_default(bool keep_redirector);
|
||||
#else
|
||||
int plat_factory_default(void);
|
||||
#endif
|
||||
int plat_rtty(struct plat_rtty_cfg *rtty_cfg);
|
||||
int plat_upgrade(char *uri, char *signature);
|
||||
|
||||
@@ -772,10 +621,15 @@ 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 PLAT_EC
|
||||
void clean_stats();
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,19 +1,12 @@
|
||||
plat.a: plat.o
|
||||
ar crs $@ $^
|
||||
|
||||
plat.o: plat-gnma.o gnma/gnma.full.a netlink/netlink.full.a
|
||||
plat.o: plat-gnma.o gnma/gnma.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 -I../netlink $<
|
||||
gcc -c -o $@ ${CFLAGS} -I ./ -I../../../include $<
|
||||
|
||||
gnma.a: gnma_common.o
|
||||
ar crs $@ $^
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -7,7 +7,6 @@
|
||||
#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
|
||||
|
||||
@@ -27,16 +26,6 @@ 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];
|
||||
@@ -69,17 +58,6 @@ 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;
|
||||
@@ -151,9 +129,7 @@ struct gnma_route_attrs {
|
||||
} connected;
|
||||
struct {
|
||||
uint16_t vid;
|
||||
uint32_t metric;
|
||||
struct in_addr gw;
|
||||
struct gnma_port_key egress_port;
|
||||
} nexthop;
|
||||
};
|
||||
};
|
||||
@@ -280,47 +256,6 @@ 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);
|
||||
@@ -445,9 +380,6 @@ 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);
|
||||
@@ -458,53 +390,23 @@ 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_set(uint32_t list_size, uint16_t *vid_list, bool enable);
|
||||
int gnma_stp_vids_set_all(bool enable);
|
||||
int gnma_stp_vids_enable(uint32_t list_size, uint16_t *vid_list);
|
||||
int gnma_stp_vids_enable_all(void);
|
||||
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);
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
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 $@ $^
|
||||
@@ -1,220 +0,0 @@
|
||||
#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;
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
#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
@@ -1,14 +0,0 @@
|
||||
#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
|
||||
3
src/ucentral-client/platform/ec/CMakeLists.txt
Normal file
3
src/ucentral-client/platform/ec/CMakeLists.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
list(APPEND PLAT_SOURCES
|
||||
${CMAKE_CURRENT_LIST_DIR}/plat-ec.c
|
||||
)
|
||||
1176
src/ucentral-client/platform/ec/plat-ec.c
Normal file
1176
src/ucentral-client/platform/ec/plat-ec.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -2,8 +2,4 @@ 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,7 +2,6 @@
|
||||
|
||||
#include <ucentral-platform.h>
|
||||
#include <ucentral-log.h>
|
||||
#include <plat-revision.h>
|
||||
|
||||
#define UNUSED_PARAM(param) (void)((param))
|
||||
|
||||
@@ -13,11 +12,7 @@ int plat_init(void)
|
||||
|
||||
int plat_info_get(struct plat_platform_info *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");
|
||||
|
||||
UNUSED_PARAM(info);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -161,45 +156,10 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
#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,13 +70,12 @@ int ucentral_router_fib_key_cmp(const struct ucentral_router_fib_key *a,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ucentral_router_fib_info_cmp(const struct ucentral_router_fib_info *a,
|
||||
const struct ucentral_router_fib_info *b)
|
||||
/* 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)
|
||||
{
|
||||
if (a->type > b->type)
|
||||
return 1;
|
||||
if (a->type < b->type)
|
||||
return -1;
|
||||
if (a->type != b->type)
|
||||
return false;
|
||||
|
||||
switch (a->type) {
|
||||
case UCENTRAL_ROUTE_BLACKHOLE:
|
||||
@@ -84,32 +83,24 @@ int 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 1;
|
||||
if (a->connected.vid < b->connected.vid)
|
||||
return -1;
|
||||
if (a->connected.vid != b->connected.vid)
|
||||
return false;
|
||||
break;
|
||||
case UCENTRAL_ROUTE_BROADCAST:
|
||||
if (a->broadcast.vid > b->broadcast.vid)
|
||||
return 1;
|
||||
if (a->broadcast.vid < b->broadcast.vid)
|
||||
return -1;
|
||||
if (a->broadcast.vid != b->broadcast.vid)
|
||||
return false;
|
||||
break;
|
||||
case UCENTRAL_ROUTE_NH:
|
||||
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;
|
||||
if (a->nh.vid != b->nh.vid)
|
||||
return false;
|
||||
if (a->nh.gw.s_addr != b->nh.gw.s_addr)
|
||||
return false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int __fib_node_key_cmp_cb(const void *a, const void *b)
|
||||
|
||||
@@ -22,14 +22,18 @@
|
||||
#include <cjson/cJSON.h>
|
||||
|
||||
#include "ucentral.h"
|
||||
/* WA for parser issue */
|
||||
/* #include "ucentral-json-parser.h" */
|
||||
#include "ucentral-json-parser.h"
|
||||
|
||||
#include <openssl/conf.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/x509v3.h>
|
||||
|
||||
#ifdef PLAT_EC
|
||||
#include "api_device.h"
|
||||
#include "api_session.h"
|
||||
#endif
|
||||
|
||||
struct per_vhost_data__minimal {
|
||||
struct lws_context *context;
|
||||
struct lws_vhost *vhost;
|
||||
@@ -48,6 +52,7 @@ 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;
|
||||
@@ -65,10 +70,13 @@ lws_protocols protocols[] = {
|
||||
};
|
||||
|
||||
struct client_config client = {
|
||||
#ifdef PLAT_EC
|
||||
.redirector_file = "/etc/ucentral/redirector.json",
|
||||
.redirector_file_dbg = "/etc/ucentral/firstcontact.hdr",
|
||||
#else
|
||||
.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",
|
||||
#endif
|
||||
.server = NULL,
|
||||
.port = 15002,
|
||||
.path = "/",
|
||||
@@ -341,7 +349,6 @@ 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;
|
||||
@@ -353,7 +360,6 @@ static void parse_error_cb(void *data)
|
||||
(void)data;
|
||||
UC_LOG_ERR("JSON config parse failed");
|
||||
}
|
||||
*/
|
||||
|
||||
static const char *redirector_host_get(void)
|
||||
{
|
||||
@@ -378,8 +384,12 @@ static int gateway_cert_trust(void)
|
||||
|
||||
static int redirector_cert_trust(void)
|
||||
{
|
||||
#ifdef PLAT_EC
|
||||
return 1;
|
||||
#else
|
||||
char *v = getenv("UC_REDIRECTOR_CERT_TRUST");
|
||||
return v && *v && strcmp("0", v);
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -428,15 +438,12 @@ callback_broker(struct lws *wsi, enum lws_callback_reasons reason,
|
||||
websocket = wsi;
|
||||
connect_send();
|
||||
conn_successfull = 1;
|
||||
/* WA for parser issue */
|
||||
/* uc_json_parser_init(&parser, parse_cb, parse_error_cb, 0); */
|
||||
uc_json_parser_init(&parser, parse_cb, parse_error_cb, 0);
|
||||
lws_callback_on_writable(websocket);
|
||||
break;
|
||||
|
||||
case LWS_CALLBACK_CLIENT_RECEIVE:
|
||||
/* WA for parser issue */
|
||||
/* uc_json_parser_feed(&parser, in, len); */
|
||||
proto_handle((char *)in);
|
||||
uc_json_parser_feed(&parser, in, len);
|
||||
break;
|
||||
|
||||
case LWS_CALLBACK_CLIENT_CONNECTION_ERROR:
|
||||
@@ -450,8 +457,7 @@ callback_broker(struct lws *wsi, enum lws_callback_reasons reason,
|
||||
/* fall through */
|
||||
case LWS_CALLBACK_CLIENT_CLOSED:
|
||||
UC_LOG_INFO("connection closed\n");
|
||||
/* WA for parser issue */
|
||||
/* uc_json_parser_uninit(&parser); */
|
||||
uc_json_parser_uninit(&parser);
|
||||
websocket = NULL;
|
||||
set_conn_time();
|
||||
vhd->client_wsi = NULL;
|
||||
@@ -691,57 +697,6 @@ 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;
|
||||
@@ -752,11 +707,13 @@ 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;
|
||||
|
||||
#ifdef PLAT_EC
|
||||
sleep(50); // wait for system ready
|
||||
#endif
|
||||
|
||||
sigthread_create(); /* move signal handling to a dedicated thread */
|
||||
|
||||
openlog("ucentral-client", LOG_CONS | LOG_NDELAY | LOG_PERROR, LOG_DAEMON);
|
||||
@@ -774,6 +731,17 @@ int main(void)
|
||||
uc_log_severity_set(UC_LOG_COMPONENT_CLIENT, UC_LOG_SV_ERR);
|
||||
uc_log_severity_set(UC_LOG_COMPONENT_PLAT, UC_LOG_SV_ERR);
|
||||
|
||||
#ifdef PLAT_EC
|
||||
int status = session_start();
|
||||
|
||||
if (status == STATUS_SUCCESS) {
|
||||
UC_LOG_INFO("Successfully connected to SNMP!\n");
|
||||
} else {
|
||||
UC_LOG_INFO("Could not connect to SNMP!\n");
|
||||
exit(EXIT_FAILURE);;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (client_config_read()) {
|
||||
UC_LOG_CRIT("client_config_read failed");
|
||||
exit(EXIT_FAILURE);
|
||||
@@ -783,18 +751,39 @@ int main(void)
|
||||
UC_LOG_CRIT("Platform initialization failed");
|
||||
}
|
||||
|
||||
plat_revision_get(client.firmware, sizeof(client.firmware));
|
||||
plat_running_img_name_get(client.firmware, sizeof(client.firmware));
|
||||
|
||||
if ((gw_host = getenv("UC_GATEWAY_ADDRESS"))) {
|
||||
client.server = strdup(gw_host);
|
||||
#ifdef PLAT_EC
|
||||
FILE *f = fopen(REDIRECTOR_USER_DEFINE_FILE, "r");
|
||||
|
||||
if (f) {
|
||||
size_t cnt;
|
||||
char redirector_url[256];
|
||||
memset(redirector_url, 0, sizeof(redirector_url));
|
||||
|
||||
cnt = fread(redirector_url, 1, sizeof(redirector_url), f);
|
||||
fclose(f);
|
||||
client.server = redirector_url;
|
||||
} else {
|
||||
ret = ucentral_redirector_parse(&gw_host);
|
||||
if (ret) {
|
||||
/* parse failed by present redirector file, try to get redirector file from digicert */
|
||||
#else
|
||||
if ((gw_host = getenv("UC_GATEWAY_ADDRESS"))) {
|
||||
gw_host = strdup(gw_host);
|
||||
} else {
|
||||
#endif
|
||||
while (1) {
|
||||
if (uc_loop_interrupted_get())
|
||||
goto exit;
|
||||
if (firstcontact()) {
|
||||
UC_LOG_INFO(
|
||||
"Firstcontact failed; trying again in 1 second...\n");
|
||||
"Firstcontact failed; trying again in 30 second...\n");
|
||||
#ifdef PLAT_EC
|
||||
sleep(30);
|
||||
#else
|
||||
sleep(1);
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -809,6 +798,11 @@ int main(void)
|
||||
} else {
|
||||
client.server = gw_host;
|
||||
}
|
||||
#ifdef PLAT_EC
|
||||
} else {
|
||||
client.server = gw_host;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
memset(&info, 0, sizeof info);
|
||||
@@ -831,20 +825,13 @@ 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) {
|
||||
if (password_len) {
|
||||
deviceupdate_send(password);
|
||||
password_len = 0;
|
||||
}
|
||||
deviceupdate_send();
|
||||
if (!reboot_reason_sent) {
|
||||
device_rebootcause_send();
|
||||
reboot_reason_sent = true;
|
||||
@@ -861,5 +848,9 @@ exit:
|
||||
|
||||
free(gw_host);
|
||||
curl_global_cleanup();
|
||||
#ifdef PLAT_EC
|
||||
session_close();
|
||||
clean_stats();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -175,7 +175,12 @@ void uc_json_parser_init(struct uc_json_parser *uctx, uc_json_parse_cb cb,
|
||||
|
||||
void uc_json_parser_uninit(struct uc_json_parser *uctx)
|
||||
{
|
||||
/* The function lejp_destruct() cause segmentation fault on EC platform, comment out this line when building EC platform.
|
||||
* The function lejp_destruct() describes "no allocations... just let callback know what it happening".
|
||||
*/
|
||||
#ifndef PLAT_EC
|
||||
lejp_destruct(&uctx->ctx);
|
||||
#endif
|
||||
free(uctx->str);
|
||||
cJSON_Delete(uctx->root);
|
||||
*uctx = (struct uc_json_parser){ 0 };
|
||||
|
||||
@@ -32,6 +32,10 @@ extern "C" {
|
||||
#define UCENTRAL_TMP "/tmp/ucentral.cfg"
|
||||
#define UCENTRAL_LATEST "/etc/ucentral/ucentral.active"
|
||||
|
||||
#ifdef PLAT_EC
|
||||
#define REDIRECTOR_USER_DEFINE_FILE "/etc/ucentral/redirector-user-defined"
|
||||
#endif
|
||||
|
||||
/* It's expected that dev-id format is the following:
|
||||
* 11111111-1111-1111-1111-111111111111
|
||||
* and the max size of such string is 36 symbols.
|
||||
@@ -41,8 +45,6 @@ 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;
|
||||
@@ -62,14 +64,14 @@ extern time_t conn_time;
|
||||
extern struct plat_metrics_cfg ucentral_metrics;
|
||||
|
||||
/* proto.c */
|
||||
void proto_handle(char *cmd);
|
||||
void proto_handle(cJSON *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(const char *updated_pass);
|
||||
void deviceupdate_send(void);
|
||||
void device_rebootcause_send(void);
|
||||
void telemetry_send(struct plat_state_info *plat_state_info);
|
||||
void log_send(const char *message, int severity);
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"major": 3,
|
||||
"minor": 2,
|
||||
"patch": 7
|
||||
}
|
||||
Reference in New Issue
Block a user