diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..5e24190c
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,20 @@
+# Everything in the REPO directory is ignored by default.
+
+# Build products
+BUILD/
+dependmodules.x
+*.deb
+*.cpio.gz
+*.sqsh
+*.pyc
+
+# Package cache and lock files
+.lock
+.PKGs.cache
+.PKGs.cache.lock
+
+# Local module manifest.
+.manifest.mk
+
+
+
diff --git a/REPO/.gitignore b/REPO/.gitignore
new file mode 100644
index 00000000..1477bd1f
--- /dev/null
+++ b/REPO/.gitignore
@@ -0,0 +1 @@
+extracts
diff --git a/REPO/Makefile b/REPO/Makefile
new file mode 100644
index 00000000..9637ab11
--- /dev/null
+++ b/REPO/Makefile
@@ -0,0 +1,11 @@
+
+help:
+ @echo "Targets:"
+ @echo " clean : Clean all extracts and debian packages."
+
+clean:
+ @find packages -name "*.deb" -delete
+ @find packages -name Packages -delete
+ @find packages -name Packages.gz -delete
+ @rm -rf extracts
+
diff --git a/REPO/packages/.gitignore b/REPO/packages/.gitignore
new file mode 100644
index 00000000..a1f17ae9
--- /dev/null
+++ b/REPO/packages/.gitignore
@@ -0,0 +1,3 @@
+*.deb
+Packages
+Packages.gz
diff --git a/REPO/packages/all/Makefile b/REPO/packages/all/Makefile
new file mode 100644
index 00000000..6283cc30
--- /dev/null
+++ b/REPO/packages/all/Makefile
@@ -0,0 +1 @@
+include $(ONL)/make/repo.mk
diff --git a/REPO/packages/amd64/Makefile b/REPO/packages/amd64/Makefile
new file mode 100644
index 00000000..6283cc30
--- /dev/null
+++ b/REPO/packages/amd64/Makefile
@@ -0,0 +1 @@
+include $(ONL)/make/repo.mk
diff --git a/REPO/packages/powerpc/Makefile b/REPO/packages/powerpc/Makefile
new file mode 100644
index 00000000..6283cc30
--- /dev/null
+++ b/REPO/packages/powerpc/Makefile
@@ -0,0 +1 @@
+include $(ONL)/make/repo.mk
diff --git a/builds/swi/.gitignore b/builds/swi/.gitignore
new file mode 100644
index 00000000..e231f9df
--- /dev/null
+++ b/builds/swi/.gitignore
@@ -0,0 +1,2 @@
+*.swi
+*.swi.md5sum
diff --git a/builds/swi/amd64/Makefile b/builds/swi/amd64/Makefile
new file mode 100644
index 00000000..0c007902
--- /dev/null
+++ b/builds/swi/amd64/Makefile
@@ -0,0 +1,3 @@
+ROOTFS_PACKAGE := onl-rootfs
+include $(ONL)/make/config.amd64.mk
+include $(ONL)/make/swi.mk
diff --git a/builds/swi/powerpc/Makefile b/builds/swi/powerpc/Makefile
new file mode 100644
index 00000000..dbd07c9b
--- /dev/null
+++ b/builds/swi/powerpc/Makefile
@@ -0,0 +1,3 @@
+ROOTFS_PACKAGE := onl-rootfs
+include $(ONL)/make/config.powerpc.mk
+include $(ONL)/make/swi.mk
diff --git a/make/.gitignore b/make/.gitignore
new file mode 100644
index 00000000..8efe6e45
--- /dev/null
+++ b/make/.gitignore
@@ -0,0 +1,2 @@
+version-onl.*
+
diff --git a/make/Makefile b/make/Makefile
new file mode 100644
index 00000000..d7a2afeb
--- /dev/null
+++ b/make/Makefile
@@ -0,0 +1,8 @@
+############################################################
+#
+# Convenience makefile for generating
+# the local version variables.
+#
+versions.env:
+ $(ONL_V_at) $(MAKE) -f versions.mk ONL_VERSION_ENV_FILE=versions.env
+
diff --git a/make/config.amd64.mk b/make/config.amd64.mk
new file mode 100644
index 00000000..5648d13f
--- /dev/null
+++ b/make/config.amd64.mk
@@ -0,0 +1,10 @@
+############################################################
+#
+# Open Network Linux
+#
+############################################################
+include $(ONL)/make/config.mk
+export TOOLCHAIN := x86_64-linux-gnu
+export ARCH := amd64
+
+
diff --git a/make/config.mk b/make/config.mk
new file mode 100644
index 00000000..508734e3
--- /dev/null
+++ b/make/config.mk
@@ -0,0 +1,36 @@
+############################################################
+#
+# Open Network Linux Configuration Makefile
+#
+############################################################
+ifndef ONL
+ $(error $$ONL is not defined)
+endif
+
+ifndef ONLPM_PY
+ ONLPM := $(ONL)/tools/onlpm.py
+endif
+
+ifndef BUILDER
+ # Builder is here
+ export BUILDER := $(ONL)/sm/infra/builder/unix
+endif
+
+#
+# The default build directory for all infra:builder compilations is the following.
+#
+export BUILD_DIR_BASE=BUILD
+
+
+# Generate manifest if necessary
+export MODULEMANIFEST := $(shell $(ONL)/tools/scripts/manifest.sh $(ONL) $(BUILDER))
+
+#
+# Default make options.
+#
+ONL_MAKE_FLAGS += --no-print-directory -s
+ONL_MAKE := $(MAKE) $(ONL_MAKE_FLAGS)
+ONL_V_at := @
+
+
+
diff --git a/make/config.powerpc.mk b/make/config.powerpc.mk
new file mode 100644
index 00000000..29f0a0ec
--- /dev/null
+++ b/make/config.powerpc.mk
@@ -0,0 +1,10 @@
+############################################################
+#
+# Open Network Linux
+#
+############################################################
+include $(ONL)/make/config.mk
+export TOOLCHAIN := powerpc-linux-gnu
+export ARCH := powerpc
+
+
diff --git a/make/kbuild.mk b/make/kbuild.mk
new file mode 100644
index 00000000..4c36eaf7
--- /dev/null
+++ b/make/kbuild.mk
@@ -0,0 +1,166 @@
+############################################################
+#
+#
+# Copyright 2015 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+# Prepare and build a kernel.
+#
+############################################################
+
+ifndef ARCH
+$(error $$ARCH must be set)
+endif
+
+#
+# The kernel patchlevel.
+#
+ifndef K_PATCH_LEVEL
+$(error $$K_PATCH_LEVEL must be set)
+endif
+
+#
+# The kernel sublevel
+#
+ifndef K_SUB_LEVEL
+$(error $$K_SUB_LEVEL must be set)
+endif
+
+#
+# The directory containing the patches to be applied
+# to the kernel sources.
+#
+ifndef K_PATCH_DIR
+$(error $$K_PATCH_DIR must be set)
+endif
+
+#
+# This is the directory that will receive the build targets.
+# The kernel build tree is placed in this directory,
+# as well as any custom copy targets.
+#
+ifndef K_TARGET_DIR
+$(error $$K_TARGET_DIR not set)
+endif
+
+#
+# This is the absolute path to the kernel configuration
+# that should be used for this build.
+#
+ifndef K_CONFIG
+$(error $$K_CONFIG not set)
+endif
+
+#
+# This is the build target. bzImage, uImage, etc.
+#
+ifndef K_BUILD_TARGET
+$(error $$K_BUILD_TARGET not set)
+endif
+
+############################################################
+############################################################
+ONL_KERNELS := $(ONL)/packages/base/any/kernels
+
+K_VERSION := 3.$(K_PATCH_LEVEL).$(K_SUB_LEVEL)$(K_SUFFIX)
+K_NAME := linux-$(K_VERSION)
+ifndef K_ARCHIVE_EXT
+K_ARCHIVE_EXT := tar.xz
+endif
+K_ARCHIVE_NAME := $(K_NAME).$(K_ARCHIVE_EXT)
+K_ARCHIVE_PATH := $(ONL_KERNELS)/archives/$(K_ARCHIVE_NAME)
+ifndef K_ARCHIVE_URL
+K_ARCHIVE_URL := https://www.kernel.org/pub/linux/kernel/v3.x/$(K_ARCHIVE_NAME)
+endif
+K_SOURCE_DIR := $(K_TARGET_DIR)/$(K_NAME)
+K_MBUILD_DIR := $(K_SOURCE_DIR)-mbuild
+K_DTBS_DIR := $(K_SOURCE_DIR)-dtbs
+
+#
+# The kernel source archive. Download if not present.
+#
+$(K_ARCHIVE_PATH):
+ cd $(ONL_KERNELS)/archives && wget $(K_ARCHIVE_URL)
+
+
+.PHONY : ksource kpatched
+
+#
+# The extracted kernel sources
+#
+$(K_SOURCE_DIR)/Makefile: $(K_ARCHIVE_PATH)
+ cd $(K_TARGET_DIR) && tar kxf $(K_ARCHIVE_PATH)
+ touch -c $(K_SOURCE_DIR)/Makefile
+ $(K_MAKE) mrproper
+
+ksource: $(K_SOURCE_DIR)/Makefile
+
+#
+# The patched kernel sources
+#
+$(K_SOURCE_DIR)/.PATCHED: $(K_SOURCE_DIR)/Makefile
+ $(ONL)/tools/scripts/apply-patches.sh $(K_SOURCE_DIR) $(K_PATCH_DIR)
+ touch $(K_SOURCE_DIR)/.PATCHED
+
+kpatched: $(K_SOURCE_DIR)/.PATCHED
+
+#
+# Setup the kernel and output directory for the build.
+#
+setup: $(K_SOURCE_DIR)/.PATCHED
+ cp $(K_CONFIG) $(K_SOURCE_DIR)/.config
+
+#
+# Kernel build command.
+#
+K_MAKE := $(MAKE) -C $(K_SOURCE_DIR)
+
+#
+# Build the kernel.
+#
+build: setup
+ +$(K_MAKE) $(K_BUILD_TARGET)
+ifdef K_COPY_SRC
+ifdef K_COPY_DST
+ cp $(K_SOURCE_DIR)/$(K_COPY_SRC) $(K_TARGET_DIR)/$(K_COPY_DST)
+endif
+endif
+
+
+MODSYNCLIST := .config Module.symvers Makefile include scripts arch/x86/include arch/x86/Makefile arch/powerpc/include arch/powerpc/Makefile arch/powerpc/lib
+
+mbuild: build
+ rm -rf $(K_MBUILD_DIR)
+ mkdir -p $(K_MBUILD_DIR)
+ $(foreach f,$(MODSYNCLIST),$(ONL)/tools/scripts/tree-copy.sh $(K_SOURCE_DIR) $(f) $(K_MBUILD_DIR);)
+
+dtbs: mbuild
+ifdef DTS_LIST
+ rm -rf $(K_DTBS_DIR)
+ mkdir -p $(K_DTBS_DIR)
+ $(foreach name,$(DTS_LIST),$(K_SOURCE_DIR)/scripts/dtc/dtc -I dts -O dtb -o $(K_DTBS_DIR)/$(name).dtb $(K_SOURCE_DIR)/arch/$(ARCH)/boot/dts/$(name).dts; )
+endif
+
+#
+# This target can be used to manage the configuration file.
+#
+configure: setup
+ $(K_MAKE) menuconfig
+ cp $(K_SOURCE_DIR)/.config $(K_CONFIG)
+
+.DEFAULT_GOAL := dtbs
diff --git a/make/pkg.mk b/make/pkg.mk
new file mode 100644
index 00000000..03bd6108
--- /dev/null
+++ b/make/pkg.mk
@@ -0,0 +1,53 @@
+############################################################
+#
+# pkg.mk
+#
+# Default rules for building packages.
+#
+# Build all package groups in the current subtree.
+#
+############################################################
+include $(ONL)/make/config.mk
+
+#
+# Invoke onlpm to build all packages in the current
+# directory tree.
+#
+pkgall:
+ $(ONL_V_at) MAKE=$(MAKE) onlpm.py --build all
+
+
+clean:
+ $(ONL_V_at) MAKE=$(MAKE) onlpm.py --clean all
+
+rebuild:
+ $(ONL_V_at) MAKE=$(MAKE) onlpm.py --rebuild-pkg-cache
+
+#
+# Check all package declarations.
+#
+check:
+ $(ONL_V_at) MAKE=$(MAKE) onlpm.py --packagedirs=`pwd` --no-pkg-cache
+
+subdir:
+ $(ONL_V_at) MAKE=$(MAKE) onlpm.py --packagedirs=`pwd` --build all --no-pkg-cache
+
+
+#
+# Package construction only (no build step)
+#
+pkg:
+ $(ONL_V_at) MAKE=$(MAKE) NOBUILD=1 onlpm.py --build all
+
+
+
+#
+# Generate a rule for all available packages
+#
+ALL_PACKAGES := $(shell onlpm.py --list-all)
+define package_build_template
+package-$(1):
+ $(ONL_V_at) onlpm.py --build $(2)
+
+endef
+$(foreach p,$(ALL_PACKAGES),$(eval $(call package_build_template,$(subst :,_,$(p)),$(p))))
diff --git a/make/repo.mk b/make/repo.mk
new file mode 100644
index 00000000..ac113fc1
--- /dev/null
+++ b/make/repo.mk
@@ -0,0 +1,6 @@
+PACKAGES := $(wildcard *.deb)
+
+Packages: $(PACKAGES)
+ @echo "Updating Package Manifest..."
+ $(ONL_V_at) dpkg-scanpackages . > Packages
+
diff --git a/make/require-packages.mk b/make/require-packages.mk
new file mode 100644
index 00000000..aa32a8da
--- /dev/null
+++ b/make/require-packages.mk
@@ -0,0 +1,6 @@
+include $(ONL)/make/config.mk
+
+required_packages:
+ifdef REQUIRED_PACKAGES
+ $(ONLPM) --require $(REQUIRED_PACKAGES)
+endif
diff --git a/make/rfs.mk b/make/rfs.mk
new file mode 100644
index 00000000..1c8e0d52
--- /dev/null
+++ b/make/rfs.mk
@@ -0,0 +1,42 @@
+############################################################
+#
+# Common rules for invoking the onlrfs script.
+#
+# See $(ONL)/tools/onlrfs.py
+#
+############################################################
+
+ifndef ARCH
+$(error $$ARCH must be specified)
+endif
+
+ifndef RFS_CONFIG
+$(error $$RFS_CONFIG must be set to the RFS yaml configuration file)
+endif
+
+ifndef RFS_DIR
+$(error $$RFS_DIR must be set)
+endif
+
+RFS_COMMAND := $(ONL)/tools/onlrfs.py --arch $(ARCH) --config $(RFS_CONFIG) --dir $(RFS_DIR)
+
+ifdef RFS_CPIO
+RFS_COMMAND += --cpio $(RFS_CPIO)
+endif
+
+ifdef RFS_SQUASH
+RFS_COMMAND += --squash $(RFS_SQUASH)
+endif
+
+RFS:
+ $(ONL_V_at) rm -rf manifest.json
+ $(ONL_V_at) $(RFS_COMMAND)
+ $(ONL_V_at) [ -f $(RFS_DIR)/etc/onl/rootfs/manifest.json ] && cp $(RFS_DIR)/etc/onl/rootfs/manifest.json .
+
+clean:
+ $(ONL_V_at) sudo rm -rf $(RFS_DIR)
+ $(ONL_v_at) rm -rf $(RFS_CPIO) $(RFS_SQUASH)
+
+
+show-packages:
+ $(ONL_V_at) $(RFS_COMMAND) --show-packages
diff --git a/make/subdirs.mk b/make/subdirs.mk
new file mode 100644
index 00000000..acb3fa62
--- /dev/null
+++ b/make/subdirs.mk
@@ -0,0 +1,19 @@
+############################################################
+#
+#
+############################################################
+include $(ONL)/make/config.mk
+
+ifndef DIRECTORIES
+DIRECTORIES := $(notdir $(wildcard $(CURDIR)/*))
+endif
+
+FILTER := make Makefile Makefile~ $(FILTER)
+DIRECTORIES := $(filter-out $(FILTER),$(DIRECTORIES))
+
+all $(MAKECMDGOALS):
+ +$(ONL_V_at) $(foreach d,$(DIRECTORIES),$(ONL_MAKE) -C $(d) $(MAKECMDGOALS) || exit 1;)
+
+
+
+
diff --git a/make/swi.mk b/make/swi.mk
new file mode 100644
index 00000000..b5b16a43
--- /dev/null
+++ b/make/swi.mk
@@ -0,0 +1,26 @@
+ifndef ARCH
+$(error $$ARCH is not set)
+endif
+
+ifndef ROOTFS_PACKAGE
+$(error $$ROOTFS_PACKAGE not set.)
+endif
+
+ifdef REBUILD_RFS
+FORCE_OPTION = --force
+endif
+
+LINK_OPTIONS := $(FORCE_OPTION) --link-file $(ROOTFS_PACKAGE):$(ARCH) rootfs-$(ARCH).sqsh . --link-file $(ROOTFS_PACKAGE):$(ARCH) manifest.json .
+
+ifndef FILENAMER
+FILENAMER := $(ONL)/tools/filenamer.py
+endif
+
+swi: FORCE
+ $(ONL_V_at) $(ONLPM) $(LINK_OPTIONS)
+ $(ONL_V_at) zip -n rootfs-$(ARCH).sqsh - rootfs-$(ARCH).sqsh manifest.json > $@
+ $(ONL_V_at) mv $@ `$(FILENAMER) --type swi --manifest manifest.json $@`
+ $(ONL_V_at) for f in `ls *.swi`; do md5sum $$f > $$f.md5sum; done
+ $(ONL_V_at) rm -rf rootfs-$(ARCH).sqsh manifest.json
+ $(ONL_V_at) ls *.swi
+FORCE:
diff --git a/packages/base/all/Makefile b/packages/base/all/Makefile
new file mode 100644
index 00000000..003238cf
--- /dev/null
+++ b/packages/base/all/Makefile
@@ -0,0 +1 @@
+include $(ONL)/make/pkg.mk
\ No newline at end of file
diff --git a/packages/base/all/initrds/loader-initrd-files/Makefile b/packages/base/all/initrds/loader-initrd-files/Makefile
new file mode 100644
index 00000000..003238cf
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/Makefile
@@ -0,0 +1 @@
+include $(ONL)/make/pkg.mk
\ No newline at end of file
diff --git a/packages/base/all/initrds/loader-initrd-files/PKG.yml b/packages/base/all/initrds/loader-initrd-files/PKG.yml
new file mode 100644
index 00000000..97f1bdc7
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/PKG.yml
@@ -0,0 +1,36 @@
+common:
+ arch: all
+ version: 1.0.0
+ copyright: Copyright 2013, 2014, 2015 Big Switch Networks
+ maintainer: support@bigswitch.com
+
+packages:
+ - name: onl-loader-initrd-files
+ version: 1.0.0
+ summary: Open Network Linux System Loader Source Files
+
+ files:
+ - src/bin : /bin
+ - src/etc : /etc
+ - src/lib : /lib
+ - $ONL/make/version-onl.sh : /etc/onl/loader/versions.sh
+ - $ONL/make/version-onl.json : /etc/onl/loader/versions.json
+ - $ONL/make/version-onl.mk : /etc/onl/loader/versions.mk
+
+ changelog: Change changes changes.,
+
+
+ - name: onl-loader-initscripts
+ version: 1.0.0
+ summary: Open Network Linux System Loader Common Initscripts
+
+ files:
+ src/bin/initblockdev : /sbin/
+ src/bin/initmounts : /sbin/
+ src/bin/initnetdev : /sbin/
+
+ changelog: Change changes changes.,
+
+
+
+
diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/autoboot b/packages/base/all/initrds/loader-initrd-files/src/bin/autoboot
new file mode 100644
index 00000000..574131c4
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/bin/autoboot
@@ -0,0 +1,121 @@
+#!/bin/sh
+############################################################
+#
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+#
+#
+#
+############################################################
+#
+# autoboot
+#
+# Automatic boot sequence.
+#
+############################################################
+. /lib/msgs
+
+if [ -f /etc/onl/abort ]; then
+ sleep 3
+ exit 1
+fi
+
+
+#
+# The maximum number of times we will retry autobooting before
+# rebooting the system.
+#
+AUTOBOOT_MAX=50
+AUTOBOOT_COUNTER=/var/run/autoboot.count
+
+tryagain() {
+ # The timeout call to the boot script does not always kill stalled wgets properly.
+ # If there are any lingering wgets because of a timeout in downloading
+ # lets make sure they die a proper death.
+ killall -9 wget > /dev/null 2>&1
+
+ # Get the current retry count.
+ autoboot_count=0
+ if [ -f "$AUTOBOOT_COUNTER" ]; then
+ . "$AUTOBOOT_COUNTER"
+ fi
+ let "autoboot_count=autoboot_count+1"
+ echo "autoboot_count=$autoboot_count" > "$AUTOBOOT_COUNTER"
+ if [ "$autoboot_count" -gt "$AUTOBOOT_MAX" ]; then
+ # Reboot
+ msg_info "The Maximum number of autoboot attempts has been reached. Restarting..."
+ sleep 3
+ reboot
+ fi
+ exec $0 "$@"
+}
+
+if [ "$1" != "now" ]; then
+ if [ -f /bin/banner ]; then
+ /bin/banner
+ if [ -f /etc/onl/abort ]; then
+ sleep 3
+ exit 1
+ fi
+ fi
+ echo
+ echo
+ echo "Press Control-C now to enter the interactive loader shell."
+ sleep 3
+ echo
+ msg_info "Starting Autoboot"
+fi
+
+#
+# Apply any network settings indicated in the boot-config.
+#
+msg_info "Configuring Interfaces"
+
+if ! ifup; then
+ msg_error "The network settings indicated in the boot-config could not be applied."
+ echo $(cat /etc/onl/NET)
+ echo
+ tryagain
+fi
+
+
+#
+# Bootmode selection.
+#
+if [ ! -f /etc/onl/BOOTMODE ]; then
+ msg_error "There is no BOOTMODE setting. Autobooting cannot continue."
+ exit 1
+fi
+
+BOOTMODE=$(cat /etc/onl/BOOTMODE)
+if [ ! "$BOOTMODE" ]; then
+ msg_error "The BOOTMODE setting is empty. Autobooting cannot continue."
+ exit 1
+fi
+
+BOOTMODE=$(echo $BOOTMODE | tr '[:upper:]' '[:lower:]')
+msg_info "BOOTMODE is $BOOTMODE."
+
+if [ -f "/bootmodes/$BOOTMODE" ]; then
+ "/bootmodes/$BOOTMODE"
+ rv=$?
+ #
+ # If successful the BOOTMODE handler should not even return.
+ # If we get here its because of some sort of error.
+ #
+ if [ $rv -eq 0 ]; then
+ msg_error "The $BOOTMODE boot handler returned successfully. This is likely a bug. Autobooting cannot continue."
+ exit 1
+ elif [ $rv -eq 200 ]; then
+ msg_error "The $BOOTMODE boot handler indicates an unrecoverable error. Autobooting cannot continue."
+ exit 1
+ else
+ # Potentially recoverable error. Continue trying.
+ tryagain
+ fi
+else
+ msg_error "BOOTMODE $BOOTMODE is not implemented. Autobooting cannot continue."
+ exit 1
+fi
+
diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/banner b/packages/base/all/initrds/loader-initrd-files/src/bin/banner
new file mode 100755
index 00000000..54165d40
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/bin/banner
@@ -0,0 +1,42 @@
+#!/bin/sh
+. /lib/msgs
+. /lib/customize.sh
+
+field()
+{
+ if [ -n "$1" ]; then
+ echo "* $2"
+ fi
+
+}
+ONL_PLATFORM=$(cat /etc/onl/platform)
+MA1_ADDR=$(ifconfig ma1 | awk '/HWaddr/ { print tolower($5)}')
+
+echo "************************************************************"
+echo "*"
+echo "* $LOADER_SYSTEM_NAME $LOADER_LOADER_NAME"
+echo "* "
+field "$VERSION_ID" " Version: $VERSION_ID"
+field "$VERSION_ID" " Id: $BUILD_ID"
+echo "*"
+field "$ONL_PLATFORM" " Platform: $ONL_PLATFORM"
+field "MA1_ADDR" " ma1: $MA1_ADDR"
+echo "*"
+echo "************************************************************"
+if [ -f /mnt/flash/boot-config ]; then
+ msg_info "boot-config"
+ cat /mnt/flash/boot-config
+else
+
+ if [ -f /bin/boot-config.py ]; then
+ if /bin/boot-config.py configure; then
+ echo "The system will now reboot to apply your configuration."
+ reboot
+ else
+ echo "The boot-config script failed." >> /etc/onl/abort
+ fi
+ else
+ msg_info "No boot-config"
+ fi
+fi
+
diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/boot b/packages/base/all/initrds/loader-initrd-files/src/bin/boot
new file mode 100755
index 00000000..1791ed36
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/bin/boot
@@ -0,0 +1,149 @@
+#!/bin/sh
+############################################################
+#
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+# boot
+#
+# Handle booting SWI image locators.
+#
+############################################################
+set -e
+unset testonly help cache
+
+while [ "$1" ]; do
+ case "$1" in
+ -h|--help) help=1 ;;
+ -t|--testonly) testonly=1 ;;
+ --cache) shift; cache="$1" ;;
+ *) break ;;
+ esac
+ shift
+done
+SWI=$1
+
+mkdir -p /etc/onl
+
+if [ ! "${SWI}" ] || [ "${help}" ]; then
+ cat </tmp/swi0
+ mv /tmp/swi0 /tmp/swi
+ swipath=/tmp/swi
+ ;;
+ tftp:*)
+ echo "Downloading ${SWI}"
+ eval $(echo "${SWI}" | sed -n 's#tftp://\([^/:]*\|\[[^]/]*\]\)\(:\([0-9]\+\)\)\?/\(.*\)#host="\1" port="\3" file="\4"#p')
+ tftp -g -r "${file}" -l /tmp/swi0 "${host}" ${port}
+ mv /tmp/swi0 /tmp/swi
+ swipath=/tmp/swi
+ ;;
+ nfs:*)
+ eval $(echo "${SWI}" | sed -n 's#nfs://\([^/:]*\|\[[^]/]*\]\)\(:\([0-9]\+\)\)\?\(.*\)/\(.*\)#host="\1" port="\3" dir="\4" file="\5"#p')
+ [ "${dir}" ] || dir=/
+ [ "${port}" ] || port=0
+ echo "Mounting nfs://${host}:${port}${dir}"
+ umount -l /tmp/nfs 2>/dev/null || :
+ mkdir -p /tmp/nfs
+ mount -t nfs -o "nolock,port=${port}" "${host}:${dir}" /tmp/nfs
+ if [ "${file}" ]; then
+ swipath="/tmp/nfs/${file}"
+ [ ! -d ${swipath} ] || { echo "${SWI} must be a SWI file (use ${SWI}/ for a SWI directory)"; exit 1; }
+ else
+ swipath=/tmp/nfs
+ [ -d "${swipath}/${rootfs}" ] || { echo "${SWI}${rootfs} must be an unpacked rootfs"; exit 1; }
+ mount -t nfs -o "nolock,port=${port}" "${host}:${dir}/${rootfs}" "${swipath}/${rootfs}"
+ fi
+ ;;
+ *)
+ # Parse dev:file or dev:/file or /mnt/dev/file
+ parselocal='s#\(\([^:/]*\):/\?\|/mnt/\([^/]*\)/\)\?\(.*\)#dev="\2\3" file="\4"#p'
+ eval $(echo "${SWI}" | sed -n "${parselocal}")
+ if [ "${dev}" ] ; then
+ # Wait for /mnt/dev to show up
+ waitforblockdev "/mnt/${dev}"
+ else
+ # Assume file is relative, parse absolutified file
+ eval $(realpath "${file}" | sed -n "${parselocal}")
+ SWI="${dev}:${file}"
+ fi
+ swipath="/mnt/${dev}/${file}"
+ [ -f "${swipath}" ] || { echo "${SWI} not found or not a file"; exit 1; }
+ ;;
+esac
+
+echo "SWI=${SWI}" >/etc/onl/boot-config
+echo "CONSOLESPEED=$(stty speed)" >>/etc/onl/boot-config
+PASSWORD=$(cat /etc/onl/PASSWORD)
+[ ! "${PASSWORD}" ] || echo "PASSWORD=${PASSWORD}" >>/etc/onl/boot-config
+if [ "${swipath#/tmp/nfs}" != "${swipath}" ]; then
+ ifget
+ cat /etc/onl/NET >>/etc/onl/boot-config
+fi
+
+#
+# Cache the SWI if necessary.
+#
+if [ -n "$cache" ]; then
+ python /bin/swicache.py "${swipath}" "${cache}"
+fi
+
+. /lib/boot1
+
+echo "Boot failed"
+exit 1
diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/discoverbootconf b/packages/base/all/initrds/loader-initrd-files/src/bin/discoverbootconf
new file mode 100644
index 00000000..c6d63bf1
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/bin/discoverbootconf
@@ -0,0 +1,119 @@
+#!/bin/sh
+############################################################
+#
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+# discoverbootconf
+#
+# Discover the current boot configuration.
+#
+############################################################
+
+. /lib/loader-functions || exit 1
+
+intf=$1
+
+if [ ! ${intf} ]; then
+ echo "Usage: $0 INTERFACE"
+ exit 1
+fi
+
+if ! ifconfig ${intf} >/dev/null 2>&1; then
+ echo "Interface ${intf} not found; can't discover boot configuration"
+ exit 1
+fi
+
+ifconfig ${intf} up
+ip route add to 224.0.0.0/4 dev ${intf}
+
+zcip ${intf}
+
+rm -f /tmp/udhcpc.boot_file /tmp/udhcpc.pid
+udhcpc -i ${intf} -b -t 1 -A 3
+
+trap "exit 1" SIGINT
+trap "kill \$(cat /tmp/udhcpc.pid); ifconfig ${intf} down" EXIT
+
+macaddr=$(ifconfig ${intf} | awk '/HWaddr/ { print tolower($5) }')
+platform=$(cat /etc/onl/platform)
+
+# see if we are in (or if we want to be in) ZTN mode
+# retrieve the cached state of the previous swi
+swi_url_orig=$(sed -n -e 's/^SWI=\(.*\)/\1/p' /etc/onl/boot-config)
+case "$swi_url_orig" in
+ "")
+ ZTN=1
+ swi_url_orig="flash2:.ztn-onl.swi"
+ ;;
+ flash2:.ztn-onl.swi)
+ ZTN=1
+ ;;
+ /mnt/flash2/.ztn-onl.swi)
+ ZTN=1
+ swi_url_orig="flash2:.ztn-onl.swi"
+ ;;
+esac
+
+if [ "$ZTN" ]; then
+
+ waitforblockdev /mnt/flash2
+
+ if [ -f /mnt/flash2/.ztn-onl.swi ]; then
+ swi_md5_orig=$(md5sum /mnt/flash2/.ztn-onl.swi 2>/dev/null | awk '{print $1}')
+ fi
+
+ if [ -f /mnt/flash2/.ztn-startup-config ]; then
+ cfg_md5_orig=$(md5sum /mnt/flash2/.ztn-startup-config 2>/dev/null | awk '{print $1}')
+ fi
+
+fi
+
+while true; do
+ echo "Looking for boot configuration; press Control-C to stop"
+
+ dsc_dhcp_boot $intf $macaddr && exit
+
+ if [ "$ZTN" ]; then
+ # borrow liberally from ONIE (rootconf/default/bin/discover)
+
+ # ha ha, the wget IPv6 link local syntax is screwy
+ # (and also does not match upstream GNU wget)
+ ping6 -I ${intf} -c 3 ff02::1 > /dev/null 2>&1
+ neighs6=$(ip -6 neigh show | awk '{printf("%s%%'$intf'\n", $1)}')
+
+ ping -I ${intf} -w 2 -c 3 -q 255.255.255.255 > /dev/null 2>&1
+ neighs=$(ip -4 neigh show | awk '{print $1}')
+ fi
+
+ for a in $neighs6 $neighs; do
+ dsc_swi_manifest $macaddr $a && exit
+ done
+
+ bootservers=$(cat /tmp/udhcpc.boot_file 2>/dev/null)
+ for a in ${bootservers} ff02::fb 224.0.0.251; do
+ dsc_dnssd $macaddr $a && exit
+ done
+
+done
+
+# Local variables:
+# indent-tabs-mode: nil
+# sh-basic-offset: 4
+# End:
diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/help b/packages/base/all/initrds/loader-initrd-files/src/bin/help
new file mode 100755
index 00000000..e4a276fb
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/bin/help
@@ -0,0 +1,50 @@
+#!/bin/sh
+############################################################
+#
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+# help
+#
+# Loader Help
+#
+############################################################
+
+cat <
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+# ifget
+#
+# Scrape network interface settings into /etc/onl/NET
+#
+############################################################
+: >/etc/onl/NET
+
+NETDEV=$(ip -o link show up | sed -n -e '/LOOPBACK/d' -e 's/^[0-9]\+: \([^:]\+\): .*/\1/p' | head -n 1)
+[ "${NETDEV}" ] || exit 0
+
+echo "NETDEV=${NETDEV}" >>/etc/onl/NET
+
+if [ -f /tmp/udhcpc.pid ]; then
+ echo "NETAUTO=dhcp" >>/etc/onl/NET
+else
+ set -- $(ip -o addr show dev ${NETDEV} | sed -n 's/^[0-9]\+: [^ ]\+ \+\([^ ]\+ [^ ]\+\) scope global.*/\1/p' | tail -n 1)
+ echo "NETIP=$2" >>/etc/onl/NET
+ if [ "$1" ]; then
+ echo "NETGW=$(ip -o -f $1 route show | sed -n 's/^default via \([^ ]\+\).*/\1/p')" >>/etc/onl/NET
+ fi
+ if [ -f /etc/resolv.conf ]; then
+ echo "NETDOMAIN=$(sed -n 's/search \+\([a-zA-Z0-9\.-]\+\).*/\1/p' /etc/resolv.conf)" >>/etc/onl/NET
+ echo "NETDNS=$(sed -n 's/nameserver \+\([0-9\.]\+\).*/\1/p' /etc/resolv.conf)" >>/etc/onl/NET
+ fi
+fi
+
+echo "NETHW=$(ip -o link show dev ${NETDEV} | sed -n 's/^.*link\/ether \([0-9a-fA-F:]\+\).*/\1/p')" >>/etc/onl/NET
diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/ifup b/packages/base/all/initrds/loader-initrd-files/src/bin/ifup
new file mode 100644
index 00000000..b9edbe67
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/bin/ifup
@@ -0,0 +1,89 @@
+#!/bin/sh
+############################################################
+#
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+# ifup
+#
+# Configure a network interface from settings in /etc/onl/NET
+# NETDEV: device name
+# NETAUTO: autoconfiguration method ("dhcp" or empty)
+# NETIP: IP address (/prefix optional for v4)
+# NETMASK: netmask (if NETIP has no prefix)
+# NETGW: default gateway IP address (optional)
+# NETDOMAIN: DNS default domain (optional)
+# NETDNS: DNS server IP address (optional)
+# NETHW: hardware (MAC) address (optional)
+#
+############################################################
+
+unset NETDEV NETAUTO NETIP NETMASK NETGW NETDOMAIN NETDNS NETHW
+. /etc/onl/NET
+
+[ "${NETDEV}" ] || exit
+
+if [ "${NETHW}" ]; then
+ ip link set dev ${NETDEV} addr ${NETHW}
+fi
+
+case "${NETAUTO}" in
+ dhcp|auto)
+ echo 1 >/proc/sys/net/ipv6/conf/${NETDEV}/autoconf
+ udhcpc -i ${NETDEV}
+ ;;
+ up)
+ ifconfig "${NETDEV}" up
+ ;;
+ *)
+ if [ "${NETIP}" ] && [ "${NETMASK}" ] && [ "${NETIP#*/}" = "${NETIP}" ]; then
+ NETIP=${NETIP}/$(ipcalc -p -s ${NETIP} ${NETMASK} | sed -n 's/PREFIX=//p')
+ fi
+ ip link set ${NETDEV} down
+ echo 0 >/proc/sys/net/ipv6/conf/${NETDEV}/autoconf
+ ip addr flush dev ${NETDEV}
+ if [ "${NETIP}" ]; then
+ ip addr add ${NETIP} dev ${NETDEV}
+ fi
+ ip link set ${NETDEV} up
+ if [ "${NETGW}" ]; then
+ ip route add default via ${NETGW}
+ fi
+ >/etc/resolv.conf
+ if [ "${NETDOMAIN}" ]; then
+ echo "search ${NETDOMAIN}" >>/etc/resolv.conf
+ fi
+ if [ "${NETDNS}" ]; then
+ echo "nameserver ${NETDNS}" >>/etc/resolv.conf
+ fi
+ ;;
+esac
+
+#
+# If no network settings were applied, bring the interface up for link-local usage.
+#
+grep -q down "/sys/class/net/${NETDEV}/operstate" || ifconfig "${NETDEV}" up
+
+for i in $(seq 30); do
+ (ip -o -6 addr list dev ${NETDEV} | grep tentative >/dev/null) || break
+ if [ $i = 5 ]; then
+ echo "Waiting for IPv6 duplicate address detection to complete..."
+ fi
+ sleep 1
+done
diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/initblockdev b/packages/base/all/initrds/loader-initrd-files/src/bin/initblockdev
new file mode 100755
index 00000000..a98d2f24
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/bin/initblockdev
@@ -0,0 +1,82 @@
+#!/bin/sh
+############################################################
+#
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+# initblockdev
+#
+# Initialize all block mounts for the platform.
+#
+############################################################
+set -e
+exec 9<$0
+flock -x 9
+case $2 in
+ add)
+ eval $(echo $1 | sed "s#^\(mmcblk[0-9]*\|ubi[0-9]*_[0-9]*\|mtdblock[0-9]*\|[a-z]*\)\(p[0-9]*\|[0-9]*\).*#dev='\1' part='\2'#")
+ devid=
+ if [ -e /sys/class/ubi/${dev}/device ]; then
+ eval $(realpath /sys/class/ubi/${dev}/device | sed "s#/sys/devices/\(.*\)#devid='\1'#")
+ fi
+ if [ -e /sys/class/block/${dev}/device ]; then
+ eval $(realpath /sys/class/block/${dev}/device | sed "s#/sys/devices/\(.*\)#devid='\1'#")
+ fi
+ while read i n; do
+ expr match "$i" "#" >/dev/null && continue || :
+ [ -n "${devid}" ] && expr match "${devid}" "$i" >/dev/null && mount=/mnt/$n && break || :
+ expr match "@${dev}" "$i" >/dev/null && mount=/mnt/$n && break || :
+ done /dev/null)" = "070701" ]; then
+ mount=${mount}-recover
+ else
+ mkdir -p ${mount}
+ [ $(stat -c %D ${mount}) = $(stat -c %D /mnt) ]
+ if [ "$(dd if=/dev/${dev}${part} bs=1 skip=82 count=5 2>/dev/null)" = "FAT32" ] \
+ || [ "$(dd if=/dev/${dev}${part} bs=1 skip=54 count=5 2>/dev/null)" = "FAT16" ]; then
+ if [ ! -e /etc/onl/kdump ]; then
+ # Try to repair FAT filesystem automatically to prevent further
+ # damage (but skip it in kdump to save time and memory)
+ if dosfsck -a /dev/${dev}${part} >/dev/null 2>&1; then
+ :
+ else
+ dosfsck -n /dev/${dev}${part} >/dev/null 2>&1
+ fi
+ dosfsck -a /dev/${dev}${part} >/dev/null 2>&1 || :
+ fi
+ mount -o flush,dirsync,noatime,umask=0007 /dev/${dev}${part} ${mount} 2>/dev/null
+ else
+ mount -o noatime /dev/${dev}${part} ${mount} 2>/dev/null
+ fi
+ fi
+ echo -e "devid='${devid}'\ndev='${dev}'\npart='${part}'" >${mount}.conf
+ ;;
+ remove)
+ mtab=$(mktemp /tmp/tmp.XXXXXX)
+ cp /proc/mounts ${mtab}
+ while read dev mount x; do
+ if [ /dev/$1 = "${dev}" ]; then
+ rm -f ${mount}.conf
+ umount -l ${mount} 2>/dev/null || :
+ fi
+ done <${mtab}
+ rm -f ${mtab}
+ ;;
+esac
diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/initmounts b/packages/base/all/initrds/loader-initrd-files/src/bin/initmounts
new file mode 100755
index 00000000..6f4f0ff0
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/bin/initmounts
@@ -0,0 +1,275 @@
+#!/bin/sh
+############################################################
+#
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+#
+#
+#
+############################################################
+#
+# initmounts
+#
+# Mount all mount points listed in /etc/onl/mounts
+#
+# Each line in /etc/onl/mounts is in the following syntax:
+#
+# /dev/sda sda mount-point
+# - wait for /dev/sda to appear,
+# then mount /dev/sda as /mnt/mount-point
+#
+# /dev/sda * mount-point
+# - wait for block device /dev/sda to appear,
+# then mount /dev/sda as /mnt/mount-point
+# (infer /dev/sda from the left-hand path specification)
+#
+# block/sda sda mount-point
+# block/sda * mount-point
+# SYSDEV=block/sda sda mount-point
+# SYSDEV=block/sda * mount-point
+# - wait for /sys/block/sda to appear,
+# then mount /mnt/sda as /mnt/mnt-point
+#
+# LABEL=MYDEV * mount-point
+# LABEL="MYDEV" * mount-point
+# - wait for a partition with the given label to appear
+# (via polling 'blkid')
+# then mount as /mnt/mnt-point
+#
+# UUID=some-uuid * mount-point
+# UUID="some-uuid" * mount-point
+# - wait for a partition with the given UUID to appear
+# (via polling 'blkid')
+# then mount as /mnt/mnt-point
+#
+# - multiple lines mapping to the same mount point can
+# be listed in /etc/onl/mounts, the first one that
+# is valid wins
+#
+# - initmounts exits with code zero (success)
+# if each mount point is mounted once
+#
+# - initmounts exits with non-zero (failure)
+# if un-mounted mount points are still remaining after 10s
+#
+############################################################
+exec 9<$0
+flock -x 9
+
+CR="
+"
+PATH=$PATH:/sbin:/usr/sbin
+
+recover="fsck"
+
+try_mount_block()
+{
+ local dev devpart mount
+ dev=$1; shift
+ devpart=$1; shift
+ mount=$1; shift
+
+ if test -b "$dev"; then
+
+ if test "$devpart" = "*"; then
+ devpart=`echo "$dev" | sed -e 's/^.*[/]//' `
+ fi
+
+ test -d /mnt/$mount || mkdir -p /mnt/$mount
+ if test "$recover" = "fsck"; then
+ if dosfsck -a /dev/$devpart; then
+ :
+ else
+ dosfsck -n /dev/$devpart || return
+ fi
+ else
+ dosfsck -n /dev/$devpart || return
+ fi
+ mount -o noatime /dev/$devpart /mnt/$mount || return
+ echo "mounted /dev/$devpart --> /mnt/$mount"
+
+ fi
+}
+
+try_mount_sysdev()
+{
+ local syspath devpart mount
+ syspath=$1; shift
+ devpart=$1; shift
+ mount=$1; shift
+
+ if test -e /sys/$syspath; then
+
+ if test "$devpart" = "*"; then
+ devpart=`echo "$syspath" | sed -e 's/^.*[/]//' `
+ fi
+
+ test -d /mnt/$mount || mkdir -p /mnt/$mount
+ if test "$recover" = "fsck"; then
+ if dosfsck -a /dev/$devpart; then
+ :
+ else
+ dosfsck -n /dev/$devpart || return
+ fi
+ else
+ dosfsck -n /dev/$devpart || return
+ fi
+ mount -o noatime /dev/$devpart /mnt/$mount || return
+ echo "mounted /dev/$devpart --> /mnt/$mount"
+
+ fi
+}
+
+try_mount_label()
+{
+ local label devpart mount
+ label=$1; shift
+ devpart=$1; shift
+ mount=$1; shift
+
+ local ifs dummy line dev
+ ifs=$IFS; IFS=$CR
+ for line in `blkid`; do
+ IFS=$ifs
+ case " $line " in
+ *" LABEL=${label} "*)
+ dev=`echo "$line" | sed -e 's/:.*//'`
+ break
+ ;;
+ *" LABEL=\"${label}\" "*)
+ dev=`echo "$line" | sed -e 's/:.*//'`
+ break
+ ;;
+ esac
+ done
+ IFS=$ifs
+
+ if test "$dev"; then
+ try_mount_block "$dev" "$devpart" "$mount"
+ fi
+}
+
+try_mount_uuid()
+{
+ local uuid devpart mount
+ uuid=$1; shift
+ devpart=$1; shift
+ mount=$1; shift
+
+ local ifs dummy line dev
+ ifs=$IFS; IFS=$CR
+ for line in `blkid`; do
+ IFS=$ifs
+ case " $line " in
+ *" UUID=${uuid} "*)
+ dev=`echo "$line" | sed -e 's/:.*//'`
+ break
+ ;;
+ *" UUID=\"${label}\" "*)
+ dev=`echo "$uuid" | sed -e 's/:.*//'`
+ break
+ ;;
+ esac
+ done
+ IFS=$ifs
+
+ if test "$dev"; then
+ try_mount_block "$dev" "$devpart" "$mount"
+ fi
+}
+
+try_mount()
+{
+ local devspec devpart mount
+ devspec=$1; shift
+ devpart=$1; shift
+ mount=$1; shift
+
+ if grep " /mnt/$mount " /proc/mounts 1>/dev/null; then
+ return
+ fi
+
+ local sysdev label uuid
+
+ case "$devspec" in
+ /dev/*)
+ try_mount_block "$devspec" "$devpart" "$mount"
+ ;;
+ block/*)
+ try_mount_sysdev "$devspec" "$devpart" "$mount"
+ ;;
+ SYSDEV=\"*\")
+ sysdev=`echo "$devspec" | sed -e 's/SYSDEV=\"\(.*\)\"/\1/'`
+ try_mount_sysdev "$sysdev" "$devpart" "$mount"
+ ;;
+ SYSDEV=*)
+ sysdev=`echo "$devspec" | sed -e 's/SYSDEV=\(.*\)/\1/'`
+ try_mount_sysdev "$sysdev" "$devpart" "$mount"
+ ;;
+ LABEL=\"*\")
+ label=`echo "$devspec" | sed -e 's/LABEL=\"\(.*\)\"/\1/'`
+ try_mount_label "$label" "$devpart" "$mount"
+ ;;
+ LABEL=*)
+ label=`echo "$devspec" | sed -e 's/LABEL=\(.*\)/\1/'`
+ try_mount_label "$label" "$devpart" "$mount"
+ ;;
+ UUID=\"*\")
+ uuid=`echo "$devspec" | sed -e 's/UUID=\"\(.*\)\"/\1/'`
+ try_mount_uuid "$uuid" "$devpart" "$mount"
+ ;;
+ UUID=*)
+ uuid=`echo "$devspec" | sed -e 's/UUID=\(.*\)/\1/'`
+ try_mount_uuid "$uuid" "$devpart" "$mount"
+ ;;
+ *)
+ echo "*** invalid block specifier: $devspec" 1>&2
+ ;;
+ esac
+}
+
+visit_onl_mounts()
+{
+ local fn rest
+ fn=$1; shift
+ rest="$@"
+
+ local ifs dummy line remain
+ remain=0
+ ifs=$IFS; IFS=$CR
+ for line in $(cat /etc/onl/mounts); do
+ IFS=$ifs
+
+ set -f
+ set dummy $line; shift
+ devspec=$1; shift
+ devpart=$1; shift
+ mount=$1; shift
+
+ grep " /mnt/$mount " /proc/mounts 1>/dev/null && continue
+ remain=1
+ eval $fn "$devspec" "$devpart" "$mount" $rest
+
+ set +f
+ done
+ IFS=$ifs
+
+ return $remain
+}
+
+if test -f /etc/onl/mounts; then
+ timeout=10
+ while test $timeout -gt 0; do
+ if visit_onl_mounts try_mount; then
+ echo "Found all mounts."
+ exit 0
+ fi
+ sleep 1
+ timeout=$(( $timeout - 1 ))
+ done
+ if test "$timeout" -eq 0; then
+ echo "Timed out waiting for block devices"
+ exit 1
+ fi
+fi
diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/initnetdev b/packages/base/all/initrds/loader-initrd-files/src/bin/initnetdev
new file mode 100755
index 00000000..95744fcc
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/bin/initnetdev
@@ -0,0 +1,52 @@
+#!/bin/sh
+############################################################
+#
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+# initnetdev
+#
+# Initialize management interfaces specified in /etc/onl/net
+#
+# This maps the platform's management interface to well-known
+# interface names (such as ma1)
+#
+############################################################
+set -e
+exec 9<$0
+flock -x 9
+case $2 in
+ add)
+ dev=$1
+ devid=
+ if [ -e /sys/class/net/${dev}/device ]; then
+ eval $(realpath /sys/class/net/${dev}/device | sed 's#/sys/devices/\(.*\)#devid=\1#')
+ fi
+ while read i n; do
+ expr match "$i" "#" >/dev/null && continue || :
+ [ -n "${devid}" ] && expr match "${devid}" "$i" >/dev/null && name=$n && break || :
+ expr match "@${dev}" "$i" >/dev/null && name=$n && break || :
+ done &1 > /dev/null; then
+ ip link set dev ${dev} name ${name}
+ fi
+ ;;
+esac
diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/login b/packages/base/all/initrds/loader-initrd-files/src/bin/login
new file mode 100644
index 00000000..9925dbc8
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/bin/login
@@ -0,0 +1,49 @@
+#!/bin/sh
+############################################################
+#
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+# login
+#
+############################################################
+
+
+trap '' SIGINT
+
+
+if (
+ set -e
+ PASSWORD=$(cat /etc/onl/PASSWORD)
+ [ -z "${PASSWORD}" ] || checkpass -p "Password:" "${PASSWORD}"
+)
+then
+
+ # Authenticated succeeded
+
+ trap - SIGINT
+ exec sh --login
+
+else
+
+ # Authentication failed
+
+ echo "Authentication failed."
+ exit 1
+fi
diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/netconf b/packages/base/all/initrds/loader-initrd-files/src/bin/netconf
new file mode 100755
index 00000000..a7acd351
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/bin/netconf
@@ -0,0 +1,61 @@
+#!/bin/sh
+############################################################
+#
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+# netconf
+#
+#
+# User configuration of the management interface.
+#
+############################################################
+
+[ "$1" = "-h" ] && { echo "Manually configures a management Ethernet interface"; exit; }
+
+echo "Management network interface configuration tool"
+echo "(Press Control-C to cancel)"
+echo ""
+
+unset NETDEV NETIP NETMASK NETGW NETDOMAIN NETDNS
+read -p "Which interface (blank for ma1)? " NETDEV
+[ "${NETDEV}" ] || NETDEV=ma1
+while [ ! "${NETIP}" ]; do
+ read -p "IP address (/prefix optional for v4)? " NETIP
+done
+if [ "${NETIP#*/}" = "${NETIP}" ]; then
+ while [ ! "${NETMASK}" ]; do
+ read -p "Netmask? " NETMASK
+ done
+fi
+read -p "Default gateway IP address (blank for none)? " NETGW
+read -p "DNS IP address (blank for none)? " NETDNS
+read -p "DNS default domain (blank for none)? " NETDOMAIN
+
+echo ""
+echo "Configuring interface ${NETDEV}"
+
+echo "NETDEV=${NETDEV}" >/etc/onl/NET
+echo "NETIP=${NETIP}" >>/etc/onl/NET
+echo "NETMASK=${NETMASK}" >>/etc/onl/NET
+echo "NETGW=${NETGW}" >>/etc/onl/NET
+echo "NETDOMAIN=${NETDOMAIN}" >>/etc/onl/NET
+echo "NETDNS=${NETDNS}" >>/etc/onl/NET
+
+ifup
diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/recover b/packages/base/all/initrds/loader-initrd-files/src/bin/recover
new file mode 100644
index 00000000..e69de29b
diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/swicache.py b/packages/base/all/initrds/loader-initrd-files/src/bin/swicache.py
new file mode 100644
index 00000000..24fba30f
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/bin/swicache.py
@@ -0,0 +1,65 @@
+#!/usr/bin/python
+import argparse
+import os
+import sys
+import hashlib
+import shutil
+import logging
+
+logging.basicConfig()
+logger = logging.getLogger("swicache")
+logger.setLevel(logging.INFO)
+
+def filehash(fname, blocksize=1024*1024):
+ h = hashlib.sha1()
+ with open(fname,'rb') as f:
+ block = 0
+ while block != b'':
+ block = f.read(blocksize)
+ h.update(block)
+ return h.hexdigest()
+
+def write_hash(fname, digest):
+ open(fname, "w").write(digest)
+
+def read_hash(fname):
+ return open(fname).read()
+
+ap = argparse.ArgumentParser(description="SWI Cacher")
+ap.add_argument("src")
+ap.add_argument("dst")
+ap.add_argument("--force", action='store_true')
+
+ops = ap.parse_args()
+
+# Generate hash of the source file
+logger.info("Generating hash for %s..." % ops.src)
+src_hash = filehash(ops.src)
+logger.info("Generated hash for %s: %s" % (ops.src, src_hash))
+
+dst_hash_file = "%s.md5sum" % ops.dst
+
+if not ops.force:
+ if os.path.exists(ops.dst) and os.path.exists(dst_hash_file):
+ # Destination exists and the hash file exists.
+ dst_hash = read_hash(dst_hash_file)
+ if dst_hash == src_hash:
+ # Src and destination are the same.
+ logger.info("Cache file is up to date.")
+ sys.exit(0)
+
+#
+# Either force==True, a destination file is missing, or the
+# current file is out of date.
+#
+logger.info("Updating %s --> %s, %s" % (ops.src, ops.dst, src_hash))
+if not os.path.isdir(os.path.dirname(ops.dst)):
+ os.makedirs(os.path.dirname(ops.dst))
+shutil.copyfile(ops.src, ops.dst)
+write_hash(dst_hash_file, src_hash);
+logger.info("Syncing...")
+os.system("sync")
+logger.info("Done.")
+
+
+
diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/swiinfo b/packages/base/all/initrds/loader-initrd-files/src/bin/swiinfo
new file mode 100755
index 00000000..2216bc7c
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/bin/swiinfo
@@ -0,0 +1,35 @@
+#!/bin/sh
+############################################################
+#
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+# swiinfo
+#
+# Get the version information from the given SWI.
+#
+############################################################
+
+set -e
+[ -n "$1" ] && [ "$1" != "-h" ] || { echo "Usage: $0 SWI"; exit 1; }
+swi=$1
+rm -f /tmp/version
+unzip -l ${swi}
+echo
+unzip -pq ${swi} version
diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/switchroot b/packages/base/all/initrds/loader-initrd-files/src/bin/switchroot
new file mode 100644
index 00000000..91d08334
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/bin/switchroot
@@ -0,0 +1,60 @@
+#!/bin/sh
+############################################################
+#
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+# switchroot
+#
+# This script is a wrapper for busybox switch_root, which works only if:
+# - executed as PID 1 (i.e. replacing init)
+# - /init is a regular file
+# - /newroot is a tmpfs or ramfs
+# - /newroot is a different filesystem from /
+#
+# The only way to execute as PID 1 with busybox init is to invoke it via
+# the restart action in the inittab.
+#
+############################################################
+
+# Unmount all filesystems except / and anything under /newroot
+mtab=$(mktemp /tmp/tmp.XXXXXX)
+cp /proc/mounts ${mtab}
+while read dev mount x; do
+ case "${mount}" in
+ /|/proc|/sys|/dev|/newroot|/newroot/*)
+ ;;
+ *)
+ rm -f "${mount}".conf
+ umount -l "${mount}" 2>/dev/null
+ ;;
+ esac
+done <${mtab}
+rm -f ${mtab}
+
+mount --move /proc /newroot/proc
+mount --move /sys /newroot/sys
+mount --move /dev /newroot/dev
+
+# Switch to /newroot if possible, else re-execute /init
+if [ -x /newroot/sbin/init ]; then
+ exec switch_root -c /dev/console /newroot /sbin/init
+else
+ exec /init
+fi
diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/sysinit b/packages/base/all/initrds/loader-initrd-files/src/bin/sysinit
new file mode 100755
index 00000000..216ad7e0
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/bin/sysinit
@@ -0,0 +1,156 @@
+#!/bin/sh
+############################################################
+#
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+# sysinit
+#
+# Busybox sysinit script.
+#
+############################################################
+
+# Suppress console output until baud rate is set
+exec 4>&1 1>/tmp/sysinit.out 2>&1
+restoreconsole() { cat /tmp/sysinit.out 1>&4; exec 1>&4 2>&4; >/tmp/sysinit.out; }
+trap "restoreconsole; reboot -f" EXIT
+
+
+# Mount special filesystems
+mount -t proc proc /proc
+mount -t sysfs sysfs /sys
+mount -o remount,size=1M /dev
+
+
+# Grab cmdline settings
+
+touch /etc/onl/boot-config
+tr -s " " "\n" "/etc/onl/$filename"
+ ;;
+ esac
+done
+
+
+# Populate platform-specific settings
+. /lib/platform-detect
+
+if [ ! -f /etc/onl/abort ]; then
+
+ # Tell kernel to invoke mdev when devices are added or removed
+ echo /sbin/mdev >/proc/sys/kernel/hotplug
+
+
+ # Initialize any block and net devices already present
+ ( cd /sys/class/block; for d in *; do initblockdev $d add; done )
+ if [ -d /sys/class/ubi ]; then
+ ( cd /sys/class/ubi; for d in *; do initblockdev $d add; done )
+ fi
+ ( cd /sys/class/net; for d in *; do initnetdev $d add; done )
+
+ # Initialize platform mounts
+ initmounts
+
+ # Perform recovery if necessary; reboot automatically
+ if /bin/recover; then
+ initmounts
+ else
+ restoreconsole
+ echo "Recovery failed."
+ echo "Press CR now to exit sysinit and access the loader shell."
+ echo "Otherwise, the system will reboot in 3s."
+ if read -t 3 prompt; then
+ trap - EXIT
+ exit
+ fi
+ reboot -f
+ fi
+
+
+ if [ -f /etc/issue ]; then
+ cat /etc/issue
+ fi
+
+ waitforblockdev /mnt/flash
+ sleep 1 # wait for external block devices to be mounted
+ [ ! -f /mnt/flash/boot-config ] || cat /mnt/flash/boot-config >>/etc/onl/boot-config
+
+ #
+ # Initialize the /mnt/flash/boot area.
+ #
+ mkdir -p /mnt/flash/boot
+ rm -rf /mnt/flash/boot/*
+fi
+
+
+#
+# Initialize PKI
+#
+if [ -f /sbin/init-pki ]; then
+ /sbin/init-pki
+fi
+
+
+# Parse settings
+touch /etc/onl/SWI /etc/onl/CONSOLESPEED /etc/onl/PASSWORD /etc/onl/NET /etc/onl/BOOTMODE /etc/onl/BOOTPARAMS
+while read -r l; do
+ n=${l%%=*}
+ [ "$l" = "${l#*=}" ] && v= || v="${l#*=}"
+ case $n in
+ CONSOLESPEED)
+ echo "$v" >/etc/onl/CONSOLESPEED
+ ;;
+ PASSWORD)
+ echo "$v" >/etc/onl/PASSWORD
+ ;;
+ NET*)
+ echo "$l" >>/etc/onl/NET
+ ;;
+ BOOTMODE)
+ echo "$v" >/etc/onl/BOOTMODE
+ ;;
+ *)
+ if [ -n "$n" ]; then
+ echo "$n=$v" >> /etc/onl/BOOTPARAMS
+ fi
+ ;;
+ esac
+done
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+# udhcp
+#
+############################################################
+. /lib/customize.sh
+
+kill $(cat /tmp/udhcpc.pid 2>/dev/null) 2>/dev/null
+exec busybox udhcpc -V $ONL_UDHCPC_VENDOR -p /tmp/udhcpc.pid -s /lib/udhcpc-script "$@"
diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/waitforblockdev b/packages/base/all/initrds/loader-initrd-files/src/bin/waitforblockdev
new file mode 100644
index 00000000..cea55477
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/bin/waitforblockdev
@@ -0,0 +1,36 @@
+#!/bin/sh
+############################################################
+#
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+# waitforblockdev
+#
+# Wait for a block device to appear on $1, time out after
+# 10 seconds
+#
+############################################################
+
+local i=10
+while [ $i -gt 0 ]; do
+ grep -q " "$1" " /proc/mounts && break
+ sleep 1
+ let i--
+done
+[ $i -gt 0 ] || { echo "Timed out waiting for $1"; exit 1; }
diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/waitforsysdev b/packages/base/all/initrds/loader-initrd-files/src/bin/waitforsysdev
new file mode 100755
index 00000000..db37f0f4
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/bin/waitforsysdev
@@ -0,0 +1,31 @@
+#!/bin/sh
+############################################################
+#
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+#
+#
+#
+############################################################
+#
+# waitforsysdev
+#
+# Wait for a sys device to appear (as $1), time out after
+# a specified interval (10s by default)
+#
+############################################################
+
+dev=$1; shift
+if test $# -gt 0; then
+ timeout=$1; shift
+else
+ timeout=10
+fi
+local i=$timeout
+while test $i -gt 0; do
+ find /sys/devices | grep $dev 1>/dev/null && break
+ sleep 1
+ i=$(( $i - 1 ))
+done
+[ $i -gt 0 ] || { echo "Timed out waiting for $dev"; exit 1; }
diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/wipe b/packages/base/all/initrds/loader-initrd-files/src/bin/wipe
new file mode 100644
index 00000000..f8cd1823
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/bin/wipe
@@ -0,0 +1,36 @@
+#!/bin/sh
+############################################################
+#
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+# wipe
+#
+############################################################
+
+set -e
+echo "All data on /mnt/flash will be erased; type \"yes\" and press Enter to proceed,"
+echo -n "or just press Enter to cancel: "
+read arg
+[ "${arg}" = "yes" ] || exit 1
+echo "Erasing /mnt/flash"
+cd /
+rm -rf /mnt/flash/* /mnt/flash/.[^.]* /mnt/flash/..?*
+cd /mnt/flash
+recover
diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/zcip b/packages/base/all/initrds/loader-initrd-files/src/bin/zcip
new file mode 100644
index 00000000..70a14c10
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/bin/zcip
@@ -0,0 +1,27 @@
+#!/bin/sh
+############################################################
+#
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+# zcip
+#
+############################################################
+
+exec busybox zcip "$1" /lib/zcip-script
diff --git a/packages/base/all/initrds/loader-initrd-files/src/bootmodes/swi b/packages/base/all/initrds/loader-initrd-files/src/bootmodes/swi
new file mode 100755
index 00000000..d1fa5d96
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/bootmodes/swi
@@ -0,0 +1,35 @@
+############################################################
+#
+# Bootmode: SWI
+#
+# Boot a SWI URL from the SWI BOOTPARAM value.
+#
+############################################################
+. /lib/msgs
+. /etc/onl/BOOTPARAMS
+
+if [ ! "${SWI}" ]; then
+ msg_error "No SWI specified in the boot configuration. SWI booting cannot continue."
+ # Do not continue the autoboot sequence, nothing can be resolved automatically here.
+ exit 200
+fi
+
+if [ "${SWI}" = "flash2::latest" ]; then
+ # Boot the latest (by mtime) SWI in the flash2 partition.
+ SWI=`ls /mnt/flash2/*.swi -t | head -n1`
+ if [ -z "${SWI}" ]; then
+ msg_error "No SWI available in /mnt/flash2. SWI booting cannot continue."
+ exit 200
+ fi
+fi
+
+
+#
+# The SWI setting can be a list of URLs
+#
+for url in $SWI; do
+ msg_info "Trying ${url}..."
+ timeout -t 60 boot "${url}" && exit 0
+done
+
+exit 1
diff --git a/packages/base/all/initrds/loader-initrd-files/src/etc/filesystems b/packages/base/all/initrds/loader-initrd-files/src/etc/filesystems
new file mode 100644
index 00000000..01350bea
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/etc/filesystems
@@ -0,0 +1,6 @@
+jffs2
+ubifs
+vfat
+ext4
+ext3
+ext2
diff --git a/packages/base/all/initrds/loader-initrd-files/src/etc/group b/packages/base/all/initrds/loader-initrd-files/src/etc/group
new file mode 100644
index 00000000..ed76cd85
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/etc/group
@@ -0,0 +1,2 @@
+root:x:0:
+tty:x:5:
diff --git a/packages/base/all/initrds/loader-initrd-files/src/etc/hosts b/packages/base/all/initrds/loader-initrd-files/src/etc/hosts
new file mode 100644
index 00000000..ba712fe0
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/etc/hosts
@@ -0,0 +1 @@
+127.0.0.1 localhost
diff --git a/packages/base/all/initrds/loader-initrd-files/src/etc/inittab b/packages/base/all/initrds/loader-initrd-files/src/etc/inittab
new file mode 100644
index 00000000..e2b1e3fb
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/etc/inittab
@@ -0,0 +1,12 @@
+# Run /bin/sysinit without a controlling tty so that job control
+# cannot be used to circumvent password security
+::sysinit:/bin/sysinit
+
+# Try booting automatically, start a shell if user interrupts it
+::wait:-/bin/autoboot
+::wait:-/bin/login
+::wait:/bin/umount -a -r
+::wait:/sbin/reboot -f
+
+# Try to switch to rootfs if init receives SIGHUP or SIGQUIT
+::restart:/bin/switchroot
diff --git a/packages/base/all/initrds/loader-initrd-files/src/etc/issue b/packages/base/all/initrds/loader-initrd-files/src/etc/issue
new file mode 100644
index 00000000..e69de29b
diff --git a/packages/base/all/initrds/loader-initrd-files/src/etc/mdev.conf b/packages/base/all/initrds/loader-initrd-files/src/etc/mdev.conf
new file mode 100644
index 00000000..a1773b92
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/etc/mdev.conf
@@ -0,0 +1,4 @@
+[hs]d[a-z]+[0-9]* 0:0 0660 */bin/initblockdev ${MDEV} ${ACTION:-add}
+mmcblk[0-9]+ 0:0 0660 */bin/initblockdev ${MDEV} ${ACTION:-add}
+mmcblk[0-9]+p[0-9]+ 0:0 0660 */bin/initblockdev ${MDEV} ${ACTION:-add}
+eth[0-9]+ 0:0 0660 */bin/initnetdev ${MDEV} ${ACTION:-add}
diff --git a/packages/base/all/initrds/loader-initrd-files/src/etc/passwd b/packages/base/all/initrds/loader-initrd-files/src/etc/passwd
new file mode 100644
index 00000000..eb85a552
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/etc/passwd
@@ -0,0 +1 @@
+root:x:0:0:root:/root:/bin/sh
diff --git a/packages/base/all/initrds/loader-initrd-files/src/etc/profile b/packages/base/all/initrds/loader-initrd-files/src/etc/profile
new file mode 100644
index 00000000..6a2ac05f
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/etc/profile
@@ -0,0 +1,21 @@
+#!/bin/sh
+. /lib/customize.sh
+
+PS1=${ONL_PROMPT:-"loader# "}
+
+if [ -f /etc/onl/abort ]; then
+ PS1="loader(aborted)# "
+ echo
+ echo "************************************************************"
+ echo "*** Booting cannot continue."
+ echo "***"
+ echo "*** $(cat /etc/onl/abort)"
+ echo "***"
+ echo "************************************************************"
+ echo
+fi
+
+echo
+echo "Welcome to the $ONL_SYSTEM_NAME $ONL_SYSTEM_LOADER_NAME shell."
+echo "Type 'help' for command help."
+echo
diff --git a/packages/base/all/initrds/loader-initrd-files/src/etc/rootperms b/packages/base/all/initrds/loader-initrd-files/src/etc/rootperms
new file mode 100644
index 00000000..8d76e780
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/etc/rootperms
@@ -0,0 +1,33 @@
+# See package/makedevs/README for details
+#
+# This device table is used to assign proper ownership and permissions
+# on various files. It doesn't create any device file, as it is used
+# in both static device configurations (where /dev/ is static) and in
+# dynamic configurations (where devtmpfs, mdev or udev are used).
+#
+#
+/dev d 755 0 0 - - - - -
+/tmp d 1777 0 0 - - - - -
+/etc d 755 0 0 - - - - -
+/etc/shadow f 600 0 0 - - - - -
+/etc/passwd f 644 0 0 - - - - -
+/bin/autoboot f 755 0 0 - - - - -
+/bin/boot f 755 0 0 - - - - -
+/bin/discoverbootconf f 755 0 0 - - - - -
+/bin/help f 755 0 0 - - - - -
+/bin/ifget f 755 0 0 - - - - -
+/bin/ifup f 755 0 0 - - - - -
+/bin/initblockdev f 755 0 0 - - - - -
+/bin/initnetdev f 755 0 0 - - - - -
+/bin/login f 755 0 0 - - - - -
+/bin/netconf f 755 0 0 - - - - -
+/bin/recover f 755 0 0 - - - - -
+/bin/swiinfo f 755 0 0 - - - - -
+/bin/switchroot f 755 0 0 - - - - -
+/bin/sysinit f 755 0 0 - - - - -
+/bin/udhcpc f 755 0 0 - - - - -
+/bin/waitforblockdev f 755 0 0 - - - - -
+/bin/wipe f 755 0 0 - - - - -
+/bin/zcip f 755 0 0 - - - - -
+/lib/udhcpc-script f 755 0 0 - - - - -
+/lib/zcip-script f 755 0 0 - - - - -
diff --git a/packages/base/all/initrds/loader-initrd-files/src/etc/shadow b/packages/base/all/initrds/loader-initrd-files/src/etc/shadow
new file mode 100644
index 00000000..d8eb9471
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/etc/shadow
@@ -0,0 +1 @@
+root::10933:0:99999:7:::
diff --git a/packages/base/all/initrds/loader-initrd-files/src/lib/boot1 b/packages/base/all/initrds/loader-initrd-files/src/lib/boot1
new file mode 100644
index 00000000..47348966
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/lib/boot1
@@ -0,0 +1,105 @@
+# -*- sh -*-
+############################################################
+#
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+# boot1
+#
+# Copies/mounts rootfs from swi and switches root
+#
+######################################################################
+
+mkdir -p /newroot
+umount -l /newroot 2>/dev/null || :
+
+if [ -d "${swipath}" ]; then
+ # rootfs is a directory
+ mount --bind "${swipath}/${rootfs}" /newroot
+else
+ # rootfs is a squashfs
+ echo "Booting: ${swipath}"
+ mkdir -p /newroot.lower /newroot.upper
+ umount -l /newroot.lower 2>/dev/null || :
+ umount -l /newroot.upper 2>/dev/null || :
+ rm -f /tmp/rootfs
+ uarch=`uname -m`
+
+
+ if [ "$uarch" == "ppc" ]; then
+ # Try both rootfs-ppc and rootfs-powerpc
+ for arch in ppc powerpc; do
+ unzip -pq "${swipath}" "rootfs-$arch.sqsh" >/tmp/rootfs
+ [ ! -s /tmp/rootfs ] || break
+ done
+ elif [ "$uarch" == "x86_64" ]; then
+ # Try both rootfs-amd64 and rootfs-x86_64
+ for arch in x86_64 amd64; do
+ unzip -pq "${swipath}" "rootfs-$arch.sqsh" >/tmp/rootfs
+ [ ! -s /tmp/rootfs ] || break
+ done
+ fi
+
+ if [ ! -s /tmp/rootfs ]; then
+ echo "${swipath} does not contain a rootfs image for the current architecture ($uarch). Booting cannot continue."
+ exit 1
+ fi
+ mount -t squashfs -o loop /tmp/rootfs /newroot.lower
+ mount -t tmpfs -o size=15%,mode=0755 none /newroot.upper
+ mount -t overlayfs -o lowerdir=/newroot.lower,upperdir=/newroot.upper none /newroot
+fi
+
+mkdir -p /newroot/etc/onl
+cp -R /etc/onl/* /newroot/etc/onl
+
+if [ -f /etc/fw_env.config ]; then
+ cat /etc/fw_env.config >/newroot/etc/fw_env.config
+fi
+
+unzip -oq "${swipath}" swi-data.tar.gz -d /tmp
+
+# Install any SWI data packages.
+if [ -s /tmp/swi-data.tar.gz ]; then
+ echo "Installing SWI data into /boot..."
+ tar -C /newroot/boot -xzf /tmp/swi-data.tar.gz
+else
+ echo "No SWI data to install."
+fi
+
+# If there is a SWI version file put it in /etc/onl/swi_version
+unzip -oq "${swipath}" version -d /tmp
+if [ -f /tmp/version ]; then
+ cp /tmp/version /newroot/etc/onl/swi_version
+ fi
+
+#
+# The file /lib/boot-custom can be provided by customized builds to
+# add functionality before the root is switched.
+#
+if [ -f /lib/boot-custom ]; then
+ . /lib/boot-custom
+fi
+
+echo "Switching rootfs" # limit 16 chars since serial buffer is not flushed
+kill -QUIT 1 # exec /bin/switchroot as PID 1
+sleep 30
+
+# Local variables:
+# sh-basic-offset: 4
+# End:
diff --git a/packages/base/all/initrds/loader-initrd-files/src/lib/customize.sh b/packages/base/all/initrds/loader-initrd-files/src/lib/customize.sh
new file mode 100644
index 00000000..8bd74bc3
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/lib/customize.sh
@@ -0,0 +1,11 @@
+LOADER_LOADER_NAME="Loader"
+LOADER_PROMPT="loader# "
+LOADER_UDHCPC_VENDOR="onl"
+LOADER_SYSTEM_NAME="Open Network Linux"
+
+if [ -f /etc/onl/loader/versions.sh ]; then
+ . /etc/onl/loader/versions.sh
+fi
+
+
+
diff --git a/packages/base/all/initrds/loader-initrd-files/src/lib/kdump b/packages/base/all/initrds/loader-initrd-files/src/lib/kdump
new file mode 100644
index 00000000..aad33bd5
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/lib/kdump
@@ -0,0 +1,39 @@
+#-*-sh-*-
+############################################################
+#
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+# kdump
+#
+# TODO: turn off the phys to prevent network loops?
+# TODO: trigger watchdog?
+#
+############################################################
+
+waitforblockdev /mnt/flash || exit
+echo "Entered kernel crash handler"
+if ! vmcore-dmesg /proc/vmcore >/tmp/kernelcrash; then
+ echo "vmcore-dmesg failed; cannot dump kernel crash log"
+ return
+fi
+mkdir -p /mnt/flash/debug
+cp /tmp/kernelcrash /mnt/flash/debug/ && echo "Wrote /mnt/flash/debug/kernelcrash"
+echo "Last 50 lines of kernel crash log:"
+tail -50 /mnt/flash/debug/kernelcrash
diff --git a/packages/base/all/initrds/loader-initrd-files/src/lib/loader-functions b/packages/base/all/initrds/loader-initrd-files/src/lib/loader-functions
new file mode 100644
index 00000000..45d491a0
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/lib/loader-functions
@@ -0,0 +1,212 @@
+# -*- sh -*-
+############################################################
+#
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+#
+# loader-functions
+#
+# Loader support routines.
+#
+############################################################
+
+##############################
+#
+# dsc_dhcp_boot INTF
+#
+# Grovel through the dhcp lease (udhcp) for a boot file entry.
+# Return '0' for success (discovery can cease)
+# Return '2' for undetermined (continue discovery)
+# Anything else is an error
+#
+##############################
+
+dsc_dhcp_boot()
+{
+ local intf macaddr bootservers
+ intf=$1; shift
+ macaddr=$1; shift
+ bootservers=$(cat /tmp/udhcpc.boot_file 2>/dev/null)
+ case "$bootservers" in
+ SWI=*)
+ echo "Discovered boot configuration from DHCP"
+ echo "${bootservers#SWI=}" | sed "s/__macaddr__/${macaddr}/g;s/__platform__/${platform}/g" >/etc/onl/SWI
+ echo "NETDEV=${intf}" >/etc/onl/NET
+ echo "NETAUTO=dhcp" >>/etc/onl/NET
+ return 0
+ ;;
+ esac
+
+ # else, nothing to see here
+ return 2
+}
+
+##############################
+#
+# dsc_swi_manifest
+#
+# Download a SWI manifest and its components.
+# Return '0' for success (discovery can cease)
+# Return '2' for undetermined (continue discovery)
+# Anything else is an error
+#
+# Enviromnent:
+# $swi_md5_orig
+# $cfg_md5_orig
+#
+##############################
+
+dsc_swi_manifest()
+{
+ local macaddr neigh
+ macaddr=$1; shift
+ neigh=$1; shift
+
+ local url
+ local swi_url_mf swi_md5_new swi_md5_dl
+ local cfg_url_mf cfg_md5_new cfg_md5_dl
+
+ rm -f /tmp/mf0 /tmp/swi0 /tmp/cfg0
+
+ url="http://${neigh}/ztn/switch/${macaddr}/switch_light_manifest"
+ echo "Trying $url"
+ wget -O /tmp/mf0 "$url" 1>/dev/null 2>&1
+ test $? -eq 0 || return 2
+
+ echo "Discovered ONL manifest from neighbor discovery ($neigh)"
+ swi_url_mf=$(jq -M -r '.swi_url' < /tmp/mf0)
+ test "$swi_url_mf" || return 2
+
+ # see if there is a locally-cached SWI
+ swi_md5_new=$(jq -M -r '.swi_md5' < /tmp/mf0)
+ if [ "$swi_md5_new" = "$swi_md5_orig" ]; then
+ echo "Using cached ZTN SWI ($swi_url_orig)"
+ else
+ echo "Downloading new ZTN SWI $swi_url_mf"
+ wget -O /tmp/swi0 "$swi_url_mf" 1>/dev/null 2>&1
+ test $? -eq 0 || return 2
+ swi_md5_dl=$(md5sum /tmp/swi0 | awk '{print $1}')
+ if [ "$swi_md5_dl" != "$swi_md5_new" ]; then
+ echo "MD5 mismatch in downloaded SWI"
+ return 2
+ fi
+ fi
+
+ # Try to get a startup-config too
+ cfg_url_mf=$(jq -M -r '.startup_config_url' < /tmp/mf0)
+ if [ "$cfg_url_mf" ]; then
+ cfg_md5_new=$(jq -M -r '.startup_config_md5' < /tmp/mf0)
+ if [ "$cfg_md5_orig" = "$cfg_md5_new" ]; then
+ echo "Using cached ZTN startup-config"
+ else
+ echo "Downloading new startup-config $cfg_url_mf"
+ wget -O /tmp/cfg0 "$cfg_url_mf" 1>/dev/null 2>&1
+ test $? -eq 0 || return 2
+ cfg_md5_dl=$(md5sum /tmp/cfg0 | awk '{print $1}')
+ if [ "$cfg_md5_dl" != "$cfg_md5_new" ]; then
+ echo "MD5 mismatch in downloaded startup-config"
+ return 2
+ fi
+ fi
+ fi
+
+ if [ -f /tmp/swi0 ]; then
+ echo "Caching ZTN SWI $swi_url_mf --> /mnt/flash2/.ztn-onl.swi"
+ rm -f /mnt/flash2/.ztn-onl.swi
+ mv /tmp/swi0 /mnt/flash2/.ztn-onl.swi
+ fi
+ echo "$swi_url_orig" > /etc/onl/SWI
+ echo "$swi_url_mf" > /mnt/flash2/.ztn-onl.swi.url
+
+ # startup-config is optional here
+ if [ -f /tmp/cfg0 ]; then
+ echo "Caching ZTN startup-config $cfg_url_mf --> /mnt/flash2/.ztn-startup-config"
+ rm -f /mnt/flash2/.ztn-startup-config
+ mv /tmp/cfg0 /mnt/flash2/.ztn-startup-config
+ fi
+ if [ "$cfg_url_mf" ]; then
+ echo "$cfg_url_mf" > /mnt/flash2/.ztn-startup-config.url
+ else
+ rm -f /mnt/flash2/.ztn-startup-config /mnt/flash2/.ztn-startup-config.url
+ fi
+
+ return 0
+}
+
+##############################
+#
+# dsc_dsnssd
+#
+# Try to discover switch config (net and/or SWI) from DNS-SD
+#
+##############################
+
+dsc_dnssd()
+{
+ local macaddr dns
+ macaddr=$1; shift
+ dns=$1; shift
+
+ local txt word key val
+
+ echo "Trying $dns"
+ txt=$(dig +short +time=5 +tries=1 @$dns -p5353 ${macaddr}._slconfig._udp.local TXT)
+ test $? -eq 0 || return 2
+
+ echo "Discovered boot configuration from DNS-SD"
+ cp /dev/null /etc/onl/NET
+ for word in $txt; do
+ # words may be quoted
+ word=$(expr "$word" : '["]\?\(.*[^"]\)["]\?')
+ case "$word" in
+ *=*)
+ key=${word%%=*}; val=${word#$key=}
+ ;;
+ *)
+ key=$word; val=
+ ;;
+ esac
+ case "$key" in
+ SWI)
+ echo "$val" >/etc/onl/SWI
+ ;;
+ NET*)
+ echo "$val" >> /etc/onl/NET
+ ;;
+ FLASH)
+ echo "Getting flash::${val}..."
+ mkdir -p /tmp/flash
+ cd /tmp/flash && wget "$val"
+
+ mv /tmp/flash/* /mnt/flash
+ rmdir /tmp/flash
+ ;;
+ esac
+ done
+
+ # valid DNS-SD config for this platform, stop here
+ return 0
+}
+
+# Local variables:
+# mode: sh
+# indent-tabs-mode: nil
+# sh-basic-offset: 4
+# End:
diff --git a/packages/base/all/initrds/loader-initrd-files/src/lib/msgs b/packages/base/all/initrds/loader-initrd-files/src/lib/msgs
new file mode 100644
index 00000000..b6a416cc
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/lib/msgs
@@ -0,0 +1,25 @@
+# -*- sh -*-
+############################################################
+#
+# Message logging.
+#
+############################################################
+
+msg_info()
+{
+ echo "[ $@ ]"
+}
+
+msg_error()
+{
+ echo
+ echo "************************************************************"
+ echo " ERROR "
+ echo
+ echo " $@"
+ echo
+ echo "************************************************************"
+ echo
+ sleep 1
+}
+
diff --git a/packages/base/all/initrds/loader-initrd-files/src/lib/platform-detect b/packages/base/all/initrds/loader-initrd-files/src/lib/platform-detect
new file mode 100644
index 00000000..446b3c5c
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/lib/platform-detect
@@ -0,0 +1,87 @@
+#!/bin/sh
+############################################################
+#
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+# platform-detect
+#
+# This script attempts to detect the current platform.
+#
+# Under normal circumstances the platform installer
+# will have already set the platform in the boot arguments.
+#
+# This is a fallback for older platforms, corrupt
+# boot arguments, or possible detection of misconfiguration.
+#
+############################################################
+. /lib/msgs
+
+platform_priority_detect() {
+ if [ ! -f /etc/onl/platform ]; then
+ for d in `find /lib/platform-config -name $1`; do
+ chmod +x ${d}
+ ${d}
+ if [ -f /etc/onl/platform ]; then
+ echo "platform auto-detect: $(cat /etc/onl/platform)"
+ break
+ fi
+ done
+ fi
+}
+
+############################################################
+#
+# Priority0 detection.
+#
+# Any platforms that want to preempt other platform detection
+# routines should be named detect0.sh
+#
+platform_priority_detect detect0.sh
+
+############################################################
+#
+# Normal priority detection.
+platform_priority_detect detect.sh
+
+############################################################
+#
+# Voluntary deprioritization wrt existing platforms.
+platform_priority_detect detect1.sh
+
+if [ ! -f /etc/onl/platform ]; then
+ echo "unknown" > /etc/onl/platform
+fi
+
+touch /etc/onl/net /etc/onl/block /etc/onl/mounts
+
+platform="$(cat /etc/onl/platform)"
+
+if [ -d /lib/platform-config/${platform} ]; then
+ # Grab and source the platform boot configuration file
+ x=/lib/platform-config/${platform}/onl/boot/${platform}
+ if [ -f $x ]; then
+ . $x
+ else
+ echo "The platform boot configuration for the current platform is broken, invalid, or missing." > /etc/onl/abort
+ fi
+else
+ echo "The current platform (${platform}) is not supported in this version." > /etc/onl/abort
+fi
+
diff --git a/packages/base/all/initrds/loader-initrd-files/src/lib/udhcpc-script b/packages/base/all/initrds/loader-initrd-files/src/lib/udhcpc-script
new file mode 100755
index 00000000..cd0a62ea
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/lib/udhcpc-script
@@ -0,0 +1,41 @@
+#!/bin/sh
+############################################################
+#
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+# udhcpc-script
+#
+############################################################
+
+[ "${interface}" ] || exit
+
+case "$1" in
+ deconfig)
+ ifconfig ${interface} 0.0.0.0
+ ;;
+ renew|bound)
+ ifconfig ${interface} ${ip} netmask ${subnet}
+ [ ! "${router}" ] || ip route add default via ${router}
+ : >/etc/resolv.conf
+ [ ! "${domain}" ] || echo "search ${domain}" >>/etc/resolv.conf
+ [ ! "${dns}" ] || echo "nameserver ${dns}" >>/etc/resolv.conf
+ [ ! "${boot_file}" ] || echo "${boot_file}" >/tmp/udhcpc.boot_file
+ ;;
+esac
diff --git a/packages/base/all/initrds/loader-initrd-files/src/lib/zcip-script b/packages/base/all/initrds/loader-initrd-files/src/lib/zcip-script
new file mode 100644
index 00000000..00e2b8e7
--- /dev/null
+++ b/packages/base/all/initrds/loader-initrd-files/src/lib/zcip-script
@@ -0,0 +1,36 @@
+#!/bin/sh
+############################################################
+#
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+# zcip-script
+#
+############################################################
+
+[ "${interface}" ] || exit
+
+case "$1" in
+ deconfig)
+ ifconfig ${interface}:0 down
+ ;;
+ config)
+ ifconfig ${interface}:0 ${ip} netmask 255.255.0.0
+ ;;
+esac
diff --git a/packages/base/all/vendor-config-onl/Makefile b/packages/base/all/vendor-config-onl/Makefile
new file mode 100644
index 00000000..003238cf
--- /dev/null
+++ b/packages/base/all/vendor-config-onl/Makefile
@@ -0,0 +1 @@
+include $(ONL)/make/pkg.mk
\ No newline at end of file
diff --git a/packages/base/all/vendor-config-onl/PKG.yml b/packages/base/all/vendor-config-onl/PKG.yml
new file mode 100644
index 00000000..3122ba51
--- /dev/null
+++ b/packages/base/all/vendor-config-onl/PKG.yml
@@ -0,0 +1,15 @@
+packages:
+ - name: onl-vendor-config-onl
+ depends: python-yaml
+ version: 1.0.0
+ arch: all
+ copyright: Copyright 2013, 2014, 2015 Big Switch Networks
+ maintainer: support@bigswitch.com
+ summary: ONL Base Configuration Package
+
+ files:
+ src/python/onl : $PY_INSTALL/onl
+ src/init.d : /etc/init.d
+ src/bin : /usr/bin
+
+ changelog: Changes
diff --git a/packages/base/all/vendor-config-onl/src/bin/onl-platform-show b/packages/base/all/vendor-config-onl/src/bin/onl-platform-show
new file mode 100755
index 00000000..721f861c
--- /dev/null
+++ b/packages/base/all/vendor-config-onl/src/bin/onl-platform-show
@@ -0,0 +1,4 @@
+#!/usr/bin/python
+from onl.platform.current import OnlPlatform
+print OnlPlatform()
+
diff --git a/packages/base/all/vendor-config-onl/src/init.d/onl-platform-baseconf b/packages/base/all/vendor-config-onl/src/init.d/onl-platform-baseconf
new file mode 100755
index 00000000..718fa281
--- /dev/null
+++ b/packages/base/all/vendor-config-onl/src/init.d/onl-platform-baseconf
@@ -0,0 +1,17 @@
+#!/usr/bin/python
+
+### BEGIN INIT INFO
+# Provides: onl-platform-baseconf
+# Required-Start:
+# Required-Stop:
+# Default-Start: S
+# Default-Stop:
+# Short-Description: Set up ONL Platform
+### END INIT INFO
+
+from onl.platform.baseconfig import baseconfig
+
+baseconfig()
+
+
+
diff --git a/packages/base/all/vendor-config-onl/src/python/onl/__init__.py b/packages/base/all/vendor-config-onl/src/python/onl/__init__.py
new file mode 100644
index 00000000..c71a523a
--- /dev/null
+++ b/packages/base/all/vendor-config-onl/src/python/onl/__init__.py
@@ -0,0 +1,9 @@
+############################################################
+#
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+#
+#
+#
+############################################################
diff --git a/packages/base/all/vendor-config-onl/src/python/onl/platform/__init__.py b/packages/base/all/vendor-config-onl/src/python/onl/platform/__init__.py
new file mode 100644
index 00000000..c71a523a
--- /dev/null
+++ b/packages/base/all/vendor-config-onl/src/python/onl/platform/__init__.py
@@ -0,0 +1,9 @@
+############################################################
+#
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+#
+#
+#
+############################################################
diff --git a/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py b/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py
new file mode 100644
index 00000000..9ee22bd8
--- /dev/null
+++ b/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py
@@ -0,0 +1,249 @@
+#!/usr/bin/python
+############################################################
+#
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+#
+#
+#
+############################################################
+
+import pprint
+import yaml
+import json
+import os
+
+class OnlInfoObject(object):
+ DEFAULT_INDENT=" "
+
+ def __init__(self, d, klass=None):
+ self._data = d
+ if klass:
+ for (m,n) in klass.__dict__.iteritems():
+ if m == m.upper():
+ setattr(self, m, None)
+
+ for (k,v) in d.iteritems():
+ for (m,n) in klass.__dict__.iteritems():
+ if n == k:
+ setattr(self, m, v);
+ break
+
+ def __getattr__(self, name):
+ if name in self._data:
+ return self._data[name]
+ else:
+ return None
+
+ def __str__(self, indent=DEFAULT_INDENT):
+ """String representation of the information container."""
+ return OnlInfoObject.string(self._data, indent)
+
+ @staticmethod
+ def string(d, indent=DEFAULT_INDENT):
+ return "\n".join( sorted("%s%s: %s" % (indent,k,v) for k,v in d.iteritems() if not k.startswith('_') and d[k] is not None) )
+
+
+############################################################
+#
+# System-specific information keys.
+# These represent information about a particular box.
+#
+############################################################
+
+class OnieInfo(object):
+ PRODUCT_NAME='Product Name'
+ PART_NUMBER='Part Number'
+ SERIAL_NUMBER='Serial Number'
+ MAC_ADDRESS='MAC'
+ MAC_RANGE='MAC Range'
+ MANUFACTURER='Manufacturer'
+ MANUFACTURE_DATE='Manufacture Date'
+ VENDOR='Vendor'
+ PLATFORM_NAME='Platform Name'
+ DEVICE_VERSION='Device Version'
+ LABEL_REVISION='Label Revision'
+ COUNTRY_CODE='Country Code'
+ DIAG_VERSION='Diag Version'
+ SERVICE_TAG='Service Tag'
+ ONIE_VERSION='ONIE Version'
+ oids = {
+ PRODUCT_NAME : '.1',
+ PART_NUMBER : '.2',
+ SERIAL_NUMBER : '.3',
+ MAC_ADDRESS : '.4',
+ MAC_RANGE : '.5',
+ MANUFACTURER : '.6',
+ MANUFACTURE_DATE : '.7',
+ VENDOR : '.8',
+ PLATFORM_NAME : '.9',
+ DEVICE_VERSION : '.10',
+ LABEL_REVISION : '.11',
+ COUNTRY_CODE : '.12',
+ DIAG_VERSION : '.13',
+ SERVICE_TAG : '.14',
+ ONIE_VERSION : '.15',
+ }
+
+
+############################################################
+#
+# ONL Platform Base
+# Baseclass for all OnlPlatform objects.
+#
+############################################################
+class OnlPlatformBase(object):
+
+ CONFIG_DIR='/lib/platform-config'
+ CURRENT_DIR=os.path.join(CONFIG_DIR, 'current')
+
+ def __init__(self):
+ self.add_info_json("onie_info", "%s/onie-info.json" % self.basedir_onl(), OnieInfo,
+ required=False)
+ self.add_info_json("platform_info", "%s/platform-info.json" % self.basedir_onl(),
+ required=False)
+
+ def add_info_dict(self, name, d, klass=None):
+ setattr(self, name, OnlInfoObject(d, klass))
+
+ def add_info_json(self, name, f, klass=None, required=True):
+ if os.path.exists(f):
+ d = json.load(file(f))
+ self.add_info_dict(name, d, klass)
+ elif required:
+ raise RuntimeError("A required system file (%s) is missing." % f)
+
+
+
+ def load_configs(self, reload=False):
+ if reload or hasattr(self, 'configs') is False:
+ self.configs = {}
+ for subsys in os.listdir(self.basedir()):
+ cpath = os.path.join(self.basedir(), subsys, "configs")
+ if os.path.isdir(cpath):
+ for config in os.listdir(cpath):
+ with file(os.path.join(cpath, config)) as f:
+ if not subsys in self.configs:
+ self.configs[subsys] = {}
+ self.configs[subsys][config] = json.load(f)
+
+ def basedir(self):
+ return os.path.join(self.CONFIG_DIR, self.platform())
+
+ def basedir_onl(self):
+ return os.path.join(self.basedir(), 'onl')
+
+ def baseconfig(self):
+ return True
+
+ def manufacturer(self):
+ raise Exception("Manufacturer is not set.")
+
+ def model(self):
+ raise Exception("Model is not set.")
+
+ def platform(self):
+ raise Exception("Platform is not set.")
+
+ def description(self):
+ return "%s %s (%s)" % (self.manufacturer(), self.model(),
+ self.platform())
+
+ def serialnumber(self):
+ return self.onie_info.SERIAL_NUMBER
+
+ def hw_description(self):
+ return "%s (%s)" % (self.onie_info.PRODUCT_NAME,
+ self.onie_info.PART_NUMBER)
+
+
+ # ONL Platform Information Tree
+ def opit_oid(self):
+ return "1.3.6.1.4.1.37538.2.1000"
+
+ # ONL Platform Information General Tree
+ def opitg_oid(self):
+ return self.opit_oid() + ".1"
+
+ # ONL Platform Information General Sys Tree
+ def opitg_sys_oid(self):
+ return self.opitg_oid() + ".1"
+
+ # ONL Platform Information Vendor Tree
+ def opitv_oid(self):
+ return self.opit_oid() + ".2"
+
+ def sys_oid_vendor(self):
+ return ".37538"
+
+ def sys_oid_platform(self):
+ raise Exception("sys_oid_platform() is not set.")
+
+ def sys_object_id(self):
+ return ( self.opitv_oid() +
+ self.sys_oid_vendor() +
+ self.sys_oid_platform());
+
+
+ def new_device(self, driver, addr, bus, devdir):
+ if not os.path.exists(os.path.join(bus, devdir)):
+ try:
+ with open("%s/new_device" % bus, "w") as f:
+ f.write("%s 0x%x\n" % (driver, addr))
+ except Exception, e:
+ print "Unexpected error initialize device %s:0x%x:%s: %s" % (driver, addr, bus, e)
+ else:
+ print("Device %s:%x:%s already exists." % (driver, addr, bus))
+
+ def new_devices(self, new_device_list):
+ for (driver, addr, bus, devdir) in new_device_list:
+ self.new_device(driver, addr, bus, devdir)
+
+ def new_i2c_device(self, driver, addr, bus_number):
+ bus = '/sys/bus/i2c/devices/i2c-%d' % bus_number
+ devdir = "%d-%4.4x" % (bus_number, addr)
+ return self.new_device(driver, addr, bus, devdir)
+
+ def new_i2c_devices(self, new_device_list):
+ for (driver, addr, bus_number) in new_device_list:
+ self.new_i2c_device(driver, addr, bus_number)
+
+ def ifnumber(self):
+ # The default assumption for any platform
+ # is ma1 and lo
+ return 2
+
+ def __str__(self):
+ s = """Manufacturer: %s
+Model: %s
+Platform: %s
+Description: %s
+System Object Id: %s
+System Information:
+%s
+%s
+""" % (
+ self.manufacturer(),
+ self.model(),
+ self.platform(),
+ self.description(),
+ self.sys_object_id(),
+ str(self.onie_info),
+ str(self.platform_info),
+ )
+
+
+ if hasattr(self, 'warning'):
+ s += """
+
+Warning: %s
+
+""" % (self.warning())
+ return s
+
+
+
+
+
+
diff --git a/packages/base/all/vendor-config-onl/src/python/onl/platform/baseconfig.py b/packages/base/all/vendor-config-onl/src/python/onl/platform/baseconfig.py
new file mode 100644
index 00000000..2aec8f0b
--- /dev/null
+++ b/packages/base/all/vendor-config-onl/src/python/onl/platform/baseconfig.py
@@ -0,0 +1,66 @@
+############################################################
+#
+# Platform Base Configuration
+#
+############################################################
+import sys
+import os
+from onl.platform.base import OnlPlatformBase
+from onl.platform.current import OnlPlatform
+import shutil
+
+def msg(s, fatal=False):
+ sys.stderr.write(s)
+ sys.stderr.flush()
+ if fatal:
+ sys.exit(1)
+
+def baseconfig():
+
+ platform=OnlPlatform()
+
+ msg("Setting up base ONL platform configuration for %s...\n" %
+ platform.platform())
+
+ if os.path.exists(OnlPlatform.CURRENT_DIR):
+ os.unlink(OnlPlatform.CURRENT_DIR)
+
+ os.symlink(platform.basedir(), OnlPlatform.CURRENT_DIR)
+
+ DEB_GNU_HOST_TYPE = None
+ HOST_TYPES = [ 'powerpc-linux-gnu',
+ 'i486-linux-gnu',
+ 'i386-linux-gnu',
+ 'x86_64-linux-gnu' ]
+
+ for ht in HOST_TYPES:
+ if os.path.exists('/lib/%s' % ht):
+ DEB_GNU_HOST_TYPE=ht
+ break
+
+ if DEB_GNU_HOST_TYPE is None:
+ msg("Could not determine the current host type.\n", fatal=True)
+
+ DEFAULT_ONLP_LIB = "/lib/%s/libonlp-platform.so" % DEB_GNU_HOST_TYPE
+ PLATFORM_ONLP_LIB = "%s/lib/libonlp-%s.so" % (platform.basedir_onl(), platform.platform())
+
+ if os.path.exists(PLATFORM_ONLP_LIB):
+ if os.path.exists(DEFAULT_ONLP_LIB):
+ os.unlink(DEFAULT_ONLP_LIB)
+ os.symlink(PLATFORM_ONLP_LIB, DEFAULT_ONLP_LIB)
+
+ ONLPDUMP = "%s/bin/onlpdump" % (platform.basedir_onl())
+
+ if not platform.baseconfig():
+ msg("*** platform class baseconfig failed.\n", fatal=True)
+
+ if os.path.exists(ONLPDUMP):
+ os.system("%s -i > %s/oids" % (ONLPDUMP,platform.basedir_onl()))
+ os.system("%s -o -j > %s/onie-info.json" % (ONLPDUMP, platform.basedir_onl()))
+ os.system("%s -x -j > %s/platform-info.json" % (ONLPDUMP, platform.basedir_onl()))
+
+ msg("Setting up base platform configuration for %s: done\n" %
+ platform.platform())
+
+
+
diff --git a/packages/base/all/vendor-config-onl/src/python/onl/platform/current.py b/packages/base/all/vendor-config-onl/src/python/onl/platform/current.py
new file mode 100644
index 00000000..68606154
--- /dev/null
+++ b/packages/base/all/vendor-config-onl/src/python/onl/platform/current.py
@@ -0,0 +1,33 @@
+#!/usr/bin/python
+############################################################
+#
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+#
+#
+#
+############################################################
+#
+# This file provides the container for the
+# platform-specific class provided by the files in the
+# platform-config packages.
+#
+############################################################
+import importlib
+
+def import_subsystem_platform_class(subsystem='onl', klass='OnlPlatform'):
+ # Determine the current platform name.
+ with open("/etc/onl/platform", 'r') as f:
+ platform=f.read().strip()
+
+ platform_module = platform.replace('-', '_')
+
+ # Import the platform module
+ m = importlib.import_module('%s.platform.%s' % (subsystem, platform_module))
+
+ return getattr(m, '%s_%s' % (klass, platform_module))
+
+
+OnlPlatform = import_subsystem_platform_class()
+
diff --git a/packages/base/all/vendor-config-onl/src/python/onl/platform/main.py b/packages/base/all/vendor-config-onl/src/python/onl/platform/main.py
new file mode 100644
index 00000000..dde3be48
--- /dev/null
+++ b/packages/base/all/vendor-config-onl/src/python/onl/platform/main.py
@@ -0,0 +1,24 @@
+#!/usr/bin/python
+############################################################
+#
+# Common commandline main implementation for platform
+# testing.
+#
+############################################################
+import argparse
+
+def main(platform):
+
+ ap = argparse.ArgumentParser(description="ONL Platform tool.")
+
+ ap.add_argument("--info", action='store_true')
+ ap.add_argument("--env", action='store_true')
+
+ ops = ap.parse_args()
+
+ if ops.info:
+ print platform
+
+ if ops.env:
+ print platform.get_environment()
+
diff --git a/packages/base/amd64/faultd/.gitignore b/packages/base/amd64/faultd/.gitignore
new file mode 100644
index 00000000..8b137891
--- /dev/null
+++ b/packages/base/amd64/faultd/.gitignore
@@ -0,0 +1 @@
+
diff --git a/packages/base/amd64/faultd/Makefile b/packages/base/amd64/faultd/Makefile
new file mode 100644
index 00000000..003238cf
--- /dev/null
+++ b/packages/base/amd64/faultd/Makefile
@@ -0,0 +1 @@
+include $(ONL)/make/pkg.mk
\ No newline at end of file
diff --git a/packages/base/amd64/faultd/PKG.yml b/packages/base/amd64/faultd/PKG.yml
new file mode 100644
index 00000000..13dbec15
--- /dev/null
+++ b/packages/base/amd64/faultd/PKG.yml
@@ -0,0 +1,5 @@
+!include $ONL/packages/base/any/faultd/APKG.yml ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu
+
+
+
+
diff --git a/packages/base/amd64/faultd/builds/.gitignore b/packages/base/amd64/faultd/builds/.gitignore
new file mode 100644
index 00000000..d3be4daa
--- /dev/null
+++ b/packages/base/amd64/faultd/builds/.gitignore
@@ -0,0 +1,2 @@
+faultd.mk
+faultd-module.mk
diff --git a/packages/base/amd64/faultd/builds/Makefile b/packages/base/amd64/faultd/builds/Makefile
new file mode 100644
index 00000000..aba3104e
--- /dev/null
+++ b/packages/base/amd64/faultd/builds/Makefile
@@ -0,0 +1,3 @@
+include $(ONL)/make/config.amd64.mk
+include $(ONL)/packages/base/any/faultd/builds/Makefile
+
diff --git a/packages/base/amd64/initrds/loader/Makefile b/packages/base/amd64/initrds/loader/Makefile
new file mode 100644
index 00000000..003238cf
--- /dev/null
+++ b/packages/base/amd64/initrds/loader/Makefile
@@ -0,0 +1 @@
+include $(ONL)/make/pkg.mk
\ No newline at end of file
diff --git a/packages/base/amd64/initrds/loader/PKG.yml b/packages/base/amd64/initrds/loader/PKG.yml
new file mode 100644
index 00000000..9badcf4a
--- /dev/null
+++ b/packages/base/amd64/initrds/loader/PKG.yml
@@ -0,0 +1 @@
+!include $ONL/packages/base/any/initrds/loader/APKG.yml ARCH=amd64
diff --git a/packages/base/amd64/initrds/loader/builds/.gitignore b/packages/base/amd64/initrds/loader/builds/.gitignore
new file mode 100644
index 00000000..1b4a5fd6
--- /dev/null
+++ b/packages/base/amd64/initrds/loader/builds/.gitignore
@@ -0,0 +1,3 @@
+loader-rootfs
+buildroot-makedevs
+manifest.json
diff --git a/packages/base/amd64/initrds/loader/builds/Makefile b/packages/base/amd64/initrds/loader/builds/Makefile
new file mode 100644
index 00000000..34302324
--- /dev/null
+++ b/packages/base/amd64/initrds/loader/builds/Makefile
@@ -0,0 +1,2 @@
+include $(ONL)/make/config.amd64.mk
+include $(ONL)/packages/base/any/initrds/loader/builds/Makefile
diff --git a/packages/base/amd64/onlp/Makefile b/packages/base/amd64/onlp/Makefile
new file mode 100644
index 00000000..003238cf
--- /dev/null
+++ b/packages/base/amd64/onlp/Makefile
@@ -0,0 +1 @@
+include $(ONL)/make/pkg.mk
\ No newline at end of file
diff --git a/packages/base/amd64/onlp/PKG.yml b/packages/base/amd64/onlp/PKG.yml
new file mode 100644
index 00000000..89193a43
--- /dev/null
+++ b/packages/base/amd64/onlp/PKG.yml
@@ -0,0 +1,2 @@
+!include $ONL/packages/base/any/onlp/APKG.yml ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu
+
diff --git a/packages/base/amd64/onlp/builds/.gitignore b/packages/base/amd64/onlp/builds/.gitignore
new file mode 100644
index 00000000..d850afd1
--- /dev/null
+++ b/packages/base/amd64/onlp/builds/.gitignore
@@ -0,0 +1 @@
+libonlp-module.mk
diff --git a/packages/base/amd64/onlp/builds/Makefile b/packages/base/amd64/onlp/builds/Makefile
new file mode 100644
index 00000000..1a15e2fe
--- /dev/null
+++ b/packages/base/amd64/onlp/builds/Makefile
@@ -0,0 +1,3 @@
+DIRECTORIES := onlp-platform-defaults onlp-platform onlp
+include $(ONL)/make/subdirs.mk
+
diff --git a/packages/base/amd64/onlp/builds/onlp-platform-defaults/.gitignore b/packages/base/amd64/onlp/builds/onlp-platform-defaults/.gitignore
new file mode 100644
index 00000000..4e86ab53
--- /dev/null
+++ b/packages/base/amd64/onlp/builds/onlp-platform-defaults/.gitignore
@@ -0,0 +1 @@
+libonlp-platform-defaults-module.mk
diff --git a/packages/base/amd64/onlp/builds/onlp-platform-defaults/Makefile b/packages/base/amd64/onlp/builds/onlp-platform-defaults/Makefile
new file mode 100644
index 00000000..e3ae5051
--- /dev/null
+++ b/packages/base/amd64/onlp/builds/onlp-platform-defaults/Makefile
@@ -0,0 +1,2 @@
+include $(ONL)/make/config.amd64.mk
+include $(ONL)/packages/base/any/onlp/builds/onlp-platform-defaults/Makefile
diff --git a/packages/base/amd64/onlp/builds/onlp-platform/.gitignore b/packages/base/amd64/onlp/builds/onlp-platform/.gitignore
new file mode 100644
index 00000000..8979873a
--- /dev/null
+++ b/packages/base/amd64/onlp/builds/onlp-platform/.gitignore
@@ -0,0 +1 @@
+libonlp-platform-module.mk
diff --git a/packages/base/amd64/onlp/builds/onlp-platform/Makefile b/packages/base/amd64/onlp/builds/onlp-platform/Makefile
new file mode 100644
index 00000000..88a9ebad
--- /dev/null
+++ b/packages/base/amd64/onlp/builds/onlp-platform/Makefile
@@ -0,0 +1,3 @@
+include $(ONL)/make/config.amd64.mk
+include $(ONL)/packages/base/any/onlp/builds/onlp-platform/Makefile
+
diff --git a/packages/base/amd64/onlp/builds/onlp/Makefile b/packages/base/amd64/onlp/builds/onlp/Makefile
new file mode 100644
index 00000000..0e5518bd
--- /dev/null
+++ b/packages/base/amd64/onlp/builds/onlp/Makefile
@@ -0,0 +1,3 @@
+include $(ONL)/make/config.amd64.mk
+include $(ONL)/packages/base/any/onlp/builds/onlp/Makefile
+
diff --git a/packages/base/amd64/rootfs/.gitignore b/packages/base/amd64/rootfs/.gitignore
new file mode 100644
index 00000000..b2918169
--- /dev/null
+++ b/packages/base/amd64/rootfs/.gitignore
@@ -0,0 +1 @@
+*.d/
diff --git a/packages/base/amd64/rootfs/Makefile b/packages/base/amd64/rootfs/Makefile
new file mode 100644
index 00000000..dc1e7b86
--- /dev/null
+++ b/packages/base/amd64/rootfs/Makefile
@@ -0,0 +1 @@
+include $(ONL)/make/pkg.mk
diff --git a/packages/base/amd64/rootfs/PKG.yml b/packages/base/amd64/rootfs/PKG.yml
new file mode 100644
index 00000000..f7a80d0b
--- /dev/null
+++ b/packages/base/amd64/rootfs/PKG.yml
@@ -0,0 +1 @@
+!include $ONL/packages/base/any/rootfs/APKG.yml ARCH=amd64
diff --git a/packages/base/amd64/rootfs/builds/.gitignore b/packages/base/amd64/rootfs/builds/.gitignore
new file mode 100644
index 00000000..2ddf5f27
--- /dev/null
+++ b/packages/base/amd64/rootfs/builds/.gitignore
@@ -0,0 +1 @@
+manifest.json
diff --git a/packages/base/amd64/rootfs/builds/Makefile b/packages/base/amd64/rootfs/builds/Makefile
new file mode 100644
index 00000000..aa896dda
--- /dev/null
+++ b/packages/base/amd64/rootfs/builds/Makefile
@@ -0,0 +1,16 @@
+include $(ONL)/make/config.amd64.mk
+
+#
+# Default to include all available amd64 platforms.
+# You override this with you own list or yaml file.
+#
+export PLATFORM_LIST=$(shell onlpm --list-platforms --arch amd64 --csv )
+
+RFS_CONFIG := $(ONL)/packages/base/any/rootfs/standard/standard.yml
+RFS_DIR := rootfs-amd64.d
+RFS_CPIO := rootfs-amd64.cpio.gz
+RFS_SQUASH := rootfs-amd64.sqsh
+
+include $(ONL)/make/rfs.mk
+
+
diff --git a/packages/base/any/faultd/APKG.yml b/packages/base/any/faultd/APKG.yml
new file mode 100644
index 00000000..fbcd0bef
--- /dev/null
+++ b/packages/base/any/faultd/APKG.yml
@@ -0,0 +1,22 @@
+common:
+ arch: $ARCH
+ version: 1.0.0
+ copyright: Copyright 2013, 2014, 2015 Big Switch Networks
+ maintainer: support@bigswitch.com
+
+packages:
+ - name: onl-faultd
+ version: 1.0.0
+ summary: Fault Reporting Daemon
+ provides: [ faultd ]
+
+ files:
+ builds/$BUILD_DIR/${TOOLCHAIN}/bin/faultd.bin : /usr/bin/faultd
+
+ init: ${ONL}/packages/base/any/faultd/faultd.init
+
+ changelog: Change changes changes.,
+
+
+
+
diff --git a/packages/base/any/faultd/builds/Makefile b/packages/base/any/faultd/builds/Makefile
new file mode 100644
index 00000000..1e58f391
--- /dev/null
+++ b/packages/base/any/faultd/builds/Makefile
@@ -0,0 +1,57 @@
+# -*- Makefile -*-
+############################################################
+#
+#
+# Copyright 2013, 2014 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+include $(ONL)/make/config.mk
+
+ifndef TOOLCHAIN
+$(error $$TOOLCHAIN must be specified.)
+else
+export TOOLCHAIN
+endif
+
+MODULE := faultd-module
+include $(BUILDER)/standardinit.mk
+
+LIBRARY := faultd-main
+$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST)))
+include $(BUILDER)/lib.mk
+
+
+DEPENDMODULES := faultd AIM
+
+include $(BUILDER)/dependmodules.mk
+
+BINARY := faultd.bin
+$(BINARY)_LIBRARIES := $(LIBRARY_TARGETS)
+include $(BUILDER)/bin.mk
+
+include $(BUILDER)/targets.mk
+
+GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1
+GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1
+GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_PVS_SYSLOG=1
+GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_DAEMONIZE=1
+GLOBAL_CFLAGS += -DFAULTD_CONFIG_INCLUDE_MAIN=1
+GLOBAL_CFLAGS += -DFAULTD_CONFIG_INCLUDE_AIM_MAIN=1
+GLOBAL_CFLAGS += -g
+
+GLOBAL_LINK_LIBS += -lpthread
+
diff --git a/packages/base/any/faultd/faultd.init b/packages/base/any/faultd/faultd.init
new file mode 100644
index 00000000..c7571115
--- /dev/null
+++ b/packages/base/any/faultd/faultd.init
@@ -0,0 +1,66 @@
+#!/bin/sh
+
+### BEGIN INIT INFO
+# Provides: faultd
+# Required-Start: $remote_fs $syslog
+# Required-Stop: $remote_fs $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Start Faultd Agent
+### END INIT INFO
+
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
+
+. /lib/lsb/init-functions
+
+DAEMON=/usr/bin/faultd
+PIDFILE=/var/run/faultd.pid
+FAULTD_OPTS="-dr -pid $PIDFILE"
+QUIET=
+
+test -x $DAEMON || exit 5
+
+RUNASUSER=root
+UGID=$(getent passwd $RUNASUSER | cut -f 3,4 -d:) || true
+
+case $1 in
+ start)
+ log_daemon_msg "Starting Fault Agent" "faultd"
+ if [ -z "$UGID" ]; then
+ log_failure_msg "user \"$RUNASUSER\" does not exist"
+ exit 1
+ fi
+ start-stop-daemon --start $QUIET --oknodo --pidfile $PIDFILE --startas $DAEMON -- $FAULTD_OPTS $FAULTD_EXTRA_OPTS
+ status=$?
+ log_end_msg $status
+ ;;
+ stop)
+ log_daemon_msg "Stopping Fault Agent" "faultd"
+ start-stop-daemon --stop $QUIET --oknodo --pidfile $PIDFILE
+ log_end_msg $?
+ rm -f $PIDFILE
+ ;;
+ restart|force-reload)
+ $0 stop && sleep 2 && $0 start
+ ;;
+ try-restart)
+ if $0 status >/dev/null; then
+ $0 restart
+ else
+ exit 0
+ fi
+ ;;
+ reload)
+ log_daemon_msg "Reloading Fault Agent" "faultd"
+ start-stop-daemon --stop $QUIET --oknodo --pidfile $PIDFILE --signal 1
+ status=$?
+ log_end_msg $status
+ ;;
+ status)
+ status_of_proc $DAEMON "Fault Agent"
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart|try-restart|force-reload|reload|status}"
+ exit 2
+ ;;
+esac
diff --git a/packages/base/any/faultd/src/.gitignore b/packages/base/any/faultd/src/.gitignore
new file mode 100644
index 00000000..f479fcb8
--- /dev/null
+++ b/packages/base/any/faultd/src/.gitignore
@@ -0,0 +1,2 @@
+/faultd.mk
+/doc
diff --git a/packages/base/any/faultd/src/Makefile b/packages/base/any/faultd/src/Makefile
new file mode 100644
index 00000000..c78c32eb
--- /dev/null
+++ b/packages/base/any/faultd/src/Makefile
@@ -0,0 +1,28 @@
+############################################################
+#
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+include $(ONL)/make/config.mk
+
+MODULE := faultd
+AUTOMODULE := faultd
+ifndef BUILDER
+$(error "$$BUILDER must be specified.")
+endif
+include $(BUILDER)/definemodule.mk
diff --git a/packages/base/any/faultd/src/README b/packages/base/any/faultd/src/README
new file mode 100644
index 00000000..598ea203
--- /dev/null
+++ b/packages/base/any/faultd/src/README
@@ -0,0 +1,6 @@
+###############################################################################
+#
+# faultd README
+#
+###############################################################################
+
diff --git a/packages/base/any/faultd/src/faultd.doxy b/packages/base/any/faultd/src/faultd.doxy
new file mode 100644
index 00000000..6b77f058
--- /dev/null
+++ b/packages/base/any/faultd/src/faultd.doxy
@@ -0,0 +1,1792 @@
+# Doxyfile 1.8.1.2
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project.
+#
+# All text after a hash (#) is considered a comment and will be ignored.
+# The format is:
+# TAG = value [value, ...]
+# For lists items can also be appended using:
+# TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ").
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the config file
+# that follow. The default is UTF-8 which is also the encoding used for all
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the
+# iconv built into libc) for the transcoding. See
+# http://www.gnu.org/software/libiconv for the list of possible encodings.
+
+DOXYFILE_ENCODING = UTF-8
+
+# The PROJECT_NAME tag is a single word (or sequence of words) that should
+# identify the project. Note that if you do not use Doxywizard you need
+# to put quotes around the project name if it contains spaces.
+
+PROJECT_NAME = "faultd"
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number.
+# This could be handy for archiving the generated documentation or
+# if some version control system is used.
+
+PROJECT_NUMBER =
+
+# Using the PROJECT_BRIEF tag one can provide an optional one line description
+# for a project that appears at the top of each page and should give viewer
+# a quick idea about the purpose of the project. Keep the description short.
+
+PROJECT_BRIEF = "Fault Management Daemon."
+
+# With the PROJECT_LOGO tag one can specify an logo or icon that is
+# included in the documentation. The maximum height of the logo should not
+# exceed 55 pixels and the maximum width should not exceed 200 pixels.
+# Doxygen will copy the logo to the output directory.
+
+PROJECT_LOGO =
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
+# base path where the generated documentation will be put.
+# If a relative path is entered, it will be relative to the location
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY = doc
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
+# 4096 sub-directories (in 2 levels) under the output directory of each output
+# format and will distribute the generated files over these directories.
+# Enabling this option can be useful when feeding doxygen a huge amount of
+# source files, where putting all generated files in the same directory would
+# otherwise cause performance problems for the file system.
+
+CREATE_SUBDIRS = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# The default language is English, other supported languages are:
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
+# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,
+# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English
+# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian,
+# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak,
+# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
+
+OUTPUT_LANGUAGE = English
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
+# include brief member descriptions after the members that are listed in
+# the file and class documentation (similar to JavaDoc).
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
+# the brief description of a member or function before the detailed description.
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator
+# that is used to form the text in various listings. Each string
+# in this list, if found as the leading text of the brief description, will be
+# stripped from the text and the result after processing the whole list, is
+# used as the annotated text. Otherwise, the brief description is used as-is.
+# If left blank, the following values are used ("$name" is automatically
+# replaced with the name of the entity): "The $name class" "The $name widget"
+# "The $name file" "is" "provides" "specifies" "contains"
+# "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF =
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# Doxygen will generate a detailed section even if there is only a brief
+# description.
+
+ALWAYS_DETAILED_SEC = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
+# operators of the base classes will not be shown.
+
+INLINE_INHERITED_MEMB = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
+# path before files name in the file list and in the header files. If set
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES = YES
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
+# can be used to strip a user-defined part of the path. Stripping is
+# only done if one of the specified strings matches the left-hand part of
+# the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the
+# path to strip.
+
+STRIP_FROM_PATH =
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
+# the path mentioned in the documentation of a class, which tells
+# the reader which header file to include in order to use a class.
+# If left blank only the name of the header file containing the class
+# definition is used. Otherwise one should specify the include paths that
+# are normally passed to the compiler using the -I flag.
+
+STRIP_FROM_INC_PATH =
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
+# (but less readable) file names. This can be useful if your file system
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
+# will interpret the first line (until the first dot) of a JavaDoc-style
+# comment as the brief description. If set to NO, the JavaDoc
+# comments will behave just like regular Qt-style comments
+# (thus requiring an explicit @brief command for a brief description.)
+
+JAVADOC_AUTOBRIEF = NO
+
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
+# interpret the first line (until the first dot) of a Qt-style
+# comment as the brief description. If set to NO, the comments
+# will behave just like regular Qt-style comments (thus requiring
+# an explicit \brief command for a brief description.)
+
+QT_AUTOBRIEF = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
+# treat a multi-line C++ special comment block (i.e. a block of //! or ///
+# comments) as a brief description. This used to be the default behaviour.
+# The new default is to treat a multi-line C++ comment block as a detailed
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
+# member inherits the documentation from any documented member that it
+# re-implements.
+
+INHERIT_DOCS = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
+# a new page for each member. If set to NO, the documentation of a member will
+# be part of the file/class/namespace that contains it.
+
+SEPARATE_MEMBER_PAGES = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab.
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE = 8
+
+# This tag can be used to specify a number of aliases that acts
+# as commands in the documentation. An alias has the form "name=value".
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to
+# put the command \sideeffect (or @sideeffect) in the documentation, which
+# will result in a user-defined paragraph with heading "Side Effects:".
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES =
+
+# This tag can be used to specify a number of word-keyword mappings (TCL only).
+# A mapping has the form "name=value". For example adding
+# "class=itcl::class" will allow you to use the command class in the
+# itcl::class meaning.
+
+TCL_SUBST =
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
+# sources only. Doxygen will then generate output that is more tailored for C.
+# For instance, some of the names that are used will be different. The list
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C = YES
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
+# sources only. Doxygen will then generate output that is more tailored for
+# Java. For instance, namespaces will be presented as packages, qualified
+# scopes will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA = NO
+
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
+# sources only. Doxygen will then generate output that is more tailored for
+# Fortran.
+
+OPTIMIZE_FOR_FORTRAN = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
+# sources. Doxygen will then generate output that is tailored for
+# VHDL.
+
+OPTIMIZE_OUTPUT_VHDL = NO
+
+# Doxygen selects the parser to use depending on the extension of the files it
+# parses. With this tag you can assign which parser to use for a given extension.
+# Doxygen has a built-in mapping, but you can override or extend it using this
+# tag. The format is ext=language, where ext is a file extension, and language
+# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C,
+# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make
+# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C
+# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions
+# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen.
+
+EXTENSION_MAPPING =
+
+# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all
+# comments according to the Markdown format, which allows for more readable
+# documentation. See http://daringfireball.net/projects/markdown/ for details.
+# The output of markdown processing is further processed by doxygen, so you
+# can mix doxygen, HTML, and XML commands with Markdown formatting.
+# Disable only in case of backward compatibilities issues.
+
+MARKDOWN_SUPPORT = YES
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
+# to include (a tag file for) the STL sources as input, then you should
+# set this tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
+# func(std::string) {}). This also makes the inheritance and collaboration
+# diagrams that involve STL classes more complete and accurate.
+
+BUILTIN_STL_SUPPORT = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to
+# enable parsing support.
+
+CPP_CLI_SUPPORT = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
+# Doxygen will parse them like normal C++ but will assume all classes use public
+# instead of private inheritance when no explicit protection keyword is present.
+
+SIP_SUPPORT = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate getter
+# and setter methods for a property. Setting this option to YES (the default)
+# will make doxygen replace the get and set methods by a property in the
+# documentation. This will only work if the methods are indeed getting or
+# setting a simple type. If this is not the case, or you want to show the
+# methods anyway, you should set this option to NO.
+
+IDL_PROPERTY_SUPPORT = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES, then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
+# the same type (for instance a group of public functions) to be put as a
+# subgroup of that type (e.g. under the Public Functions section). Set it to
+# NO to prevent subgrouping. Alternatively, this can be done per class using
+# the \nosubgrouping command.
+
+SUBGROUPING = YES
+
+# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and
+# unions are shown inside the group in which they are included (e.g. using
+# @ingroup) instead of on a separate page (for HTML and Man pages) or
+# section (for LaTeX and RTF).
+
+INLINE_GROUPED_CLASSES = NO
+
+# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and
+# unions with only public data fields will be shown inline in the documentation
+# of the scope in which they are defined (i.e. file, namespace, or group
+# documentation), provided this scope is documented. If set to NO (the default),
+# structs, classes, and unions are shown on a separate page (for HTML and Man
+# pages) or section (for LaTeX and RTF).
+
+INLINE_SIMPLE_STRUCTS = NO
+
+# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
+# is documented as struct, union, or enum with the name of the typedef. So
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
+# with name TypeT. When disabled the typedef will appear as a member of a file,
+# namespace, or class. And the struct will be named TypeS. This can typically
+# be useful for C code in case the coding convention dictates that all compound
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+
+TYPEDEF_HIDES_STRUCT = NO
+
+# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
+# determine which symbols to keep in memory and which to flush to disk.
+# When the cache is full, less often used symbols will be written to disk.
+# For small to medium size projects (<1000 input files) the default value is
+# probably good enough. For larger projects a too small cache size can cause
+# doxygen to be busy swapping symbols to and from disk most of the time
+# causing a significant performance penalty.
+# If the system has enough physical memory increasing the cache will improve the
+# performance by keeping more symbols in memory. Note that the value works on
+# a logarithmic scale so increasing the size by one will roughly double the
+# memory usage. The cache size is given by this formula:
+# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
+# corresponding to a cache size of 2^16 = 65536 symbols.
+
+SYMBOL_CACHE_SIZE = 0
+
+# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be
+# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given
+# their name and scope. Since this can be an expensive process and often the
+# same symbol appear multiple times in the code, doxygen keeps a cache of
+# pre-resolved symbols. If the cache is too small doxygen will become slower.
+# If the cache is too large, memory is wasted. The cache size is given by this
+# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0,
+# corresponding to a cache size of 2^16 = 65536 symbols.
+
+LOOKUP_CACHE_SIZE = 0
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
+# documentation are documented, even if no documentation was available.
+# Private class members and static file members will be hidden unless
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL = NO
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
+# will be included in the documentation.
+
+EXTRACT_PRIVATE = NO
+
+# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal scope will be included in the documentation.
+
+EXTRACT_PACKAGE = NO
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file
+# will be included in the documentation.
+
+EXTRACT_STATIC = NO
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
+# defined locally in source files will be included in the documentation.
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES = YES
+
+# This flag is only useful for Objective-C code. When set to YES local
+# methods, which are defined in the implementation section but not in
+# the interface are included in the documentation.
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS = NO
+
+# If this flag is set to YES, the members of anonymous namespaces will be
+# extracted and appear in the documentation as a namespace called
+# 'anonymous_namespace{file}', where file will be replaced with the base
+# name of the file that contains the anonymous namespace. By default
+# anonymous namespaces are hidden.
+
+EXTRACT_ANON_NSPACES = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
+# undocumented members of documented classes, files or namespaces.
+# If set to NO (the default) these members will be included in the
+# various overviews, but no documentation section is generated.
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy.
+# If set to NO (the default) these classes will be included in the various
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
+# friend (class|struct|union) declarations.
+# If set to NO (the default) these declarations will be included in the
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
+# documentation blocks found inside the body of a function.
+# If set to NO (the default) these blocks will be appended to the
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS = NO
+
+# The INTERNAL_DOCS tag determines if documentation
+# that is typed after a \internal command is included. If the tag is set
+# to NO (the default) then the documentation will be excluded.
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
+# file names in lower-case letters. If set to YES upper-case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
+# and Mac users are advised to set this option to NO.
+
+CASE_SENSE_NAMES = YES
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
+# will show members with their full class and namespace scopes in the
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES = NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
+# will put a list of the files that are included by a file in the documentation
+# of that file.
+
+SHOW_INCLUDE_FILES = YES
+
+# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen
+# will list include files with double quotes in the documentation
+# rather than with sharp brackets.
+
+FORCE_LOCAL_INCLUDES = NO
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
+# is inserted in the documentation for inline members.
+
+INLINE_INFO = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
+# will sort the (detailed) documentation of file and class members
+# alphabetically by member name. If set to NO the members will appear in
+# declaration order.
+
+SORT_MEMBER_DOCS = YES
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
+# brief documentation of file, namespace and class members alphabetically
+# by member name. If set to NO (the default) the members will appear in
+# declaration order.
+
+SORT_BRIEF_DOCS = NO
+
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen
+# will sort the (brief and detailed) documentation of class members so that
+# constructors and destructors are listed first. If set to NO (the default)
+# the constructors will appear in the respective orders defined by
+# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS.
+# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO
+# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
+
+SORT_MEMBERS_CTORS_1ST = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
+# hierarchy of group names into alphabetical order. If set to NO (the default)
+# the group names will appear in their defined order.
+
+SORT_GROUP_NAMES = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
+# sorted by fully-qualified names, including namespaces. If set to
+# NO (the default), the class list will be sorted only by class name,
+# not including the namespace part.
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME = NO
+
+# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to
+# do proper type resolution of all parameters of a function it will reject a
+# match between the prototype and the implementation of a member function even
+# if there is only one candidate or it is obvious which candidate to choose
+# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen
+# will still accept a match between prototype and implementation in such cases.
+
+STRICT_PROTO_MATCHING = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or
+# disable (NO) the todo list. This list is created by putting \todo
+# commands in the documentation.
+
+GENERATE_TODOLIST = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or
+# disable (NO) the test list. This list is created by putting \test
+# commands in the documentation.
+
+GENERATE_TESTLIST = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or
+# disable (NO) the bug list. This list is created by putting \bug
+# commands in the documentation.
+
+GENERATE_BUGLIST = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
+# disable (NO) the deprecated list. This list is created by putting
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS =
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
+# the initial value of a variable or macro consists of for it to appear in
+# the documentation. If the initializer consists of more lines than specified
+# here it will be hidden. Use a value of 0 to hide initializers completely.
+# The appearance of the initializer of individual variables and macros in the
+# documentation can be controlled using \showinitializer or \hideinitializer
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
+# at the bottom of the documentation of classes and structs. If set to YES the
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES = YES
+
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
+# This will remove the Files entry from the Quick Index and from the
+# Folder Tree View (if specified). The default is YES.
+
+SHOW_FILES = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the
+# Namespaces page.
+# This will remove the Namespaces entry from the Quick Index
+# and from the Folder Tree View (if specified). The default is YES.
+
+SHOW_NAMESPACES = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from
+# the version control system). Doxygen will invoke the program by executing (via
+# popen()) the command , where is the value of
+# the FILE_VERSION_FILTER tag, and is the name of an input file
+# provided by doxygen. Whatever the program writes to standard output
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER =
+
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed
+# by doxygen. The layout file controls the global structure of the generated
+# output files in an output format independent way. To create the layout file
+# that represents doxygen's defaults, run doxygen with the -l option.
+# You can optionally specify a file name after the option, if omitted
+# DoxygenLayout.xml will be used as the name of the layout file.
+
+LAYOUT_FILE =
+
+# The CITE_BIB_FILES tag can be used to specify one or more bib files
+# containing the references data. This must be a list of .bib files. The
+# .bib extension is automatically appended if omitted. Using this command
+# requires the bibtex tool to be installed. See also
+# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style
+# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this
+# feature you need bibtex and perl available in the search path.
+
+CITE_BIB_FILES =
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated by doxygen. Possible values are YES and NO. If left blank
+# NO is used.
+
+WARNINGS = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED = YES
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some
+# parameters in a documented function, or documenting parameters that
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR = YES
+
+# The WARN_NO_PARAMDOC option can be enabled to get warnings for
+# functions that are documented, but have no documentation for their parameters
+# or return value. If set to NO (the default) doxygen will only warn about
+# wrong or incomplete parameter documentation, but not about the absence of
+# documentation.
+
+WARN_NO_PARAMDOC = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that
+# doxygen can produce. The string should contain the $file, $line, and $text
+# tags, which will be replaced by the file and line number from which the
+# warning originated and the warning text. Optionally the format may contain
+# $version, which will be replaced by the version of the file (if it could
+# be obtained via FILE_VERSION_FILTER)
+
+WARN_FORMAT = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning
+# and error messages should be written. If left blank the output is written
+# to stderr.
+
+WARN_LOGFILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain
+# documented source files. You may enter file names like "myfile.cpp" or
+# directories like "/usr/src/myproject". Separate the files or directories
+# with spaces.
+
+INPUT = module/inc
+
+# This tag can be used to specify the character encoding of the source files
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
+# also the default input encoding. Doxygen uses libiconv (or the iconv built
+# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
+# the list of possible encodings.
+
+INPUT_ENCODING = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank the following patterns are tested:
+# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh
+# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py
+# *.f90 *.f *.for *.vhd *.vhdl
+
+FILE_PATTERNS =
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories
+# should be searched for input files as well. Possible values are YES and NO.
+# If left blank NO is used.
+
+RECURSIVE = YES
+
+# The EXCLUDE tag can be used to specify files and/or directories that should be
+# excluded from the INPUT source files. This way you can easily exclude a
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+# Note that relative paths are relative to the directory from which doxygen is
+# run.
+
+EXCLUDE =
+
+# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
+# directories that are symbolic links (a Unix file system feature) are excluded
+# from the input.
+
+EXCLUDE_SYMLINKS = NO
+
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories. Note that the wildcards are matched
+# against the file with absolute path, so to exclude all test directories
+# for example use the pattern */test/*
+
+EXCLUDE_PATTERNS =
+
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
+# (namespaces, classes, functions, etc.) that should be excluded from the
+# output. The symbol name can be a fully qualified name, a word, or if the
+# wildcard * is used, a substring. Examples: ANamespace, AClass,
+# AClass::ANamespace, ANamespace::*Test
+
+EXCLUDE_SYMBOLS =
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or
+# directories that contain example code fragments that are included (see
+# the \include command).
+
+EXAMPLE_PATH =
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank all files are included.
+
+EXAMPLE_PATTERNS =
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
+# searched for input files to be used with the \include or \dontinclude
+# commands irrespective of the value of the RECURSIVE tag.
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or
+# directories that contain image that are included in the documentation (see
+# the \image command).
+
+IMAGE_PATH =
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command , where
+# is the value of the INPUT_FILTER tag, and is the name of an
+# input file. Doxygen will then use the output that the filter program writes
+# to standard output.
+# If FILTER_PATTERNS is specified, this tag will be
+# ignored.
+
+INPUT_FILTER =
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
+# basis.
+# Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match.
+# The filters are a list of the form:
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
+# info on how filters are used. If FILTER_PATTERNS is empty or if
+# non of the patterns match the file name, INPUT_FILTER is applied.
+
+FILTER_PATTERNS =
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER) will be used to filter the input files when producing source
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES = NO
+
+# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file
+# pattern. A pattern will override the setting for FILTER_PATTERN (if any)
+# and it is also possible to disable source filtering for a specific pattern
+# using *.ext= (so without naming a filter). This option only has effect when
+# FILTER_SOURCE_FILES is enabled.
+
+FILTER_SOURCE_PATTERNS =
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will
+# be generated. Documented entities will be cross-referenced with these sources.
+# Note: To get rid of all source code in the generated output, make sure also
+# VERBATIM_HEADERS is set to NO.
+
+SOURCE_BROWSER = NO
+
+# Setting the INLINE_SOURCES tag to YES will include the body
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
+# doxygen to hide any special comment blocks from generated source code
+# fragments. Normal C, C++ and Fortran comments will always remain visible.
+
+STRIP_CODE_COMMENTS = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES
+# then for each documented function all documented
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = NO
+
+# If the REFERENCES_RELATION tag is set to YES
+# then for each documented function all documented entities
+# called/used by that function will be listed.
+
+REFERENCES_RELATION = NO
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
+# link to the source code.
+# Otherwise they will link to the documentation.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code
+# will point to the HTML generated by the htags(1) tool instead of doxygen
+# built-in source browser. The htags tool is part of GNU's global source
+# tagging system (see http://www.gnu.org/software/global/global.html). You
+# will need version 4.8.6 or higher.
+
+USE_HTAGS = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
+# will generate a verbatim copy of the header file for each class for
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
+# of all compounds will be generated. Enable this if the project
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX = YES
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX = 5
+
+# In case all classes in a project start with a common prefix, all
+# classes will be put under the same header in the alphabetical index.
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX =
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
+# generate HTML output.
+
+GENERATE_HTML = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard header. Note that when using a custom header you are responsible
+# for the proper inclusion of any scripts and style sheets that doxygen
+# needs, which is dependent on the configuration options used.
+# It is advised to generate a default header using "doxygen -w html
+# header.html footer.html stylesheet.css YourConfigFile" and then modify
+# that header. Note that the header is subject to change so you typically
+# have to redo this when upgrading to a newer version of doxygen or when
+# changing the value of configuration settings such as GENERATE_TREEVIEW!
+
+HTML_HEADER =
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard footer.
+
+HTML_FOOTER =
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
+# style sheet that is used by each HTML page. It can be used to
+# fine-tune the look of the HTML output. If the tag is left blank doxygen
+# will generate a default style sheet. Note that doxygen will try to copy
+# the style sheet file to the HTML output directory, so don't put your own
+# style sheet in the HTML output directory as well, or it will be erased!
+
+HTML_STYLESHEET =
+
+# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
+# other source files which should be copied to the HTML output directory. Note
+# that these files will be copied to the base HTML output directory. Use the
+# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these
+# files. In the HTML_STYLESHEET file, use the file name only. Also note that
+# the files will be copied as-is; there are no commands or markers available.
+
+HTML_EXTRA_FILES =
+
+# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output.
+# Doxygen will adjust the colors in the style sheet and background images
+# according to this color. Hue is specified as an angle on a colorwheel,
+# see http://en.wikipedia.org/wiki/Hue for more information.
+# For instance the value 0 represents red, 60 is yellow, 120 is green,
+# 180 is cyan, 240 is blue, 300 purple, and 360 is red again.
+# The allowed range is 0 to 359.
+
+HTML_COLORSTYLE_HUE = 220
+
+# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of
+# the colors in the HTML output. For a value of 0 the output will use
+# grayscales only. A value of 255 will produce the most vivid colors.
+
+HTML_COLORSTYLE_SAT = 100
+
+# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to
+# the luminance component of the colors in the HTML output. Values below
+# 100 gradually make the output lighter, whereas values above 100 make
+# the output darker. The value divided by 100 is the actual gamma applied,
+# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2,
+# and 100 does not change the gamma.
+
+HTML_COLORSTYLE_GAMMA = 80
+
+# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
+# page will contain the date and time when the page was generated. Setting
+# this to NO can help when comparing the output of multiple runs.
+
+HTML_TIMESTAMP = YES
+
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
+# documentation will contain sections that can be hidden and shown after the
+# page has loaded.
+
+HTML_DYNAMIC_SECTIONS = NO
+
+# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of
+# entries shown in the various tree structured indices initially; the user
+# can expand and collapse entries dynamically later on. Doxygen will expand
+# the tree to such a level that at most the specified number of entries are
+# visible (unless a fully collapsed tree already exceeds this amount).
+# So setting the number of entries 1 will produce a full collapsed tree by
+# default. 0 is a special value representing an infinite number of entries
+# and will result in a full expanded tree by default.
+
+HTML_INDEX_NUM_ENTRIES = 100
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files
+# will be generated that can be used as input for Apple's Xcode 3
+# integrated development environment, introduced with OSX 10.5 (Leopard).
+# To create a documentation set, doxygen will generate a Makefile in the
+# HTML output directory. Running make will produce the docset in that
+# directory and running "make install" will install the docset in
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
+# it at startup.
+# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html
+# for more information.
+
+GENERATE_DOCSET = NO
+
+# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
+# feed. A documentation feed provides an umbrella under which multiple
+# documentation sets from a single provider (such as a company or product suite)
+# can be grouped.
+
+DOCSET_FEEDNAME = "Doxygen generated docs"
+
+# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
+# should uniquely identify the documentation set bundle. This should be a
+# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
+# will append .docset to the name.
+
+DOCSET_BUNDLE_ID = org.doxygen.Project
+
+# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify
+# the documentation publisher. This should be a reverse domain-name style
+# string, e.g. com.mycompany.MyDocSet.documentation.
+
+DOCSET_PUBLISHER_ID = org.doxygen.Publisher
+
+# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher.
+
+DOCSET_PUBLISHER_NAME = Publisher
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files
+# will be generated that can be used as input for tools like the
+# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
+# be used to specify the file name of the resulting .chm file. You
+# can add a path in front of the file if the result should not be
+# written to the html output directory.
+
+CHM_FILE =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
+# be used to specify the location (absolute path including file name) of
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
+# controls if a separate .chi index file is generated (YES) or that
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
+# is used to encode HtmlHelp index (hhk), content (hhc) and project file
+# content.
+
+CHM_INDEX_ENCODING =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
+# controls whether a binary table of contents is generated (YES) or a
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND = NO
+
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and
+# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated
+# that can be used as input for Qt's qhelpgenerator to generate a
+# Qt Compressed Help (.qch) of the generated HTML documentation.
+
+GENERATE_QHP = NO
+
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can
+# be used to specify the file name of the resulting .qch file.
+# The path specified is relative to the HTML output folder.
+
+QCH_FILE =
+
+# The QHP_NAMESPACE tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#namespace
+
+QHP_NAMESPACE = org.doxygen.Project
+
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#virtual-folders
+
+QHP_VIRTUAL_FOLDER = doc
+
+# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to
+# add. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#custom-filters
+
+QHP_CUST_FILTER_NAME =
+
+# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the
+# custom filter to add. For more information please see
+#
+# Qt Help Project / Custom Filters.
+
+QHP_CUST_FILTER_ATTRS =
+
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
+# project's
+# filter section matches.
+#
+# Qt Help Project / Filter Attributes.
+
+QHP_SECT_FILTER_ATTRS =
+
+# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
+# be used to specify the location of Qt's qhelpgenerator.
+# If non-empty doxygen will try to run qhelpgenerator on the generated
+# .qhp file.
+
+QHG_LOCATION =
+
+# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files
+# will be generated, which together with the HTML files, form an Eclipse help
+# plugin. To install this plugin and make it available under the help contents
+# menu in Eclipse, the contents of the directory containing the HTML and XML
+# files needs to be copied into the plugins directory of eclipse. The name of
+# the directory within the plugins directory should be the same as
+# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before
+# the help appears.
+
+GENERATE_ECLIPSEHELP = NO
+
+# A unique identifier for the eclipse help plugin. When installing the plugin
+# the directory name containing the HTML and XML files should also have
+# this name.
+
+ECLIPSE_DOC_ID = org.doxygen.Project
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs)
+# at top of each HTML page. The value NO (the default) enables the index and
+# the value YES disables it. Since the tabs have the same information as the
+# navigation tree you can set this option to NO if you already set
+# GENERATE_TREEVIEW to YES.
+
+DISABLE_INDEX = NO
+
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
+# structure should be generated to display hierarchical information.
+# If the tag value is set to YES, a side panel will be generated
+# containing a tree-like index structure (just like the one that
+# is generated for HTML Help). For this to work a browser that supports
+# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser).
+# Windows users are probably better off using the HTML help feature.
+# Since the tree basically has the same information as the tab index you
+# could consider to set DISABLE_INDEX to NO when enabling this option.
+
+GENERATE_TREEVIEW = NO
+
+# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values
+# (range [0,1..20]) that doxygen will group on one line in the generated HTML
+# documentation. Note that a value of 0 will completely suppress the enum
+# values from appearing in the overview section.
+
+ENUM_VALUES_PER_LINE = 4
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
+# used to set the initial width (in pixels) of the frame in which the tree
+# is shown.
+
+TREEVIEW_WIDTH = 250
+
+# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open
+# links to external symbols imported via tag files in a separate window.
+
+EXT_LINKS_IN_WINDOW = NO
+
+# Use this tag to change the font size of Latex formulas included
+# as images in the HTML documentation. The default is 10. Note that
+# when you change the font size after a successful doxygen run you need
+# to manually remove any form_*.png images from the HTML output directory
+# to force them to be regenerated.
+
+FORMULA_FONTSIZE = 10
+
+# Use the FORMULA_TRANPARENT tag to determine whether or not the images
+# generated for formulas are transparent PNGs. Transparent PNGs are
+# not supported properly for IE 6.0, but are supported on all modern browsers.
+# Note that when changing this option you need to delete any form_*.png files
+# in the HTML output before the changes have effect.
+
+FORMULA_TRANSPARENT = YES
+
+# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax
+# (see http://www.mathjax.org) which uses client side Javascript for the
+# rendering instead of using prerendered bitmaps. Use this if you do not
+# have LaTeX installed or if you want to formulas look prettier in the HTML
+# output. When enabled you may also need to install MathJax separately and
+# configure the path to it using the MATHJAX_RELPATH option.
+
+USE_MATHJAX = NO
+
+# When MathJax is enabled you need to specify the location relative to the
+# HTML output directory using the MATHJAX_RELPATH option. The destination
+# directory should contain the MathJax.js script. For instance, if the mathjax
+# directory is located at the same level as the HTML output directory, then
+# MATHJAX_RELPATH should be ../mathjax. The default value points to
+# the MathJax Content Delivery Network so you can quickly see the result without
+# installing MathJax.
+# However, it is strongly recommended to install a local
+# copy of MathJax from http://www.mathjax.org before deployment.
+
+MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest
+
+# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension
+# names that should be enabled during MathJax rendering.
+
+MATHJAX_EXTENSIONS =
+
+# When the SEARCHENGINE tag is enabled doxygen will generate a search box
+# for the HTML output. The underlying search engine uses javascript
+# and DHTML and should work on any modern browser. Note that when using
+# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets
+# (GENERATE_DOCSET) there is already a search function so this one should
+# typically be disabled. For large projects the javascript based search engine
+# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution.
+
+SEARCHENGINE = YES
+
+# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
+# implemented using a PHP enabled web server instead of at the web client
+# using Javascript. Doxygen will generate the search PHP script and index
+# file to put on the web server. The advantage of the server
+# based approach is that it scales better to large projects and allows
+# full text search. The disadvantages are that it is more difficult to setup
+# and does not have live searching capabilities.
+
+SERVER_BASED_SEARCH = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
+# generate Latex output.
+
+GENERATE_LATEX = YES
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
+# invoked. If left blank `latex' will be used as the default command name.
+# Note that when enabling USE_PDFLATEX this option is only used for
+# generating bitmaps for formulas in the HTML output, but not in the
+# Makefile that is written to the output directory.
+
+LATEX_CMD_NAME = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
+# generate index for LaTeX. If left blank `makeindex' will be used as the
+# default command name.
+
+MAKEINDEX_CMD_NAME = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
+# LaTeX documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_LATEX = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used
+# by the printer. Possible values are: a4, letter, legal and
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE = a4
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES =
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
+# the generated latex document. The header should contain everything until
+# the first chapter. If it is left blank doxygen will generate a
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER =
+
+# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for
+# the generated latex document. The footer should contain everything after
+# the last chapter. If it is left blank doxygen will generate a
+# standard footer. Notice: only use this tag if you know what you are doing!
+
+LATEX_FOOTER =
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will
+# contain links (just like the HTML output) instead of page references
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS = YES
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
+# plain latex in the generated Makefile. Set this option to YES to get a
+# higher quality PDF documentation.
+
+USE_PDFLATEX = YES
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
+# command to the generated LaTeX files. This will instruct LaTeX to keep
+# running if errors occur, instead of asking the user for help.
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE = NO
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not
+# include the index chapters (such as File Index, Compound Index, etc.)
+# in the output.
+
+LATEX_HIDE_INDICES = NO
+
+# If LATEX_SOURCE_CODE is set to YES then doxygen will include
+# source code with syntax highlighting in the LaTeX output.
+# Note that which sources are shown also depends on other settings
+# such as SOURCE_BROWSER.
+
+LATEX_SOURCE_CODE = NO
+
+# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
+# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See
+# http://en.wikipedia.org/wiki/BibTeX for more info.
+
+LATEX_BIB_STYLE = plain
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
+# The RTF output is optimized for Word 97 and may not look very pretty with
+# other RTF readers or editors.
+
+GENERATE_RTF = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
+# RTF documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_RTF = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
+# will contain hyperlink fields. The RTF file will
+# contain links (just like the HTML output) instead of page references.
+# This makes the output suitable for online browsing using WORD or other
+# programs which support those fields.
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS = NO
+
+# Load style sheet definitions from file. Syntax is similar to doxygen's
+# config file, i.e. a series of assignments. You only have to provide
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE =
+
+# Set optional variables used in the generation of an rtf document.
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
+# generate man pages
+
+GENERATE_MAN = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT = man
+
+# The MAN_EXTENSION tag determines the extension that is added to
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
+# then it will generate one additional man file for each entity
+# documented in the real man page(s). These additional files
+# only source the real man page, but without them the man command
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will
+# generate an XML file that captures the structure of
+# the code including all documentation.
+
+GENERATE_XML = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_SCHEMA =
+
+# The XML_DTD tag can be used to specify an XML DTD,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_DTD =
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
+# dump the program listings (including syntax highlighting
+# and cross-referencing information) to the XML output. Note that
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING = YES
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
+# generate an AutoGen Definitions (see autogen.sf.net) file
+# that captures the structure of the code including all
+# documentation. Note that this feature is still experimental
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will
+# generate a Perl module file that captures the structure of
+# the code including all documentation. Note that this
+# feature is still experimental and incomplete at the
+# moment.
+
+GENERATE_PERLMOD = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
+# nicely formatted so it can be parsed by a human reader.
+# This is useful
+# if you want to understand what is going on.
+# On the other hand, if this
+# tag is set to NO the size of the Perl module output will be much smaller
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY = YES
+
+# The names of the make variables in the generated doxyrules.make file
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
+# This is useful so different doxyrules.make files included by the same
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
+# evaluate all C-preprocessor directives found in the sources and include
+# files.
+
+ENABLE_PREPROCESSING = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
+# names in the source code. If set to NO (the default) only conditional
+# compilation will be performed. Macro expansion can be done in a controlled
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
+# then the macro expansion is limited to the macros specified with the
+# PREDEFINED and EXPAND_AS_DEFINED tags.
+
+EXPAND_ONLY_PREDEF = NO
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
+# pointed to by INCLUDE_PATH will be searched when a #include is found.
+
+SEARCH_INCLUDES = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by
+# the preprocessor.
+
+INCLUDE_PATH =
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will
+# be used.
+
+INCLUDE_FILE_PATTERNS =
+
+# The PREDEFINED tag can be used to specify one or more macro names that
+# are defined before the preprocessor is started (similar to the -D option of
+# gcc). The argument of the tag is a list of macros of the form: name
+# or name=definition (no spaces). If the definition and the = are
+# omitted =1 is assumed. To prevent a macro definition from being
+# undefined via #undef or recursively expanded use the := operator
+# instead of the = operator.
+
+PREDEFINED =
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
+# this tag can be used to specify a list of macro names that should be expanded.
+# The macro definition that is found in the sources will be used.
+# Use the PREDEFINED tag if you want to use a different macro definition that
+# overrules the definition found in the source code.
+
+EXPAND_AS_DEFINED =
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
+# doxygen's preprocessor will remove all references to function-like macros
+# that are alone on a line, have an all uppercase name, and do not end with a
+# semicolon, because these will confuse the parser if not removed.
+
+SKIP_FUNCTION_MACROS = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles. For each
+# tag file the location of the external documentation should be added. The
+# format of a tag file without this location is as follows:
+#
+# TAGFILES = file1 file2 ...
+# Adding location for the tag files is done as follows:
+#
+# TAGFILES = file1=loc1 "file2 = loc2" ...
+# where "loc1" and "loc2" can be relative or absolute paths
+# or URLs. Note that each tag file must have a unique name (where the name does
+# NOT include the path). If a tag file is not located in the directory in which
+# doxygen is run, you must also specify the path to the tagfile here.
+
+TAGFILES =
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE =
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed
+# in the class index. If set to NO only the inherited external classes
+# will be listed.
+
+ALLEXTERNALS = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will
+# be listed.
+
+EXTERNAL_GROUPS = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
+# or super classes. Setting the tag to NO turns the diagrams off. Note that
+# this option also works with HAVE_DOT disabled, but it is recommended to
+# install and use dot, since it yields more powerful graphs.
+
+CLASS_DIAGRAMS = YES
+
+# You can define message sequence charts within doxygen comments using the \msc
+# command. Doxygen will then run the mscgen tool (see
+# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where
+# the mscgen tool resides. If left empty the tool is assumed to be found in the
+# default search path.
+
+MSCGEN_PATH =
+
+# If set to YES, the inheritance and collaboration graphs will hide
+# inheritance and usage relations if the target is undocumented
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz, a graph visualization
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT = NO
+
+# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is
+# allowed to run in parallel. When set to 0 (the default) doxygen will
+# base this on the number of processors available in the system. You can set it
+# explicitly to a value larger than 0 to get control over the balance
+# between CPU load and processing speed.
+
+DOT_NUM_THREADS = 0
+
+# By default doxygen will use the Helvetica font for all dot files that
+# doxygen generates. When you want a differently looking font you can specify
+# the font name using DOT_FONTNAME. You need to make sure dot is able to find
+# the font, which can be done by putting it in a standard location or by setting
+# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the
+# directory containing the font.
+
+DOT_FONTNAME = Helvetica
+
+# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
+# The default size is 10pt.
+
+DOT_FONTSIZE = 10
+
+# By default doxygen will tell dot to use the Helvetica font.
+# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to
+# set the path where dot can find it.
+
+DOT_FONTPATH =
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect inheritance relations. Setting this tag to YES will force the
+# CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect implementation dependencies (inheritance, containment, and
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH = YES
+
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
+# collaboration diagrams in a style similar to the OMG's Unified Modeling
+# Language.
+
+UML_LOOK = NO
+
+# If the UML_LOOK tag is enabled, the fields and methods are shown inside
+# the class node. If there are many fields or methods and many nodes the
+# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS
+# threshold limits the number of items for each type to make the size more
+# managable. Set this to 0 for no limit. Note that the threshold may be
+# exceeded by 50 percent before the limit is enforced.
+
+UML_LIMIT_NUM_FIELDS = 10
+
+# If set to YES, the inheritance and collaboration graphs will show the
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS = NO
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
+# tags are set to YES then doxygen will generate a graph for each documented
+# file showing the direct and indirect include dependencies of the file with
+# other documented files.
+
+INCLUDE_GRAPH = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
+# documented header file showing the documented files that directly or
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH = YES
+
+# If the CALL_GRAPH and HAVE_DOT options are set to YES then
+# doxygen will generate a call dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable call graphs
+# for selected functions only using the \callgraph command.
+
+CALL_GRAPH = NO
+
+# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
+# doxygen will generate a caller dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable caller
+# graphs for selected functions only using the \callergraph command.
+
+CALLER_GRAPH = NO
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
+# will generate a graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY = YES
+
+# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES
+# then doxygen will show the dependencies a directory has on other directories
+# in a graphical way. The dependency relations are determined by the #include
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
+# generated by dot. Possible values are svg, png, jpg, or gif.
+# If left blank png will be used. If you choose svg you need to set
+# HTML_FILE_EXTENSION to xhtml in order to make the SVG files
+# visible in IE 9+ (other browsers do not have this requirement).
+
+DOT_IMAGE_FORMAT = png
+
+# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to
+# enable generation of interactive SVG images that allow zooming and panning.
+# Note that this requires a modern browser other than Internet Explorer.
+# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you
+# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files
+# visible. Older versions of IE do not have SVG support.
+
+INTERACTIVE_SVG = NO
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be
+# found. If left blank, it is assumed the dot tool can be found in the path.
+
+DOT_PATH =
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that
+# contain dot files that are included in the documentation (see the
+# \dotfile command).
+
+DOTFILE_DIRS =
+
+# The MSCFILE_DIRS tag can be used to specify one or more directories that
+# contain msc files that are included in the documentation (see the
+# \mscfile command).
+
+MSCFILE_DIRS =
+
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
+# nodes that will be shown in the graph. If the number of nodes in a graph
+# becomes larger than this value, doxygen will truncate the graph, which is
+# visualized by representing a node as a red box. Note that doxygen if the
+# number of direct children of the root node in a graph is already larger than
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
+# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+
+DOT_GRAPH_MAX_NODES = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
+# graphs generated by dot. A depth value of 3 means that only nodes reachable
+# from the root by following a path via at most 3 edges will be shown. Nodes
+# that lay further from the root node will be omitted. Note that setting this
+# option to 1 or 2 may greatly reduce the computation time needed for large
+# code bases. Also note that the size of a graph can be further restricted by
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+
+MAX_DOT_GRAPH_DEPTH = 0
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
+# background. This is disabled by default, because dot on Windows does not
+# seem to support this out of the box. Warning: Depending on the platform used,
+# enabling this option may lead to badly anti-aliased labels on the edges of
+# a graph (i.e. they become hard to read).
+
+DOT_TRANSPARENT = NO
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
+# files in one run (i.e. multiple -o and -T options on the command line). This
+# makes dot run faster, but since only newer versions of dot (>1.8.10)
+# support this, this feature is disabled by default.
+
+DOT_MULTI_TARGETS = YES
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
+# generate a legend page explaining the meaning of the various boxes and
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND = YES
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
+# remove the intermediate dot files that are used to generate
+# the various graphs.
+
+DOT_CLEANUP = YES
diff --git a/packages/base/any/faultd/src/module/auto/faultd.yml b/packages/base/any/faultd/src/module/auto/faultd.yml
new file mode 100644
index 00000000..a2ea33d9
--- /dev/null
+++ b/packages/base/any/faultd/src/module/auto/faultd.yml
@@ -0,0 +1,86 @@
+############################################################
+#
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+# faultd Autogeneration Definitions.
+#
+############################################################
+
+cdefs: &cdefs
+- FAULTD_CONFIG_INCLUDE_LOGGING:
+ doc: "Include or exclude logging."
+ default: 1
+- FAULTD_CONFIG_LOG_OPTIONS_DEFAULT:
+ doc: "Default enabled log options."
+ default: AIM_LOG_OPTIONS_DEFAULT
+- FAULTD_CONFIG_LOG_BITS_DEFAULT:
+ doc: "Default enabled log bits."
+ default: AIM_LOG_BITS_DEFAULT
+- FAULTD_CONFIG_LOG_CUSTOM_BITS_DEFAULT:
+ doc: "Default enabled custom log bits."
+ default: 0
+- FAULTD_CONFIG_PORTING_STDLIB:
+ doc: "Default all porting macros to use the C standard libraries."
+ default: 1
+- FAULTD_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS:
+ doc: "Include standard library headers for stdlib porting macros."
+ default: FAULTD_CONFIG_PORTING_STDLIB
+- FAULTD_CONFIG_INCLUDE_UCLI:
+ doc: "Include generic uCli support."
+ default: 0
+- FAULTD_CONFIG_PIPE_NAME_DEFAULT:
+ doc: "Default named pipe."
+ default: "\"/var/run/faultd.pipe\""
+- FAULTD_CONFIG_BINARY_SIZE:
+ doc: "Maximum binary name size."
+ default: 255
+- FAULTD_CONFIG_BACKTRACE_SIZE_MAX:
+ doc: "Maximum backtrace size."
+ default: 32
+- FAULTD_CONFIG_SERVICE_PIPES_MAX:
+ doc: "Maximum number of simulatanous service pipes."
+ default: 8
+- FAULTD_CONFIG_BACKTRACE_SYMBOLS_SIZE:
+ doc: "Maximum backtrace symbols size"
+ default: 4096
+- FAULTD_CONFIG_INCLUDE_MAIN:
+ doc: "Include faultd_main() for standard faultd daemon build."
+ default: 0
+- FAULTD_CONFIG_INCLUDE_AIM_MAIN:
+ doc: "Include aim_main() as faultd_main()."
+ default: FAULTD_CONFIG_INCLUDE_MAIN
+- FAULTD_CONFIG_MAIN_PIPENAME:
+ doc: "Default pipename used by faultd_main() if included."
+ default: "\"/var/run/faultd.fifo\""
+
+
+definitions:
+ cdefs:
+ FAULTD_CONFIG_HEADER:
+ defs: *cdefs
+ basename: faultd_config
+
+ portingmacro:
+ FAULTD:
+ macros:
+ - memset
+ - memcpy
+ - strncpy
+ - strlen
diff --git a/packages/base/any/faultd/src/module/auto/make.mk b/packages/base/any/faultd/src/module/auto/make.mk
new file mode 100644
index 00000000..07f6d0f8
--- /dev/null
+++ b/packages/base/any/faultd/src/module/auto/make.mk
@@ -0,0 +1,28 @@
+############################################################
+#
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+# faultd Autogeneration
+#
+############################################################
+faultd_AUTO_DEFS := module/auto/faultd.yml
+faultd_AUTO_DIRS := module/inc/faultd module/src
+include $(BUILDER)/auto.mk
+
diff --git a/packages/base/any/faultd/src/module/inc/faultd/faultd.h b/packages/base/any/faultd/src/module/inc/faultd/faultd.h
new file mode 100644
index 00000000..fb7e92db
--- /dev/null
+++ b/packages/base/any/faultd/src/module/inc/faultd/faultd.h
@@ -0,0 +1,205 @@
+/**************************************************************************//**
+ *
+ *
+ *
+ * Copyright 2013, 2014 BigSwitch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ *
+ *****************************************************************************/
+#ifndef __FAULTD_H__
+#define __FAULTD_H__
+
+#include
+#include
+
+/**
+ * This structure contains the full fault information.
+ *
+ * This structure will be filled out by the fault handler
+ *
+ */
+typedef struct faultd_info_s {
+ /** Service pipe name - Server side only */
+ char* pipename;
+
+ /** The full name and path of the process binary */
+ char binary[FAULTD_CONFIG_BINARY_SIZE];
+
+ /** The pid of the process */
+ pid_t pid;
+ /** The kernel thread id of the process */
+ pid_t tid;
+
+ /** The signal number that caused the fault. */
+ int signal;
+ /** The signal code for the fault. */
+ int signal_code;
+ /** Offending address, if applicable. */
+ void* fault_address;
+
+ /** The last value of errno at the time of the fault */
+ int last_errno;
+
+ /** The size of this backtrace */
+ int backtrace_size;
+ /** The backtrace */
+ void* backtrace[FAULTD_CONFIG_BACKTRACE_SIZE_MAX];
+
+ /**
+ * This will store the output from backtrace_symbols_fd().
+ *
+ * When writing the message to the pipe, set it to non-zero.
+ * The reader will then read additional bytes until the null
+ * terminating byte is found.
+ *
+ * The pointer will then be replaced on the receiving side.
+ *
+ */
+ char* backtrace_symbols;
+
+} faultd_info_t;
+
+
+
+/**************************************************************************//**
+ *
+ * FaultD Servers
+ *
+ *
+ *****************************************************************************/
+typedef struct faultd_server_s faultd_server_t;
+
+typedef int faultd_sid_t;
+
+/**
+ * @brief Create a faultd server object.
+ * @param rfso Receives the faultd_server object.
+ */
+int faultd_server_create(faultd_server_t** rfso);
+
+/**
+ * @brief Destroy a server object.
+ * @param fco The faultd server object.
+ */
+void faultd_server_destroy(faultd_server_t* fco);
+
+/**
+ * @brief Add a named pipe service to the server.
+ * @param fso The faultd server object.
+ * @param pipename The name of the pipe.
+ * @returns The service id.
+ * @note FAULTD_CONFIG_PIPE_NAME_DEFAULT will be used if pipename is NULL.
+ */
+faultd_sid_t faultd_server_add(faultd_server_t* fso, char* pipename);
+
+/**
+ * @brief Remove a named pipe service.
+ * @param fso The faultd server object.
+ * @param pipename The name of the pipe.
+ * @param sid The service id.
+ *
+ * @note You can remove either by pipename or servicename.
+ */
+int faultd_server_remove(faultd_server_t* fso, char* pipename,
+ faultd_sid_t sid);
+
+/**
+ * @brief Read a fault message from any service pipe.
+ * @param fso The faultd server object.
+ * @param info The fault information.
+ * @note if sid == -1, all services will be polled.
+ * @note else the given service will be polled.
+ * @returns The sid from which the message was received.
+ */
+int faultd_server_read(faultd_server_t* fso, faultd_info_t* info,
+ faultd_sid_t sid);
+
+
+/**
+ * @brief Read and report all messages on all service pipes.
+ * @param fso The fault descriptor.
+ * @param sid The fault service.
+ * @param count Process at most 'count' messages.
+ * @param pvs The output pvs passed to fauld_info_show()
+ * @param decode Passed to faultd_info_show()
+ * @note if count is -1, process forever.
+ */
+int faultd_server_process(faultd_server_t* fso, faultd_sid_t sid,
+ int count, aim_pvs_t* pvs, int decode);
+
+
+/**************************************************************************//**
+ *
+ * faultd Clients
+ *
+ *
+ *****************************************************************************/
+typedef struct faultd_client_s faultd_client_t;
+
+/**
+ * @brief Create a faultd client object.
+ * @param fco Receives the faultd client object.
+ * @param pipename The named pipe filename.
+ * @note FAULTD_CONFIG_PIPE_NAME_DEFAULT will be used if pipename is NULL.
+ */
+int faultd_client_create(faultd_client_t** fco, const char* pipename);
+
+/**
+ * @brief Send a fault message to the server.
+ * @param fco The faultd client object.
+ * @param info The fault information.
+ * @note If backtrace_symbols is not NULL, the
+ * backtrace_symbols_fd() will be called on the backtrace
+ * and included in the report.
+ */
+int faultd_client_write(faultd_client_t* fco, faultd_info_t* info);
+
+/**
+ * @brief Destroy a client object.
+ * @param fco The faultd client object.
+ */
+void faultd_client_destroy(faultd_client_t* fco);
+
+
+/**************************************************************************//**
+ *
+ * faultd Hander
+ *
+ *
+ *****************************************************************************/
+int faultd_handler_register(int localfd,
+ const char* pipename,
+ const char* binaryname);
+
+
+/**************************************************************************//**
+ *
+ * Common
+ *
+ *
+ *****************************************************************************/
+
+/**
+ * @brief Output the fault message information to the given PVS.
+ * @param info The fault message.
+ * @param pvs The output pvs.
+ * @param decode If set, the backtrace will be processing through addr2line
+ */
+int faultd_info_show(faultd_info_t* info, aim_pvs_t* pvs, int decode);
+
+
+#endif /* __FAULTD_H__ */
diff --git a/packages/base/any/faultd/src/module/inc/faultd/faultd.x b/packages/base/any/faultd/src/module/inc/faultd/faultd.x
new file mode 100644
index 00000000..65b75329
--- /dev/null
+++ b/packages/base/any/faultd/src/module/inc/faultd/faultd.x
@@ -0,0 +1,32 @@
+/* -*- C -*-
+ *
+ *
+ *
+ * Copyright 2013, 2014 BigSwitch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ *
+ */
+
+#include
+
+/* <--auto.start.xmacro(ALL).define> */
+/* */
+
+/* <--auto.start.xenum(ALL).define> */
+/* */
+
+
diff --git a/packages/base/any/faultd/src/module/inc/faultd/faultd_config.h b/packages/base/any/faultd/src/module/inc/faultd/faultd_config.h
new file mode 100644
index 00000000..4a376845
--- /dev/null
+++ b/packages/base/any/faultd/src/module/inc/faultd/faultd_config.h
@@ -0,0 +1,226 @@
+/**************************************************************************//**
+ *
+ *
+ *
+ * Copyright 2013, 2014 BigSwitch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ *
+ * @file
+ * @brief faultd Configuration Header
+ *
+ * @addtogroup faultd-config
+ * @{
+ *
+ *****************************************************************************/
+#ifndef __FAULTD_CONFIG_H__
+#define __FAULTD_CONFIG_H__
+
+#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG
+#include
+#endif
+#ifdef FAULTD_INCLUDE_CUSTOM_CONFIG
+#include
+#endif
+
+/* */
+#include
+/**
+ * FAULTD_CONFIG_INCLUDE_LOGGING
+ *
+ * Include or exclude logging. */
+
+
+#ifndef FAULTD_CONFIG_INCLUDE_LOGGING
+#define FAULTD_CONFIG_INCLUDE_LOGGING 1
+#endif
+
+/**
+ * FAULTD_CONFIG_LOG_OPTIONS_DEFAULT
+ *
+ * Default enabled log options. */
+
+
+#ifndef FAULTD_CONFIG_LOG_OPTIONS_DEFAULT
+#define FAULTD_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT
+#endif
+
+/**
+ * FAULTD_CONFIG_LOG_BITS_DEFAULT
+ *
+ * Default enabled log bits. */
+
+
+#ifndef FAULTD_CONFIG_LOG_BITS_DEFAULT
+#define FAULTD_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT
+#endif
+
+/**
+ * FAULTD_CONFIG_LOG_CUSTOM_BITS_DEFAULT
+ *
+ * Default enabled custom log bits. */
+
+
+#ifndef FAULTD_CONFIG_LOG_CUSTOM_BITS_DEFAULT
+#define FAULTD_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0
+#endif
+
+/**
+ * FAULTD_CONFIG_PORTING_STDLIB
+ *
+ * Default all porting macros to use the C standard libraries. */
+
+
+#ifndef FAULTD_CONFIG_PORTING_STDLIB
+#define FAULTD_CONFIG_PORTING_STDLIB 1
+#endif
+
+/**
+ * FAULTD_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS
+ *
+ * Include standard library headers for stdlib porting macros. */
+
+
+#ifndef FAULTD_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS
+#define FAULTD_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS FAULTD_CONFIG_PORTING_STDLIB
+#endif
+
+/**
+ * FAULTD_CONFIG_INCLUDE_UCLI
+ *
+ * Include generic uCli support. */
+
+
+#ifndef FAULTD_CONFIG_INCLUDE_UCLI
+#define FAULTD_CONFIG_INCLUDE_UCLI 0
+#endif
+
+/**
+ * FAULTD_CONFIG_PIPE_NAME_DEFAULT
+ *
+ * Default named pipe. */
+
+
+#ifndef FAULTD_CONFIG_PIPE_NAME_DEFAULT
+#define FAULTD_CONFIG_PIPE_NAME_DEFAULT "/var/run/faultd.pipe"
+#endif
+
+/**
+ * FAULTD_CONFIG_BINARY_SIZE
+ *
+ * Maximum binary name size. */
+
+
+#ifndef FAULTD_CONFIG_BINARY_SIZE
+#define FAULTD_CONFIG_BINARY_SIZE 255
+#endif
+
+/**
+ * FAULTD_CONFIG_BACKTRACE_SIZE_MAX
+ *
+ * Maximum backtrace size. */
+
+
+#ifndef FAULTD_CONFIG_BACKTRACE_SIZE_MAX
+#define FAULTD_CONFIG_BACKTRACE_SIZE_MAX 32
+#endif
+
+/**
+ * FAULTD_CONFIG_SERVICE_PIPES_MAX
+ *
+ * Maximum number of simulatanous service pipes. */
+
+
+#ifndef FAULTD_CONFIG_SERVICE_PIPES_MAX
+#define FAULTD_CONFIG_SERVICE_PIPES_MAX 8
+#endif
+
+/**
+ * FAULTD_CONFIG_BACKTRACE_SYMBOLS_SIZE
+ *
+ * Maximum backtrace symbols size */
+
+
+#ifndef FAULTD_CONFIG_BACKTRACE_SYMBOLS_SIZE
+#define FAULTD_CONFIG_BACKTRACE_SYMBOLS_SIZE 4096
+#endif
+
+/**
+ * FAULTD_CONFIG_INCLUDE_MAIN
+ *
+ * Include faultd_main() for standard faultd daemon build. */
+
+
+#ifndef FAULTD_CONFIG_INCLUDE_MAIN
+#define FAULTD_CONFIG_INCLUDE_MAIN 0
+#endif
+
+/**
+ * FAULTD_CONFIG_INCLUDE_AIM_MAIN
+ *
+ * Include aim_main() as faultd_main(). */
+
+
+#ifndef FAULTD_CONFIG_INCLUDE_AIM_MAIN
+#define FAULTD_CONFIG_INCLUDE_AIM_MAIN FAULTD_CONFIG_INCLUDE_MAIN
+#endif
+
+/**
+ * FAULTD_CONFIG_MAIN_PIPENAME
+ *
+ * Default pipename used by faultd_main() if included. */
+
+
+#ifndef FAULTD_CONFIG_MAIN_PIPENAME
+#define FAULTD_CONFIG_MAIN_PIPENAME "/var/run/faultd.fifo"
+#endif
+
+
+
+/**
+ * All compile time options can be queried or displayed
+ */
+
+/** Configuration settings structure. */
+typedef struct faultd_config_settings_s {
+ /** name */
+ const char* name;
+ /** value */
+ const char* value;
+} faultd_config_settings_t;
+
+/** Configuration settings table. */
+/** faultd_config_settings table. */
+extern faultd_config_settings_t faultd_config_settings[];
+
+/**
+ * @brief Lookup a configuration setting.
+ * @param setting The name of the configuration option to lookup.
+ */
+const char* faultd_config_lookup(const char* setting);
+
+/**
+ * @brief Show the compile-time configuration.
+ * @param pvs The output stream.
+ */
+int faultd_config_show(struct aim_pvs_s* pvs);
+
+/* */
+
+#include "faultd_porting.h"
+
+#endif /* __FAULTD_CONFIG_H__ */
+/* @} */
diff --git a/packages/base/any/faultd/src/module/inc/faultd/faultd_dox.h b/packages/base/any/faultd/src/module/inc/faultd/faultd_dox.h
new file mode 100644
index 00000000..62d0f2df
--- /dev/null
+++ b/packages/base/any/faultd/src/module/inc/faultd/faultd_dox.h
@@ -0,0 +1,45 @@
+/**************************************************************************//**
+ *
+ *
+ *
+ * Copyright 2013, 2014 BigSwitch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ *
+ * faultd Doxygen Header
+ *
+ *****************************************************************************/
+#ifndef __FAULTD_DOX_H__
+#define __FAULTD_DOX_H__
+
+/**
+ * @defgroup faultd faultd - faultd Description
+ *
+
+The documentation overview for this module should go here.
+
+ *
+ * @{
+ *
+ * @defgroup faultd-faultd Public Interface
+ * @defgroup faultd-config Compile Time Configuration
+ * @defgroup faultd-porting Porting Macros
+ *
+ * @}
+ *
+ */
+
+#endif /* __FAULTD_DOX_H__ */
diff --git a/packages/base/any/faultd/src/module/inc/faultd/faultd_porting.h b/packages/base/any/faultd/src/module/inc/faultd/faultd_porting.h
new file mode 100644
index 00000000..c2212095
--- /dev/null
+++ b/packages/base/any/faultd/src/module/inc/faultd/faultd_porting.h
@@ -0,0 +1,86 @@
+/**************************************************************************//**
+ *
+ *
+ *
+ * Copyright 2013, 2014 BigSwitch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ *
+ * @file
+ * @brief faultd Porting Macros.
+ *
+ * @addtogroup faultd_porting
+ * @{
+ *
+ *****************************************************************************/
+#ifndef __FAULTD_PORTING_H__
+#define __FAULTD_PORTING_H__
+
+
+/* */
+#if FAULTD_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1
+#include
+#include
+#include
+#include
+#include
+#endif
+
+#ifndef FAULTD_MEMSET
+ #if defined(GLOBAL_MEMSET)
+ #define FAULTD_MEMSET GLOBAL_MEMSET
+ #elif FAULTD_CONFIG_PORTING_STDLIB == 1
+ #define FAULTD_MEMSET memset
+ #else
+ #error The macro FAULTD_MEMSET is required but cannot be defined.
+ #endif
+#endif
+
+#ifndef FAULTD_MEMCPY
+ #if defined(GLOBAL_MEMCPY)
+ #define FAULTD_MEMCPY GLOBAL_MEMCPY
+ #elif FAULTD_CONFIG_PORTING_STDLIB == 1
+ #define FAULTD_MEMCPY memcpy
+ #else
+ #error The macro FAULTD_MEMCPY is required but cannot be defined.
+ #endif
+#endif
+
+#ifndef FAULTD_STRNCPY
+ #if defined(GLOBAL_STRNCPY)
+ #define FAULTD_STRNCPY GLOBAL_STRNCPY
+ #elif FAULTD_CONFIG_PORTING_STDLIB == 1
+ #define FAULTD_STRNCPY strncpy
+ #else
+ #error The macro FAULTD_STRNCPY is required but cannot be defined.
+ #endif
+#endif
+
+#ifndef FAULTD_STRLEN
+ #if defined(GLOBAL_STRLEN)
+ #define FAULTD_STRLEN GLOBAL_STRLEN
+ #elif FAULTD_CONFIG_PORTING_STDLIB == 1
+ #define FAULTD_STRLEN strlen
+ #else
+ #error The macro FAULTD_STRLEN is required but cannot be defined.
+ #endif
+#endif
+
+/* */
+
+
+#endif /* __FAULTD_PORTING_H__ */
+/* @} */
diff --git a/packages/base/any/faultd/src/module/make.mk b/packages/base/any/faultd/src/module/make.mk
new file mode 100644
index 00000000..d25ba44c
--- /dev/null
+++ b/packages/base/any/faultd/src/module/make.mk
@@ -0,0 +1,25 @@
+###############################################################################
+#
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+###############################################################################
+THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
+faultd_INCLUDES := -I $(THIS_DIR)inc
+faultd_INTERNAL_INCLUDES := -I $(THIS_DIR)src
+faultd_DEPENDMODULE_ENTRIES := init:faultd ucli:faultd
+
diff --git a/packages/base/any/faultd/src/module/src/Makefile b/packages/base/any/faultd/src/module/src/Makefile
new file mode 100644
index 00000000..6fc6508e
--- /dev/null
+++ b/packages/base/any/faultd/src/module/src/Makefile
@@ -0,0 +1,31 @@
+############################################################
+#
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+# Local source generation targets.
+#
+############################################################
+include ../../../../init.mk
+
+.DEFAULT_GOAL := ucli
+
+ucli:
+ $(SUBMODULE_BIGCODE)/tools/uclihandlers.py faultd_ucli.c
+
diff --git a/packages/base/any/faultd/src/module/src/faultd.c b/packages/base/any/faultd/src/module/src/faultd.c
new file mode 100644
index 00000000..2579780c
--- /dev/null
+++ b/packages/base/any/faultd/src/module/src/faultd.c
@@ -0,0 +1,538 @@
+/**************************************************************************//**
+ *
+ *
+ * Copyright 2013, 2014 BigSwitch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ *****************************************************************************/
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include "faultd_log.h"
+
+
+typedef struct faultd_service_s {
+ /** The filename of the named pipe */
+ char* pipename;
+
+ /**
+ * The open pipe descriptor.
+ *
+ * This is opened RDONLY for the server.
+ * This is opened WRONLY for the client.
+ */
+ int pipefd;
+
+ /**
+ * Server's open write descriptor.
+ *
+ * The server-side always opens the named pipe for reading.
+ * There is not necessarily a writer for the pipe at all times, as
+ * this depends on whether any clients are currently connected.
+ *
+ * The server wants to use select() on the named pipe to wait for
+ * any client connections, but this only works properly if
+ * there is a writer connected to the pipe from which we are reading.
+ *
+ * The server always opens a write connection to the named pipe at
+ * startup time to make sure there is always at least one writer connected.
+ * We never write anything to it.
+ *
+ * Note -- empirically, it seems possible to open the pipe descriptor in
+ * O_RDWR to accomplish this behavior (instead of opening a separate
+ * descriptor), but this is technically undefined behavior.
+ */
+ int writefd;
+
+} faultd_service_t;
+
+
+
+/**
+ * faultd Server Object
+ */
+struct faultd_server_s {
+ /** All services */
+ faultd_service_t services[FAULTD_CONFIG_SERVICE_PIPES_MAX];
+ /** The last service from which we read a message */
+ int sid_last;
+}; /* faultd_server_t */
+
+
+int
+faultd_server_create(faultd_server_t** rfso)
+{
+ faultd_server_t* fso;
+
+ if(rfso == NULL) {
+ return -1;
+ }
+
+ fso = aim_zmalloc(sizeof(*fso));
+
+ *rfso = fso;
+ return 0;
+}
+
+void
+faultd_server_destroy(faultd_server_t* fso)
+{
+ int i;
+ if(fso) {
+ for(i = 0; i < AIM_ARRAYSIZE(fso->services); i++) {
+ faultd_server_remove(fso, NULL, i);
+ }
+ AIM_FREE(fso);
+ }
+}
+
+static void
+faultd_service_destroy__(faultd_service_t* sp)
+{
+ if(sp) {
+ if(sp->pipename) {
+ AIM_FREE(sp->pipename);
+ }
+ if(sp->pipefd) {
+ close(sp->pipefd);
+ }
+ if(sp->writefd) {
+ close(sp->writefd);
+ }
+ AIM_MEMSET(sp, 0, sizeof(*sp));
+ }
+}
+
+int
+faultd_server_add(faultd_server_t* fso, char* pipename)
+{
+ int i;
+ if(fso == NULL) {
+ return -1;
+ }
+ if(pipename == NULL) {
+ pipename = FAULTD_CONFIG_PIPE_NAME_DEFAULT;
+ }
+
+ /* Find a free slot */
+ for(i = 0; i < AIM_ARRAYSIZE(fso->services); i++) {
+ if(fso->services[i].pipename == NULL) {
+ int rv;
+ faultd_service_t* sp = fso->services+i;
+
+ sp->pipename = aim_strdup(pipename);
+
+ /**
+ * Create the fifo if it doesn't already exist.
+ */
+ if( mkfifo(sp->pipename, 0644) < 0) {
+ if(errno != EEXIST) {
+ goto server_add_failed;
+ }
+ }
+
+ /**
+ * Open the fifo.
+ */
+ rv = open(sp->pipename, O_RDONLY | O_NONBLOCK);
+ if(rv < 0) {
+ AIM_LOG_ERROR("open(pipe): %s", strerror(errno));
+ goto server_add_failed;
+ }
+ sp->pipefd = rv;
+
+ /**
+ * Open our write connection.
+ */
+ rv = open(sp->pipename, O_WRONLY | O_NONBLOCK);
+ if(rv < 0) {
+ AIM_LOG_ERROR("open(writefd): %s", strerror(errno));
+ goto server_add_failed;
+ }
+ sp->writefd = rv;
+
+ /**
+ * We opened the pipe originally in non-blocking mode.
+ * Otherwise, the open() would have blocked waiting for
+ * a client a client to open() it for writing.
+ *
+ * We now want all reads on the pipe to be blocking so
+ * we can use select() to pend on clients.
+ *
+ * Reset the pipe to blocking here:
+ */
+ if( (rv = fcntl(sp->pipefd, F_GETFL, 0)) < 0) {
+ goto server_add_failed;
+ }
+ rv &= ~O_NONBLOCK;
+ if(fcntl(sp->pipefd, F_SETFL, rv) < 0) {
+ goto server_add_failed;
+ }
+
+ /* Good to go. 'i' is the service id. */
+ return i;
+ }
+ }
+ /* All services full */
+ return -1;
+
+ server_add_failed:
+ faultd_server_remove(fso, NULL, i);
+ return -1;
+}
+
+int
+faultd_server_remove(faultd_server_t* fso, char* pipename,
+ faultd_sid_t sid)
+{
+ if(fso == NULL) {
+ return -1;
+ }
+ else if(sid < 0 || sid >= AIM_ARRAYSIZE(fso->services)) {
+ return -1;
+ }
+ else {
+ faultd_service_destroy__(fso->services + sid);
+ return 0;
+ }
+}
+
+int
+faultd_server_process(faultd_server_t* fdo, faultd_sid_t sid,
+ int count, aim_pvs_t* pvs, int decode)
+{
+ int c;
+ faultd_info_t fault_info;
+
+ for(c = 0; c < count || count == -1; c++) {
+ FAULTD_MEMSET(&fault_info, 0, sizeof(fault_info));
+ faultd_server_read(fdo, &fault_info, sid);
+ faultd_info_show(&fault_info, pvs, decode);
+ if(fault_info.backtrace_symbols) {
+ AIM_FREE(fault_info.backtrace_symbols);
+ }
+ }
+ return 0;
+}
+
+struct faultd_client_s {
+ faultd_service_t s;
+}; /* faultd_client_t */
+
+int
+faultd_client_create(faultd_client_t** rfco, const char* pipename)
+{
+ int rv;
+ faultd_client_t* fco;
+
+ if(rfco == NULL) {
+ return -1;
+ }
+
+ if(pipename == NULL) {
+ pipename = FAULTD_CONFIG_PIPE_NAME_DEFAULT;
+ }
+
+ fco = aim_zmalloc(sizeof(*fco));
+ fco->s.pipename = aim_strdup(pipename);
+
+ /**
+ * Open the fifo.
+ */
+ rv = open(fco->s.pipename, O_WRONLY | O_NONBLOCK);
+ if(rv < 0) {
+ goto client_create_failed;
+ }
+ fco->s.pipefd = rv;
+
+ *rfco = fco;
+ return 0;
+
+ client_create_failed:
+ faultd_client_destroy(fco);
+ return rv;
+}
+
+void
+faultd_client_destroy(faultd_client_t* fco)
+{
+ if(fco) {
+ faultd_service_destroy__(&fco->s);
+ AIM_FREE(fco);
+ }
+}
+
+static int
+read_until__(int fd, char terminator, char* dst, int size)
+{
+ int rv;
+ int count = 0;
+ char c;
+
+ do {
+ rv = read(fd, &c, 1);
+ if(rv < 0) {
+ if(errno == EINTR) {
+ continue;
+ }
+ else {
+ return rv;
+ }
+ }
+ if(count < size) {
+ dst[count] = c;
+ }
+ if(c == terminator) {
+ return count;
+ }
+ count++;
+
+ /* Fixme - need a timeout */
+ } while(1);
+}
+
+
+
+static int
+read_size__(int fd, char* dst, int size)
+{
+ int rv;
+ int remaining = size;
+ char* p = dst;
+
+ do {
+ rv = read(fd, p, remaining);
+ if(rv < 0) {
+ if(errno == EINTR) {
+ /* Keep trying */
+ continue;
+ }
+ else {
+ /* Read failed. Probably not good. */
+ /* Do something here */
+ AIM_LOG_MSG("read failed errno=%d %s\n", errno, strerror(errno));
+ return -1;
+ }
+ }
+ if(rv == 0 && remaining) {
+ /* What to do here? */
+ AIM_LOG_MSG("read() returned zero but we didn't get everything.");
+ return -1;
+ }
+ p += rv;
+ remaining -= rv;
+ } while(remaining);
+
+ return size;
+}
+
+
+static int
+write_size__(int fd, char* src, int size)
+{
+ int rv;
+ int remaining = size;
+ char* p = src;
+
+ do {
+ rv = write(fd, p, remaining);
+ if(rv < 0) {
+ if(errno == EINTR) {
+ /* Keep trying */
+ continue;
+ }
+ else {
+ /*
+ * Write failed. Probably not good.
+ * The faultd server may have died, or doesn't
+ * exist, or something else extra bad in our process.
+ * Given why we're here, maybe not too surpising.
+ *
+ * Theres really nothing else to do.
+ */
+ return -1;
+ }
+ }
+ p += rv;
+ remaining -= rv;
+ } while(remaining);
+
+ return size;
+}
+
+int
+faultd_wait_services__(faultd_server_t* fso, int sid, fd_set* rfds)
+{
+ int rv;
+ int maxfd;
+
+ FD_ZERO(rfds);
+
+ if(sid < 0 && sid >= AIM_ARRAYSIZE(fso->services) && sid != -1) {
+ /* invalid sid */
+ return -1;
+ }
+
+ if(sid == -1) {
+ /* All services */
+ int i;
+ for(i = 0, maxfd = 0; i < AIM_ARRAYSIZE(fso->services); i++) {
+ if(fso->services[i].pipefd) {
+ FD_SET(fso->services[i].pipefd, rfds);
+ if(fso->services[i].pipefd > maxfd) {
+ maxfd = fso->services[i].pipefd;
+ }
+ }
+ }
+ }
+ else {
+ /* Single service */
+ if(fso->services[sid].pipefd == 0) {
+ /* Invalid sid */
+ return -1;
+ }
+ else {
+ FD_SET(fso->services[sid].pipefd, rfds);
+ maxfd = fso->services[sid].pipefd;
+ }
+ }
+
+ /* Wait on configured services */
+ do {
+ rv = select(maxfd+1, rfds, NULL, NULL, NULL);
+ } while(rv == -1 && errno == EINTR);
+
+ return rv;
+}
+
+
+int
+faultd_server_read(faultd_server_t* fso, faultd_info_t* info, int sid)
+{
+ int i;
+ int rv;
+ fd_set rfds;
+ int count;
+
+ rv = faultd_wait_services__(fso, sid, &rfds);
+
+ if(rv < 0) {
+ /* Error on select or sid */
+ return rv;
+ }
+
+ /**
+ * Read message on a ready descriptor.
+ *
+ * If we're polling all services, we start looking for the
+ * next sid after the last sid we've received a message on.
+ * This avoids starvation if multiple services are producing
+ * messages. This is unlikely to be a problem under normal
+ * circumstances and use cases, but can be avoided easily nonetheless.
+ */
+ for(i = fso->sid_last+1, count = 0;
+ count < AIM_ARRAYSIZE(fso->services);
+ i++, count++) {
+ int s = i % AIM_ARRAYSIZE(fso->services);
+ if(FD_ISSET(fso->services[s].pipefd, &rfds)) {
+ rv = read_size__(fso->services[s].pipefd, (char*)info, sizeof(*info));
+
+ if(rv < 0) {
+ /* Do something here, like restare the pipe */
+ AIM_LOG_ERROR("truncated read on pipe.");
+ continue;
+ }
+
+ /**
+ * Backtrace symbols information available?
+ */
+ if(info->backtrace_symbols) {
+ /*
+ * The backtrace symbol information is of variable length.
+ */
+ info->backtrace_symbols = aim_zmalloc(FAULTD_CONFIG_BACKTRACE_SYMBOLS_SIZE);
+ /* Backtrace symbols are terminated with a null character. */
+ read_until__(fso->services[s].pipefd, 0, info->backtrace_symbols,
+ FAULTD_CONFIG_BACKTRACE_SYMBOLS_SIZE);
+ }
+
+ info->pipename = fso->services[s].pipename;
+ fso->sid_last = s;
+ return s;
+ }
+ }
+ /* Error while reading on the only ready descriptor */
+ return -1;
+}
+
+
+int
+faultd_client_write(faultd_client_t* fco, faultd_info_t* info)
+{
+ int rv = write_size__(fco->s.pipefd, (char*)info, sizeof(*info));
+
+ if(rv < 0) {
+ return rv;
+ }
+
+ if(info->backtrace_symbols) {
+ char c = 0;
+ backtrace_symbols_fd(info->backtrace, info->backtrace_size,
+ fco->s.pipefd);
+ /* Terminate backtrace symbols with a null character. */
+ write_size__(fco->s.pipefd, &c, 1);
+ }
+ return 0;
+}
+
+int
+faultd_info_show(faultd_info_t* info, aim_pvs_t* pvs, int decode)
+{
+ int i = 0;
+ aim_printf(pvs, "service = %s\n", info->pipename);
+ aim_printf(pvs, "binary = %s\n", info->binary);
+ aim_printf(pvs, "pid = %d\n", info->pid);
+ aim_printf(pvs, "tid = %d\n", info->tid);
+ aim_printf(pvs, "signal = %d (%s)\n", info->signal, strsignal(info->signal));
+ aim_printf(pvs, "code = %d\n", info->signal_code);
+ aim_printf(pvs, "fa = %p\n", info->fault_address);
+ aim_printf(pvs, "errno = %d\n", info->last_errno);
+ aim_printf(pvs, "backtrace_size=%d\n", info->backtrace_size);
+ for(i = 0; i < info->backtrace_size; i++) {
+ aim_printf(pvs, " %p\n", info->backtrace[i]);
+ }
+ aim_printf(pvs, "backtrace_symbols: %p\n", info->backtrace_symbols);
+ if(info->backtrace_symbols) {
+ aim_printf(pvs, "%s\n", info->backtrace_symbols);
+ }
+ return 0;
+}
+
+
+
+
+
+
+
+
+
diff --git a/packages/base/any/faultd/src/module/src/faultd_config.c b/packages/base/any/faultd/src/module/src/faultd_config.c
new file mode 100644
index 00000000..97d2e176
--- /dev/null
+++ b/packages/base/any/faultd/src/module/src/faultd_config.c
@@ -0,0 +1,131 @@
+/**************************************************************************//**
+ *
+ *
+ * Copyright 2013, 2014 BigSwitch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ *****************************************************************************/
+#include
+
+/* */
+#define __faultd_config_STRINGIFY_NAME(_x) #_x
+#define __faultd_config_STRINGIFY_VALUE(_x) __faultd_config_STRINGIFY_NAME(_x)
+faultd_config_settings_t faultd_config_settings[] =
+{
+#ifdef FAULTD_CONFIG_INCLUDE_LOGGING
+ { __faultd_config_STRINGIFY_NAME(FAULTD_CONFIG_INCLUDE_LOGGING), __faultd_config_STRINGIFY_VALUE(FAULTD_CONFIG_INCLUDE_LOGGING) },
+#else
+{ FAULTD_CONFIG_INCLUDE_LOGGING(__faultd_config_STRINGIFY_NAME), "__undefined__" },
+#endif
+#ifdef FAULTD_CONFIG_LOG_OPTIONS_DEFAULT
+ { __faultd_config_STRINGIFY_NAME(FAULTD_CONFIG_LOG_OPTIONS_DEFAULT), __faultd_config_STRINGIFY_VALUE(FAULTD_CONFIG_LOG_OPTIONS_DEFAULT) },
+#else
+{ FAULTD_CONFIG_LOG_OPTIONS_DEFAULT(__faultd_config_STRINGIFY_NAME), "__undefined__" },
+#endif
+#ifdef FAULTD_CONFIG_LOG_BITS_DEFAULT
+ { __faultd_config_STRINGIFY_NAME(FAULTD_CONFIG_LOG_BITS_DEFAULT), __faultd_config_STRINGIFY_VALUE(FAULTD_CONFIG_LOG_BITS_DEFAULT) },
+#else
+{ FAULTD_CONFIG_LOG_BITS_DEFAULT(__faultd_config_STRINGIFY_NAME), "__undefined__" },
+#endif
+#ifdef FAULTD_CONFIG_LOG_CUSTOM_BITS_DEFAULT
+ { __faultd_config_STRINGIFY_NAME(FAULTD_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __faultd_config_STRINGIFY_VALUE(FAULTD_CONFIG_LOG_CUSTOM_BITS_DEFAULT) },
+#else
+{ FAULTD_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__faultd_config_STRINGIFY_NAME), "__undefined__" },
+#endif
+#ifdef FAULTD_CONFIG_PORTING_STDLIB
+ { __faultd_config_STRINGIFY_NAME(FAULTD_CONFIG_PORTING_STDLIB), __faultd_config_STRINGIFY_VALUE(FAULTD_CONFIG_PORTING_STDLIB) },
+#else
+{ FAULTD_CONFIG_PORTING_STDLIB(__faultd_config_STRINGIFY_NAME), "__undefined__" },
+#endif
+#ifdef FAULTD_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS
+ { __faultd_config_STRINGIFY_NAME(FAULTD_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __faultd_config_STRINGIFY_VALUE(FAULTD_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) },
+#else
+{ FAULTD_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__faultd_config_STRINGIFY_NAME), "__undefined__" },
+#endif
+#ifdef FAULTD_CONFIG_INCLUDE_UCLI
+ { __faultd_config_STRINGIFY_NAME(FAULTD_CONFIG_INCLUDE_UCLI), __faultd_config_STRINGIFY_VALUE(FAULTD_CONFIG_INCLUDE_UCLI) },
+#else
+{ FAULTD_CONFIG_INCLUDE_UCLI(__faultd_config_STRINGIFY_NAME), "__undefined__" },
+#endif
+#ifdef FAULTD_CONFIG_PIPE_NAME_DEFAULT
+ { __faultd_config_STRINGIFY_NAME(FAULTD_CONFIG_PIPE_NAME_DEFAULT), __faultd_config_STRINGIFY_VALUE(FAULTD_CONFIG_PIPE_NAME_DEFAULT) },
+#else
+{ FAULTD_CONFIG_PIPE_NAME_DEFAULT(__faultd_config_STRINGIFY_NAME), "__undefined__" },
+#endif
+#ifdef FAULTD_CONFIG_BINARY_SIZE
+ { __faultd_config_STRINGIFY_NAME(FAULTD_CONFIG_BINARY_SIZE), __faultd_config_STRINGIFY_VALUE(FAULTD_CONFIG_BINARY_SIZE) },
+#else
+{ FAULTD_CONFIG_BINARY_SIZE(__faultd_config_STRINGIFY_NAME), "__undefined__" },
+#endif
+#ifdef FAULTD_CONFIG_BACKTRACE_SIZE_MAX
+ { __faultd_config_STRINGIFY_NAME(FAULTD_CONFIG_BACKTRACE_SIZE_MAX), __faultd_config_STRINGIFY_VALUE(FAULTD_CONFIG_BACKTRACE_SIZE_MAX) },
+#else
+{ FAULTD_CONFIG_BACKTRACE_SIZE_MAX(__faultd_config_STRINGIFY_NAME), "__undefined__" },
+#endif
+#ifdef FAULTD_CONFIG_SERVICE_PIPES_MAX
+ { __faultd_config_STRINGIFY_NAME(FAULTD_CONFIG_SERVICE_PIPES_MAX), __faultd_config_STRINGIFY_VALUE(FAULTD_CONFIG_SERVICE_PIPES_MAX) },
+#else
+{ FAULTD_CONFIG_SERVICE_PIPES_MAX(__faultd_config_STRINGIFY_NAME), "__undefined__" },
+#endif
+#ifdef FAULTD_CONFIG_BACKTRACE_SYMBOLS_SIZE
+ { __faultd_config_STRINGIFY_NAME(FAULTD_CONFIG_BACKTRACE_SYMBOLS_SIZE), __faultd_config_STRINGIFY_VALUE(FAULTD_CONFIG_BACKTRACE_SYMBOLS_SIZE) },
+#else
+{ FAULTD_CONFIG_BACKTRACE_SYMBOLS_SIZE(__faultd_config_STRINGIFY_NAME), "__undefined__" },
+#endif
+#ifdef FAULTD_CONFIG_INCLUDE_MAIN
+ { __faultd_config_STRINGIFY_NAME(FAULTD_CONFIG_INCLUDE_MAIN), __faultd_config_STRINGIFY_VALUE(FAULTD_CONFIG_INCLUDE_MAIN) },
+#else
+{ FAULTD_CONFIG_INCLUDE_MAIN(__faultd_config_STRINGIFY_NAME), "__undefined__" },
+#endif
+#ifdef FAULTD_CONFIG_INCLUDE_AIM_MAIN
+ { __faultd_config_STRINGIFY_NAME(FAULTD_CONFIG_INCLUDE_AIM_MAIN), __faultd_config_STRINGIFY_VALUE(FAULTD_CONFIG_INCLUDE_AIM_MAIN) },
+#else
+{ FAULTD_CONFIG_INCLUDE_AIM_MAIN(__faultd_config_STRINGIFY_NAME), "__undefined__" },
+#endif
+#ifdef FAULTD_CONFIG_MAIN_PIPENAME
+ { __faultd_config_STRINGIFY_NAME(FAULTD_CONFIG_MAIN_PIPENAME), __faultd_config_STRINGIFY_VALUE(FAULTD_CONFIG_MAIN_PIPENAME) },
+#else
+{ FAULTD_CONFIG_MAIN_PIPENAME(__faultd_config_STRINGIFY_NAME), "__undefined__" },
+#endif
+ { NULL, NULL }
+};
+#undef __faultd_config_STRINGIFY_VALUE
+#undef __faultd_config_STRINGIFY_NAME
+
+const char*
+faultd_config_lookup(const char* setting)
+{
+ int i;
+ for(i = 0; faultd_config_settings[i].name; i++) {
+ if(strcmp(faultd_config_settings[i].name, setting)) {
+ return faultd_config_settings[i].value;
+ }
+ }
+ return NULL;
+}
+
+int
+faultd_config_show(struct aim_pvs_s* pvs)
+{
+ int i;
+ for(i = 0; faultd_config_settings[i].name; i++) {
+ aim_printf(pvs, "%s = %s\n", faultd_config_settings[i].name, faultd_config_settings[i].value);
+ }
+ return i;
+}
+
+/* */
+
diff --git a/packages/base/any/faultd/src/module/src/faultd_enums.c b/packages/base/any/faultd/src/module/src/faultd_enums.c
new file mode 100644
index 00000000..bfaf116c
--- /dev/null
+++ b/packages/base/any/faultd/src/module/src/faultd_enums.c
@@ -0,0 +1,25 @@
+/**************************************************************************//**
+ *
+ *
+ * Copyright 2013, 2014 BigSwitch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ *****************************************************************************/
+#include
+
+/* <--auto.start.enum(ALL).source> */
+/* */
+
diff --git a/packages/base/any/faultd/src/module/src/faultd_handler.c b/packages/base/any/faultd/src/module/src/faultd_handler.c
new file mode 100644
index 00000000..7c01ebf1
--- /dev/null
+++ b/packages/base/any/faultd/src/module/src/faultd_handler.c
@@ -0,0 +1,202 @@
+/**************************************************************************//**
+ *
+ *
+ * Copyright 2013, 2014 BigSwitch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ *****************************************************************************/
+#include
+
+#define __USE_GNU /* Needed to get REG_EIP from ucontext.h */
+
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#define _XOPEN_SOURCE 600
+#include
+
+
+static pthread_spinlock_t thread_lock__;
+static faultd_client_t* faultd_client__ = NULL;
+static faultd_info_t faultd_info__;
+static int localfd__ = -1;
+
+inline int signal_backtrace__(void** buffer, int size, ucontext_t* context,
+ int distance)
+{
+#define IP_STACK_FRAME_NUMBER 3
+
+ int rv;
+ rv = backtrace(buffer, size);
+
+ if(context) {
+ distance += IP_STACK_FRAME_NUMBER;
+
+#ifdef __i386__
+ buffer[distance] = (void*)(context->uc_mcontext.gregs[REG_EIP]);
+#endif
+#ifdef __PPC__
+ buffer[distance] = (void*)(context->uc_mcontext.regs->nip);
+#endif
+ /* Note -- 64bit does not require require modifications */
+ }
+ return rv;
+}
+ #include
+static void
+faultd_signal_handler__(int signal, siginfo_t* siginfo, void* context)
+{
+ int rv;
+
+ /*
+ * Make sure we syncronize properly with other threads that
+ * may *also* be faulting
+ */
+ rv = pthread_spin_trylock(&thread_lock__);
+
+ if (rv == EBUSY) {
+ sigset_t mask;
+ sigemptyset(&mask);
+ pselect(0, NULL, NULL, NULL, NULL, &mask);
+ }
+
+ /*
+ * Generate our fault information.
+ */
+ faultd_info__.pid = getpid();
+ faultd_info__.tid = 0;
+ faultd_info__.signal = signal;
+ faultd_info__.signal_code = siginfo->si_code;
+ faultd_info__.fault_address = siginfo->si_addr;
+ faultd_info__.last_errno = errno;
+
+ faultd_info__.backtrace_size = signal_backtrace__(faultd_info__.backtrace,
+ AIM_ARRAYSIZE(faultd_info__.backtrace),
+ context, 0);
+ faultd_info__.backtrace_symbols = (void*)1;
+ if(faultd_client__) {
+ faultd_client_write(faultd_client__, &faultd_info__);
+ }
+ if(localfd__ >= 0) {
+ char* signame = strsignal(faultd_info__.signal);
+ char* nl = "\n";
+ write(localfd__, signame, strlen(signame)+1);
+ write(localfd__, nl, 2);
+ backtrace_symbols_fd(faultd_info__.backtrace,
+ faultd_info__.backtrace_size,
+ localfd__);
+ }
+
+ /*
+ * Unlock spinlock, in case this signal wasn't fatal
+ */
+ pthread_spin_unlock(&thread_lock__);
+}
+
+
+int
+faultd_handler_register(int localfd,
+ const char* pipename,
+ const char* binaryname)
+{
+ int rv;
+ struct sigaction saction;
+ void* dummy_backtrace[1];
+ int dummy_backtrace_size;
+ int fd;
+
+ if ( (rv = pthread_spin_init(&thread_lock__, 0)) ) {
+ return rv;
+ }
+
+ /*
+ * These calls to backtrace are to assure that
+ * backtrace() and backtrace_symbols_fd() have actually
+ * been loaded into our process -- its possible they
+ * come from a dynamic library, and we don't want them
+ * to get loaded at fault-time.
+ */
+ dummy_backtrace_size = backtrace(dummy_backtrace, 1);
+
+ /** Note - we could just pass an invalid descriptor here, but it
+ * it flags errors in valgrind.
+ */
+ fd = open("/dev/null", O_WRONLY);
+ backtrace_symbols_fd(dummy_backtrace, dummy_backtrace_size, fd);
+ close(fd);
+
+ AIM_MEMSET(&faultd_info__, 0, sizeof(faultd_info__));
+ if(!binaryname) {
+ binaryname = "Not specified.";
+ }
+ aim_strlcpy(faultd_info__.binary, binaryname, sizeof(faultd_info__.binary));
+
+
+ if(pipename) {
+ faultd_client_create(&faultd_client__, pipename);
+ }
+
+ AIM_MEMSET(&saction, 0, sizeof(saction));
+ saction.sa_sigaction = faultd_signal_handler__;
+
+ sigfillset(&saction.sa_mask);
+ saction.sa_flags = SA_SIGINFO | SA_RESETHAND;
+
+ rv = sigaction (SIGSEGV, &saction, NULL);
+ rv |= sigaction (SIGILL, &saction, NULL);
+ rv |= sigaction (SIGFPE, &saction, NULL);
+ rv |= sigaction (SIGBUS, &saction, NULL);
+ rv |= sigaction (SIGQUIT, &saction, NULL);
+ rv |= sigaction (SIGALRM, &saction, NULL);
+
+ /*
+ * SIGUSR2 can be used to request a backtrace explicitly.
+ * In this case, we don't want to reset the handler.
+ */
+ saction.sa_flags = SA_SIGINFO;
+ rv |= sigaction (SIGUSR2, &saction, NULL);
+
+ /*
+ * The local fault handler will attempt to write a subset of
+ * the fault information (signal type and backtrace)
+ * to the localfd descriptor if specified.
+ */
+ localfd__ = localfd;
+
+ return rv;
+}
+
+
+
+
+
+
diff --git a/packages/base/any/faultd/src/module/src/faultd_int.h b/packages/base/any/faultd/src/module/src/faultd_int.h
new file mode 100644
index 00000000..a5d5997d
--- /dev/null
+++ b/packages/base/any/faultd/src/module/src/faultd_int.h
@@ -0,0 +1,30 @@
+/**************************************************************************//**
+ *
+ *
+ * Copyright 2013, 2014 BigSwitch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ *
+ * faultd Internal Header
+ *
+ *****************************************************************************/
+#ifndef __FAULTD_INT_H__
+#define __FAULTD_INT_H__
+
+#include
+
+
+#endif /* __FAULTD_INT_H__ */
diff --git a/packages/base/any/faultd/src/module/src/faultd_log.c b/packages/base/any/faultd/src/module/src/faultd_log.c
new file mode 100644
index 00000000..1ea149e1
--- /dev/null
+++ b/packages/base/any/faultd/src/module/src/faultd_log.c
@@ -0,0 +1,33 @@
+/**************************************************************************//**
+ *
+ *
+ * Copyright 2013, 2014 BigSwitch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ *****************************************************************************/
+#include
+
+#include "faultd_log.h"
+/*
+ * faultd log struct.
+ */
+AIM_LOG_STRUCT_DEFINE(
+ FAULTD_CONFIG_LOG_OPTIONS_DEFAULT | AIM_LOG_OPTION_BIT_TIMESTAMP,
+ FAULTD_CONFIG_LOG_BITS_DEFAULT,
+ NULL, /* Custom log map */
+ FAULTD_CONFIG_LOG_CUSTOM_BITS_DEFAULT
+ );
+
diff --git a/packages/base/any/faultd/src/module/src/faultd_log.h b/packages/base/any/faultd/src/module/src/faultd_log.h
new file mode 100644
index 00000000..58ff10e7
--- /dev/null
+++ b/packages/base/any/faultd/src/module/src/faultd_log.h
@@ -0,0 +1,29 @@
+/**************************************************************************//**
+ *
+ *
+ *
+ * Copyright 2013, 2014 BigSwitch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ * *
+ *
+ *****************************************************************************/
+#ifndef __FAULTD_LOG_H__
+#define __FAULTD_LOG_H__
+
+#define AIM_LOG_MODULE_NAME faultd
+#include
+
+#endif /* __FAULTD_LOG_H__ */
diff --git a/packages/base/any/faultd/src/module/src/faultd_main.c b/packages/base/any/faultd/src/module/src/faultd_main.c
new file mode 100644
index 00000000..d1b5a581
--- /dev/null
+++ b/packages/base/any/faultd/src/module/src/faultd_main.c
@@ -0,0 +1,221 @@
+/**************************************************************************//**
+ *
+ *
+ *
+ * Copyright 2013, 2014 BigSwitch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ *
+ *****************************************************************************/
+#include
+
+#if FAULTD_CONFIG_INCLUDE_MAIN == 1
+
+#include
+#include
+
+#define AIM_LOG_MODULE_NAME faultd
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+
+AIM_LOG_STRUCT_DEFINE(
+ AIM_LOG_OPTIONS_DEFAULT,
+ AIM_LOG_BITS_DEFAULT,
+ NULL, 0);
+
+
+static int test__(const char* binaryname, const char* pipename);
+
+/**
+ * Basic faultd Agent
+ *
+ * Hardcoded to :
+ * - Listen on FAULTD_CONFIG_MAIN_PIPENAME
+ * - Output messages to syslog and stderr (if a tty)
+ * - Daemonize and Restart on "-d", "-dr"
+ */
+
+static char help__[] =
+"NAME\n\
+ faultd - Fault Reporting Agent\n\
+\n\
+SYNOPSIS\n\
+\n\
+ faultd [-dr|-d] [-pid file] [-t] [-h | --help]\n\
+\n\
+OPTIONS\n\
+ -d Daemonize.\n\
+\n\
+ -dr Daemonize with automatic restart.\n\
+ -p Server pipe. Default is %s\n\
+\n\
+ -pid file Write PID to the given filename.\n\
+\n\
+ -t Test mode. Sends a test backtrace the the existing faultd\n\
+ server.\n\
+\n\
+ -h This help message.\n\
+ -help\n\
+\n";
+
+
+int
+faultd_main(int argc, char* argv[])
+{
+ char** arg;
+
+ char* pidfile = NULL;
+ int daemonize = 0;
+ int restart = 0;
+ int test = 0;
+ char* pipename = FAULTD_CONFIG_MAIN_PIPENAME;
+
+ aim_pvs_t* aim_pvs_syslog = NULL;
+ faultd_server_t* faultd_server = NULL;
+ int sid = -1;
+
+
+ for(arg = argv+1; *arg; arg++) {
+ if(!strcmp(*arg, "-dr")) {
+ daemonize=1;
+ restart=1;
+ }
+ else if(!strcmp(*arg, "-d")) {
+ daemonize=1;
+ restart=0;
+ }
+ else if(!strcmp(*arg, "-pid")) {
+ arg++;
+ pidfile = *arg;
+ if(!pidfile) {
+ fprintf(stderr, "-pid requires an argument.\n");
+ exit(1);
+ }
+ }
+ else if(!strcmp(*arg, "-p")) {
+ arg++;
+ pipename = *arg;
+ if(!pipename) {
+ fprintf(stderr, "-p requires an argument.\n");
+ exit(1);
+ }
+ }
+ else if(!strcmp(*arg, "-t")) {
+ test = 1;
+ }
+ else if(!strcmp(*arg, "-h") || !strcmp(*arg, "--help")) {
+ printf(help__, FAULTD_CONFIG_MAIN_PIPENAME);
+ exit(0);
+ }
+ }
+
+ if(test) {
+ return test__(argv[0], pipename);
+ }
+
+ /**
+ * Start Server
+ */
+ aim_pvs_syslog = aim_pvs_syslog_open("faultd", LOG_PID, LOG_DAEMON);
+ aim_printf(aim_pvs_syslog, "faultd starting");
+ faultd_server_create(&faultd_server);
+ sid = faultd_server_add(faultd_server, pipename);
+
+ if(sid < 0) {
+ perror("server_add:");
+ abort();
+ }
+
+ if(daemonize) {
+ aim_daemon_restart_config_t rconfig;
+ aim_daemon_config_t config;
+
+ memset(&config, 0, sizeof(config));
+ aim_daemon_restart_config_init(&rconfig, 1, 1);
+ AIM_BITMAP_CLR(&rconfig.signal_restarts, SIGTERM);
+ AIM_BITMAP_CLR(&rconfig.signal_restarts, SIGKILL);
+ rconfig.maximum_restarts=0;
+ rconfig.pvs = aim_pvs_syslog_get();
+
+ config.wd = "/";
+ if(restart) {
+ aim_daemonize(&config, &rconfig);
+ }
+ else {
+ aim_daemonize(&config, NULL);
+ }
+ }
+
+ /*
+ * Write our PID file if requested.
+ */
+ if(pidfile) {
+ FILE* fp = fopen(pidfile, "w");
+ if(fp == NULL) {
+ int e = errno;
+ aim_printf(aim_pvs_syslog, "fatal: open(%s): %s\n",
+ pidfile, strerror(e));
+ aim_printf(&aim_pvs_stderr, "fatal: open(%s): %s\n",
+ pidfile, strerror(e));
+
+ /* Don't attempt restart */
+ raise(SIGTERM);
+ }
+ fprintf(fp, "%d\n", getpid());
+ fclose(fp);
+ }
+
+ /**
+ * Process Fault Messages
+ */
+ for(;;) {
+ faultd_info_t faultd_info;
+ memset(&faultd_info, 0, sizeof(faultd_info));
+ if(faultd_server_read(faultd_server, &faultd_info, sid) >= 0) {
+ faultd_info_show(&faultd_info, aim_pvs_syslog, 0);
+ if(aim_pvs_isatty(&aim_pvs_stderr)) {
+ faultd_info_show(&faultd_info, &aim_pvs_stderr, 0);
+ }
+ }
+ }
+}
+
+static int
+test__(const char* binaryname, const char* pipename)
+{
+ /**
+ * Send a backtrace to the current faultd server.
+ */
+ faultd_handler_register(0, pipename, binaryname);
+ raise(SIGUSR2);
+ return 0;
+}
+
+#if FAULTD_CONFIG_INCLUDE_AIM_MAIN == 1
+int aim_main(int argc, char* argv[])
+{
+ return faultd_main(argc, argv);
+}
+#endif
+#else /* FAULTD_CONFIG_INCLUDE_MAIN */
+int __not_empty__;
+#endif
diff --git a/packages/base/any/faultd/src/module/src/faultd_module.c b/packages/base/any/faultd/src/module/src/faultd_module.c
new file mode 100644
index 00000000..ca4789f6
--- /dev/null
+++ b/packages/base/any/faultd/src/module/src/faultd_module.c
@@ -0,0 +1,41 @@
+/**************************************************************************//**
+ *
+ *
+ *
+ * Copyright 2013, 2014 BigSwitch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ *
+ *
+ *****************************************************************************/
+#include
+
+#include "faultd_log.h"
+
+static int
+datatypes_init__(void)
+{
+#define FAULTD_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL);
+#include
+ return 0;
+}
+
+void __faultd_module_init__(void)
+{
+ AIM_LOG_STRUCT_REGISTER();
+ datatypes_init__();
+}
+
diff --git a/packages/base/any/faultd/src/module/src/faultd_ucli.c b/packages/base/any/faultd/src/module/src/faultd_ucli.c
new file mode 100644
index 00000000..a8a4b7d7
--- /dev/null
+++ b/packages/base/any/faultd/src/module/src/faultd_ucli.c
@@ -0,0 +1,77 @@
+/**************************************************************************//**
+ *
+ *
+ * Copyright 2013, 2014 BigSwitch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ *****************************************************************************/
+#include
+
+#if FAULTD_CONFIG_INCLUDE_UCLI == 1
+
+#include
+#include
+#include
+
+static ucli_status_t
+faultd_ucli_ucli__config__(ucli_context_t* uc)
+{
+ UCLI_HANDLER_MACRO_MODULE_CONFIG(faultd)
+}
+
+/* */
+/******************************************************************************
+ *
+ * These handler table(s) were autogenerated from the symbols in this
+ * source file.
+ *
+ *****************************************************************************/
+static ucli_command_handler_f faultd_ucli_ucli_handlers__[] =
+{
+ faultd_ucli_ucli__config__,
+ NULL
+};
+/******************************************************************************/
+/* */
+
+static ucli_module_t
+faultd_ucli_module__ =
+ {
+ "faultd_ucli",
+ NULL,
+ faultd_ucli_ucli_handlers__,
+ NULL,
+ NULL,
+ };
+
+ucli_node_t*
+faultd_ucli_node_create(void)
+{
+ ucli_node_t* n;
+ ucli_module_init(&faultd_ucli_module__);
+ n = ucli_node_create("faultd", NULL, &faultd_ucli_module__);
+ ucli_node_subnode_add(n, ucli_module_log_node_create("faultd"));
+ return n;
+}
+
+#else
+void*
+faultd_ucli_node_create(void)
+{
+ return NULL;
+}
+#endif
+
diff --git a/packages/base/any/faultd/src/module/src/make.mk b/packages/base/any/faultd/src/module/src/make.mk
new file mode 100644
index 00000000..34aaf2b4
--- /dev/null
+++ b/packages/base/any/faultd/src/module/src/make.mk
@@ -0,0 +1,24 @@
+###############################################################################
+#
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+###############################################################################
+
+LIBRARY := faultd
+$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST)))
+include $(BUILDER)/lib.mk
diff --git a/packages/base/any/faultd/src/utest/_make.mk b/packages/base/any/faultd/src/utest/_make.mk
new file mode 100644
index 00000000..0f4642e9
--- /dev/null
+++ b/packages/base/any/faultd/src/utest/_make.mk
@@ -0,0 +1,27 @@
+############################################################
+#
+#
+# Copyright 2013, 2014 BigSwitch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+# faultd Unit Test Makefile.
+#
+############################################################
+UMODULE := faultd
+UMODULE_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST)))
+include $(BUILDER)/utest.mk
diff --git a/packages/base/any/faultd/src/utest/main.c b/packages/base/any/faultd/src/utest/main.c
new file mode 100644
index 00000000..cc12e4dd
--- /dev/null
+++ b/packages/base/any/faultd/src/utest/main.c
@@ -0,0 +1,166 @@
+/**************************************************************************//**
+ *
+ *
+ * Copyright 2013, 2014 BigSwitch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ *****************************************************************************/
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#define LOCALNAME "faultd.pipe"
+
+int
+client_main(int argc, char* argv[])
+{
+ /* Report a dummy message */
+ faultd_info_t info;
+ faultd_client_t* clientfd;
+ int count = 1;
+ int i;
+ void* backtrace_symbols = NULL;
+ char* service = LOCALNAME;
+
+ if(argc >= 1) {
+ count = atoi(argv[0]);
+ }
+ if(argc >= 2) {
+ intptr_t bts = atoi(argv[1]);
+ backtrace_symbols = (void*)bts;
+ }
+ if(argc >= 3) {
+ service = argv[2];
+ }
+ for(i = 0; i < count || count == -1; i++) {
+ if(faultd_client_create(&clientfd, service) < 0) {
+ perror("client_create: ");
+ abort();
+ }
+ strcpy(info.binary, "client_main");
+ info.pid = getpid();
+ info.tid = 100;
+ info.signal = SIGSEGV;
+ info.signal_code = i;
+ info.fault_address = (void*)(0xDEAD);
+ info.last_errno = -42;
+ info.backtrace_size = backtrace(info.backtrace, AIM_ARRAYSIZE(info.backtrace));
+ info.backtrace_symbols = backtrace_symbols;
+ printf("writing msg...\n");
+ faultd_client_write(clientfd, &info);
+ faultd_client_destroy(clientfd);
+ }
+ return 0;
+
+}
+
+int
+server_main(int argc, char* argv[])
+{
+ int count = -1;
+ int decode = 0;
+ faultd_server_t* fso;
+
+ if(argc >= 1) {
+ count = atoi(argv[0]);
+ }
+ if(argc >= 2) {
+ decode = atoi(argv[1]);
+ }
+
+ if(faultd_server_create(&fso)) {
+ abort();
+ }
+
+ if(argc >= 3) {
+ int i;
+ for(i = 2; i < argc; i++) {
+ if(faultd_server_add(fso, argv[i]) < 0) {
+ abort();
+ }
+ }
+ }
+ else {
+ if(faultd_server_add(fso, LOCALNAME) < 0) {
+ abort();
+ }
+ }
+ faultd_server_process(fso, -1, count, &aim_pvs_stdout, decode);
+ faultd_server_destroy(fso);
+ return 0;
+}
+
+int
+utest_main(int argc, char* argv[])
+{
+ fprintf(stderr, "No standalone unit test implemented.\n");
+ return 0;
+}
+
+int
+local_main(int argc, char* argv[])
+{
+ int i = 0;
+ /** Just test local descriptor fault processing */
+ if(faultd_handler_register(0, LOCALNAME, "utest") < 0) {
+ fprintf(stderr, "faultd_handler_register() failed.");
+ abort();
+ }
+ for(;;) {
+ sleep(1);
+ printf("count = %d\n", i++);
+ if(i % 5 == 0) {
+ * ((int*)(0)) = 0;
+ }
+ }
+ return 0;
+}
+
+int
+aim_main(int argc, char* argv[])
+{
+ if(argc == 1) {
+ /* Run in unit test mode */
+ return utest_main(argc, argv);
+ }
+ else {
+ argc--;
+ argv++;
+ if(!strcmp(argv[0], "-c")) {
+ return client_main(--argc, ++argv);
+ }
+ if(!strcmp(argv[0], "-s")) {
+ return server_main(--argc, ++argv);
+ }
+ if(!strcmp(argv[0], "-l")) {
+ return local_main(--argc, ++argv);
+ }
+ if(!strcmp(argv[0], "-u")) {
+ return utest_main(--argc, ++argv);
+ }
+ fprintf(stderr, "Unknown option '%s'\n", argv[0]);
+ return 1;
+ }
+}
+
diff --git a/packages/base/any/initrds/loader/APKG.yml b/packages/base/any/initrds/loader/APKG.yml
new file mode 100644
index 00000000..bb3b8793
--- /dev/null
+++ b/packages/base/any/initrds/loader/APKG.yml
@@ -0,0 +1,30 @@
+############################################################
+#
+# Loader Package Template
+#
+# Requires: ARCH
+#
+############################################################
+prerequisites:
+ packages: [ "onl-buildroot-initrd:$ARCH", "onl-loader-initrd-files:all" ]
+
+common:
+ arch: $ARCH
+ version: 1.0.0
+ copyright: Copyright 2013, 2014, 2015 Big Switch Networks
+ maintainer: support@bigswitch.com
+
+packages:
+ - name: onl-loader-initrd
+ version: 1.0.0
+ summary: Open Network Linux Loader Initrd CPIO ($ARCH)
+
+ files:
+ builds/onl-loader-initrd-$ARCH.cpio.gz : $$PKG_INSTALL/
+ builds/manifest.json : $$PKG_INSTALL/
+
+ changelog: Change changes changes.,
+
+
+
+
diff --git a/packages/base/any/initrds/loader/builds/Makefile b/packages/base/any/initrds/loader/builds/Makefile
new file mode 100644
index 00000000..23bc0fbb
--- /dev/null
+++ b/packages/base/any/initrds/loader/builds/Makefile
@@ -0,0 +1,35 @@
+############################################################
+#
+# ONL Loader Initrd Build Template.
+#
+############################################################
+ifndef ARCH
+$(error $$ARCH must be set)
+endif
+
+ifndef PLATFORMS
+# Include all available platforms in the current architecture.
+PLATFORMS := $(shell onlpm --list-platforms --arch $(ARCH))
+endif
+
+PLATFORM_PACKAGES := $(foreach p,$(PLATFORMS),onl-platform-config-$(p):$(ARCH))
+
+ROOT := root
+TARGET := onl-loader-initrd-$(ARCH).cpio.gz
+.PHONY: $(TARGET)
+
+$(TARGET):
+ $(ONLPM) --copy-file onl-buildroot-initrd:$(ARCH) onl-buildroot-initrd-$(ARCH).cpio.gz .
+ sudo rm -rf $(ROOT) && mkdir $(ROOT)
+ $(ONLPM) --sudo --force --extract-dir onl-loader-initrd-files:all $(ROOT)
+ $(ONLPM) --sudo $(foreach p,$(PLATFORM_PACKAGES),--extract-dir $(p) $(ROOT))
+ $(ONL)/tools/sjson.py --kj version $(ONL)/make/version-onl.json --kl platforms $(PLATFORMS) --kv arch $(ARCH) --out manifest.json
+ sudo mkdir -p $(ROOT)/etc/onl/loader && sudo cp manifest.json $(ROOT)/etc/onl/loader
+ sudo $(ONL)/tools/makedevs -d $(ROOT)/etc/rootperms $(abspath $(ROOT))
+ sudo $(ONL)/tools/cpiomod.py --cpio onl-buildroot-initrd-$(ARCH).cpio.gz --add-directory $(ROOT) --out $@
+ sudo rm -rf $(ROOT) onl-buildroot-initrd-$(ARCH).cpio.gz
+
+
+
+
+
diff --git a/packages/base/any/onlp/.gitignore b/packages/base/any/onlp/.gitignore
new file mode 100644
index 00000000..c9fb117a
--- /dev/null
+++ b/packages/base/any/onlp/.gitignore
@@ -0,0 +1,2 @@
+build/
+*-module.mk
diff --git a/packages/base/any/onlp/APKG.yml b/packages/base/any/onlp/APKG.yml
new file mode 100644
index 00000000..c5441696
--- /dev/null
+++ b/packages/base/any/onlp/APKG.yml
@@ -0,0 +1,31 @@
+############################################################
+#
+# ONLP Package Build Template
+#
+# Requires: ARCH, TOOLCHAIN
+#
+############################################################
+variables:
+ libdir: /lib/${TOOLCHAIN}
+
+common:
+ arch: $ARCH
+ version: 1.0.0
+ copyright: Copyright 2013, 2014, 2015 Big Switch Networks
+ maintainer: support@bigswitch.com
+
+packages:
+ - name: onlp
+ version: 1.0.0
+ summary: Open Network Linux Platform Infrastructure
+
+ files:
+ builds/onlp/$BUILD_DIR/${TOOLCHAIN}/bin/libonlp.so : $libdir/
+ builds/onlp-platform/$BUILD_DIR/${TOOLCHAIN}/bin/libonlp-platform.so : $libdir/
+ builds/onlp-platform-defaults/$BUILD_DIR/${TOOLCHAIN}/bin/libonlp-platform-defaults.so : $libdir/
+
+ changelog: Change changes changes.,
+
+
+
+
diff --git a/packages/base/any/onlp/builds/Makefile b/packages/base/any/onlp/builds/Makefile
new file mode 100644
index 00000000..6da335a9
--- /dev/null
+++ b/packages/base/any/onlp/builds/Makefile
@@ -0,0 +1,3 @@
+# These must be built in the given order
+DIRECTORIES := onlp-platform-defaults onlp-platform onlp
+include $(ONL)/make/subdirs.mk
diff --git a/packages/base/any/onlp/builds/onlp-platform-defaults/Makefile b/packages/base/any/onlp/builds/onlp-platform-defaults/Makefile
new file mode 100644
index 00000000..bcbfc1b4
--- /dev/null
+++ b/packages/base/any/onlp/builds/onlp-platform-defaults/Makefile
@@ -0,0 +1,67 @@
+# -*- Makefile -*-
+############################################################
+#
+#
+# Copyright 2014 BigSwitch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+# Build the ONLP Default Platform Library.
+#
+# This library provides the baseline stub implementations
+# for all required ONLP entry points.
+#
+# All ONLP applications are linked against this library.
+#
+#
+############################################################
+include $(ONL)/make/config.mk
+
+ifndef TOOLCHAIN
+$(error $$TOOLCHAIN must be specified.)
+else
+export TOOLCHAIN
+endif
+
+MODULE := libonlp-platform-defaults-module
+include $(BUILDER)/standardinit.mk
+
+#
+# We use the onlp_platform_defaults entry points as
+# the link stubs
+#
+DEPENDMODULES := AIM onlplib onlp_platform_defaults IOF sff
+
+include $(BUILDER)/dependmodules.mk
+
+SHAREDLIB := libonlp-platform-defaults.so
+$(SHAREDLIB)_TARGETS := $(ALL_TARGETS)
+include $(BUILDER)/so.mk
+
+.DEFAULT_GOAL := sharedlibs
+
+GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_CTOR_DTOR=1
+GLOBAL_CFLAGS += -DONLP_PLATFORM_DEFAULTS_CONFIG_AS_PLATFORM=0
+GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc
+GLOBAL_CFLAGS += -fPIC
+GLOBAL_LINK_LIBS += -lpthread
+
+include $(BUILDER)/targets.mk
+
+.PHONY: deb
+deb:
+ $(MAKE) -C deb
diff --git a/packages/base/any/onlp/builds/onlp-platform/Makefile b/packages/base/any/onlp/builds/onlp-platform/Makefile
new file mode 100644
index 00000000..81f09fcb
--- /dev/null
+++ b/packages/base/any/onlp/builds/onlp-platform/Makefile
@@ -0,0 +1,56 @@
+# -*- Makefile -*-
+############################################################
+#
+#
+# Copyright 2014 BigSwitch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+#
+############################################################
+include $(ONL)/make/config.mk
+
+ifndef TOOLCHAIN
+$(error $$TOOLCHAIN must be specified.)
+else
+export TOOLCHAIN
+endif
+
+MODULE := libonlp-platform-module
+include $(BUILDER)/standardinit.mk
+
+DEPENDMODULES := AIM onlplib onlp_platform_defaults IOF sff
+
+include $(BUILDER)/dependmodules.mk
+
+SHAREDLIB := libonlp-platform.so
+$(SHAREDLIB)_TARGETS := $(ALL_TARGETS)
+include $(BUILDER)/so.mk
+
+.DEFAULT_GOAL := sharedlibs
+
+GLOBAL_CFLAGS += -DONLP_PLATFORM_DEFAULTS_CONFIG_AS_PLATFORM=1
+GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_CTOR_DTOR=1
+GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc
+GLOBAL_CFLAGS += -fPIC
+GLOBAL_LINK_LIBS += -lpthread
+
+include $(BUILDER)/targets.mk
+
+.PHONY: deb
+deb:
+ $(MAKE) -C deb
diff --git a/packages/base/any/onlp/builds/onlp/Makefile b/packages/base/any/onlp/builds/onlp/Makefile
new file mode 100644
index 00000000..52f8f5e6
--- /dev/null
+++ b/packages/base/any/onlp/builds/onlp/Makefile
@@ -0,0 +1,59 @@
+# -*- Makefile -*-
+############################################################
+#
+#
+# Copyright 2014 BigSwitch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+#
+############################################################
+include $(ONL)/make/config.mk
+
+ifndef TOOLCHAIN
+$(error $$TOOLCHAIN must be specified.)
+else
+export TOOLCHAIN
+endif
+
+MODULE := libonlp-module
+include $(BUILDER)/standardinit.mk
+
+DEPENDMODULES := AIM onlplib onlp cjson cjson_util sff IOF timer_wheel OS
+
+LIBONLP_PLATFORM_DEFAULTS := ../onlp-platform-defaults/$(BUILD_DIR)/bin/libonlp-platform-defaults.so
+LIBONLP_PLATFORM := ../onlp-platform/$(BUILD_DIR)/bin/libonlp-platform.so
+
+include $(BUILDER)/dependmodules.mk
+
+SHAREDLIB := libonlp.so
+$(SHAREDLIB)_TARGETS := $(ALL_TARGETS)
+include $(BUILDER)/so.mk
+
+.DEFAULT_GOAL := sharedlibs
+
+GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_CTOR_DTOR=1
+GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1
+GLOBAL_CFLAGS += -DONLP_CONFIG_PLATFORM_FILENAME="\"/etc/sl_platform\""
+GLOBAL_CFLAGS += -fPIC
+GLOBAL_LINK_LIBS += -lpthread $(LIBONLP_PLATFORM) $(LIBONLP_PLATFORM_DEFAULTS)
+
+include $(BUILDER)/targets.mk
+
+.PHONY: deb
+deb:
+ $(MAKE) -C deb
diff --git a/packages/base/any/onlp/src/Makefile b/packages/base/any/onlp/src/Makefile
new file mode 100644
index 00000000..533b3f8c
--- /dev/null
+++ b/packages/base/any/onlp/src/Makefile
@@ -0,0 +1,37 @@
+################################################################
+#
+#
+# Copyright 2014, 2015 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+################################################################
+include ../init.mk
+
+-include Manifest.mk
+
+include $(BUILDER)/moduledir.mk
+
+#
+# Available targets
+#
+moduledir_show_targets::
+ @echo " autogen Make autogen in all modules."
+
+autogen:
+
+
+
+
diff --git a/packages/base/any/onlp/src/onlp/Makefile b/packages/base/any/onlp/src/onlp/Makefile
new file mode 100644
index 00000000..c2250874
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/Makefile
@@ -0,0 +1,28 @@
+############################################################
+#
+#
+# Copyright 2014, 2015 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+#
+#
+############################################################
+include $(ONL)/make/config.mk
+MODULE := onlp
+AUTOMODULE := onlp
+include $(BUILDER)/definemodule.mk
diff --git a/packages/base/any/onlp/src/onlp/README b/packages/base/any/onlp/src/onlp/README
new file mode 100644
index 00000000..7917b603
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/README
@@ -0,0 +1,6 @@
+###############################################################################
+#
+# onlp README
+#
+###############################################################################
+
diff --git a/packages/base/any/onlp/src/onlp/module/auto/make.mk b/packages/base/any/onlp/src/onlp/module/auto/make.mk
new file mode 100644
index 00000000..1e68bdb8
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/auto/make.mk
@@ -0,0 +1,29 @@
+############################################################
+#
+#
+# Copyright 2014, 2015 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+# onlp Autogeneration
+#
+############################################################
+
+onlp_AUTO_DEFS := module/auto/onlp.yml
+onlp_AUTO_DIRS := module/inc/onlp module/src
+include $(BUILDER)/auto.mk
+
diff --git a/packages/base/any/onlp/src/onlp/module/auto/onlp.yml b/packages/base/any/onlp/src/onlp/module/auto/onlp.yml
new file mode 100644
index 00000000..6e39ae96
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/auto/onlp.yml
@@ -0,0 +1,299 @@
+############################################################
+#
+#
+# Copyright 2014, 2015 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+# onlp Autogeneration Definitions.
+#
+############################################################
+
+cdefs: &cdefs
+- ONLP_CONFIG_INCLUDE_LOGGING:
+ doc: "Include or exclude logging."
+ default: 1
+- ONLP_CONFIG_LOG_OPTIONS_DEFAULT:
+ doc: "Default enabled log options."
+ default: AIM_LOG_OPTIONS_DEFAULT
+- ONLP_CONFIG_LOG_BITS_DEFAULT:
+ doc: "Default enabled log bits."
+ default: AIM_LOG_BITS_DEFAULT
+- ONLP_CONFIG_LOG_CUSTOM_BITS_DEFAULT:
+ doc: "Default enabled custom log bits."
+ default: 0
+- ONLP_CONFIG_PORTING_STDLIB:
+ doc: "Default all porting macros to use the C standard libraries."
+ default: 1
+- ONLP_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS:
+ doc: "Include standard library headers for stdlib porting macros."
+ default: ONLP_CONFIG_PORTING_STDLIB
+- ONLP_CONFIG_INCLUDE_UCLI:
+ doc: "Include generic uCli support."
+ default: 0
+- ONLP_CONFIG_INCLUDE_PLATFORM_ERROR_CHECK:
+ doc: "Include platform error checking at initialization."
+ default: 1
+- ONLP_CONFIG_INCLUDE_SHLOCK_GLOBAL_INIT:
+ doc: "Include global shlock initialization at module init time."
+ default: 0
+- ONLP_CONFIG_INCLUDE_PLATFORM_STATIC:
+ doc: "Specify the platform name directly as a compile-time option."
+ default: 0
+- ONLP_CONFIG_PLATFORM_STATIC:
+ doc: "The name of the static platform if configured."
+ default: "\"unknown\""
+- ONLP_CONFIG_PLATFORM_FILENAME:
+ doc: "The local filename containing the current platform identifier."
+ default: "\"/etc/onl/platform\""
+- ONLP_CONFIG_INCLUDE_PLATFORM_OVERRIDES:
+ doc: "Allow support for local overrides of all platform OID values (testing)."
+ default: 1
+- ONLP_CONFIG_CONFIGURATION_FILENAME:
+ doc: "The filename for the (optional) ONLP JSON configuration file."
+ default: "\"/etc/onlp.conf\""
+- ONLP_CONFIG_CONFIGURATION_ENV:
+ doc: "Environment variable to check for configuration filenames. Overrides default."
+ default: "\"ONLP_CONF\""
+- ONLP_CONFIG_INCLUDE_API_LOCK:
+ doc: "Include exclusive locking for all API calls."
+ default: 1
+- ONLP_CONFIG_API_LOCK_GLOBAL_SHARED:
+ doc: "If 0, the API lock is a simple semaphore. If 1, the API lock is a global shared mutex."
+ default: 0
+- ONLP_CONFIG_API_LOCK_TIMEOUT:
+ doc: "The maximum amount of time (in usecs) to wait while attempting to acquire the API lock. Failure to acquire is fatal. A value of zero disables this feature. "
+ default: 60000000
+- ONLP_CONFIG_INFO_STR_MAX:
+ doc: "The maximum size of static information string buffers."
+ default: 64
+
+# Error codes
+onlp_status: &onlp_status
+- OK : 0
+- E_UNSUPPORTED : -1
+- E_MISSING : -2
+- E_INVALID : -3
+- E_INTERNAL : -4
+- E_PARAM : -5
+
+# OID Types
+oid_types: &oid_types
+- SYS : 1
+- THERMAL : 2
+- FAN : 3
+- PSU : 4
+- LED : 5
+- MODULE : 6
+- RTC : 7
+
+# SFP Control
+sfp_control: &sfp_control
+- RESET
+- RESET_STATE
+- RX_LOS
+- TX_FAULT
+- TX_DISABLE
+- LP_MODE
+- POWER_OVERRIDE
+
+# Fan modes
+fan_modes: &fan_modes
+- 'OFF'
+- SLOW
+- NORMAL
+- FAST
+- MAX
+
+# Fan Capabilities
+fan_caps: &fan_caps
+- B2F : (1 << 0)
+- F2B : (1 << 1)
+- SET_RPM : (1 << 2)
+- SET_PERCENTAGE : (1 << 3)
+- GET_RPM : (1 << 4)
+- GET_PERCENTAGE : (1 << 5)
+
+# Fan Direction
+fan_dirs: &fan_dirs
+- B2F
+- F2B
+
+# Fan status
+fan_status: &fan_status
+- PRESENT : (1 << 0)
+- FAILED : (1 << 1)
+- B2F : (1 << 2)
+- F2B : (1 << 3)
+
+# Thermal status
+thermal_status: &thermal_status
+- PRESENT : (1 << 0)
+- FAILED : (1 << 1)
+
+# Thermal caps
+thermal_caps: &thermal_caps
+- GET_TEMPERATURE : (1 << 0)
+- GET_WARNING_THRESHOLD : (1 << 1)
+- GET_ERROR_THRESHOLD : (1 << 2)
+- GET_SHUTDOWN_THRESHOLD : (1 << 3)
+
+# LED caps
+led_caps: &led_caps
+- ON_OFF : (1 << 0)
+- RED : (1 << 10)
+- RED_BLINKING : (1 << 11)
+- ORANGE : (1 << 12)
+- ORANGE_BLINKING : (1 << 13)
+- YELLOW : ( 1 << 14)
+- YELLOW_BLINKING : (1 << 15)
+- GREEN : (1 << 16)
+- GREEN_BLINKING : (1 << 17)
+- BLUE : (1 << 18)
+- BLUE_BLINKING : (1 << 19)
+- PURPLE: (1 << 20)
+- PURPLE_BLINKING : (1 << 21)
+- AUTO : (1 << 22)
+
+# LED status
+led_status: &led_status
+- PRESENT : (1 << 0)
+- FAILED : (1 << 1)
+- 'ON' : (1 << 2)
+
+# LED modes
+# The enumerations MUST match the CAP bit positions.
+led_mode: &led_mode
+- 'OFF'
+- 'ON'
+- 'BLINKING'
+- 'RED' : 10
+- 'RED_BLINKING' : 11
+- 'ORANGE' : 12
+- 'ORANGE_BLINKING' : 13
+- 'YELLOW' : 14
+- 'YELLOW_BLINKING' : 15
+- 'GREEN' : 16
+- 'GREEN_BLINKING' : 17
+- 'BLUE' : 18
+- 'BLUE_BLINKING' : 19
+- 'PURPLE' : 20
+- 'PURPLE_BLINKING' : 21
+- 'AUTO' : 22
+
+# PSU Status
+psu_status: &psu_status
+- PRESENT : (1 << 0)
+- FAILED : (1 << 1)
+- UNPLUGGED : (1 << 2)
+
+# PSU caps
+psu_caps: &psu_caps
+- AC : (1 << 0)
+- DC12 : (1 << 1)
+- DC48 : (1 << 2)
+- VIN : (1 << 3)
+- VOUT : (1 << 4)
+- IIN : (1 << 5)
+- IOUT : (1 << 6)
+- PIN : (1 << 7)
+- POUT : (1 << 8)
+
+definitions:
+ cdefs:
+ ONLP_CONFIG_HEADER:
+ defs: *cdefs
+ basename: onlp_config
+
+ enum: &enums
+ onlp_status:
+ tag: onlp
+ members: *onlp_status
+ onlp_oid_type:
+ tag: oid
+ members: *oid_types
+ onlp_thermal_status:
+ tag: thermal
+ members: *thermal_status
+ onlp_thermal_caps:
+ tag: thermal
+ members: *thermal_caps
+ onlp_sfp_control:
+ tag: sfp1
+ members:
+ - RESET
+ - RESET_STATE
+ - RX_LOS
+ - TX_FAULT
+ - TX_DISABLE
+ - LP_MODE
+ - POWER_OVERRIDE
+ onlp_sfp_control_flag:
+ tag: sfp2
+ members:
+ - RESET : (1 << ONLP_SFP_CONTROL_RESET)
+ - RESET_STATE : ( 1 << ONLP_SFP_CONTROL_RESET_STATE )
+ - RX_LOS : ( 1 << ONLP_SFP_CONTROL_RX_LOS )
+ - TX_FAULT : ( 1 << ONLP_SFP_CONTROL_TX_FAULT )
+ - TX_DISABLE : ( 1 << ONLP_SFP_CONTROL_TX_DISABLE )
+ - LP_MODE : ( 1 << ONLP_SFP_CONTROL_LP_MODE )
+ - POWER_OVERRIDE : ( 1 << ONLP_SFP_CONTROL_POWER_OVERRIDE )
+ onlp_fan_mode:
+ tag: fan
+ members: *fan_modes
+ onlp_fan_status:
+ tag: fan
+ members: *fan_status
+ onlp_fan_dir:
+ tag: fan
+ members: *fan_dirs
+ onlp_fan_caps:
+ tag: fan
+ members: *fan_caps
+ onlp_led_caps:
+ tag: led
+ members: *led_caps
+ onlp_led_status:
+ tag: led
+ members: *led_status
+ onlp_led_mode:
+ tag: led
+ members: *led_mode
+ onlp_psu_status:
+ tag: psu
+ members: *psu_status
+ onlp_psu_caps:
+ tag: psu
+ members: *psu_caps
+
+ portingmacro:
+ ONLP:
+ macros:
+ - memset
+ - memcpy
+ - strncpy
+ - strlen
+
+ xenum:
+ ONLP_ENUMERATION_ENTRY:
+ members: *enums
+
+ xmacro:
+ ONLP_OID_TYPE_ENTRY:
+ members: *oid_types
+
+
diff --git a/packages/base/any/onlp/src/onlp/module/inc/onlp/fan.h b/packages/base/any/onlp/src/onlp/module/inc/onlp/fan.h
new file mode 100644
index 00000000..0b45723f
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/inc/onlp/fan.h
@@ -0,0 +1,278 @@
+/************************************************************
+ *
+ *
+ * Copyright 2014, 2015 Big Switch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ ************************************************************
+ *
+ * Fan Management.
+ *
+ ***********************************************************/
+#ifndef __ONLP_FAN_H__
+#define __ONLP_FAN_H__
+
+#include
+#include
+
+/* */
+/** onlp_fan_status */
+typedef enum onlp_fan_status_e {
+ ONLP_FAN_STATUS_PRESENT = (1 << 0),
+ ONLP_FAN_STATUS_FAILED = (1 << 1),
+ ONLP_FAN_STATUS_B2F = (1 << 2),
+ ONLP_FAN_STATUS_F2B = (1 << 3),
+} onlp_fan_status_t;
+
+/** onlp_fan_mode */
+typedef enum onlp_fan_mode_e {
+ ONLP_FAN_MODE_OFF,
+ ONLP_FAN_MODE_SLOW,
+ ONLP_FAN_MODE_NORMAL,
+ ONLP_FAN_MODE_FAST,
+ ONLP_FAN_MODE_MAX,
+ ONLP_FAN_MODE_LAST = ONLP_FAN_MODE_MAX,
+ ONLP_FAN_MODE_COUNT,
+ ONLP_FAN_MODE_INVALID = -1,
+} onlp_fan_mode_t;
+
+/** onlp_fan_caps */
+typedef enum onlp_fan_caps_e {
+ ONLP_FAN_CAPS_B2F = (1 << 0),
+ ONLP_FAN_CAPS_F2B = (1 << 1),
+ ONLP_FAN_CAPS_SET_RPM = (1 << 2),
+ ONLP_FAN_CAPS_SET_PERCENTAGE = (1 << 3),
+ ONLP_FAN_CAPS_GET_RPM = (1 << 4),
+ ONLP_FAN_CAPS_GET_PERCENTAGE = (1 << 5),
+} onlp_fan_caps_t;
+
+/** onlp_fan_dir */
+typedef enum onlp_fan_dir_e {
+ ONLP_FAN_DIR_B2F,
+ ONLP_FAN_DIR_F2B,
+ ONLP_FAN_DIR_LAST = ONLP_FAN_DIR_F2B,
+ ONLP_FAN_DIR_COUNT,
+ ONLP_FAN_DIR_INVALID = -1,
+} onlp_fan_dir_t;
+/* */
+
+/**
+ * Fan information structure.
+ */
+typedef struct onlp_fan_info_s {
+ /** OID Header */
+ onlp_oid_hdr_t hdr;
+
+ /* Status */
+ uint32_t status;
+
+ /* Capabilities */
+ uint32_t caps;
+
+ /* Current fan speed, in RPM, if available */
+ int rpm;
+
+ /* Current fan percentage, if available */
+ int percentage;
+
+ /* Current fan mode, if available */
+ onlp_fan_mode_t mode;
+
+ /* Model (if applicable) */
+ char model[ONLP_CONFIG_INFO_STR_MAX];
+
+ /* Serial Number (if applicable) */
+ char serial[ONLP_CONFIG_INFO_STR_MAX];
+
+} onlp_fan_info_t;
+
+
+/**
+ * @brief Initialize the fan subsystem.
+ */
+int onlp_fan_init(void);
+
+
+/**
+ * @brief Retrieve fan information.
+ * @param id The fan OID.
+ * @param rv [out] Receives the fan information.
+ */
+int onlp_fan_info_get(onlp_oid_t id, onlp_fan_info_t* rv);
+
+/**
+ * @brief Set the fan speed in RPMs.
+ * @param id The fan OID.
+ * @param rpm The new RPM.
+ * @note Only valid if the fan has the SET_RPM capability.
+ */
+int onlp_fan_rpm_set(onlp_oid_t id, int rpm);
+
+/**
+ * @brief Set the fan speed in percentage.
+ * @param id The fan OID.
+ * @param p The percentage.
+ * @note Only valid if the fan has the SET_PERCENTAGE capability.
+ */
+int onlp_fan_percentage_set(onlp_oid_t id, int p);
+
+/**
+ * @brief Set the fan speed by mode.
+ * @param id The fan OID.
+ * @param mode The fan mode value.
+ */
+int onlp_fan_mode_set(onlp_oid_t id, onlp_fan_mode_t mode);
+
+/**
+ * @brief Set the fan direction.
+ * @param id The fan OID.
+ * @param dir The fan direction (B2F or F2B)
+ * @notes Only called if both capabilities are set.
+ */
+int onlp_fan_dir_set(onlp_oid_t id, onlp_fan_dir_t dir);
+
+/**
+ * @brief Fan OID debug dump.
+ * @param id The fan OID.
+ * @param pvs The output pvs.
+ * @param flags The output flags.
+ */
+void onlp_fan_dump(onlp_oid_t id, aim_pvs_t* pvs, uint32_t flags);
+
+/**
+ * @brief Show the given Fan OID.
+ * @param id The Fan OID
+ * @param pvs The output pvs
+ * @param flags The output flags.
+ */
+void onlp_fan_show(onlp_oid_t id, aim_pvs_t* pvs, uint32_t flags);
+
+/**
+ * Convenience macros for processing Fan status information.
+ */
+#define ONLP_FAN_STATUS_PRESENT(_fi) ((_fi).status & ONLP_FAN_STATUS_PRESENT)
+#define ONLP_FAN_STATUS_MISSING(_fi) (!ONLP_FAN_INFO_PRESENT(_fi))
+#define ONLP_FAN_STATUS_FAILED(_fi) ( (_fi).status & ONLP_FAN_STATUS_FAILED)
+#define ONLP_FAN_STATUS_NORMAL(_fi) ( ONLP_FAN_STATUS_PRESENT(_fi) && !ONLP_FAN_STATUS_FAILED(_fi) )
+
+
+
+
+/******************************************************************************
+ *
+ * Enumeration Support Definitions.
+ *
+ * Please do not add additional code beyond this point.
+ *
+ *****************************************************************************/
+/* */
+/** Enum names. */
+const char* onlp_fan_status_name(onlp_fan_status_t e);
+
+/** Enum values. */
+int onlp_fan_status_value(const char* str, onlp_fan_status_t* e, int substr);
+
+/** Enum descriptions. */
+const char* onlp_fan_status_desc(onlp_fan_status_t e);
+
+/** Enum validator. */
+int onlp_fan_status_valid(onlp_fan_status_t e);
+
+/** validator */
+#define ONLP_FAN_STATUS_VALID(_e) \
+ (onlp_fan_status_valid((_e)))
+
+/** onlp_fan_status_map table. */
+extern aim_map_si_t onlp_fan_status_map[];
+/** onlp_fan_status_desc_map table. */
+extern aim_map_si_t onlp_fan_status_desc_map[];
+
+/** Strings macro. */
+#define ONLP_FAN_MODE_STRINGS \
+{\
+ "OFF", \
+ "SLOW", \
+ "NORMAL", \
+ "FAST", \
+ "MAX", \
+}
+/** Enum names. */
+const char* onlp_fan_mode_name(onlp_fan_mode_t e);
+
+/** Enum values. */
+int onlp_fan_mode_value(const char* str, onlp_fan_mode_t* e, int substr);
+
+/** Enum descriptions. */
+const char* onlp_fan_mode_desc(onlp_fan_mode_t e);
+
+/** validator */
+#define ONLP_FAN_MODE_VALID(_e) \
+ ( (0 <= (_e)) && ((_e) <= ONLP_FAN_MODE_MAX))
+
+/** onlp_fan_mode_map table. */
+extern aim_map_si_t onlp_fan_mode_map[];
+/** onlp_fan_mode_desc_map table. */
+extern aim_map_si_t onlp_fan_mode_desc_map[];
+
+/** Enum names. */
+const char* onlp_fan_caps_name(onlp_fan_caps_t e);
+
+/** Enum values. */
+int onlp_fan_caps_value(const char* str, onlp_fan_caps_t* e, int substr);
+
+/** Enum descriptions. */
+const char* onlp_fan_caps_desc(onlp_fan_caps_t e);
+
+/** Enum validator. */
+int onlp_fan_caps_valid(onlp_fan_caps_t e);
+
+/** validator */
+#define ONLP_FAN_CAPS_VALID(_e) \
+ (onlp_fan_caps_valid((_e)))
+
+/** onlp_fan_caps_map table. */
+extern aim_map_si_t onlp_fan_caps_map[];
+/** onlp_fan_caps_desc_map table. */
+extern aim_map_si_t onlp_fan_caps_desc_map[];
+
+/** Strings macro. */
+#define ONLP_FAN_DIR_STRINGS \
+{\
+ "B2F", \
+ "F2B", \
+}
+/** Enum names. */
+const char* onlp_fan_dir_name(onlp_fan_dir_t e);
+
+/** Enum values. */
+int onlp_fan_dir_value(const char* str, onlp_fan_dir_t* e, int substr);
+
+/** Enum descriptions. */
+const char* onlp_fan_dir_desc(onlp_fan_dir_t e);
+
+/** validator */
+#define ONLP_FAN_DIR_VALID(_e) \
+ ( (0 <= (_e)) && ((_e) <= ONLP_FAN_DIR_F2B))
+
+/** onlp_fan_dir_map table. */
+extern aim_map_si_t onlp_fan_dir_map[];
+/** onlp_fan_dir_desc_map table. */
+extern aim_map_si_t onlp_fan_dir_desc_map[];
+/* */
+
+
+#endif /* __ONLP_FAN_H__ */
+
diff --git a/packages/base/any/onlp/src/onlp/module/inc/onlp/led.h b/packages/base/any/onlp/src/onlp/module/inc/onlp/led.h
new file mode 100644
index 00000000..3366a39d
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/inc/onlp/led.h
@@ -0,0 +1,218 @@
+/************************************************************
+ *
+ *
+ * Copyright 2014, 2015 Big Switch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ ************************************************************
+ *
+ * LED Management
+ *
+ ***********************************************************/
+#ifndef __ONLP_LED_H__
+#define __ONLP_LED_H__
+
+#include
+#include
+
+/* */
+/** onlp_led_status */
+typedef enum onlp_led_status_e {
+ ONLP_LED_STATUS_PRESENT = (1 << 0),
+ ONLP_LED_STATUS_FAILED = (1 << 1),
+ ONLP_LED_STATUS_ON = (1 << 2),
+} onlp_led_status_t;
+
+/** onlp_led_mode */
+typedef enum onlp_led_mode_e {
+ ONLP_LED_MODE_OFF,
+ ONLP_LED_MODE_ON,
+ ONLP_LED_MODE_BLINKING,
+ ONLP_LED_MODE_RED = 10,
+ ONLP_LED_MODE_RED_BLINKING = 11,
+ ONLP_LED_MODE_ORANGE = 12,
+ ONLP_LED_MODE_ORANGE_BLINKING = 13,
+ ONLP_LED_MODE_YELLOW = 14,
+ ONLP_LED_MODE_YELLOW_BLINKING = 15,
+ ONLP_LED_MODE_GREEN = 16,
+ ONLP_LED_MODE_GREEN_BLINKING = 17,
+ ONLP_LED_MODE_BLUE = 18,
+ ONLP_LED_MODE_BLUE_BLINKING = 19,
+ ONLP_LED_MODE_PURPLE = 20,
+ ONLP_LED_MODE_PURPLE_BLINKING = 21,
+ ONLP_LED_MODE_AUTO = 22,
+} onlp_led_mode_t;
+
+/** onlp_led_caps */
+typedef enum onlp_led_caps_e {
+ ONLP_LED_CAPS_ON_OFF = (1 << 0),
+ ONLP_LED_CAPS_RED = (1 << 10),
+ ONLP_LED_CAPS_RED_BLINKING = (1 << 11),
+ ONLP_LED_CAPS_ORANGE = (1 << 12),
+ ONLP_LED_CAPS_ORANGE_BLINKING = (1 << 13),
+ ONLP_LED_CAPS_YELLOW = ( 1 << 14),
+ ONLP_LED_CAPS_YELLOW_BLINKING = (1 << 15),
+ ONLP_LED_CAPS_GREEN = (1 << 16),
+ ONLP_LED_CAPS_GREEN_BLINKING = (1 << 17),
+ ONLP_LED_CAPS_BLUE = (1 << 18),
+ ONLP_LED_CAPS_BLUE_BLINKING = (1 << 19),
+ ONLP_LED_CAPS_PURPLE = (1 << 20),
+ ONLP_LED_CAPS_PURPLE_BLINKING = (1 << 21),
+ ONLP_LED_CAPS_AUTO = (1 << 22),
+} onlp_led_caps_t;
+/* */
+
+
+/**
+ * LED information structure.
+ */
+typedef struct onlp_led_info_s {
+ /** Header */
+ onlp_oid_hdr_t hdr;
+
+ /** Status */
+ uint32_t status;
+
+ /** Capabilities */
+ uint32_t caps;
+
+ /** Current mode, if capable. */
+ onlp_led_mode_t mode;
+} onlp_led_info_t;
+
+/**
+ * @brief Initialize the LED subsystem.
+ */
+int onlp_led_init(void);
+
+/**
+ * @brief Get LED information.
+ * @param id The LED OID
+ * @param rv [out] Receives the information structure.
+ */
+int onlp_led_info_get(onlp_oid_t id, onlp_led_info_t* rv);
+
+/**
+ * @brief Turn an LED on or off.
+ * @param id The LED OID
+ * @param on_or_off Led on (1) or LED off (0)
+ * @param Relevant if the LED has the ON_OFF capability.
+ * @note For the purposes of this function the
+ * interpretation of "on" for multi-mode or multi-color LEDs
+ * is up to the platform implementation.
+ */
+int onlp_led_set(onlp_oid_t id, int on_or_off);
+
+/**
+ * @brief Set the LED color
+ * @param id The LED OID
+ * @param color The color.
+ * @note Only relevant if the LED supports the color capability.
+ */
+int onlp_led_mode_set(onlp_oid_t id, onlp_led_mode_t color);
+
+/**
+ * @brief LED OID debug dump
+ * @param id The LED OID
+ * @param pvs The output pvs
+ * @param flags The output flags
+ */
+void onlp_led_dump(onlp_oid_t oid, aim_pvs_t* pvs, uint32_t flags);
+
+/**
+ * @brief Show the given LED OID.
+ * @param id The LED OID
+ * @param pvs The output pvs
+ * @param flags The output flags
+ */
+void onlp_led_show(onlp_oid_t id, aim_pvs_t* pvs, uint32_t flags);
+
+
+
+
+/******************************************************************************
+ *
+ * Enumeration Support Definitions.
+ *
+ * Please do not add additional code beyond this point.
+ *
+ *****************************************************************************/
+/* */
+/** Enum names. */
+const char* onlp_led_status_name(onlp_led_status_t e);
+
+/** Enum values. */
+int onlp_led_status_value(const char* str, onlp_led_status_t* e, int substr);
+
+/** Enum descriptions. */
+const char* onlp_led_status_desc(onlp_led_status_t e);
+
+/** Enum validator. */
+int onlp_led_status_valid(onlp_led_status_t e);
+
+/** validator */
+#define ONLP_LED_STATUS_VALID(_e) \
+ (onlp_led_status_valid((_e)))
+
+/** onlp_led_status_map table. */
+extern aim_map_si_t onlp_led_status_map[];
+/** onlp_led_status_desc_map table. */
+extern aim_map_si_t onlp_led_status_desc_map[];
+
+/** Enum names. */
+const char* onlp_led_mode_name(onlp_led_mode_t e);
+
+/** Enum values. */
+int onlp_led_mode_value(const char* str, onlp_led_mode_t* e, int substr);
+
+/** Enum descriptions. */
+const char* onlp_led_mode_desc(onlp_led_mode_t e);
+
+/** Enum validator. */
+int onlp_led_mode_valid(onlp_led_mode_t e);
+
+/** validator */
+#define ONLP_LED_MODE_VALID(_e) \
+ (onlp_led_mode_valid((_e)))
+
+/** onlp_led_mode_map table. */
+extern aim_map_si_t onlp_led_mode_map[];
+/** onlp_led_mode_desc_map table. */
+extern aim_map_si_t onlp_led_mode_desc_map[];
+
+/** Enum names. */
+const char* onlp_led_caps_name(onlp_led_caps_t e);
+
+/** Enum values. */
+int onlp_led_caps_value(const char* str, onlp_led_caps_t* e, int substr);
+
+/** Enum descriptions. */
+const char* onlp_led_caps_desc(onlp_led_caps_t e);
+
+/** Enum validator. */
+int onlp_led_caps_valid(onlp_led_caps_t e);
+
+/** validator */
+#define ONLP_LED_CAPS_VALID(_e) \
+ (onlp_led_caps_valid((_e)))
+
+/** onlp_led_caps_map table. */
+extern aim_map_si_t onlp_led_caps_map[];
+/** onlp_led_caps_desc_map table. */
+extern aim_map_si_t onlp_led_caps_desc_map[];
+/* */
+
+#endif /* __ONLP_LED_H__ */
diff --git a/packages/base/any/onlp/src/onlp/module/inc/onlp/oids.h b/packages/base/any/onlp/src/onlp/module/inc/onlp/oids.h
new file mode 100644
index 00000000..20ce5746
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/inc/onlp/oids.h
@@ -0,0 +1,224 @@
+/************************************************************
+ *
+ *
+ * Copyright 2014, 2015 Big Switch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ ************************************************************
+ *
+ * ONLP Platform Object Identifiers.
+ *
+ ***********************************************************/
+#ifndef __ONLP_OID_H__
+#define __ONLP_OID_H__
+
+#include
+
+#include
+#include
+#include
+
+/**
+ * System peripherals are identified by a 32bit OID.
+ *
+ * The First byte is the object-class identifier:
+ * Thermal sensor object
+ * Fan object
+ * PSU object
+ * LED object
+ * MODULE object
+ * etc..
+ * The remaining bytes are the object id.
+ */
+
+typedef uint32_t onlp_oid_t;
+
+/* */
+/** onlp_oid_type */
+typedef enum onlp_oid_type_e {
+ ONLP_OID_TYPE_SYS = 1,
+ ONLP_OID_TYPE_THERMAL = 2,
+ ONLP_OID_TYPE_FAN = 3,
+ ONLP_OID_TYPE_PSU = 4,
+ ONLP_OID_TYPE_LED = 5,
+ ONLP_OID_TYPE_MODULE = 6,
+ ONLP_OID_TYPE_RTC = 7,
+} onlp_oid_type_t;
+/* */
+
+
+/**
+ * Get the or set the type of an OID
+ */
+#define ONLP_OID_TYPE_GET(_id) ( ( (_id) >> 24) )
+#define ONLP_OID_TYPE_CREATE(_type, _id) ( ( (_type) << 24) | (_id))
+#define ONLP_OID_IS_TYPE(_type,_id) (ONLP_OID_TYPE_GET((_id)) == _type)
+#define ONLP_OID_ID_GET(_id) (_id & 0xFFFFFF)
+#define ONLP_THERMAL_ID_CREATE(_id) ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_THERMAL, _id)
+#define ONLP_FAN_ID_CREATE(_id) ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_FAN, _id)
+#define ONLP_PSU_ID_CREATE(_id) ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_PSU, _id)
+#define ONLP_LED_ID_CREATE(_id) ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_LED, _id)
+#define ONLP_MODULE_ID_CREATE(_id) ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_MODULE, _id)
+
+#define ONLP_OID_IS_THERMAL(_id) ONLP_OID_IS_TYPE(ONLP_OID_TYPE_THERMAL,_id)
+#define ONLP_OID_IS_FAN(_id) ONLP_OID_IS_TYPE(ONLP_OID_TYPE_FAN,_id)
+#define ONLP_OID_IS_PSU(_id) ONLP_OID_IS_TYPE(ONLP_OID_TYPE_PSU,_id)
+#define ONLP_OID_IS_LED(_id) ONLP_OID_IS_TYPE(ONLP_OID_TYPE_LED,_id)
+#define ONLP_OID_IS_MODULE(_id) ONLP_OID_IS_TYPE(ONLP_OID_TYPE_MODULE,_id)
+
+
+/**
+ * There is only one SYS OID. This value should be used.
+ */
+#define ONLP_OID_SYS ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_SYS, 1)
+
+/**
+ * All OIDs have user-level description strings:
+ */
+#define ONLP_OID_DESC_SIZE 128
+
+typedef char onlp_oid_desc_t[ONLP_OID_DESC_SIZE];
+
+/* fixme */
+#define ONLP_OID_TABLE_SIZE 32
+typedef onlp_oid_t onlp_oid_table_t[ONLP_OID_TABLE_SIZE];
+#define ONLP_OID_TABLE_SIZE_BYTES (sizeof(onlp_oid_t)*ONLP_OID_TABLE_SIZE)
+#define ONLP_OID_TABLE_COPY(_dst, _src) memcpy(_dst, _src, ONLP_OID_TABLE_SIZE_BYTES)
+#define ONLP_OID_TABLE_CLEAR(_table) memset(_table, 0, ONLP_OID_TABLE_SIZE_BYTES)
+
+
+/**
+ * This macro can be used to construct your OID hdr tables
+ */
+#define ONLP_OID_THERMAL_ENTRY(_id, _desc, _parent_type, _parent_id) \
+ { ONLP_THERMAL_ID_CREATE(_id), _desc, ONLP_OID_TYPE_CREATE(_parent_type, _parent_id) }
+
+/**
+ * All OID objects contain this header as the first member.
+ */
+typedef struct onlp_oid_hdr_s {
+ /** The OID */
+ onlp_oid_t id;
+ /** The description of this object. */
+ onlp_oid_desc_t description;
+ /** The parent OID of this object. */
+ onlp_oid_t poid;
+ /** The children of this OID */
+ onlp_oid_table_t coids;
+} onlp_oid_hdr_t;
+
+
+#define ONLP_OID_DUMP_F_RECURSE 0x1
+#define ONLP_OID_DUMP_F_EVEN_IF_ABSENT 0x2
+
+#define ONLP_OID_SHOW_F_RECURSE 0x1
+#define ONLP_OID_SHOW_F_EXTENDED 0x2
+#define ONLP_OID_SHOW_F_YAML 0x4
+
+void onlp_oid_dump(onlp_oid_t oid, aim_pvs_t* pvs, uint32_t flags);
+void onlp_oid_table_dump(onlp_oid_table_t table, aim_pvs_t* pvs,
+ uint32_t flags);
+
+void onlp_oid_show(onlp_oid_t oid, aim_pvs_t* pvs, uint32_t flags);
+void onlp_oid_table_show(onlp_oid_table_t table, aim_pvs_t* pvs,
+ uint32_t flags);
+
+/**
+ * @brief Iterate over all OIDS in the given table that match the given expression.
+ * @param _table The OID table
+ * @param _oidp OID pointer iterator
+ * @param _expr OID Expression which must be true
+ */
+#define ONLP_OID_TABLE_ITER_EXPR(_table, _oidp, _expr) \
+ for(_oidp = _table; _oidp < (_table+ONLP_OID_TABLE_SIZE); _oidp++) \
+ if( (*_oidp) && (_expr) )
+
+/**
+ * @brief Iterate over all OIDs in the given table.
+ * @param _table The OID table
+ * @param _oidp OID pointer iterator
+ */
+#define ONLP_OID_TABLE_ITER(_table, _oidp) ONLP_OID_TABLE_ITER_EXPR(_table, _oidp, 1)
+
+/**
+ * @brief Iterate over all OIDs in the given table of the given type.
+ * @param _table The OID table
+ * @param _oidp OID pointer iteration.
+ * @param _type The OID Type
+ */
+
+#define ONLP_OID_TABLE_ITER_TYPE(_table, _oidp, _type) \
+ ONLP_OID_TABLE_ITER_EXPR(_table, _oidp, ONLP_OID_IS_TYPE(ONLP_OID_TYPE_##_type, *_oidp))
+
+
+/**
+ * Iterator
+ */
+typedef int (*onlp_oid_iterate_f)(onlp_oid_t oid, void* cookie);
+
+/**
+ * @brief Iterate over all platform OIDs.
+ * @param oid The root OID.
+ * @param type The OID type filter (optional)
+ * @param itf The iterator function.
+ * @param cookie The cookie.
+ */
+int onlp_oid_iterate(onlp_oid_t oid, onlp_oid_type_t type,
+ onlp_oid_iterate_f itf, void* cookie);
+
+/**
+ * @brief Get the OID header for a given OID.
+ * @param oid The oid
+ * @param hdr [out] Receives the header
+ */
+int onlp_oid_hdr_get(onlp_oid_t oid, onlp_oid_hdr_t* hdr);
+
+
+
+
+
+
+/******************************************************************************
+ *
+ * Enumeration Support Definitions.
+ *
+ * Please do not add additional code beyond this point.
+ *
+ *****************************************************************************/
+/* */
+/** Enum names. */
+const char* onlp_oid_type_name(onlp_oid_type_t e);
+
+/** Enum values. */
+int onlp_oid_type_value(const char* str, onlp_oid_type_t* e, int substr);
+
+/** Enum descriptions. */
+const char* onlp_oid_type_desc(onlp_oid_type_t e);
+
+/** Enum validator. */
+int onlp_oid_type_valid(onlp_oid_type_t e);
+
+/** validator */
+#define ONLP_OID_TYPE_VALID(_e) \
+ (onlp_oid_type_valid((_e)))
+
+/** onlp_oid_type_map table. */
+extern aim_map_si_t onlp_oid_type_map[];
+/** onlp_oid_type_desc_map table. */
+extern aim_map_si_t onlp_oid_type_desc_map[];
+/* */
+
+#endif /* __ONLP_OID_H__ */
diff --git a/packages/base/any/onlp/src/onlp/module/inc/onlp/onlp.h b/packages/base/any/onlp/src/onlp/module/inc/onlp/onlp.h
new file mode 100644
index 00000000..6c0e7d2a
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/inc/onlp/onlp.h
@@ -0,0 +1,104 @@
+/************************************************************
+ *
+ *
+ * Copyright 2014, 2015 Big Switch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ ************************************************************
+ *
+ *
+ *
+ ***********************************************************/
+#ifndef __ONLP_ONLP_H__
+#define __ONLP_ONLP_H__
+
+#include
+
+/* */
+/** onlp_status */
+typedef enum onlp_status_e {
+ ONLP_STATUS_OK = 0,
+ ONLP_STATUS_E_UNSUPPORTED = -1,
+ ONLP_STATUS_E_MISSING = -2,
+ ONLP_STATUS_E_INVALID = -3,
+ ONLP_STATUS_E_INTERNAL = -4,
+ ONLP_STATUS_E_PARAM = -5,
+} onlp_status_t;
+/* */
+
+#define ONLP_IF_ERROR_RETURN(_expr) \
+ do { \
+ int _rv = (_expr); \
+ if(_rv < 0) { \
+ return _rv; \
+ } \
+ } while(0)
+
+
+/**
+ * @brief Initialize all subsystems.
+ */
+int onlp_init(void);
+
+
+/**
+ * @brief Dump the current platform data.
+ * @param pvs The output pvs
+ */
+
+void onlp_platform_dump(aim_pvs_t* pvs, uint32_t flags);
+void onlp_platform_show(aim_pvs_t* pvs, uint32_t flags);
+
+/** Standardized macros for dealing with sensor milli-values */
+#define ONLP_MILLI_NORMAL_INTEGER(_m) (_m / 1000)
+#define ONLP_MILLI_NORMAL_TENTHS(_m) ( (_m % 1000) / 100)
+#define ONLP_MILLI_NORMAL_INTEGER_TENTHS(_m) ONLP_MILLI_NORMAL_INTEGER(_m), ONLP_MILLI_NORMAL_TENTHS(_m)
+
+
+
+
+
+/******************************************************************************
+ *
+ * Enumeration Support Definitions.
+ *
+ * Please do not add additional code beyond this point.
+ *
+ *****************************************************************************/
+/* */
+/** Enum names. */
+const char* onlp_status_name(onlp_status_t e);
+
+/** Enum values. */
+int onlp_status_value(const char* str, onlp_status_t* e, int substr);
+
+/** Enum descriptions. */
+const char* onlp_status_desc(onlp_status_t e);
+
+/** Enum validator. */
+int onlp_status_valid(onlp_status_t e);
+
+/** validator */
+#define ONLP_STATUS_VALID(_e) \
+ (onlp_status_valid((_e)))
+
+/** onlp_status_map table. */
+extern aim_map_si_t onlp_status_map[];
+/** onlp_status_desc_map table. */
+extern aim_map_si_t onlp_status_desc_map[];
+/* */
+
+#endif /* __ONLP_ONLP_H__ */
diff --git a/packages/base/any/onlp/src/onlp/module/inc/onlp/onlp.x b/packages/base/any/onlp/src/onlp/module/inc/onlp/onlp.x
new file mode 100644
index 00000000..6598122c
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/inc/onlp/onlp.x
@@ -0,0 +1,63 @@
+/************************************************************
+ *
+ *
+ * Copyright 2014, 2015 Big Switch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ ************************************************************
+ *
+ *
+ *
+ ***********************************************************/
+
+#include
+
+
+/* */
+#ifdef ONLP_OID_TYPE_ENTRY
+ONLP_OID_TYPE_ENTRY(SYS, 1)
+ONLP_OID_TYPE_ENTRY(THERMAL, 2)
+ONLP_OID_TYPE_ENTRY(FAN, 3)
+ONLP_OID_TYPE_ENTRY(PSU, 4)
+ONLP_OID_TYPE_ENTRY(LED, 5)
+ONLP_OID_TYPE_ENTRY(MODULE, 6)
+ONLP_OID_TYPE_ENTRY(RTC, 7)
+#undef ONLP_OID_TYPE_ENTRY
+#endif
+/* */
+
+/* */
+#ifdef ONLP_ENUMERATION_ENTRY
+ONLP_ENUMERATION_ENTRY(onlp_sfp_control_flag, "")
+ONLP_ENUMERATION_ENTRY(onlp_psu_status, "")
+ONLP_ENUMERATION_ENTRY(onlp_sfp_control, "")
+ONLP_ENUMERATION_ENTRY(onlp_led_caps, "")
+ONLP_ENUMERATION_ENTRY(onlp_led_status, "")
+ONLP_ENUMERATION_ENTRY(onlp_thermal_status, "")
+ONLP_ENUMERATION_ENTRY(onlp_oid_type, "")
+ONLP_ENUMERATION_ENTRY(onlp_fan_caps, "")
+ONLP_ENUMERATION_ENTRY(onlp_fan_status, "")
+ONLP_ENUMERATION_ENTRY(onlp_status, "")
+ONLP_ENUMERATION_ENTRY(onlp_thermal_caps, "")
+ONLP_ENUMERATION_ENTRY(onlp_fan_dir, "")
+ONLP_ENUMERATION_ENTRY(onlp_fan_mode, "")
+ONLP_ENUMERATION_ENTRY(onlp_psu_caps, "")
+ONLP_ENUMERATION_ENTRY(onlp_led_mode, "")
+#undef ONLP_ENUMERATION_ENTRY
+#endif
+/* */
+
+
diff --git a/packages/base/any/onlp/src/onlp/module/inc/onlp/onlp_config.h b/packages/base/any/onlp/src/onlp/module/inc/onlp/onlp_config.h
new file mode 100644
index 00000000..baecc3f9
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/inc/onlp/onlp_config.h
@@ -0,0 +1,272 @@
+/************************************************************
+ *
+ *
+ * Copyright 2014, 2015 Big Switch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ ************************************************************
+ *
+ *
+ *
+ ***********************************************************/
+
+/**************************************************************************//**
+ *
+ * @file
+ * @brief onlp Configuration Header
+ *
+ * @addtogroup onlp-config
+ * @{
+ *
+ *****************************************************************************/
+#ifndef __ONLP_CONFIG_H__
+#define __ONLP_CONFIG_H__
+
+#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG
+#include
+#endif
+#ifdef ONLP_INCLUDE_CUSTOM_CONFIG
+#include
+#endif
+
+/* */
+#include
+/**
+ * ONLP_CONFIG_INCLUDE_LOGGING
+ *
+ * Include or exclude logging. */
+
+
+#ifndef ONLP_CONFIG_INCLUDE_LOGGING
+#define ONLP_CONFIG_INCLUDE_LOGGING 1
+#endif
+
+/**
+ * ONLP_CONFIG_LOG_OPTIONS_DEFAULT
+ *
+ * Default enabled log options. */
+
+
+#ifndef ONLP_CONFIG_LOG_OPTIONS_DEFAULT
+#define ONLP_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT
+#endif
+
+/**
+ * ONLP_CONFIG_LOG_BITS_DEFAULT
+ *
+ * Default enabled log bits. */
+
+
+#ifndef ONLP_CONFIG_LOG_BITS_DEFAULT
+#define ONLP_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT
+#endif
+
+/**
+ * ONLP_CONFIG_LOG_CUSTOM_BITS_DEFAULT
+ *
+ * Default enabled custom log bits. */
+
+
+#ifndef ONLP_CONFIG_LOG_CUSTOM_BITS_DEFAULT
+#define ONLP_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0
+#endif
+
+/**
+ * ONLP_CONFIG_PORTING_STDLIB
+ *
+ * Default all porting macros to use the C standard libraries. */
+
+
+#ifndef ONLP_CONFIG_PORTING_STDLIB
+#define ONLP_CONFIG_PORTING_STDLIB 1
+#endif
+
+/**
+ * ONLP_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS
+ *
+ * Include standard library headers for stdlib porting macros. */
+
+
+#ifndef ONLP_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS
+#define ONLP_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS ONLP_CONFIG_PORTING_STDLIB
+#endif
+
+/**
+ * ONLP_CONFIG_INCLUDE_UCLI
+ *
+ * Include generic uCli support. */
+
+
+#ifndef ONLP_CONFIG_INCLUDE_UCLI
+#define ONLP_CONFIG_INCLUDE_UCLI 0
+#endif
+
+/**
+ * ONLP_CONFIG_INCLUDE_PLATFORM_ERROR_CHECK
+ *
+ * Include platform error checking at initialization. */
+
+
+#ifndef ONLP_CONFIG_INCLUDE_PLATFORM_ERROR_CHECK
+#define ONLP_CONFIG_INCLUDE_PLATFORM_ERROR_CHECK 1
+#endif
+
+/**
+ * ONLP_CONFIG_INCLUDE_SHLOCK_GLOBAL_INIT
+ *
+ * Include global shlock initialization at module init time. */
+
+
+#ifndef ONLP_CONFIG_INCLUDE_SHLOCK_GLOBAL_INIT
+#define ONLP_CONFIG_INCLUDE_SHLOCK_GLOBAL_INIT 0
+#endif
+
+/**
+ * ONLP_CONFIG_INCLUDE_PLATFORM_STATIC
+ *
+ * Specify the platform name directly as a compile-time option. */
+
+
+#ifndef ONLP_CONFIG_INCLUDE_PLATFORM_STATIC
+#define ONLP_CONFIG_INCLUDE_PLATFORM_STATIC 0
+#endif
+
+/**
+ * ONLP_CONFIG_PLATFORM_STATIC
+ *
+ * The name of the static platform if configured. */
+
+
+#ifndef ONLP_CONFIG_PLATFORM_STATIC
+#define ONLP_CONFIG_PLATFORM_STATIC "unknown"
+#endif
+
+/**
+ * ONLP_CONFIG_PLATFORM_FILENAME
+ *
+ * The local filename containing the current platform identifier. */
+
+
+#ifndef ONLP_CONFIG_PLATFORM_FILENAME
+#define ONLP_CONFIG_PLATFORM_FILENAME "/etc/onl/platform"
+#endif
+
+/**
+ * ONLP_CONFIG_INCLUDE_PLATFORM_OVERRIDES
+ *
+ * Allow support for local overrides of all platform OID values (testing). */
+
+
+#ifndef ONLP_CONFIG_INCLUDE_PLATFORM_OVERRIDES
+#define ONLP_CONFIG_INCLUDE_PLATFORM_OVERRIDES 1
+#endif
+
+/**
+ * ONLP_CONFIG_CONFIGURATION_FILENAME
+ *
+ * The filename for the (optional) ONLP JSON configuration file. */
+
+
+#ifndef ONLP_CONFIG_CONFIGURATION_FILENAME
+#define ONLP_CONFIG_CONFIGURATION_FILENAME "/etc/onlp.conf"
+#endif
+
+/**
+ * ONLP_CONFIG_CONFIGURATION_ENV
+ *
+ * Environment variable to check for configuration filenames. Overrides default. */
+
+
+#ifndef ONLP_CONFIG_CONFIGURATION_ENV
+#define ONLP_CONFIG_CONFIGURATION_ENV "ONLP_CONF"
+#endif
+
+/**
+ * ONLP_CONFIG_INCLUDE_API_LOCK
+ *
+ * Include exclusive locking for all API calls. */
+
+
+#ifndef ONLP_CONFIG_INCLUDE_API_LOCK
+#define ONLP_CONFIG_INCLUDE_API_LOCK 1
+#endif
+
+/**
+ * ONLP_CONFIG_API_LOCK_GLOBAL_SHARED
+ *
+ * If 0, the API lock is a simple semaphore. If 1, the API lock is a global shared mutex. */
+
+
+#ifndef ONLP_CONFIG_API_LOCK_GLOBAL_SHARED
+#define ONLP_CONFIG_API_LOCK_GLOBAL_SHARED 0
+#endif
+
+/**
+ * ONLP_CONFIG_API_LOCK_TIMEOUT
+ *
+ * The maximum amount of time (in usecs) to wait while attempting to acquire the API lock. Failure to acquire is fatal. A value of zero disables this feature. */
+
+
+#ifndef ONLP_CONFIG_API_LOCK_TIMEOUT
+#define ONLP_CONFIG_API_LOCK_TIMEOUT 60000000
+#endif
+
+/**
+ * ONLP_CONFIG_INFO_STR_MAX
+ *
+ * The maximum size of static information string buffers. */
+
+
+#ifndef ONLP_CONFIG_INFO_STR_MAX
+#define ONLP_CONFIG_INFO_STR_MAX 64
+#endif
+
+
+
+/**
+ * All compile time options can be queried or displayed
+ */
+
+/** Configuration settings structure. */
+typedef struct onlp_config_settings_s {
+ /** name */
+ const char* name;
+ /** value */
+ const char* value;
+} onlp_config_settings_t;
+
+/** Configuration settings table. */
+/** onlp_config_settings table. */
+extern onlp_config_settings_t onlp_config_settings[];
+
+/**
+ * @brief Lookup a configuration setting.
+ * @param setting The name of the configuration option to lookup.
+ */
+const char* onlp_config_lookup(const char* setting);
+
+/**
+ * @brief Show the compile-time configuration.
+ * @param pvs The output stream.
+ */
+int onlp_config_show(struct aim_pvs_s* pvs);
+
+/* */
+
+#include "onlp_porting.h"
+
+#endif /* __ONLP_CONFIG_H__ */
+/* @} */
diff --git a/packages/base/any/onlp/src/onlp/module/inc/onlp/onlp_dox.h b/packages/base/any/onlp/src/onlp/module/inc/onlp/onlp_dox.h
new file mode 100644
index 00000000..9da554c4
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/inc/onlp/onlp_dox.h
@@ -0,0 +1,45 @@
+/************************************************************
+ *
+ *
+ * Copyright 2014, 2015 Big Switch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ ************************************************************
+ *
+ *
+ *
+ ***********************************************************/
+#ifndef __ONLP_DOX_H__
+#define __ONLP_DOX_H__
+
+/**
+ * @defgroup onlp onlp - onlp Description
+ *
+
+The documentation overview for this module should go here.
+
+ *
+ * @{
+ *
+ * @defgroup onlp-onlp Public Interface
+ * @defgroup onlp-config Compile Time Configuration
+ * @defgroup onlp-porting Porting Macros
+ *
+ * @}
+ *
+ */
+
+#endif /* __ONLP_DOX_H__ */
diff --git a/packages/base/any/onlp/src/onlp/module/inc/onlp/onlp_porting.h b/packages/base/any/onlp/src/onlp/module/inc/onlp/onlp_porting.h
new file mode 100644
index 00000000..281a323b
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/inc/onlp/onlp_porting.h
@@ -0,0 +1,92 @@
+/************************************************************
+ *
+ *
+ * Copyright 2014, 2015 Big Switch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ ************************************************************
+ *
+ *
+ *
+ ***********************************************************/
+
+/**************************************************************************//**
+ *
+ * @file
+ * @brief onlp Porting Macros.
+ *
+ * @addtogroup onlp-porting
+ * @{
+ *
+ *****************************************************************************/
+#ifndef __ONLP_PORTING_H__
+#define __ONLP_PORTING_H__
+
+
+/* */
+#if ONLP_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1
+#include
+#include
+#include
+#include
+#include
+#endif
+
+#ifndef ONLP_MEMSET
+ #if defined(GLOBAL_MEMSET)
+ #define ONLP_MEMSET GLOBAL_MEMSET
+ #elif ONLP_CONFIG_PORTING_STDLIB == 1
+ #define ONLP_MEMSET memset
+ #else
+ #error The macro ONLP_MEMSET is required but cannot be defined.
+ #endif
+#endif
+
+#ifndef ONLP_MEMCPY
+ #if defined(GLOBAL_MEMCPY)
+ #define ONLP_MEMCPY GLOBAL_MEMCPY
+ #elif ONLP_CONFIG_PORTING_STDLIB == 1
+ #define ONLP_MEMCPY memcpy
+ #else
+ #error The macro ONLP_MEMCPY is required but cannot be defined.
+ #endif
+#endif
+
+#ifndef ONLP_STRNCPY
+ #if defined(GLOBAL_STRNCPY)
+ #define ONLP_STRNCPY GLOBAL_STRNCPY
+ #elif ONLP_CONFIG_PORTING_STDLIB == 1
+ #define ONLP_STRNCPY strncpy
+ #else
+ #error The macro ONLP_STRNCPY is required but cannot be defined.
+ #endif
+#endif
+
+#ifndef ONLP_STRLEN
+ #if defined(GLOBAL_STRLEN)
+ #define ONLP_STRLEN GLOBAL_STRLEN
+ #elif ONLP_CONFIG_PORTING_STDLIB == 1
+ #define ONLP_STRLEN strlen
+ #else
+ #error The macro ONLP_STRLEN is required but cannot be defined.
+ #endif
+#endif
+
+/* */
+
+
+#endif /* __ONLP_PORTING_H__ */
+/* @} */
diff --git a/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/fani.h b/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/fani.h
new file mode 100644
index 00000000..76807822
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/fani.h
@@ -0,0 +1,83 @@
+/************************************************************
+ *
+ *
+ * Copyright 2014, 2015 Big Switch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ ************************************************************
+ *
+ * Fan Platform Implementation.
+ *
+ ***********************************************************/
+#ifndef __ONLP_FANI_H__
+#define __ONLP_FANI_H__
+
+#include
+
+/**
+ * @brief Initialize the fan platform subsystem.
+ */
+int onlp_fani_init(void);
+
+/**
+ * @brief Get the information structure for the given fan OID.
+ * @param id The fan OID
+ * @param rv [out] Receives the fan information.
+ */
+int onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* rv);
+
+/**
+ * @brief Set the fan speed in RPM.
+ * @param id The fan OID
+ * @param rpm The new RPM
+ * @note This is only relevant if the RPM capability is set.
+ */
+int onlp_fani_rpm_set(onlp_oid_t id, int rpm);
+
+
+/**
+ * @brief Set the fan speed in percentage.
+ * @param id The fan OID.
+ * @param p The new fan speed percentage.
+ * @note This is only relevant if the PERCENTAGE capability is set.
+ */
+int onlp_fani_percentage_set(onlp_oid_t id, int p);
+
+/**
+ * @brief Set the fan mode.
+ * @param id The fan OID.
+ * @param mode The new fan mode.
+ */
+int onlp_fani_mode_set(onlp_oid_t id, onlp_fan_mode_t mode);
+
+
+/**
+ * @brief Set the fan direction (if supported).
+ * @param id The fan OID
+ * @param dir The direction.
+ */
+int onlp_fani_dir_set(onlp_oid_t id, onlp_fan_dir_t dir);
+
+/**
+ * @brief Generic fan ioctl
+ * @param id The fan OID
+ * @param vargs The variable argument list for the ioctl call.
+ * @param Optional
+ */
+int onlp_fani_ioctl(onlp_oid_t fid, va_list vargs);
+
+#endif /* __ONLP_FANI_H__ */
+
diff --git a/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/ledi.h b/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/ledi.h
new file mode 100644
index 00000000..9bb043fa
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/ledi.h
@@ -0,0 +1,66 @@
+/************************************************************
+ *
+ *
+ * Copyright 2014, 2015 Big Switch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ ************************************************************
+ *
+ * LED Platform Implementation.
+ *
+ ***********************************************************/
+#ifndef __ONLP_LEDI_H__
+#define __ONLP_LEDI_H__
+
+#include
+
+/**
+ * @brief Initialize the LED subsystem.
+ */
+int onlp_ledi_init(void);
+
+/**
+ * @brief Get the information for the given LED
+ * @param id The LED OID
+ * @param rv [out] Receives the LED information.
+ */
+int onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* rv);
+
+/**
+ * @brief Turn an LED on or off
+ * @param id The LED OID
+ * @param on_or_off (boolean) on if 1 off if 0
+ * @param This function is only relevant if the ONOFF capability is set.
+ * @notes See onlp_led_set() for a description of the default behavior.
+ */
+int onlp_ledi_set(onlp_oid_t id, int on_or_off);
+
+/**
+ * @brief LED ioctl
+ * @param id The LED OID
+ * @param vargs The variable argument list for the ioctl call.
+ */
+int onlp_ledi_ioctl(onlp_oid_t id, va_list vargs);
+
+/**
+ * @brief Set the LED mode.
+ * @param id The LED OID
+ * @param mode The new mode.
+ * @notes Only called if the mode is advertised in the LED capabilities.
+ */
+int onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode);
+
+#endif /* __ONLP_LED_H__ */
diff --git a/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/psui.h b/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/psui.h
new file mode 100644
index 00000000..e9f75da5
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/psui.h
@@ -0,0 +1,50 @@
+/************************************************************
+ *
+ *
+ * Copyright 2014, 2015 Big Switch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ ************************************************************
+ *
+ * Power Supply Management Implementation.
+ *
+ ***********************************************************/
+#ifndef __ONLP_PSUI_H__
+#define __ONLP_PSUI_H__
+
+#include
+
+/**
+ * @brief Initialize the PSU subsystem.
+ */
+int onlp_psui_init(void);
+
+/**
+ * @brief Get the information structure for the given PSU
+ * @param id The PSU OID
+ * @param rv [out] Receives the PSU information.
+ */
+int onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* rv);
+
+/**
+ * @brief Generic PSU ioctl
+ * @param id The PSU OID
+ * @param vargs The variable argument list for the ioctl call.
+ */
+int onlp_psui_ioctl(onlp_oid_t pid, va_list vargs);
+
+
+#endif /* __ONLP_PSUI_H__ */
diff --git a/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/sfpi.h b/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/sfpi.h
new file mode 100644
index 00000000..3f451cbb
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/sfpi.h
@@ -0,0 +1,162 @@
+/************************************************************
+ *
+ *
+ * Copyright 2014, 2015 Big Switch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ ************************************************************
+ *
+ * SFP Platform Implementation Interface.
+ *
+ * This interface must be implemented and available for all
+ * platforms that support SFP interfaces.
+ *
+ ***********************************************************/
+#ifndef __ONLP_SFPI_H__
+#define __ONLP_SFPI_H__
+
+#include
+#include
+#include
+
+/**
+ * @brief Initialize the SFPI subsystem.
+ */
+int onlp_sfpi_init(void);
+
+/**
+ * @brief Get the bitmap of SFP-capable port numbers.
+ * @param bmap [out] Receives the bitmap.
+ */
+int onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap);
+
+/**
+ * @brief Determine if an SFP is present.
+ * @param port The port number.
+ * @returns 1 if present
+ * @returns 0 if absent
+ * @returns An error condition.
+ */
+int onlp_sfpi_is_present(int port);
+
+/**
+ * @brief Return the presence bitmap for all SFP ports.
+ * @param dst Receives the presence bitmap.
+ */
+int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst);
+
+/**
+ * @brief Return the RX_LOS bitmap for all SFP ports.
+ * @param dst Receives the RX_LOS bitmap.
+ */
+int onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst);
+
+/**
+ * @brief Read the SFP EEPROM.
+ * @param port The port number.
+ * @param data Receives the SFP data.
+ */
+int onlp_sfpi_eeprom_read(int port, uint8_t data[256]);
+
+/**
+ * @brief Read the SFP DOM EEPROM.
+ * @param port The port number.
+ * @param data Receives the SFP data.
+ */
+int onlp_sfpi_dom_read(int port, uint8_t data[256]);
+
+/**
+ * @brief Perform any actions required after an SFP is inserted.
+ * @param port The port number.
+ * @param info The SFF Module information structure.
+ * @notes Optional
+ */
+int onlp_sfpi_post_insert(int port, sff_info_t* info);
+
+/**
+ * @brief Returns whether or not the given control is suppport on the given port.
+ * @param port The port number.
+ * @param control The control.
+ * @param rv [out] Receives 1 if supported, 0 if not supported.
+ * @note This provided for convenience and is optional.
+ * If you implement this function your control_set and control_get APIs
+ * will not be called on unsupported ports.
+ */
+int onlp_sfpi_control_supported(int port, onlp_sfp_control_t control, int* rv);
+
+/**
+ * @brief Set an SFP control.
+ * @param port The port.
+ * @param control The control.
+ * @param value The value.
+ */
+int onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value);
+
+/**
+ * @brief Get an SFP control.
+ * @param port The port.
+ * @param control The control
+ * @param [out] value Receives the current value.
+ */
+int onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value);
+
+/**
+ * @brief Remap SFP user SFP port numbers before calling the SFPI interface.
+ * @param port The user SFP port number.
+ * @param [out] rport Receives the new port.
+ * @note This function will be called to remap the user SFP port number
+ * to the number returned in rport before the SFPI functions are called.
+ * This is an optional convenience for platforms with dynamic or
+ * variant physical SFP numbering.
+ */
+int onlp_sfpi_port_map(int port, int* rport);
+
+/**
+ * @brief Deinitialize the SFP driver.
+ */
+int onlp_sfpi_denit(void);
+
+/**
+ * @brief Generic debug status information.
+ * @param port The port number.
+ * @param pvs The output pvs.
+ * @notes The purpose of this vector is to allow reporting of internal debug
+ * status and information from the platform driver that might be used to debug
+ * SFP runtime issues.
+ * For example, internal equalizer settings, tuning status information, status
+ * of additional signals useful for system debug but not exposed in this interface.
+ *
+ * @notes This is function is optional.
+ */
+void onlp_sfpi_debug(int port, aim_pvs_t* pvs);
+
+/**
+ * @brief Generic ioctl
+ * @param port The port number
+ * @param The variable argument list of parameters.
+ *
+ * @notes This generic ioctl interface can be used
+ * for platform-specific or driver specific features
+ * that cannot or have not yet been defined in this
+ * interface. It is intended as a future feature expansion
+ * support mechanism.
+ *
+ * @notes Optional
+ */
+int onlp_sfpi_ioctl(int port, va_list vargs);
+
+
+#endif /* __ONLP_SFPI_H__ */
diff --git a/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/sysi.h b/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/sysi.h
new file mode 100644
index 00000000..692cedee
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/sysi.h
@@ -0,0 +1,157 @@
+/************************************************************
+ *
+ *
+ * Copyright 2014, 2015 Big Switch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ ************************************************************
+ *
+ * ONLP System Platform Interface.
+ *
+ ***********************************************************/
+#ifndef __ONLP_SYSI_H__
+#define __ONLP_SYSI_H__
+
+#include
+
+
+/**
+ * @brief Return the name of the the platform implementation.
+ * @notes This will be called PRIOR to any other calls into the
+ * platform driver, including the sysi_init() function below.
+ *
+ * The platform implementation name should match the current
+ * ONLP platform name.
+ *
+ * IF the platform implementation name equals the current platform name,
+ * initialization will continue.
+ *
+ * If the platform implementation name does not match, the following will be
+ * attempted:
+ *
+ * onlp_sysi_platform_set(current_platform_name);
+ * If this call is successful, initialization will continue.
+ * If this call fails, platform initialization will abort().
+ *
+ * The onlp_sysi_platform_set() function is optional.
+ * The onlp_sysi_platform_get() is not optional.
+ */
+const char* onlp_sysi_platform_get(void);
+
+/**
+ * @brief Attempt to set the platform personality
+ * in the event that the current platform does not match the
+ * reported platform.
+ * @note Optional
+ */
+int onlp_sysi_platform_set(const char* platform);
+
+
+
+
+/**
+ * @brief Initialize the system platform subsystem.
+ */
+int onlp_sysi_init(void);
+
+
+/**
+ * @brief Provide the physical base address for the ONIE eeprom.
+ * @param param [out] physaddr Receives the physical address.
+ * @notes If your platform provides a memory-mappable base
+ * address for the ONIE eeprom data you can return it here.
+ * The ONLP common code will then use this address and decode
+ * the ONIE TLV specification data. If you cannot return a mappable
+ * address due to the platform organization see onlp_sysi_onie_data_get()
+ * instead.
+ */
+ int onlp_sysi_onie_data_phys_addr_get(void** physaddr);
+
+/**
+ * @brief Return the raw contents of the ONIE system eeprom.
+ * @param data [out] Receives the data pointer to the ONIE data.
+ * @param size [out] Receives the size of the data (if available).
+ * @notes This function is only necessary if you cannot provide
+ * the physical base address as per onlp_sysi_onie_data_phys_addr_get().
+ */
+int onlp_sysi_onie_data_get(uint8_t** data, int* size);
+
+/**
+ * @brief Free the data returned by onlp_sys_onie_data_get()
+ * @param data The data pointer.
+ * @notes If onlp_sysi_onie_data_get() is called to retreive the
+ * contents of the ONIE system eeprom then this function
+ * will be called to perform any cleanup that may be necessary
+ * after the data has been used.
+ */
+void onlp_sysi_onie_data_free(uint8_t* data);
+
+
+/**
+ * @brief Return the ONIE system information for this platform.
+ * @param onie The onie information structure.
+ * @notes If all previous attempts to get the eeprom data fail
+ * then this routine will be called. Used as a translation option
+ * for platforms without access to an ONIE-formatted eeprom.
+ */
+int onlp_sysi_onie_info_get(onlp_onie_info_t* onie);
+
+
+/**
+ * @brief This function returns the root oid list for the platform.
+ * @param table [out] Receives the table.
+ * @param max The maximum number of entries you can fill.
+ */
+int onlp_sysi_oids_get(onlp_oid_t* table, int max);
+
+
+/**
+ * @brief This function provides a generic ioctl interface.
+ * @param code context dependent.
+ * @param vargs The variable argument list for the ioctl call.
+ * @notes This is provided as a generic expansion and
+ * and custom programming mechanism for future and non-standard
+ * functionality.
+ * @notes Optional
+ */
+int onlp_sysi_ioctl(int code, va_list vargs);
+
+
+/**
+ * @brief Perform necessary platform fan management.
+ * @note This function should automatically adjust the FAN speeds
+ * according to the platform conditions.
+ */
+int onlp_sysi_platform_manage_fans(void);
+
+/**
+ * @brief Perform necessary platform LED management.
+ * @note This function should automatically adjust the LED indicators
+ * according to the platform conditions.
+ */
+int onlp_sysi_platform_manage_leds(void);
+
+/**
+ * @brief Return custom platform information.
+ */
+int onlp_sysi_platform_info_get(onlp_platform_info_t* info);
+
+/**
+ * @brief Friee a custom platform information structure.
+ */
+void onlp_sysi_platform_info_free(onlp_platform_info_t* info);
+
+#endif /* __ONLP_SYSI_H__ */
diff --git a/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/thermali.h b/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/thermali.h
new file mode 100644
index 00000000..fd2a29af
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/thermali.h
@@ -0,0 +1,48 @@
+/************************************************************
+ *
+ *
+ * Copyright 2014, 2015 Big Switch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ ************************************************************
+ *
+ * Thermal Sensor Platform Implementation.
+ *
+ ***********************************************************/
+#ifndef __ONLP_THERMALI_H__
+#define __ONLP_THERMALI_H__
+
+#include
+
+/**
+ * @brief Initialize the thermal subsystem.
+ */
+int onlp_thermali_init(void);
+
+
+/**
+ * @brief Get the information for the given thermal OID.
+ * @param id The Thermal OID
+ * @param rv [out] Receives the thermal information.
+ */
+int onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* rv);
+
+/**
+ * @brief Generic ioctl.
+ */
+int onlp_thermali_ioctl(int id, va_list vargs);
+
+#endif /* __ONLP_THERMALI_H__ */
diff --git a/packages/base/any/onlp/src/onlp/module/inc/onlp/psu.h b/packages/base/any/onlp/src/onlp/module/inc/onlp/psu.h
new file mode 100644
index 00000000..0095ccdb
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/inc/onlp/psu.h
@@ -0,0 +1,190 @@
+/************************************************************
+ *
+ *
+ * Copyright 2014, 2015 Big Switch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ ************************************************************
+ *
+ * Power Supply Management.
+ *
+ ***********************************************************/
+#ifndef __ONLP_PSU_H__
+#define __ONLP_PSU_H__
+
+#include
+#include
+
+/* */
+/** onlp_psu_caps */
+typedef enum onlp_psu_caps_e {
+ ONLP_PSU_CAPS_AC = (1 << 0),
+ ONLP_PSU_CAPS_DC12 = (1 << 1),
+ ONLP_PSU_CAPS_DC48 = (1 << 2),
+ ONLP_PSU_CAPS_VIN = (1 << 3),
+ ONLP_PSU_CAPS_VOUT = (1 << 4),
+ ONLP_PSU_CAPS_IIN = (1 << 5),
+ ONLP_PSU_CAPS_IOUT = (1 << 6),
+ ONLP_PSU_CAPS_PIN = (1 << 7),
+ ONLP_PSU_CAPS_POUT = (1 << 8),
+} onlp_psu_caps_t;
+
+/** onlp_psu_status */
+typedef enum onlp_psu_status_e {
+ ONLP_PSU_STATUS_PRESENT = (1 << 0),
+ ONLP_PSU_STATUS_FAILED = (1 << 1),
+ ONLP_PSU_STATUS_UNPLUGGED = (1 << 2),
+} onlp_psu_status_t;
+/* */
+
+
+/**
+ * PSU Information Structure
+ */
+typedef struct onlp_psu_info_t {
+ /** OID Header */
+ onlp_oid_hdr_t hdr;
+
+ /* Model */
+ char model[ONLP_CONFIG_INFO_STR_MAX];
+
+ /* Serial Number */
+ char serial[ONLP_CONFIG_INFO_STR_MAX];
+
+ /* Status */
+ uint32_t status;
+
+ /* Capabilities */
+ uint32_t caps;
+
+ /* millivolts */
+ int mvin;
+ int mvout;
+
+ /* milliamps */
+ int miin;
+ int miout;
+
+ /* milliwatts */
+ int mpin;
+ int mpout;
+
+} onlp_psu_info_t;
+
+/**
+ * @brief Initialize the PSU subsystem.
+ */
+int onlp_psu_init(void);
+
+/**
+ * @brief Get the PSU information.
+ * @param id The PSU OID.
+ * @param rv [out] Receives the information structure.
+ */
+int onlp_psu_info_get(onlp_oid_t id, onlp_psu_info_t* rv);
+
+/**
+ * @brief Issue a PSU ioctl.
+ * @param id The PSU OID
+ * @param ... Ioctl arguments.
+ */
+int onlp_psu_ioctl(onlp_oid_t id, ...);
+
+/**
+ * @brief Issue a PSU ioctl.
+ * @param id The PSU OID
+ * @param vargs Ioctl arguments.
+ */
+int onlp_psu_vioctl(onlp_oid_t id, va_list vargs);
+
+/**
+ * @brief PSU OID debug dump
+ * @param id The PSU OID
+ * @param pvs The output pvs
+ * @param flags The output flags
+ */
+void onlp_psu_dump(onlp_oid_t id, aim_pvs_t* pvs, uint32_t flags);
+
+
+/**
+ * @brief Show the given PSU OID.
+ * @param id The PSU OID
+ * @param pvs The output pvs
+ * @param flags The output flags
+ */
+void onlp_psu_show(onlp_oid_t id, aim_pvs_t* pvs, uint32_t flags);
+
+/**
+ * Convenience macros for processing PSU status.
+ */
+#define ONLP_PSU_STATUS_PRESENT(_pi) ( (_pi).status & ONLP_PSU_STATUS_PRESENT )
+#define ONLP_PSU_STATUS_MISSING(_pi) (!ONLP_PSU_STATUS_PRESENT(_pi))
+#define ONLP_PSU_STATUS_FAILED(_pi) ( (_pi).status & ONLP_PSU_STATUS_FAILED)
+
+
+
+/******************************************************************************
+ *
+ * Enumeration Support Definitions.
+ *
+ * Please do not add additional code beyond this point.
+ *
+ *****************************************************************************/
+/* */
+/** Enum names. */
+const char* onlp_psu_caps_name(onlp_psu_caps_t e);
+
+/** Enum values. */
+int onlp_psu_caps_value(const char* str, onlp_psu_caps_t* e, int substr);
+
+/** Enum descriptions. */
+const char* onlp_psu_caps_desc(onlp_psu_caps_t e);
+
+/** Enum validator. */
+int onlp_psu_caps_valid(onlp_psu_caps_t e);
+
+/** validator */
+#define ONLP_PSU_CAPS_VALID(_e) \
+ (onlp_psu_caps_valid((_e)))
+
+/** onlp_psu_caps_map table. */
+extern aim_map_si_t onlp_psu_caps_map[];
+/** onlp_psu_caps_desc_map table. */
+extern aim_map_si_t onlp_psu_caps_desc_map[];
+
+/** Enum names. */
+const char* onlp_psu_status_name(onlp_psu_status_t e);
+
+/** Enum values. */
+int onlp_psu_status_value(const char* str, onlp_psu_status_t* e, int substr);
+
+/** Enum descriptions. */
+const char* onlp_psu_status_desc(onlp_psu_status_t e);
+
+/** Enum validator. */
+int onlp_psu_status_valid(onlp_psu_status_t e);
+
+/** validator */
+#define ONLP_PSU_STATUS_VALID(_e) \
+ (onlp_psu_status_valid((_e)))
+
+/** onlp_psu_status_map table. */
+extern aim_map_si_t onlp_psu_status_map[];
+/** onlp_psu_status_desc_map table. */
+extern aim_map_si_t onlp_psu_status_desc_map[];
+/* */
+
+#endif /* __ONLP_PSU_H__ */
diff --git a/packages/base/any/onlp/src/onlp/module/inc/onlp/sfp.h b/packages/base/any/onlp/src/onlp/module/inc/onlp/sfp.h
new file mode 100644
index 00000000..c623e089
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/inc/onlp/sfp.h
@@ -0,0 +1,256 @@
+/*************************************************************
+ *
+ *
+ * Copyright 2014, 2015 Big Switch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ *************************************************************
+ *
+ * SFP Management Interface.
+ *
+ ************************************************************/
+#ifndef __ONLP_SFP_H__
+#define __ONLP_SFP_H__
+
+#include
+#include
+#include
+#include
+#include
+
+/* */
+/** onlp_sfp_control */
+typedef enum onlp_sfp_control_e {
+ ONLP_SFP_CONTROL_RESET,
+ ONLP_SFP_CONTROL_RESET_STATE,
+ ONLP_SFP_CONTROL_RX_LOS,
+ ONLP_SFP_CONTROL_TX_FAULT,
+ ONLP_SFP_CONTROL_TX_DISABLE,
+ ONLP_SFP_CONTROL_LP_MODE,
+ ONLP_SFP_CONTROL_POWER_OVERRIDE,
+ ONLP_SFP_CONTROL_LAST = ONLP_SFP_CONTROL_POWER_OVERRIDE,
+ ONLP_SFP_CONTROL_COUNT,
+ ONLP_SFP_CONTROL_INVALID = -1,
+} onlp_sfp_control_t;
+/* */
+
+/* */
+/** onlp_sfp_control_flag */
+typedef enum onlp_sfp_control_flag_e {
+ ONLP_SFP_CONTROL_FLAG_RESET = (1 << ONLP_SFP_CONTROL_RESET),
+ ONLP_SFP_CONTROL_FLAG_RESET_STATE = ( 1 << ONLP_SFP_CONTROL_RESET_STATE ),
+ ONLP_SFP_CONTROL_FLAG_RX_LOS = ( 1 << ONLP_SFP_CONTROL_RX_LOS ),
+ ONLP_SFP_CONTROL_FLAG_TX_FAULT = ( 1 << ONLP_SFP_CONTROL_TX_FAULT ),
+ ONLP_SFP_CONTROL_FLAG_TX_DISABLE = ( 1 << ONLP_SFP_CONTROL_TX_DISABLE ),
+ ONLP_SFP_CONTROL_FLAG_LP_MODE = ( 1 << ONLP_SFP_CONTROL_LP_MODE ),
+ ONLP_SFP_CONTROL_FLAG_POWER_OVERRIDE = ( 1 << ONLP_SFP_CONTROL_POWER_OVERRIDE ),
+} onlp_sfp_control_flag_t;
+/* */
+
+/**
+ * Initialize the SFP subsystem.
+ */
+int onlp_sfp_init(void);
+
+/**
+ * Valid SFP Port bitmaps are communicated using this type.
+ */
+typedef aim_bitmap256_t onlp_sfp_bitmap_t;
+
+/**
+ * Convenience function for initializing SFP bitmaps.
+ * @param bmap The address of the bitmap to initialize.
+ */
+void onlp_sfp_bitmap_t_init(onlp_sfp_bitmap_t* bmap);
+
+/**
+ * @brief Get the set of valid {Q}SFP ports.
+ * @param bmap Returns the valid set of SFP-capable port numbers.
+ */
+int onlp_sfp_bitmap_get(onlp_sfp_bitmap_t* bmap);
+
+/**
+ * @brief Determine if a given port number is a valid SFP port.
+ * @param port The port number.
+ */
+int onlp_sfp_port_valid(int port);
+
+/**
+ * @brief Determine if an SFP is currently plugged in.
+ * @param port The SFP port number.
+ * @returns 1 if an SFP is present.
+ * @returns 0 if an SFP is not present.
+ * @returns <0 on error.
+ */
+int onlp_sfp_is_present(int port);
+
+/**
+ * @brief Return the presence bitmap for all ports.
+ * @param dst The receives the presence bitmap for all ports.
+ * @note This function can return Unsupported.
+ * It will not be emulated if the SFPI driver does not support
+ * batch collection of the SFP presence.
+ */
+int onlp_sfp_presence_bitmap_get(onlp_sfp_bitmap_t* dst);
+
+/**
+ * @brief Read IEEE standard EEPROM data from the given port.
+ * @param port The SFP Port
+ * @param rv Receives a buffer containing the EEPROM data.
+ * @notes The buffer must be freed after use.
+ * @returns The size of the eeprom data, if successful
+ * @returns -1 on error.
+ */
+int onlp_sfp_eeprom_read(int port, uint8_t** rv);
+
+
+/**
+ * @brief Read the DOM data from the given port.
+ * @param port The SFP Port
+ * @param rv Receives a buffer containing the DOM data.
+ * @notes The buffer must be freed after use.
+ * @returns The size of the eeprom data, if successful
+ * @returns -1 on error.
+ * @note This should only be called if the SFP
+ * has advertised DOM support.
+ */
+int onlp_sfp_dom_read(int port, uint8_t** rv);
+
+/**
+ * @brief Deinitialize the SFP subsystem.
+ */
+int onlp_sfp_denit(void);
+
+/**
+ * @brief Get the RX_LOS bitmap for all ports.
+ * @param dst Receives the RX_LOS bitmap for all ports.
+ * @note This function can return Unsupported.
+ * It will not be emulated if the SFPI driver does not support
+ * batch collection of the rx_los status.
+ */
+int onlp_sfp_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst);
+
+/**
+ * @brief Dump the status of all SFPs
+ * @param pvs The output pvs.
+ */
+void onlp_sfp_dump(aim_pvs_t* pvs);
+
+/**
+ * @brief Issue an ioctl to the SFP interface.
+ * @param port The port.
+ * @param ... Ioctl arguments.
+ */
+int onlp_sfp_ioctl(int port, ...);
+
+/**
+ * @brief Issue an ioctl to the SFP interface.
+ * @param port The port.
+ * @param vargs Ioctl arguments.
+ */
+int onlp_sfp_vioctl(int port, va_list vargs);
+
+/**
+ * @brief Call the SFP post-insertion handler.
+ *
+ */
+int onlp_sfp_post_insert(int port, sff_info_t* info);
+
+/**
+ * @brief Set an SFP control.
+ * @param port The port.
+ * @param control The control.
+ * @param value The value.
+ */
+int onlp_sfp_control_set(int port, onlp_sfp_control_t control, int value);
+
+/**
+ * @brief Get an SFP control.
+ * @param port The port.
+ * @param control The control
+ * @param [out] value Receives the current value.
+ */
+int onlp_sfp_control_get(int port, onlp_sfp_control_t control, int* value);
+
+/**
+ * @brief Get the value of all SFP controls.
+ * @param port The port.
+ * @param flags Receives the control flag values. See onlp_sfp_control_flags_t
+ */
+int onlp_sfp_control_flags_get(int port, uint32_t* flags);
+
+/******************************************************************************
+ *
+ * Enumeration Support Definitions.
+ *
+ * Please do not add additional code beyond this point.
+ *
+ *****************************************************************************/
+/* */
+/** Strings macro. */
+#define ONLP_SFP_CONTROL_STRINGS \
+{\
+ "RESET", \
+ "RESET_STATE", \
+ "RX_LOS", \
+ "TX_FAULT", \
+ "TX_DISABLE", \
+ "LP_MODE", \
+ "POWER_OVERRIDE", \
+}
+/** Enum names. */
+const char* onlp_sfp_control_name(onlp_sfp_control_t e);
+
+/** Enum values. */
+int onlp_sfp_control_value(const char* str, onlp_sfp_control_t* e, int substr);
+
+/** Enum descriptions. */
+const char* onlp_sfp_control_desc(onlp_sfp_control_t e);
+
+/** validator */
+#define ONLP_SFP_CONTROL_VALID(_e) \
+ ( (0 <= (_e)) && ((_e) <= ONLP_SFP_CONTROL_POWER_OVERRIDE))
+
+/** onlp_sfp_control_map table. */
+extern aim_map_si_t onlp_sfp_control_map[];
+/** onlp_sfp_control_desc_map table. */
+extern aim_map_si_t onlp_sfp_control_desc_map[];
+/* */
+
+/* */
+/** Enum names. */
+const char* onlp_sfp_control_flag_name(onlp_sfp_control_flag_t e);
+
+/** Enum values. */
+int onlp_sfp_control_flag_value(const char* str, onlp_sfp_control_flag_t* e, int substr);
+
+/** Enum descriptions. */
+const char* onlp_sfp_control_flag_desc(onlp_sfp_control_flag_t e);
+
+/** Enum validator. */
+int onlp_sfp_control_flag_valid(onlp_sfp_control_flag_t e);
+
+/** validator */
+#define ONLP_SFP_CONTROL_FLAG_VALID(_e) \
+ (onlp_sfp_control_flag_valid((_e)))
+
+/** onlp_sfp_control_flag_map table. */
+extern aim_map_si_t onlp_sfp_control_flag_map[];
+/** onlp_sfp_control_flag_desc_map table. */
+extern aim_map_si_t onlp_sfp_control_flag_desc_map[];
+/* */
+
+#endif /* __ONLP_SFP_H__ */
diff --git a/packages/base/any/onlp/src/onlp/module/inc/onlp/sys.h b/packages/base/any/onlp/src/onlp/module/inc/onlp/sys.h
new file mode 100644
index 00000000..1d9029ee
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/inc/onlp/sys.h
@@ -0,0 +1,115 @@
+/************************************************************
+ *
+ *
+ * Copyright 2014, 2015 Big Switch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ ************************************************************
+ *
+ * Platform System Information
+ *
+ ***********************************************************/
+
+#ifndef __ONLP_SYS_H__
+#define __ONLP_SYS_H__
+
+#include
+#include
+#include
+#include
+#include
+
+
+typedef struct onlp_sys_info_s {
+ /** OID Header */
+ onlp_oid_hdr_t hdr;
+
+ /* ONIE System Information */
+ onlp_onie_info_t onie_info;
+
+ /* Platform Information */
+ onlp_platform_info_t platform_info;
+
+} onlp_sys_info_t;
+
+
+/**
+ * @brief Initialize the System API
+ */
+int onlp_sys_init(void);
+
+/**
+ * @brief Get the system information structure.
+ * @param rv [out] Receives the system information.
+ */
+int onlp_sys_info_get(onlp_sys_info_t* rv);
+
+/**
+ * @brief Free a system information structure.
+ */
+void onlp_sys_info_free(onlp_sys_info_t* info);
+
+/**
+ * @brief SYS OID debug dump.
+ * @param id The SYS OID.
+ * @param pvs The output pvs.
+ * @param flags The output flags.
+ * @note This output is designed for debugging.
+ */
+void onlp_sys_dump(onlp_oid_t id, aim_pvs_t* pvs, uint32_t flags);
+
+/**
+ * @brief Show the status of the given OID.
+ * @param id the SYS OID.
+ * @param pvs The output pvs.
+ * @param flags The output flags
+ */
+void onlp_sys_show(onlp_oid_t id, aim_pvs_t* pvs, uint32_t flags);
+
+/**
+ * @brief SYS Ioctl
+ * @param code The ioctl code.
+ * @param ... Arguments
+ */
+int onlp_sys_ioctl(int code, ...);
+
+/**
+ * @brief SYS Ioctl
+ * @param code The ioctl code.
+ * @param vargs arguments.
+ */
+int onlp_sys_vioctl(int code, va_list vargs);
+
+/**
+ * @brief Start the platform management thread.
+ */
+int onlp_sys_platform_manage_start(void);
+
+/**
+ * @brief Stop the platform management thread.
+ */
+int onlp_sys_platform_manage_stop(void);
+
+/**
+ * @brief Perform any pending platform management activities.
+ * @note A call to this function will perform any pending
+ * platform management activities. It is not intended to block
+ * for an extended period of time.
+ */
+
+void onlp_sys_platform_manage_now(void);
+
+#endif /* __ONLP_SYS_H_ */
diff --git a/packages/base/any/onlp/src/onlp/module/inc/onlp/thermal.h b/packages/base/any/onlp/src/onlp/module/inc/onlp/thermal.h
new file mode 100644
index 00000000..66dbf3fb
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/inc/onlp/thermal.h
@@ -0,0 +1,188 @@
+/************************************************************
+ *
+ *
+ * Copyright 2014, 2015 Big Switch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ ************************************************************
+ *
+ * Thermal Sensor Management.
+ *
+ ************************************************************/
+#ifndef __ONLP_THERMAL_H__
+#define __ONLP_THERMAL_H__
+
+#include
+#include
+#include
+
+/* */
+/** onlp_thermal_status */
+typedef enum onlp_thermal_status_e {
+ ONLP_THERMAL_STATUS_PRESENT = (1 << 0),
+ ONLP_THERMAL_STATUS_FAILED = (1 << 1),
+} onlp_thermal_status_t;
+
+/** onlp_thermal_caps */
+typedef enum onlp_thermal_caps_e {
+ ONLP_THERMAL_CAPS_GET_TEMPERATURE = (1 << 0),
+ ONLP_THERMAL_CAPS_GET_WARNING_THRESHOLD = (1 << 1),
+ ONLP_THERMAL_CAPS_GET_ERROR_THRESHOLD = (1 << 2),
+ ONLP_THERMAL_CAPS_GET_SHUTDOWN_THRESHOLD = (1 << 3),
+} onlp_thermal_caps_t;
+/* */
+
+/**
+ * Shortcut for specifying all capabilties.
+ */
+#define ONLP_THERMAL_CAPS_ALL 0xF
+
+/**
+ * Shortcut for determining the availability of any threshold value.
+ */
+#define ONLP_THERMAL_CAPS_GET_ANY_THRESHOLD \
+ ( ONLP_THERMAL_CAPS_GET_WARNING_THRESHOLD | \
+ ONLP_THERMAL_CAPS_GET_ERROR_THRESHOLD | \
+ ONLP_THERMAL_CAPS_GET_SHUTDOWN_THRESHOLD )
+
+/**
+ * Thermal sensor information structure.
+ */
+typedef struct onlp_thermal_info_s {
+
+ /** OID Header */
+ onlp_oid_hdr_t hdr;
+
+ /** Status */
+ uint32_t status;
+
+ /** Capabilities */
+ uint32_t caps;
+
+ /* Current temperature in milli-celsius */
+ int mcelsius;
+
+ struct {
+ /* Warning temperature threshold in milli-celsius */
+ int warning;
+
+ /* Error temperature threshold in milli-celsius */
+ int error;
+
+ /* System shutdown temperature threshold in milli-celsius */
+ int shutdown;
+ } thresholds;
+
+} onlp_thermal_info_t;
+
+/**
+ * @brief Initialize the thermal subsystem.
+ */
+int onlp_thermal_init(void);
+
+/**
+ * @brief Retrieve information about the given thermal id.
+ * @param id The thermal oid.
+ * @param rv [out] Receives the thermal information.
+ */
+int onlp_thermal_info_get(onlp_oid_t id, onlp_thermal_info_t* rv);
+
+
+/**
+ * @brief Thermal driver ioctl.
+ * @param code Thermal ioctl code.
+ * @param ... Arguments
+ */
+int onlp_thermal_ioctl(int code, ...);
+
+/**
+ * @brief Thermal driver ioctl.
+ * @param code The thermal ioctl code.
+ * @param vargs The arguments.
+ */
+int onlp_thermal_vioctl(int code, va_list vargs);
+
+/**
+ * @brief Thermal OID debug dump.
+ * @param id The thermal id.
+ * @param pvs The output pvs.
+ * @param flags The dump flags.
+ */
+void onlp_thermal_dump(onlp_oid_t id, aim_pvs_t* pvs, uint32_t flags);
+
+/**
+ * @brief Show the given thermal OID.
+ * @param id The Thermal OID
+ * @param pvs The output pvs
+ * @param flags The output flags
+ */
+void onlp_thermal_show(onlp_oid_t id, aim_pvs_t* pvs, uint32_t flags);
+
+
+
+
+/******************************************************************************
+ *
+ * Enumeration Support Definitions.
+ *
+ * Please do not add additional code beyond this point.
+ *
+ *****************************************************************************/
+/* */
+/** Enum names. */
+const char* onlp_thermal_status_name(onlp_thermal_status_t e);
+
+/** Enum values. */
+int onlp_thermal_status_value(const char* str, onlp_thermal_status_t* e, int substr);
+
+/** Enum descriptions. */
+const char* onlp_thermal_status_desc(onlp_thermal_status_t e);
+
+/** Enum validator. */
+int onlp_thermal_status_valid(onlp_thermal_status_t e);
+
+/** validator */
+#define ONLP_THERMAL_STATUS_VALID(_e) \
+ (onlp_thermal_status_valid((_e)))
+
+/** onlp_thermal_status_map table. */
+extern aim_map_si_t onlp_thermal_status_map[];
+/** onlp_thermal_status_desc_map table. */
+extern aim_map_si_t onlp_thermal_status_desc_map[];
+
+/** Enum names. */
+const char* onlp_thermal_caps_name(onlp_thermal_caps_t e);
+
+/** Enum values. */
+int onlp_thermal_caps_value(const char* str, onlp_thermal_caps_t* e, int substr);
+
+/** Enum descriptions. */
+const char* onlp_thermal_caps_desc(onlp_thermal_caps_t e);
+
+/** Enum validator. */
+int onlp_thermal_caps_valid(onlp_thermal_caps_t e);
+
+/** validator */
+#define ONLP_THERMAL_CAPS_VALID(_e) \
+ (onlp_thermal_caps_valid((_e)))
+
+/** onlp_thermal_caps_map table. */
+extern aim_map_si_t onlp_thermal_caps_map[];
+/** onlp_thermal_caps_desc_map table. */
+extern aim_map_si_t onlp_thermal_caps_desc_map[];
+/* */
+
+#endif /* __ONLP_THERMAL_H__ */
diff --git a/packages/base/any/onlp/src/onlp/module/make.mk b/packages/base/any/onlp/src/onlp/module/make.mk
new file mode 100644
index 00000000..fde52d64
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/make.mk
@@ -0,0 +1,30 @@
+############################################################
+#
+#
+# Copyright 2014, 2015 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+#
+#
+############################################################
+
+THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
+onlp_INCLUDES := -I $(THIS_DIR)inc
+onlp_INTERNAL_INCLUDES := -I $(THIS_DIR)src
+onlp_DEPENDMODULE_ENTRIES := init:onlp ucli:onlp
+
diff --git a/packages/base/any/onlp/src/onlp/module/src/Makefile b/packages/base/any/onlp/src/onlp/module/src/Makefile
new file mode 100644
index 00000000..3033edf5
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/src/Makefile
@@ -0,0 +1,30 @@
+############################################################
+#
+#
+# Copyright 2014, 2015 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+# Local source generation targets.
+#
+############################################################
+include ../../../../init.mk
+
+ucli:
+ $(SUBMODULE_BIGCODE)/tools/uclihandlers.py onlp_ucli.c
+
+
diff --git a/packages/base/any/onlp/src/onlp/module/src/fan.c b/packages/base/any/onlp/src/onlp/module/src/fan.c
new file mode 100644
index 00000000..b28de2d8
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/src/fan.c
@@ -0,0 +1,293 @@
+/************************************************************
+ *
+ *
+ * Copyright 2014, 2015 Big Switch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ ************************************************************
+ *
+ * Fan Management.
+ *
+ ***********************************************************/
+#include
+#include
+#include
+#include "onlp_int.h"
+#include "onlp_locks.h"
+#include "onlp_log.h"
+#include "onlp_json.h"
+
+#define VALIDATE(_id) \
+ do { \
+ if(!ONLP_OID_IS_FAN(_id)) { \
+ return ONLP_STATUS_E_INVALID; \
+ } \
+ } while(0)
+
+#define VALIDATENR(_id) \
+ do { \
+ if(!ONLP_OID_IS_FAN(_id)) { \
+ return; \
+ } \
+ } while(0)
+
+
+static int
+onlp_fan_init_locked__(void)
+{
+ return onlp_fani_init();
+}
+ONLP_LOCKED_API0(onlp_fan_init)
+
+
+#if ONLP_CONFIG_INCLUDE_PLATFORM_OVERRIDES == 1
+
+static int
+onlp_fani_info_from_json__(cJSON* data, onlp_fan_info_t* fip, int errorcheck)
+{
+ int rv;
+
+ if(data == NULL) {
+ return (errorcheck) ? ONLP_STATUS_E_PARAM : 0;
+ }
+
+ rv = cjson_util_lookup_int(data, (int*) &fip->status, "status");
+ if(rv < 0 && errorcheck) return rv;
+
+ rv = cjson_util_lookup_int(data, (int*) &fip->caps, "caps");
+ if(rv < 0 && errorcheck) return rv;
+
+ rv = cjson_util_lookup_int(data, (int*) &fip->rpm, "rpm");
+ if(rv < 0 && errorcheck) return rv;
+
+ rv = cjson_util_lookup_int(data, (int*) &fip->percentage, "percentage");
+ if(rv < 0 && errorcheck) return rv;
+
+ rv = cjson_util_lookup_int(data, (int*) &fip->mode, "mode");
+ if(rv < 0 && errorcheck) return rv;
+
+ return 0;
+}
+
+#endif
+
+static int
+onlp_fan_info_get_locked__(onlp_oid_t oid, onlp_fan_info_t* fip)
+{
+ int rv;
+
+ VALIDATE(oid);
+
+ /* Get the information struct from the platform */
+ rv = onlp_fani_info_get(oid, fip);
+
+ if(rv >= 0) {
+
+#if ONLP_CONFIG_INCLUDE_PLATFORM_OVERRIDES == 1
+ /*
+ * Optional override from the config file.
+ * This is usually just for testing.
+ */
+ int id = ONLP_OID_ID_GET(oid);
+ cJSON* entry = NULL;
+
+
+ cjson_util_lookup(onlp_json_get(0), &entry, "overrides.fan.%d", id);
+ onlp_fani_info_from_json__(entry, fip, 0);
+#endif
+
+ if(fip->percentage && fip->rpm == 0) {
+ /* Approximate RPM based on a 10,000 RPM Maximum */
+ fip->rpm = fip->percentage * 100;
+ }
+ }
+
+ return rv;
+}
+ONLP_LOCKED_API2(onlp_fan_info_get, onlp_oid_t, oid, onlp_fan_info_t*, fip);
+
+
+static int
+onlp_fan_present__(onlp_oid_t id, onlp_fan_info_t* info)
+{
+ int rv;
+ VALIDATE(id);
+
+ /* Info retrieval required. */
+ rv = onlp_fani_info_get(id, info);
+ if(rv < 0) {
+ return rv;
+ }
+ /* The fan must be present. */
+ if((info->status & 0x1) == 0) {
+ return ONLP_STATUS_E_MISSING;
+ }
+ return ONLP_STATUS_OK;
+}
+#define ONLP_FAN_PRESENT_OR_RETURN(_id, _info) \
+ do { \
+ int _rv = onlp_fan_present__(_id, _info); \
+ if(_rv < 0) { \
+ return _rv; \
+ } \
+ } while(0)
+
+
+static int
+onlp_fan_rpm_set_locked__(onlp_oid_t id, int rpm)
+{
+ onlp_fan_info_t info;
+ ONLP_FAN_PRESENT_OR_RETURN(id, &info);
+ if(info.caps & ONLP_FAN_CAPS_SET_RPM) {
+ return onlp_fani_rpm_set(id, rpm);
+ }
+ else {
+ return ONLP_STATUS_E_UNSUPPORTED;
+ }
+}
+ONLP_LOCKED_API2(onlp_fan_rpm_set, onlp_oid_t, id, int, rpm);
+
+static int
+onlp_fan_percentage_set_locked__(onlp_oid_t id, int p)
+{
+ onlp_fan_info_t info;
+ ONLP_FAN_PRESENT_OR_RETURN(id, &info);
+ if(info.caps & ONLP_FAN_CAPS_SET_PERCENTAGE) {
+ return onlp_fani_percentage_set(id, p);
+ }
+ else {
+ return ONLP_STATUS_E_UNSUPPORTED;
+ }
+}
+ONLP_LOCKED_API2(onlp_fan_percentage_set, onlp_oid_t, id, int, p);
+
+static int
+onlp_fan_mode_set_locked__(onlp_oid_t id, onlp_fan_mode_t mode)
+{
+ onlp_fan_info_t info;
+ ONLP_FAN_PRESENT_OR_RETURN(id, &info);
+ return onlp_fani_mode_set(id, mode);
+}
+ONLP_LOCKED_API2(onlp_fan_mode_set, onlp_oid_t, id, onlp_fan_mode_t, mode);
+
+static int
+onlp_fan_dir_set_locked__(onlp_oid_t id, onlp_fan_dir_t dir)
+{
+ onlp_fan_info_t info;
+ ONLP_FAN_PRESENT_OR_RETURN(id, &info);
+ if( (info.caps & ONLP_FAN_CAPS_B2F) &&
+ (info.caps & ONLP_FAN_CAPS_F2B) ) {
+ return onlp_fani_dir_set(id, dir);
+ }
+ else {
+ return ONLP_STATUS_E_UNSUPPORTED;
+ }
+}
+ONLP_LOCKED_API2(onlp_fan_dir_set, onlp_oid_t, id, onlp_fan_dir_t, dir);
+
+
+/************************************************************
+ *
+ * Debug and Show Functions
+ *
+ ***********************************************************/
+
+void
+onlp_fan_dump(onlp_oid_t id, aim_pvs_t* pvs, uint32_t flags)
+{
+ int rv;
+ iof_t iof;
+ onlp_fan_info_t info;
+
+ VALIDATENR(id);
+
+ onlp_oid_dump_iof_init_default(&iof, pvs);
+ iof_push(&iof, "fan @ %d", ONLP_OID_ID_GET(id));
+ rv = onlp_fan_info_get(id, &info);
+ if(rv < 0) {
+ onlp_oid_info_get_error(&iof, rv);
+ }
+ else {
+ onlp_oid_show_description(&iof, &info.hdr);
+ if(info.status & 1) {
+ /* Present */
+ iof_iprintf(&iof, "Status: %{onlp_fan_status_flags}", info.status);
+ iof_iprintf(&iof, "Caps: %{onlp_fan_caps_flags}", info.caps);
+ iof_iprintf(&iof, "RPM: %d", info.rpm);
+ iof_iprintf(&iof, "Per: %d", info.percentage);
+ iof_iprintf(&iof, "Model: %s", info.model[0] ? info.model : "NULL");
+ iof_iprintf(&iof, "SN: %s", info.serial[0] ? info.serial : "NULL");
+ }
+ else {
+ iof_iprintf(&iof, "Not present.");
+ }
+ }
+ iof_pop(&iof);
+}
+
+void
+onlp_fan_show(onlp_oid_t oid, aim_pvs_t* pvs, uint32_t flags)
+{
+ int rv;
+ iof_t iof;
+ onlp_fan_info_t fi;
+
+ onlp_oid_show_iof_init_default(&iof, pvs, flags);
+
+ rv = onlp_fan_info_get(oid, &fi);
+
+ iof_push(&iof, "Fan %d", ONLP_OID_ID_GET(oid));
+ if(rv < 0) {
+ onlp_oid_info_get_error(&iof, rv);
+ }
+ else {
+ onlp_oid_show_description(&iof, &fi.hdr);
+ if(fi.status & 0x1) {
+ /* Present */
+ iof_iprintf(&iof, "State: Present");
+ if(fi.status & ONLP_FAN_STATUS_FAILED) {
+ iof_iprintf(&iof, "Status: FAILED");
+ }
+ else {
+ iof_iprintf(&iof, "Status: Running.");
+ if(fi.model[0]) {
+ iof_iprintf(&iof, "Model: %s", fi.model);
+ }
+ if(fi.serial[0]) {
+ iof_iprintf(&iof, "SN: %s", fi.serial);
+ }
+ if(fi.caps & ONLP_FAN_CAPS_GET_RPM) {
+ iof_iprintf(&iof, "RPM: %d.", fi.rpm);
+ }
+ if(fi.caps & ONLP_FAN_CAPS_GET_PERCENTAGE) {
+ iof_iprintf(&iof, "Speed: %d%%.", fi.percentage);
+ }
+ if(fi.status & ONLP_FAN_STATUS_B2F) {
+ iof_iprintf(&iof, "Airflow: Back-to-Front.");
+ }
+ if(fi.status & ONLP_FAN_STATUS_F2B) {
+ iof_iprintf(&iof, "Airflow: Front-to-Back.");
+ }
+ }
+ }
+ else {
+ /* Not present */
+ onlp_oid_show_state_missing(&iof);
+ }
+ }
+ iof_pop(&iof);
+}
+
diff --git a/packages/base/any/onlp/src/onlp/module/src/led.c b/packages/base/any/onlp/src/onlp/module/src/led.c
new file mode 100644
index 00000000..051cc223
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/src/led.c
@@ -0,0 +1,182 @@
+/************************************************************
+ *
+ *
+ * Copyright 2014, 2015 Big Switch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ ************************************************************
+ *
+ * LED Management
+ *
+ ***********************************************************/
+#include
+#include
+#include
+#include
+#include "onlp_int.h"
+#include "onlp_locks.h"
+
+#define VALIDATE(_id) \
+ do { \
+ if(!ONLP_OID_IS_LED(_id)) { \
+ return ONLP_STATUS_E_INVALID; \
+ } \
+ } while(0)
+
+#define VALIDATENR(_id) \
+ do { \
+ if(!ONLP_OID_IS_LED(_id)) { \
+ return; \
+ } \
+ } while(0)
+
+
+static int
+onlp_led_present__(onlp_oid_t id, onlp_led_info_t* info)
+{
+ int rv;
+ VALIDATE(id);
+
+ /* Info retrieval required. */
+ rv = onlp_ledi_info_get(id, info);
+ if(rv < 0) {
+ return rv;
+ }
+ /* The led must be present. */
+ if((info->status & 0x1) == 0) {
+ return ONLP_STATUS_E_MISSING;
+ }
+ return ONLP_STATUS_OK;
+}
+#define ONLP_LED_PRESENT_OR_RETURN(_id, _info) \
+ do { \
+ int _rv = onlp_led_present__(_id, _info); \
+ if(_rv < 0) { \
+ return _rv; \
+ } \
+ } while(0)
+
+static int
+onlp_led_init_locked__(void)
+{
+ return onlp_ledi_init();
+}
+ONLP_LOCKED_API0(onlp_led_init);
+
+static int
+onlp_led_info_get_locked__(onlp_oid_t id, onlp_led_info_t* info)
+{
+ VALIDATE(id);
+ return onlp_ledi_info_get(id, info);
+}
+ONLP_LOCKED_API2(onlp_led_info_get, onlp_oid_t, id, onlp_led_info_t*, info);
+
+static int
+onlp_led_set_locked__(onlp_oid_t id, int on_or_off)
+{
+ onlp_led_info_t info;
+ ONLP_LED_PRESENT_OR_RETURN(id, &info);
+ if(info.caps & ONLP_LED_CAPS_ON_OFF) {
+ return onlp_ledi_set(id, on_or_off);
+ }
+ else {
+ return ONLP_STATUS_E_UNSUPPORTED;
+ }
+}
+ONLP_LOCKED_API2(onlp_led_set, onlp_oid_t, id, int, on_or_off);
+
+static int
+onlp_led_mode_set_locked__(onlp_oid_t id, onlp_led_mode_t mode)
+{
+ onlp_led_info_t info;
+ ONLP_LED_PRESENT_OR_RETURN(id, &info);
+
+ /*
+ * The mode enumeration values always match
+ * the capability bit positions.
+ */
+ if(info.caps & (1 << mode)) {
+ return onlp_ledi_mode_set(id, mode);
+ }
+ else {
+ return ONLP_STATUS_E_UNSUPPORTED;
+ }
+}
+ONLP_LOCKED_API2(onlp_led_mode_set, onlp_oid_t, id, onlp_led_mode_t, mode);
+
+/************************************************************
+ *
+ * Debug and Show Functions
+ *
+ ***********************************************************/
+
+void
+onlp_led_dump(onlp_oid_t id, aim_pvs_t* pvs, uint32_t flags)
+{
+ int rv;
+ iof_t iof;
+ onlp_led_info_t info;
+
+ VALIDATENR(id);
+ onlp_oid_dump_iof_init_default(&iof, pvs);
+ iof_push(&iof, "led @ %d", ONLP_OID_ID_GET(id));
+ rv = onlp_led_info_get(id, &info);
+ if(rv < 0) {
+ onlp_oid_info_get_error(&iof, rv);
+ }
+ else {
+ onlp_oid_show_description(&iof, &info.hdr);
+ if(info.status & 1) {
+ /* Present */
+ iof_iprintf(&iof, "Status: %{onlp_led_status_flags}", info.status);
+ iof_iprintf(&iof, "Caps: %{onlp_led_caps_flags}", info.caps);
+ iof_iprintf(&iof, "Mode: %{onlp_led_mode}", info.mode);
+ }
+ else {
+ iof_iprintf(&iof, "Not present.");
+ }
+ }
+ iof_pop(&iof);
+}
+
+void
+onlp_led_show(onlp_oid_t id, aim_pvs_t* pvs, uint32_t flags)
+{
+ int rv;
+ iof_t iof;
+ onlp_led_info_t info;
+
+ VALIDATENR(id);
+ onlp_oid_show_iof_init_default(&iof, pvs, flags);
+ iof_push(&iof, "LED %d", ONLP_OID_ID_GET(id));
+ rv = onlp_led_info_get(id, &info);
+ if(rv < 0) {
+ onlp_oid_info_get_error(&iof, rv);
+ }
+ else {
+ onlp_oid_show_description(&iof, &info.hdr);
+ if(info.status & 1) {
+ /* Present */
+ iof_iprintf(&iof, "Mode: %{onlp_led_mode}", info.mode);
+ }
+ else {
+ onlp_oid_show_state_missing(&iof);
+ }
+ }
+ iof_pop(&iof);
+
+}
+
diff --git a/packages/base/any/onlp/src/onlp/module/src/make.mk b/packages/base/any/onlp/src/onlp/module/src/make.mk
new file mode 100644
index 00000000..9029307d
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/src/make.mk
@@ -0,0 +1,27 @@
+############################################################
+#
+#
+# Copyright 2014, 2015 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific
+# language governing permissions and limitations under the
+# License.
+#
+#
+############################################################
+#
+#
+#
+############################################################
+LIBRARY := onlp
+$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST)))
+include $(BUILDER)/lib.mk
diff --git a/packages/base/any/onlp/src/onlp/module/src/oids.c b/packages/base/any/onlp/src/onlp/module/src/oids.c
new file mode 100644
index 00000000..f2f495f1
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/src/oids.c
@@ -0,0 +1,251 @@
+/************************************************************
+ *
+ *
+ * Copyright 2014, 2015 Big Switch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ ************************************************************
+ *
+ *
+ *
+ ***********************************************************/
+#include
+#include
+#include "onlp_log.h"
+#include "onlp_int.h"
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+#define OID_TYPE_SHOWDUMP_DEFINE(_TYPE, _type) \
+ static void \
+ oid_type_##_TYPE##_dump__(onlp_oid_t oid, aim_pvs_t* pvs, uint32_t flags) \
+ { \
+ onlp_##_type##_dump(oid, pvs, flags); \
+ } \
+ static void \
+ oid_type_##_TYPE##_show__(onlp_oid_t oid, aim_pvs_t* pvs, uint32_t flags) \
+ { \
+ onlp_##_type##_show(oid, pvs, flags); \
+ }
+
+#define OID_TYPE_SHOWDUMP_DEFINE_EMPTY(_TYPE, _type) \
+ static void \
+ oid_type_##_TYPE##_dump__(onlp_oid_t oid, aim_pvs_t* pvs, uint32_t flags) \
+ { \
+ } \
+ static void \
+ oid_type_##_TYPE##_show__(onlp_oid_t oid, aim_pvs_t* pvs, uint32_t flags) \
+ { \
+ }
+
+
+OID_TYPE_SHOWDUMP_DEFINE(SYS, sys);
+OID_TYPE_SHOWDUMP_DEFINE(THERMAL, thermal);
+OID_TYPE_SHOWDUMP_DEFINE(FAN, fan);
+OID_TYPE_SHOWDUMP_DEFINE(PSU, psu);
+OID_TYPE_SHOWDUMP_DEFINE(LED, led);
+OID_TYPE_SHOWDUMP_DEFINE_EMPTY(MODULE, module);
+OID_TYPE_SHOWDUMP_DEFINE_EMPTY(RTC, rtc);
+
+static void
+oid_type_unknown_dump__(onlp_oid_t oid, aim_pvs_t* pvs, uint32_t flags)
+{
+ iof_t iof;
+ onlp_oid_dump_iof_init_default(&iof, pvs);
+ iof_push(&iof, "invalid oid @ 0x%x", oid);
+ iof_iprintf(&iof, "type = %d", ONLP_OID_TYPE_GET(oid));
+ iof_iprintf(&iof, " id = %d", ONLP_OID_ID_GET(oid));
+ iof_pop(&iof);
+}
+
+static int
+oid_type_SYS_hdr_get__(onlp_oid_t oid, onlp_oid_hdr_t* hdr)
+{
+ int rv;
+ onlp_sys_info_t si;
+ rv = onlp_sys_info_get(&si);
+ memcpy(hdr, &si.hdr, sizeof(si.hdr));
+ return rv;
+}
+
+static int
+oid_type_THERMAL_hdr_get__(onlp_oid_t oid, onlp_oid_hdr_t* hdr)
+{
+ int rv;
+ onlp_thermal_info_t ti;
+ rv = onlp_thermal_info_get(oid, &ti);
+ memcpy(hdr, &ti.hdr, sizeof(ti.hdr));
+ return rv;
+}
+
+static int
+oid_type_FAN_hdr_get__(onlp_oid_t oid, onlp_oid_hdr_t* hdr)
+{
+ int rv;
+ onlp_fan_info_t fi;
+ rv = onlp_fan_info_get(oid, &fi);
+ memcpy(hdr, &fi.hdr, sizeof(fi.hdr));
+ return rv;
+}
+
+static int
+oid_type_LED_hdr_get__(onlp_oid_t oid, onlp_oid_hdr_t* hdr)
+{
+ int rv;
+ onlp_led_info_t li;
+ rv = onlp_led_info_get(oid, &li);
+ memcpy(hdr, &li.hdr, sizeof(li.hdr));
+ return rv;
+}
+
+static int
+oid_type_PSU_hdr_get__(onlp_oid_t oid, onlp_oid_hdr_t* hdr)
+{
+ int rv;
+ onlp_psu_info_t pi;
+ rv = onlp_psu_info_get(oid, &pi);
+ memcpy(hdr, &pi.hdr, sizeof(pi.hdr));
+ return rv;
+}
+
+static int
+oid_type_RTC_hdr_get__(onlp_oid_t oid, onlp_oid_hdr_t* hdr)
+{
+ /* Not implemented yet */
+ AIM_LOG_MSG("RTC_coids_get: 0x%x", oid);
+ return ONLP_STATUS_E_INVALID;
+}
+
+
+static int
+oid_type_MODULE_hdr_get__(onlp_oid_t oid, onlp_oid_hdr_t* hdr)
+{
+ /* Not implemented yet */
+ AIM_LOG_MSG("MODULE_coids_get: 0x%x", oid);
+ return ONLP_STATUS_E_INVALID;
+}
+
+static void
+onlp_oid_showdump__(onlp_oid_t oid,
+ /* show=1, dump=0 */
+ int show,
+ aim_pvs_t* pvs,
+ uint32_t flags)
+{
+ if(oid == 0) {
+ oid = ONLP_OID_SYS;
+ }
+
+ switch(ONLP_OID_TYPE_GET(oid)) {
+ /* {dump || show} */
+#define ONLP_OID_TYPE_ENTRY(_name, _value) \
+ case ONLP_OID_TYPE_##_name: \
+ if(show) { \
+ oid_type_##_name##_show__(oid, pvs, flags); \
+ } \
+ else { \
+ oid_type_##_name##_dump__(oid, pvs, flags); \
+ } \
+ return;
+
+#include
+
+ /* Intentional compile time error if an OID decode is missing. */
+ }
+ oid_type_unknown_dump__(oid, pvs, flags);
+}
+
+void
+onlp_oid_dump(onlp_oid_t oid, aim_pvs_t* pvs, uint32_t flags)
+{
+ onlp_oid_showdump__(oid, 0, pvs, flags);
+}
+
+void
+onlp_oid_table_dump(onlp_oid_table_t table, aim_pvs_t* pvs, uint32_t flags)
+{
+ onlp_oid_t* oidp;
+ ONLP_OID_TABLE_ITER(table, oidp) {
+ onlp_oid_dump(*oidp, pvs, flags);
+ }
+}
+
+void
+onlp_oid_show(onlp_oid_t oid, aim_pvs_t* pvs, uint32_t flags)
+{
+ onlp_oid_showdump__(oid, 1, pvs, flags);
+}
+
+void
+onlp_oid_table_show(onlp_oid_table_t table, aim_pvs_t* pvs, uint32_t flags)
+{
+ onlp_oid_t* oidp;
+ ONLP_OID_TABLE_ITER(table, oidp) {
+ onlp_oid_show(*oidp, pvs, flags);
+ }
+}
+
+int
+onlp_oid_hdr_get(onlp_oid_t oid, onlp_oid_hdr_t* hdr)
+{
+ switch(ONLP_OID_TYPE_GET(oid))
+ {
+#define ONLP_OID_TYPE_ENTRY(_name, _value) \
+ case ONLP_OID_TYPE_##_name: \
+ return oid_type_##_name##_hdr_get__(oid, hdr);
+#include
+ /* Intentional compile time error if an OID handler is missing. */
+ }
+ return ONLP_STATUS_E_INVALID;
+}
+
+int
+onlp_oid_iterate(onlp_oid_t oid, onlp_oid_type_t type,
+ onlp_oid_iterate_f itf, void* cookie)
+{
+ int rv;
+ onlp_oid_hdr_t hdr;
+ onlp_oid_t* oidp;
+
+ if(oid == 0) {
+ oid = ONLP_OID_SYS;
+ }
+
+ rv = onlp_oid_hdr_get(oid, &hdr);
+ if(rv < 0) {
+ return rv;
+ }
+
+ ONLP_OID_TABLE_ITER(hdr.coids, oidp) {
+ if(type == 0 || ONLP_OID_IS_TYPE(*oidp, type)) {
+ int rv = itf(*oidp, cookie);
+ if(rv < 0) {
+ return rv;
+ }
+ rv = onlp_oid_iterate(*oidp, type, itf, cookie);
+ if(rv < 0) {
+ return rv;
+ }
+ }
+ }
+ return ONLP_STATUS_OK;
+}
diff --git a/packages/base/any/onlp/src/onlp/module/src/onlp.c b/packages/base/any/onlp/src/onlp/module/src/onlp.c
new file mode 100644
index 00000000..31d9999e
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/src/onlp.c
@@ -0,0 +1,64 @@
+/************************************************************
+ *
+ *
+ * Copyright 2014, 2015 Big Switch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ ************************************************************
+ *
+ *
+ *
+ ***********************************************************/
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "onlp_int.h"
+#include "onlp_json.h"
+#include "onlp_locks.h"
+
+int
+onlp_init(void)
+{
+ extern void __onlp_module_init__(void);
+ __onlp_module_init__();
+
+ char* cfile;
+
+ if( (cfile=getenv(ONLP_CONFIG_CONFIGURATION_ENV)) == NULL) {
+ cfile = ONLP_CONFIG_CONFIGURATION_FILENAME;
+ }
+
+#if ONLP_CONFIG_INCLUDE_API_LOCK == 1
+ onlp_api_lock_init();
+#endif
+
+
+ onlp_json_init(cfile);
+ onlp_sys_init();
+ onlp_sfp_init();
+ onlp_led_init();
+ onlp_psu_init();
+ onlp_fan_init();
+ onlp_thermal_init();
+ return 0;
+}
diff --git a/packages/base/any/onlp/src/onlp/module/src/onlp_config.c b/packages/base/any/onlp/src/onlp/module/src/onlp_config.c
new file mode 100644
index 00000000..68ddf55b
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/src/onlp_config.c
@@ -0,0 +1,156 @@
+/************************************************************
+ *
+ *
+ * Copyright 2014, 2015 Big Switch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ ************************************************************
+ *
+ *
+ *
+ ***********************************************************/
+
+#include
+
+/* */
+#define __onlp_config_STRINGIFY_NAME(_x) #_x
+#define __onlp_config_STRINGIFY_VALUE(_x) __onlp_config_STRINGIFY_NAME(_x)
+onlp_config_settings_t onlp_config_settings[] =
+{
+#ifdef ONLP_CONFIG_INCLUDE_LOGGING
+ { __onlp_config_STRINGIFY_NAME(ONLP_CONFIG_INCLUDE_LOGGING), __onlp_config_STRINGIFY_VALUE(ONLP_CONFIG_INCLUDE_LOGGING) },
+#else
+{ ONLP_CONFIG_INCLUDE_LOGGING(__onlp_config_STRINGIFY_NAME), "__undefined__" },
+#endif
+#ifdef ONLP_CONFIG_LOG_OPTIONS_DEFAULT
+ { __onlp_config_STRINGIFY_NAME(ONLP_CONFIG_LOG_OPTIONS_DEFAULT), __onlp_config_STRINGIFY_VALUE(ONLP_CONFIG_LOG_OPTIONS_DEFAULT) },
+#else
+{ ONLP_CONFIG_LOG_OPTIONS_DEFAULT(__onlp_config_STRINGIFY_NAME), "__undefined__" },
+#endif
+#ifdef ONLP_CONFIG_LOG_BITS_DEFAULT
+ { __onlp_config_STRINGIFY_NAME(ONLP_CONFIG_LOG_BITS_DEFAULT), __onlp_config_STRINGIFY_VALUE(ONLP_CONFIG_LOG_BITS_DEFAULT) },
+#else
+{ ONLP_CONFIG_LOG_BITS_DEFAULT(__onlp_config_STRINGIFY_NAME), "__undefined__" },
+#endif
+#ifdef ONLP_CONFIG_LOG_CUSTOM_BITS_DEFAULT
+ { __onlp_config_STRINGIFY_NAME(ONLP_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __onlp_config_STRINGIFY_VALUE(ONLP_CONFIG_LOG_CUSTOM_BITS_DEFAULT) },
+#else
+{ ONLP_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__onlp_config_STRINGIFY_NAME), "__undefined__" },
+#endif
+#ifdef ONLP_CONFIG_PORTING_STDLIB
+ { __onlp_config_STRINGIFY_NAME(ONLP_CONFIG_PORTING_STDLIB), __onlp_config_STRINGIFY_VALUE(ONLP_CONFIG_PORTING_STDLIB) },
+#else
+{ ONLP_CONFIG_PORTING_STDLIB(__onlp_config_STRINGIFY_NAME), "__undefined__" },
+#endif
+#ifdef ONLP_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS
+ { __onlp_config_STRINGIFY_NAME(ONLP_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __onlp_config_STRINGIFY_VALUE(ONLP_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) },
+#else
+{ ONLP_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__onlp_config_STRINGIFY_NAME), "__undefined__" },
+#endif
+#ifdef ONLP_CONFIG_INCLUDE_UCLI
+ { __onlp_config_STRINGIFY_NAME(ONLP_CONFIG_INCLUDE_UCLI), __onlp_config_STRINGIFY_VALUE(ONLP_CONFIG_INCLUDE_UCLI) },
+#else
+{ ONLP_CONFIG_INCLUDE_UCLI(__onlp_config_STRINGIFY_NAME), "__undefined__" },
+#endif
+#ifdef ONLP_CONFIG_INCLUDE_PLATFORM_ERROR_CHECK
+ { __onlp_config_STRINGIFY_NAME(ONLP_CONFIG_INCLUDE_PLATFORM_ERROR_CHECK), __onlp_config_STRINGIFY_VALUE(ONLP_CONFIG_INCLUDE_PLATFORM_ERROR_CHECK) },
+#else
+{ ONLP_CONFIG_INCLUDE_PLATFORM_ERROR_CHECK(__onlp_config_STRINGIFY_NAME), "__undefined__" },
+#endif
+#ifdef ONLP_CONFIG_INCLUDE_SHLOCK_GLOBAL_INIT
+ { __onlp_config_STRINGIFY_NAME(ONLP_CONFIG_INCLUDE_SHLOCK_GLOBAL_INIT), __onlp_config_STRINGIFY_VALUE(ONLP_CONFIG_INCLUDE_SHLOCK_GLOBAL_INIT) },
+#else
+{ ONLP_CONFIG_INCLUDE_SHLOCK_GLOBAL_INIT(__onlp_config_STRINGIFY_NAME), "__undefined__" },
+#endif
+#ifdef ONLP_CONFIG_INCLUDE_PLATFORM_STATIC
+ { __onlp_config_STRINGIFY_NAME(ONLP_CONFIG_INCLUDE_PLATFORM_STATIC), __onlp_config_STRINGIFY_VALUE(ONLP_CONFIG_INCLUDE_PLATFORM_STATIC) },
+#else
+{ ONLP_CONFIG_INCLUDE_PLATFORM_STATIC(__onlp_config_STRINGIFY_NAME), "__undefined__" },
+#endif
+#ifdef ONLP_CONFIG_PLATFORM_STATIC
+ { __onlp_config_STRINGIFY_NAME(ONLP_CONFIG_PLATFORM_STATIC), __onlp_config_STRINGIFY_VALUE(ONLP_CONFIG_PLATFORM_STATIC) },
+#else
+{ ONLP_CONFIG_PLATFORM_STATIC(__onlp_config_STRINGIFY_NAME), "__undefined__" },
+#endif
+#ifdef ONLP_CONFIG_PLATFORM_FILENAME
+ { __onlp_config_STRINGIFY_NAME(ONLP_CONFIG_PLATFORM_FILENAME), __onlp_config_STRINGIFY_VALUE(ONLP_CONFIG_PLATFORM_FILENAME) },
+#else
+{ ONLP_CONFIG_PLATFORM_FILENAME(__onlp_config_STRINGIFY_NAME), "__undefined__" },
+#endif
+#ifdef ONLP_CONFIG_INCLUDE_PLATFORM_OVERRIDES
+ { __onlp_config_STRINGIFY_NAME(ONLP_CONFIG_INCLUDE_PLATFORM_OVERRIDES), __onlp_config_STRINGIFY_VALUE(ONLP_CONFIG_INCLUDE_PLATFORM_OVERRIDES) },
+#else
+{ ONLP_CONFIG_INCLUDE_PLATFORM_OVERRIDES(__onlp_config_STRINGIFY_NAME), "__undefined__" },
+#endif
+#ifdef ONLP_CONFIG_CONFIGURATION_FILENAME
+ { __onlp_config_STRINGIFY_NAME(ONLP_CONFIG_CONFIGURATION_FILENAME), __onlp_config_STRINGIFY_VALUE(ONLP_CONFIG_CONFIGURATION_FILENAME) },
+#else
+{ ONLP_CONFIG_CONFIGURATION_FILENAME(__onlp_config_STRINGIFY_NAME), "__undefined__" },
+#endif
+#ifdef ONLP_CONFIG_CONFIGURATION_ENV
+ { __onlp_config_STRINGIFY_NAME(ONLP_CONFIG_CONFIGURATION_ENV), __onlp_config_STRINGIFY_VALUE(ONLP_CONFIG_CONFIGURATION_ENV) },
+#else
+{ ONLP_CONFIG_CONFIGURATION_ENV(__onlp_config_STRINGIFY_NAME), "__undefined__" },
+#endif
+#ifdef ONLP_CONFIG_INCLUDE_API_LOCK
+ { __onlp_config_STRINGIFY_NAME(ONLP_CONFIG_INCLUDE_API_LOCK), __onlp_config_STRINGIFY_VALUE(ONLP_CONFIG_INCLUDE_API_LOCK) },
+#else
+{ ONLP_CONFIG_INCLUDE_API_LOCK(__onlp_config_STRINGIFY_NAME), "__undefined__" },
+#endif
+#ifdef ONLP_CONFIG_API_LOCK_GLOBAL_SHARED
+ { __onlp_config_STRINGIFY_NAME(ONLP_CONFIG_API_LOCK_GLOBAL_SHARED), __onlp_config_STRINGIFY_VALUE(ONLP_CONFIG_API_LOCK_GLOBAL_SHARED) },
+#else
+{ ONLP_CONFIG_API_LOCK_GLOBAL_SHARED(__onlp_config_STRINGIFY_NAME), "__undefined__" },
+#endif
+#ifdef ONLP_CONFIG_API_LOCK_TIMEOUT
+ { __onlp_config_STRINGIFY_NAME(ONLP_CONFIG_API_LOCK_TIMEOUT), __onlp_config_STRINGIFY_VALUE(ONLP_CONFIG_API_LOCK_TIMEOUT) },
+#else
+{ ONLP_CONFIG_API_LOCK_TIMEOUT(__onlp_config_STRINGIFY_NAME), "__undefined__" },
+#endif
+#ifdef ONLP_CONFIG_INFO_STR_MAX
+ { __onlp_config_STRINGIFY_NAME(ONLP_CONFIG_INFO_STR_MAX), __onlp_config_STRINGIFY_VALUE(ONLP_CONFIG_INFO_STR_MAX) },
+#else
+{ ONLP_CONFIG_INFO_STR_MAX(__onlp_config_STRINGIFY_NAME), "__undefined__" },
+#endif
+ { NULL, NULL }
+};
+#undef __onlp_config_STRINGIFY_VALUE
+#undef __onlp_config_STRINGIFY_NAME
+
+const char*
+onlp_config_lookup(const char* setting)
+{
+ int i;
+ for(i = 0; onlp_config_settings[i].name; i++) {
+ if(strcmp(onlp_config_settings[i].name, setting)) {
+ return onlp_config_settings[i].value;
+ }
+ }
+ return NULL;
+}
+
+int
+onlp_config_show(struct aim_pvs_s* pvs)
+{
+ int i;
+ for(i = 0; onlp_config_settings[i].name; i++) {
+ aim_printf(pvs, "%s = %s\n", onlp_config_settings[i].name, onlp_config_settings[i].value);
+ }
+ return i;
+}
+
+/* */
+
diff --git a/packages/base/any/onlp/src/onlp/module/src/onlp_enums.c b/packages/base/any/onlp/src/onlp/module/src/onlp_enums.c
new file mode 100644
index 00000000..44f98d94
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/src/onlp_enums.c
@@ -0,0 +1,1048 @@
+/************************************************************
+ *
+ *
+ * Copyright 2014, 2015 Big Switch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ ************************************************************
+ *
+ *
+ *
+ ***********************************************************/
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+/* */
+aim_map_si_t onlp_fan_mode_map[] =
+{
+ { "OFF", ONLP_FAN_MODE_OFF },
+ { "SLOW", ONLP_FAN_MODE_SLOW },
+ { "NORMAL", ONLP_FAN_MODE_NORMAL },
+ { "FAST", ONLP_FAN_MODE_FAST },
+ { "MAX", ONLP_FAN_MODE_MAX },
+ { NULL, 0 }
+};
+
+aim_map_si_t onlp_fan_mode_desc_map[] =
+{
+ { "None", ONLP_FAN_MODE_OFF },
+ { "None", ONLP_FAN_MODE_SLOW },
+ { "None", ONLP_FAN_MODE_NORMAL },
+ { "None", ONLP_FAN_MODE_FAST },
+ { "None", ONLP_FAN_MODE_MAX },
+ { NULL, 0 }
+};
+
+const char*
+onlp_fan_mode_name(onlp_fan_mode_t e)
+{
+ const char* name;
+ if(aim_map_si_i(&name, e, onlp_fan_mode_map, 0)) {
+ return name;
+ }
+ else {
+ return "-invalid value for enum type 'onlp_fan_mode'";
+ }
+}
+
+int
+onlp_fan_mode_value(const char* str, onlp_fan_mode_t* e, int substr)
+{
+ int i;
+ AIM_REFERENCE(substr);
+ if(aim_map_si_s(&i, str, onlp_fan_mode_map, 0)) {
+ /* Enum Found */
+ *e = i;
+ return 0;
+ }
+ else {
+ return -1;
+ }
+}
+
+const char*
+onlp_fan_mode_desc(onlp_fan_mode_t e)
+{
+ const char* name;
+ if(aim_map_si_i(&name, e, onlp_fan_mode_desc_map, 0)) {
+ return name;
+ }
+ else {
+ return "-invalid value for enum type 'onlp_fan_mode'";
+ }
+}
+
+
+aim_map_si_t onlp_sfp_control_flag_map[] =
+{
+ { "RESET", ONLP_SFP_CONTROL_FLAG_RESET },
+ { "RESET_STATE", ONLP_SFP_CONTROL_FLAG_RESET_STATE },
+ { "RX_LOS", ONLP_SFP_CONTROL_FLAG_RX_LOS },
+ { "TX_FAULT", ONLP_SFP_CONTROL_FLAG_TX_FAULT },
+ { "TX_DISABLE", ONLP_SFP_CONTROL_FLAG_TX_DISABLE },
+ { "LP_MODE", ONLP_SFP_CONTROL_FLAG_LP_MODE },
+ { "POWER_OVERRIDE", ONLP_SFP_CONTROL_FLAG_POWER_OVERRIDE },
+ { NULL, 0 }
+};
+
+aim_map_si_t onlp_sfp_control_flag_desc_map[] =
+{
+ { "None", ONLP_SFP_CONTROL_FLAG_RESET },
+ { "None", ONLP_SFP_CONTROL_FLAG_RESET_STATE },
+ { "None", ONLP_SFP_CONTROL_FLAG_RX_LOS },
+ { "None", ONLP_SFP_CONTROL_FLAG_TX_FAULT },
+ { "None", ONLP_SFP_CONTROL_FLAG_TX_DISABLE },
+ { "None", ONLP_SFP_CONTROL_FLAG_LP_MODE },
+ { "None", ONLP_SFP_CONTROL_FLAG_POWER_OVERRIDE },
+ { NULL, 0 }
+};
+
+const char*
+onlp_sfp_control_flag_name(onlp_sfp_control_flag_t e)
+{
+ const char* name;
+ if(aim_map_si_i(&name, e, onlp_sfp_control_flag_map, 0)) {
+ return name;
+ }
+ else {
+ return "-invalid value for enum type 'onlp_sfp_control_flag'";
+ }
+}
+
+int
+onlp_sfp_control_flag_value(const char* str, onlp_sfp_control_flag_t* e, int substr)
+{
+ int i;
+ AIM_REFERENCE(substr);
+ if(aim_map_si_s(&i, str, onlp_sfp_control_flag_map, 0)) {
+ /* Enum Found */
+ *e = i;
+ return 0;
+ }
+ else {
+ return -1;
+ }
+}
+
+const char*
+onlp_sfp_control_flag_desc(onlp_sfp_control_flag_t e)
+{
+ const char* name;
+ if(aim_map_si_i(&name, e, onlp_sfp_control_flag_desc_map, 0)) {
+ return name;
+ }
+ else {
+ return "-invalid value for enum type 'onlp_sfp_control_flag'";
+ }
+}
+
+int
+onlp_sfp_control_flag_valid(onlp_sfp_control_flag_t e)
+{
+ return aim_map_si_i(NULL, e, onlp_sfp_control_flag_map, 0) ? 1 : 0;
+}
+
+
+aim_map_si_t onlp_psu_status_map[] =
+{
+ { "PRESENT", ONLP_PSU_STATUS_PRESENT },
+ { "FAILED", ONLP_PSU_STATUS_FAILED },
+ { "UNPLUGGED", ONLP_PSU_STATUS_UNPLUGGED },
+ { NULL, 0 }
+};
+
+aim_map_si_t onlp_psu_status_desc_map[] =
+{
+ { "None", ONLP_PSU_STATUS_PRESENT },
+ { "None", ONLP_PSU_STATUS_FAILED },
+ { "None", ONLP_PSU_STATUS_UNPLUGGED },
+ { NULL, 0 }
+};
+
+const char*
+onlp_psu_status_name(onlp_psu_status_t e)
+{
+ const char* name;
+ if(aim_map_si_i(&name, e, onlp_psu_status_map, 0)) {
+ return name;
+ }
+ else {
+ return "-invalid value for enum type 'onlp_psu_status'";
+ }
+}
+
+int
+onlp_psu_status_value(const char* str, onlp_psu_status_t* e, int substr)
+{
+ int i;
+ AIM_REFERENCE(substr);
+ if(aim_map_si_s(&i, str, onlp_psu_status_map, 0)) {
+ /* Enum Found */
+ *e = i;
+ return 0;
+ }
+ else {
+ return -1;
+ }
+}
+
+const char*
+onlp_psu_status_desc(onlp_psu_status_t e)
+{
+ const char* name;
+ if(aim_map_si_i(&name, e, onlp_psu_status_desc_map, 0)) {
+ return name;
+ }
+ else {
+ return "-invalid value for enum type 'onlp_psu_status'";
+ }
+}
+
+int
+onlp_psu_status_valid(onlp_psu_status_t e)
+{
+ return aim_map_si_i(NULL, e, onlp_psu_status_map, 0) ? 1 : 0;
+}
+
+
+aim_map_si_t onlp_sfp_control_map[] =
+{
+ { "RESET", ONLP_SFP_CONTROL_RESET },
+ { "RESET_STATE", ONLP_SFP_CONTROL_RESET_STATE },
+ { "RX_LOS", ONLP_SFP_CONTROL_RX_LOS },
+ { "TX_FAULT", ONLP_SFP_CONTROL_TX_FAULT },
+ { "TX_DISABLE", ONLP_SFP_CONTROL_TX_DISABLE },
+ { "LP_MODE", ONLP_SFP_CONTROL_LP_MODE },
+ { "POWER_OVERRIDE", ONLP_SFP_CONTROL_POWER_OVERRIDE },
+ { NULL, 0 }
+};
+
+aim_map_si_t onlp_sfp_control_desc_map[] =
+{
+ { "None", ONLP_SFP_CONTROL_RESET },
+ { "None", ONLP_SFP_CONTROL_RESET_STATE },
+ { "None", ONLP_SFP_CONTROL_RX_LOS },
+ { "None", ONLP_SFP_CONTROL_TX_FAULT },
+ { "None", ONLP_SFP_CONTROL_TX_DISABLE },
+ { "None", ONLP_SFP_CONTROL_LP_MODE },
+ { "None", ONLP_SFP_CONTROL_POWER_OVERRIDE },
+ { NULL, 0 }
+};
+
+const char*
+onlp_sfp_control_name(onlp_sfp_control_t e)
+{
+ const char* name;
+ if(aim_map_si_i(&name, e, onlp_sfp_control_map, 0)) {
+ return name;
+ }
+ else {
+ return "-invalid value for enum type 'onlp_sfp_control'";
+ }
+}
+
+int
+onlp_sfp_control_value(const char* str, onlp_sfp_control_t* e, int substr)
+{
+ int i;
+ AIM_REFERENCE(substr);
+ if(aim_map_si_s(&i, str, onlp_sfp_control_map, 0)) {
+ /* Enum Found */
+ *e = i;
+ return 0;
+ }
+ else {
+ return -1;
+ }
+}
+
+const char*
+onlp_sfp_control_desc(onlp_sfp_control_t e)
+{
+ const char* name;
+ if(aim_map_si_i(&name, e, onlp_sfp_control_desc_map, 0)) {
+ return name;
+ }
+ else {
+ return "-invalid value for enum type 'onlp_sfp_control'";
+ }
+}
+
+
+aim_map_si_t onlp_led_caps_map[] =
+{
+ { "ON_OFF", ONLP_LED_CAPS_ON_OFF },
+ { "RED", ONLP_LED_CAPS_RED },
+ { "RED_BLINKING", ONLP_LED_CAPS_RED_BLINKING },
+ { "ORANGE", ONLP_LED_CAPS_ORANGE },
+ { "ORANGE_BLINKING", ONLP_LED_CAPS_ORANGE_BLINKING },
+ { "YELLOW", ONLP_LED_CAPS_YELLOW },
+ { "YELLOW_BLINKING", ONLP_LED_CAPS_YELLOW_BLINKING },
+ { "GREEN", ONLP_LED_CAPS_GREEN },
+ { "GREEN_BLINKING", ONLP_LED_CAPS_GREEN_BLINKING },
+ { "BLUE", ONLP_LED_CAPS_BLUE },
+ { "BLUE_BLINKING", ONLP_LED_CAPS_BLUE_BLINKING },
+ { "PURPLE", ONLP_LED_CAPS_PURPLE },
+ { "PURPLE_BLINKING", ONLP_LED_CAPS_PURPLE_BLINKING },
+ { "AUTO", ONLP_LED_CAPS_AUTO },
+ { NULL, 0 }
+};
+
+aim_map_si_t onlp_led_caps_desc_map[] =
+{
+ { "None", ONLP_LED_CAPS_ON_OFF },
+ { "None", ONLP_LED_CAPS_RED },
+ { "None", ONLP_LED_CAPS_RED_BLINKING },
+ { "None", ONLP_LED_CAPS_ORANGE },
+ { "None", ONLP_LED_CAPS_ORANGE_BLINKING },
+ { "None", ONLP_LED_CAPS_YELLOW },
+ { "None", ONLP_LED_CAPS_YELLOW_BLINKING },
+ { "None", ONLP_LED_CAPS_GREEN },
+ { "None", ONLP_LED_CAPS_GREEN_BLINKING },
+ { "None", ONLP_LED_CAPS_BLUE },
+ { "None", ONLP_LED_CAPS_BLUE_BLINKING },
+ { "None", ONLP_LED_CAPS_PURPLE },
+ { "None", ONLP_LED_CAPS_PURPLE_BLINKING },
+ { "None", ONLP_LED_CAPS_AUTO },
+ { NULL, 0 }
+};
+
+const char*
+onlp_led_caps_name(onlp_led_caps_t e)
+{
+ const char* name;
+ if(aim_map_si_i(&name, e, onlp_led_caps_map, 0)) {
+ return name;
+ }
+ else {
+ return "-invalid value for enum type 'onlp_led_caps'";
+ }
+}
+
+int
+onlp_led_caps_value(const char* str, onlp_led_caps_t* e, int substr)
+{
+ int i;
+ AIM_REFERENCE(substr);
+ if(aim_map_si_s(&i, str, onlp_led_caps_map, 0)) {
+ /* Enum Found */
+ *e = i;
+ return 0;
+ }
+ else {
+ return -1;
+ }
+}
+
+const char*
+onlp_led_caps_desc(onlp_led_caps_t e)
+{
+ const char* name;
+ if(aim_map_si_i(&name, e, onlp_led_caps_desc_map, 0)) {
+ return name;
+ }
+ else {
+ return "-invalid value for enum type 'onlp_led_caps'";
+ }
+}
+
+int
+onlp_led_caps_valid(onlp_led_caps_t e)
+{
+ return aim_map_si_i(NULL, e, onlp_led_caps_map, 0) ? 1 : 0;
+}
+
+
+aim_map_si_t onlp_led_status_map[] =
+{
+ { "PRESENT", ONLP_LED_STATUS_PRESENT },
+ { "FAILED", ONLP_LED_STATUS_FAILED },
+ { "ON", ONLP_LED_STATUS_ON },
+ { NULL, 0 }
+};
+
+aim_map_si_t onlp_led_status_desc_map[] =
+{
+ { "None", ONLP_LED_STATUS_PRESENT },
+ { "None", ONLP_LED_STATUS_FAILED },
+ { "None", ONLP_LED_STATUS_ON },
+ { NULL, 0 }
+};
+
+const char*
+onlp_led_status_name(onlp_led_status_t e)
+{
+ const char* name;
+ if(aim_map_si_i(&name, e, onlp_led_status_map, 0)) {
+ return name;
+ }
+ else {
+ return "-invalid value for enum type 'onlp_led_status'";
+ }
+}
+
+int
+onlp_led_status_value(const char* str, onlp_led_status_t* e, int substr)
+{
+ int i;
+ AIM_REFERENCE(substr);
+ if(aim_map_si_s(&i, str, onlp_led_status_map, 0)) {
+ /* Enum Found */
+ *e = i;
+ return 0;
+ }
+ else {
+ return -1;
+ }
+}
+
+const char*
+onlp_led_status_desc(onlp_led_status_t e)
+{
+ const char* name;
+ if(aim_map_si_i(&name, e, onlp_led_status_desc_map, 0)) {
+ return name;
+ }
+ else {
+ return "-invalid value for enum type 'onlp_led_status'";
+ }
+}
+
+int
+onlp_led_status_valid(onlp_led_status_t e)
+{
+ return aim_map_si_i(NULL, e, onlp_led_status_map, 0) ? 1 : 0;
+}
+
+
+aim_map_si_t onlp_thermal_status_map[] =
+{
+ { "PRESENT", ONLP_THERMAL_STATUS_PRESENT },
+ { "FAILED", ONLP_THERMAL_STATUS_FAILED },
+ { NULL, 0 }
+};
+
+aim_map_si_t onlp_thermal_status_desc_map[] =
+{
+ { "None", ONLP_THERMAL_STATUS_PRESENT },
+ { "None", ONLP_THERMAL_STATUS_FAILED },
+ { NULL, 0 }
+};
+
+const char*
+onlp_thermal_status_name(onlp_thermal_status_t e)
+{
+ const char* name;
+ if(aim_map_si_i(&name, e, onlp_thermal_status_map, 0)) {
+ return name;
+ }
+ else {
+ return "-invalid value for enum type 'onlp_thermal_status'";
+ }
+}
+
+int
+onlp_thermal_status_value(const char* str, onlp_thermal_status_t* e, int substr)
+{
+ int i;
+ AIM_REFERENCE(substr);
+ if(aim_map_si_s(&i, str, onlp_thermal_status_map, 0)) {
+ /* Enum Found */
+ *e = i;
+ return 0;
+ }
+ else {
+ return -1;
+ }
+}
+
+const char*
+onlp_thermal_status_desc(onlp_thermal_status_t e)
+{
+ const char* name;
+ if(aim_map_si_i(&name, e, onlp_thermal_status_desc_map, 0)) {
+ return name;
+ }
+ else {
+ return "-invalid value for enum type 'onlp_thermal_status'";
+ }
+}
+
+int
+onlp_thermal_status_valid(onlp_thermal_status_t e)
+{
+ return aim_map_si_i(NULL, e, onlp_thermal_status_map, 0) ? 1 : 0;
+}
+
+
+aim_map_si_t onlp_oid_type_map[] =
+{
+ { "SYS", ONLP_OID_TYPE_SYS },
+ { "THERMAL", ONLP_OID_TYPE_THERMAL },
+ { "FAN", ONLP_OID_TYPE_FAN },
+ { "PSU", ONLP_OID_TYPE_PSU },
+ { "LED", ONLP_OID_TYPE_LED },
+ { "MODULE", ONLP_OID_TYPE_MODULE },
+ { "RTC", ONLP_OID_TYPE_RTC },
+ { NULL, 0 }
+};
+
+aim_map_si_t onlp_oid_type_desc_map[] =
+{
+ { "None", ONLP_OID_TYPE_SYS },
+ { "None", ONLP_OID_TYPE_THERMAL },
+ { "None", ONLP_OID_TYPE_FAN },
+ { "None", ONLP_OID_TYPE_PSU },
+ { "None", ONLP_OID_TYPE_LED },
+ { "None", ONLP_OID_TYPE_MODULE },
+ { "None", ONLP_OID_TYPE_RTC },
+ { NULL, 0 }
+};
+
+const char*
+onlp_oid_type_name(onlp_oid_type_t e)
+{
+ const char* name;
+ if(aim_map_si_i(&name, e, onlp_oid_type_map, 0)) {
+ return name;
+ }
+ else {
+ return "-invalid value for enum type 'onlp_oid_type'";
+ }
+}
+
+int
+onlp_oid_type_value(const char* str, onlp_oid_type_t* e, int substr)
+{
+ int i;
+ AIM_REFERENCE(substr);
+ if(aim_map_si_s(&i, str, onlp_oid_type_map, 0)) {
+ /* Enum Found */
+ *e = i;
+ return 0;
+ }
+ else {
+ return -1;
+ }
+}
+
+const char*
+onlp_oid_type_desc(onlp_oid_type_t e)
+{
+ const char* name;
+ if(aim_map_si_i(&name, e, onlp_oid_type_desc_map, 0)) {
+ return name;
+ }
+ else {
+ return "-invalid value for enum type 'onlp_oid_type'";
+ }
+}
+
+int
+onlp_oid_type_valid(onlp_oid_type_t e)
+{
+ return aim_map_si_i(NULL, e, onlp_oid_type_map, 0) ? 1 : 0;
+}
+
+
+aim_map_si_t onlp_fan_caps_map[] =
+{
+ { "B2F", ONLP_FAN_CAPS_B2F },
+ { "F2B", ONLP_FAN_CAPS_F2B },
+ { "SET_RPM", ONLP_FAN_CAPS_SET_RPM },
+ { "SET_PERCENTAGE", ONLP_FAN_CAPS_SET_PERCENTAGE },
+ { "GET_RPM", ONLP_FAN_CAPS_GET_RPM },
+ { "GET_PERCENTAGE", ONLP_FAN_CAPS_GET_PERCENTAGE },
+ { NULL, 0 }
+};
+
+aim_map_si_t onlp_fan_caps_desc_map[] =
+{
+ { "None", ONLP_FAN_CAPS_B2F },
+ { "None", ONLP_FAN_CAPS_F2B },
+ { "None", ONLP_FAN_CAPS_SET_RPM },
+ { "None", ONLP_FAN_CAPS_SET_PERCENTAGE },
+ { "None", ONLP_FAN_CAPS_GET_RPM },
+ { "None", ONLP_FAN_CAPS_GET_PERCENTAGE },
+ { NULL, 0 }
+};
+
+const char*
+onlp_fan_caps_name(onlp_fan_caps_t e)
+{
+ const char* name;
+ if(aim_map_si_i(&name, e, onlp_fan_caps_map, 0)) {
+ return name;
+ }
+ else {
+ return "-invalid value for enum type 'onlp_fan_caps'";
+ }
+}
+
+int
+onlp_fan_caps_value(const char* str, onlp_fan_caps_t* e, int substr)
+{
+ int i;
+ AIM_REFERENCE(substr);
+ if(aim_map_si_s(&i, str, onlp_fan_caps_map, 0)) {
+ /* Enum Found */
+ *e = i;
+ return 0;
+ }
+ else {
+ return -1;
+ }
+}
+
+const char*
+onlp_fan_caps_desc(onlp_fan_caps_t e)
+{
+ const char* name;
+ if(aim_map_si_i(&name, e, onlp_fan_caps_desc_map, 0)) {
+ return name;
+ }
+ else {
+ return "-invalid value for enum type 'onlp_fan_caps'";
+ }
+}
+
+int
+onlp_fan_caps_valid(onlp_fan_caps_t e)
+{
+ return aim_map_si_i(NULL, e, onlp_fan_caps_map, 0) ? 1 : 0;
+}
+
+
+aim_map_si_t onlp_led_mode_map[] =
+{
+ { "OFF", ONLP_LED_MODE_OFF },
+ { "ON", ONLP_LED_MODE_ON },
+ { "BLINKING", ONLP_LED_MODE_BLINKING },
+ { "RED", ONLP_LED_MODE_RED },
+ { "RED_BLINKING", ONLP_LED_MODE_RED_BLINKING },
+ { "ORANGE", ONLP_LED_MODE_ORANGE },
+ { "ORANGE_BLINKING", ONLP_LED_MODE_ORANGE_BLINKING },
+ { "YELLOW", ONLP_LED_MODE_YELLOW },
+ { "YELLOW_BLINKING", ONLP_LED_MODE_YELLOW_BLINKING },
+ { "GREEN", ONLP_LED_MODE_GREEN },
+ { "GREEN_BLINKING", ONLP_LED_MODE_GREEN_BLINKING },
+ { "BLUE", ONLP_LED_MODE_BLUE },
+ { "BLUE_BLINKING", ONLP_LED_MODE_BLUE_BLINKING },
+ { "PURPLE", ONLP_LED_MODE_PURPLE },
+ { "PURPLE_BLINKING", ONLP_LED_MODE_PURPLE_BLINKING },
+ { "AUTO", ONLP_LED_MODE_AUTO },
+ { NULL, 0 }
+};
+
+aim_map_si_t onlp_led_mode_desc_map[] =
+{
+ { "None", ONLP_LED_MODE_OFF },
+ { "None", ONLP_LED_MODE_ON },
+ { "None", ONLP_LED_MODE_BLINKING },
+ { "None", ONLP_LED_MODE_RED },
+ { "None", ONLP_LED_MODE_RED_BLINKING },
+ { "None", ONLP_LED_MODE_ORANGE },
+ { "None", ONLP_LED_MODE_ORANGE_BLINKING },
+ { "None", ONLP_LED_MODE_YELLOW },
+ { "None", ONLP_LED_MODE_YELLOW_BLINKING },
+ { "None", ONLP_LED_MODE_GREEN },
+ { "None", ONLP_LED_MODE_GREEN_BLINKING },
+ { "None", ONLP_LED_MODE_BLUE },
+ { "None", ONLP_LED_MODE_BLUE_BLINKING },
+ { "None", ONLP_LED_MODE_PURPLE },
+ { "None", ONLP_LED_MODE_PURPLE_BLINKING },
+ { "None", ONLP_LED_MODE_AUTO },
+ { NULL, 0 }
+};
+
+const char*
+onlp_led_mode_name(onlp_led_mode_t e)
+{
+ const char* name;
+ if(aim_map_si_i(&name, e, onlp_led_mode_map, 0)) {
+ return name;
+ }
+ else {
+ return "-invalid value for enum type 'onlp_led_mode'";
+ }
+}
+
+int
+onlp_led_mode_value(const char* str, onlp_led_mode_t* e, int substr)
+{
+ int i;
+ AIM_REFERENCE(substr);
+ if(aim_map_si_s(&i, str, onlp_led_mode_map, 0)) {
+ /* Enum Found */
+ *e = i;
+ return 0;
+ }
+ else {
+ return -1;
+ }
+}
+
+const char*
+onlp_led_mode_desc(onlp_led_mode_t e)
+{
+ const char* name;
+ if(aim_map_si_i(&name, e, onlp_led_mode_desc_map, 0)) {
+ return name;
+ }
+ else {
+ return "-invalid value for enum type 'onlp_led_mode'";
+ }
+}
+
+int
+onlp_led_mode_valid(onlp_led_mode_t e)
+{
+ return aim_map_si_i(NULL, e, onlp_led_mode_map, 0) ? 1 : 0;
+}
+
+
+aim_map_si_t onlp_fan_status_map[] =
+{
+ { "PRESENT", ONLP_FAN_STATUS_PRESENT },
+ { "FAILED", ONLP_FAN_STATUS_FAILED },
+ { "B2F", ONLP_FAN_STATUS_B2F },
+ { "F2B", ONLP_FAN_STATUS_F2B },
+ { NULL, 0 }
+};
+
+aim_map_si_t onlp_fan_status_desc_map[] =
+{
+ { "None", ONLP_FAN_STATUS_PRESENT },
+ { "None", ONLP_FAN_STATUS_FAILED },
+ { "None", ONLP_FAN_STATUS_B2F },
+ { "None", ONLP_FAN_STATUS_F2B },
+ { NULL, 0 }
+};
+
+const char*
+onlp_fan_status_name(onlp_fan_status_t e)
+{
+ const char* name;
+ if(aim_map_si_i(&name, e, onlp_fan_status_map, 0)) {
+ return name;
+ }
+ else {
+ return "-invalid value for enum type 'onlp_fan_status'";
+ }
+}
+
+int
+onlp_fan_status_value(const char* str, onlp_fan_status_t* e, int substr)
+{
+ int i;
+ AIM_REFERENCE(substr);
+ if(aim_map_si_s(&i, str, onlp_fan_status_map, 0)) {
+ /* Enum Found */
+ *e = i;
+ return 0;
+ }
+ else {
+ return -1;
+ }
+}
+
+const char*
+onlp_fan_status_desc(onlp_fan_status_t e)
+{
+ const char* name;
+ if(aim_map_si_i(&name, e, onlp_fan_status_desc_map, 0)) {
+ return name;
+ }
+ else {
+ return "-invalid value for enum type 'onlp_fan_status'";
+ }
+}
+
+int
+onlp_fan_status_valid(onlp_fan_status_t e)
+{
+ return aim_map_si_i(NULL, e, onlp_fan_status_map, 0) ? 1 : 0;
+}
+
+
+aim_map_si_t onlp_status_map[] =
+{
+ { "OK", ONLP_STATUS_OK },
+ { "E_UNSUPPORTED", ONLP_STATUS_E_UNSUPPORTED },
+ { "E_MISSING", ONLP_STATUS_E_MISSING },
+ { "E_INVALID", ONLP_STATUS_E_INVALID },
+ { "E_INTERNAL", ONLP_STATUS_E_INTERNAL },
+ { "E_PARAM", ONLP_STATUS_E_PARAM },
+ { NULL, 0 }
+};
+
+aim_map_si_t onlp_status_desc_map[] =
+{
+ { "None", ONLP_STATUS_OK },
+ { "None", ONLP_STATUS_E_UNSUPPORTED },
+ { "None", ONLP_STATUS_E_MISSING },
+ { "None", ONLP_STATUS_E_INVALID },
+ { "None", ONLP_STATUS_E_INTERNAL },
+ { "None", ONLP_STATUS_E_PARAM },
+ { NULL, 0 }
+};
+
+const char*
+onlp_status_name(onlp_status_t e)
+{
+ const char* name;
+ if(aim_map_si_i(&name, e, onlp_status_map, 0)) {
+ return name;
+ }
+ else {
+ return "-invalid value for enum type 'onlp_status'";
+ }
+}
+
+int
+onlp_status_value(const char* str, onlp_status_t* e, int substr)
+{
+ int i;
+ AIM_REFERENCE(substr);
+ if(aim_map_si_s(&i, str, onlp_status_map, 0)) {
+ /* Enum Found */
+ *e = i;
+ return 0;
+ }
+ else {
+ return -1;
+ }
+}
+
+const char*
+onlp_status_desc(onlp_status_t e)
+{
+ const char* name;
+ if(aim_map_si_i(&name, e, onlp_status_desc_map, 0)) {
+ return name;
+ }
+ else {
+ return "-invalid value for enum type 'onlp_status'";
+ }
+}
+
+int
+onlp_status_valid(onlp_status_t e)
+{
+ return aim_map_si_i(NULL, e, onlp_status_map, 0) ? 1 : 0;
+}
+
+
+aim_map_si_t onlp_fan_dir_map[] =
+{
+ { "B2F", ONLP_FAN_DIR_B2F },
+ { "F2B", ONLP_FAN_DIR_F2B },
+ { NULL, 0 }
+};
+
+aim_map_si_t onlp_fan_dir_desc_map[] =
+{
+ { "None", ONLP_FAN_DIR_B2F },
+ { "None", ONLP_FAN_DIR_F2B },
+ { NULL, 0 }
+};
+
+const char*
+onlp_fan_dir_name(onlp_fan_dir_t e)
+{
+ const char* name;
+ if(aim_map_si_i(&name, e, onlp_fan_dir_map, 0)) {
+ return name;
+ }
+ else {
+ return "-invalid value for enum type 'onlp_fan_dir'";
+ }
+}
+
+int
+onlp_fan_dir_value(const char* str, onlp_fan_dir_t* e, int substr)
+{
+ int i;
+ AIM_REFERENCE(substr);
+ if(aim_map_si_s(&i, str, onlp_fan_dir_map, 0)) {
+ /* Enum Found */
+ *e = i;
+ return 0;
+ }
+ else {
+ return -1;
+ }
+}
+
+const char*
+onlp_fan_dir_desc(onlp_fan_dir_t e)
+{
+ const char* name;
+ if(aim_map_si_i(&name, e, onlp_fan_dir_desc_map, 0)) {
+ return name;
+ }
+ else {
+ return "-invalid value for enum type 'onlp_fan_dir'";
+ }
+}
+
+
+aim_map_si_t onlp_psu_caps_map[] =
+{
+ { "AC", ONLP_PSU_CAPS_AC },
+ { "DC12", ONLP_PSU_CAPS_DC12 },
+ { "DC48", ONLP_PSU_CAPS_DC48 },
+ { "VIN", ONLP_PSU_CAPS_VIN },
+ { "VOUT", ONLP_PSU_CAPS_VOUT },
+ { "IIN", ONLP_PSU_CAPS_IIN },
+ { "IOUT", ONLP_PSU_CAPS_IOUT },
+ { "PIN", ONLP_PSU_CAPS_PIN },
+ { "POUT", ONLP_PSU_CAPS_POUT },
+ { NULL, 0 }
+};
+
+aim_map_si_t onlp_psu_caps_desc_map[] =
+{
+ { "None", ONLP_PSU_CAPS_AC },
+ { "None", ONLP_PSU_CAPS_DC12 },
+ { "None", ONLP_PSU_CAPS_DC48 },
+ { "None", ONLP_PSU_CAPS_VIN },
+ { "None", ONLP_PSU_CAPS_VOUT },
+ { "None", ONLP_PSU_CAPS_IIN },
+ { "None", ONLP_PSU_CAPS_IOUT },
+ { "None", ONLP_PSU_CAPS_PIN },
+ { "None", ONLP_PSU_CAPS_POUT },
+ { NULL, 0 }
+};
+
+const char*
+onlp_psu_caps_name(onlp_psu_caps_t e)
+{
+ const char* name;
+ if(aim_map_si_i(&name, e, onlp_psu_caps_map, 0)) {
+ return name;
+ }
+ else {
+ return "-invalid value for enum type 'onlp_psu_caps'";
+ }
+}
+
+int
+onlp_psu_caps_value(const char* str, onlp_psu_caps_t* e, int substr)
+{
+ int i;
+ AIM_REFERENCE(substr);
+ if(aim_map_si_s(&i, str, onlp_psu_caps_map, 0)) {
+ /* Enum Found */
+ *e = i;
+ return 0;
+ }
+ else {
+ return -1;
+ }
+}
+
+const char*
+onlp_psu_caps_desc(onlp_psu_caps_t e)
+{
+ const char* name;
+ if(aim_map_si_i(&name, e, onlp_psu_caps_desc_map, 0)) {
+ return name;
+ }
+ else {
+ return "-invalid value for enum type 'onlp_psu_caps'";
+ }
+}
+
+int
+onlp_psu_caps_valid(onlp_psu_caps_t e)
+{
+ return aim_map_si_i(NULL, e, onlp_psu_caps_map, 0) ? 1 : 0;
+}
+
+
+aim_map_si_t onlp_thermal_caps_map[] =
+{
+ { "GET_TEMPERATURE", ONLP_THERMAL_CAPS_GET_TEMPERATURE },
+ { "GET_WARNING_THRESHOLD", ONLP_THERMAL_CAPS_GET_WARNING_THRESHOLD },
+ { "GET_ERROR_THRESHOLD", ONLP_THERMAL_CAPS_GET_ERROR_THRESHOLD },
+ { "GET_SHUTDOWN_THRESHOLD", ONLP_THERMAL_CAPS_GET_SHUTDOWN_THRESHOLD },
+ { NULL, 0 }
+};
+
+aim_map_si_t onlp_thermal_caps_desc_map[] =
+{
+ { "None", ONLP_THERMAL_CAPS_GET_TEMPERATURE },
+ { "None", ONLP_THERMAL_CAPS_GET_WARNING_THRESHOLD },
+ { "None", ONLP_THERMAL_CAPS_GET_ERROR_THRESHOLD },
+ { "None", ONLP_THERMAL_CAPS_GET_SHUTDOWN_THRESHOLD },
+ { NULL, 0 }
+};
+
+const char*
+onlp_thermal_caps_name(onlp_thermal_caps_t e)
+{
+ const char* name;
+ if(aim_map_si_i(&name, e, onlp_thermal_caps_map, 0)) {
+ return name;
+ }
+ else {
+ return "-invalid value for enum type 'onlp_thermal_caps'";
+ }
+}
+
+int
+onlp_thermal_caps_value(const char* str, onlp_thermal_caps_t* e, int substr)
+{
+ int i;
+ AIM_REFERENCE(substr);
+ if(aim_map_si_s(&i, str, onlp_thermal_caps_map, 0)) {
+ /* Enum Found */
+ *e = i;
+ return 0;
+ }
+ else {
+ return -1;
+ }
+}
+
+const char*
+onlp_thermal_caps_desc(onlp_thermal_caps_t e)
+{
+ const char* name;
+ if(aim_map_si_i(&name, e, onlp_thermal_caps_desc_map, 0)) {
+ return name;
+ }
+ else {
+ return "-invalid value for enum type 'onlp_thermal_caps'";
+ }
+}
+
+int
+onlp_thermal_caps_valid(onlp_thermal_caps_t e)
+{
+ return aim_map_si_i(NULL, e, onlp_thermal_caps_map, 0) ? 1 : 0;
+}
+
+/* */
+
diff --git a/packages/base/any/onlp/src/onlp/module/src/onlp_int.h b/packages/base/any/onlp/src/onlp/module/src/onlp_int.h
new file mode 100644
index 00000000..2a99de75
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/src/onlp_int.h
@@ -0,0 +1,47 @@
+/************************************************************
+ *
+ *
+ * Copyright 2014, 2015 Big Switch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ ************************************************************
+ *
+ *
+ *
+ ***********************************************************/
+#ifndef __ONLP_INT_H__
+#define __ONLP_INT_H__
+
+#include
+#include
+#include
+#include
+#include
+#include "onlp_json.h"
+
+/** Default IOF initializations for dump() and show() routines */
+void onlp_oid_show_iof_init_default(iof_t* iof, aim_pvs_t* pvs, uint32_t flags);
+void onlp_oid_dump_iof_init_default(iof_t* iof, aim_pvs_t* pvs);
+
+/** Default error message when the status of an OID cannot be retreived */
+void onlp_oid_info_get_error(iof_t* iof, int error);
+
+/** Standard OID description output */
+void onlp_oid_show_description(iof_t* iof, onlp_oid_hdr_t* hdr);
+/** Standard message when an OID is missing. */
+void onlp_oid_show_state_missing(iof_t* iof);
+
+#endif /* __ONLP_INT_H__ */
diff --git a/packages/base/any/onlp/src/onlp/module/src/onlp_json.c b/packages/base/any/onlp/src/onlp/module/src/onlp_json.c
new file mode 100644
index 00000000..256c8529
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/src/onlp_json.c
@@ -0,0 +1,68 @@
+/************************************************************
+ *
+ *
+ * Copyright 2014, 2015 Big Switch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ ************************************************************
+ *
+ *
+ *
+ ***********************************************************/
+#include "onlp_json.h"
+#include "onlp_log.h"
+#include
+
+static cJSON* root__ = NULL;
+static char* file__ = NULL;
+
+void
+onlp_json_init(const char* fname)
+{
+ int rv;
+ onlp_json_denit();
+
+ rv = cjson_util_parse_file(fname, &root__);
+ if(rv < 0 || root__ == NULL) {
+ root__ = cJSON_Parse("{}");
+ }
+ else {
+ file__ = aim_strdup(fname);
+ }
+
+}
+
+cJSON*
+onlp_json_get(int reload)
+{
+ if(reload) {
+ onlp_json_init(file__);
+ }
+ return root__;
+}
+
+void
+onlp_json_denit(void)
+{
+ if(root__) {
+ cJSON_Delete(root__);
+ root__ = NULL;
+ }
+ if(file__) {
+ aim_free(file__);
+ file__ = NULL;
+ }
+}
diff --git a/packages/base/any/onlp/src/onlp/module/src/onlp_json.h b/packages/base/any/onlp/src/onlp/module/src/onlp_json.h
new file mode 100644
index 00000000..3ba8e259
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/src/onlp_json.h
@@ -0,0 +1,48 @@
+/************************************************************
+ *
+ *
+ * Copyright 2014, 2015 Big Switch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ ************************************************************
+ *
+ *
+ *
+ ***********************************************************/
+
+#ifndef __ONLP_JSON_H__
+#define __ONLP_JSON_H__
+
+#include
+#include "onlp_int.h"
+#include
+
+/**
+ * @brief Initialize the JSON configuration data.
+ * @param fname JSON configuration filename.
+ */
+void onlp_json_init(const char* fname);
+
+/**
+ * @brief Get the JSON configuration root.
+ * @param reload Option to reload the config file first.
+ */
+cJSON* onlp_json_get(int reload);
+
+void onlp_json_denit(void);
+
+
+#endif /* __ONLP_JSON_H__ */
diff --git a/packages/base/any/onlp/src/onlp/module/src/onlp_locks.c b/packages/base/any/onlp/src/onlp/module/src/onlp_locks.c
new file mode 100644
index 00000000..c87d894d
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/src/onlp_locks.c
@@ -0,0 +1,70 @@
+/************************************************************
+ *
+ *
+ * Copyright 2014, 2015 Big Switch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ ************************************************************
+ *
+ *
+ *
+ ***********************************************************/
+#include
+#include
+#include "onlp_locks.h"
+
+#if ONLP_CONFIG_INCLUDE_API_LOCK == 1
+
+#if ONLP_CONFIG_API_LOCK_GLOBAL_SHARED == 0
+
+#include
+
+/**
+ * The API Lock is a simple semaphore locking within
+ * the current process only.
+ */
+static os_sem_t api_sem__;
+static const char* owner__ = NULL;
+
+void
+onlp_api_lock_init(void)
+{
+ api_sem__ = os_sem_create_flags(1, OS_SEM_CREATE_F_TRUE_RELATIVE_TIMEOUTS);
+}
+
+void
+onlp_api_lock(const char* api)
+{
+ if(os_sem_take_timeout(api_sem__, ONLP_CONFIG_API_LOCK_TIMEOUT) != 0) {
+ AIM_DIE("The ONLP API lock in %s could not be acquired after %d microseconds. It appears to be currently owned by call to %s. This is considered fatal.",
+ api, ONLP_CONFIG_API_LOCK_TIMEOUT, owner__ ? owner__ : "(none)");
+ }
+ owner__ = api;
+}
+
+void
+onlp_api_unlock(void)
+{
+ os_sem_give(api_sem__);
+}
+
+#else
+#error GLOBAL_SHARED API Lock support is not yet implemented.
+#endif
+
+#endif /* ONLP_CONFIG_INCLUDE_API_LOCK */
+
+
diff --git a/packages/base/any/onlp/src/onlp/module/src/onlp_locks.h b/packages/base/any/onlp/src/onlp/module/src/onlp_locks.h
new file mode 100644
index 00000000..dbb0e5e5
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/src/onlp_locks.h
@@ -0,0 +1,175 @@
+/************************************************************
+ *
+ *
+ * Copyright 2014, 2015 Big Switch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ ************************************************************
+ *
+ *
+ *
+ ***********************************************************/
+#ifndef __ONLP_LOCKS_H__
+#define __ONLP_LOCKS_H__
+
+#include
+
+#if ONLP_CONFIG_INCLUDE_API_LOCK == 1
+
+/**
+ * @brief Initialize the ONLP API lock infrastructure.
+ */
+void onlp_api_lock_init();
+
+/**
+ * @brief Take the ONLP API lock.
+ */
+void onlp_api_lock(const char* api);
+
+/**
+ * @brief Give the ONLP API lock.
+ */
+void onlp_api_unlock(void);
+
+
+#define ONLP_API_LOCK_INIT() onlp_api_lock_init()
+#define ONLP_API_LOCK(_api) onlp_api_lock(_api)
+#define ONLP_API_UNLOCK() onlp_api_unlock()
+
+#else
+
+#define ONLP_API_LOCK_INIT()
+#define ONLP_API_LOCK(_api)
+#define ONLP_API_UNLOCK()
+
+#endif /** ONLP_CONFIG_INCLUDE_API_LOCK */
+
+
+/****************************************************************************
+ *
+ * These macros are used the instantiate the public (and potentially locked)
+ * ONLP API entry points.
+ *
+ ***************************************************************************/
+
+#define ONLP_LOCKED_API_NAME(_name) _name##_locked__
+
+#define ONLP_LOCKED_API0(_name) \
+ int _name (void) \
+ { \
+ ONLP_API_LOCK(#_name); \
+ int _rv = ONLP_LOCKED_API_NAME(_name)(); \
+ ONLP_API_UNLOCK(); \
+ return _rv; \
+ }
+
+#define ONLP_LOCKED_API1(_name, _t, _v) \
+ int _name (_t _v) \
+ { \
+ ONLP_API_LOCK(#_name); \
+ int _rv = ONLP_LOCKED_API_NAME(_name)(_v); \
+ ONLP_API_UNLOCK(); \
+ return _rv; \
+ }
+
+#define ONLP_LOCKED_API2(_name, _t1, _v1, _t2, _v2) \
+ int _name (_t1 _v1, _t2 _v2) \
+ { \
+ ONLP_API_LOCK(#_name); \
+ int _rv = ONLP_LOCKED_API_NAME(_name) (_v1, _v2); \
+ ONLP_API_UNLOCK(); \
+ return _rv; \
+ }
+
+#define ONLP_LOCKED_API3(_name, _t1, _v1, _t2, _v2, _t3, _v3) \
+ int _name (_t1 _v1, _t2 _v2, _t3 _v3) \
+ { \
+ ONLP_API_LOCK(#_name); \
+ int _rv = ONLP_LOCKED_API_NAME(_name) (_v1, _v2, _v3); \
+ ONLP_API_UNLOCK(); \
+ return _rv; \
+ }
+
+#define ONLP_LOCKED_API4(_name, _t1, _v1, _t2, _v2, _t3, _v3, _t4, _v4) \
+ int _name (_t1 _v1, _t2 _v2, _t3 _v3, _t4 _v4) \
+ { \
+ ONLP_API_LOCK(#_name); \
+ int _rv = ONLP_LOCKED_API_NAME(_name) (_v1, _v2, _v3, _v4); \
+ ONLP_API_UNLOCK(); \
+ return _rv; \
+ }
+
+#define ONLP_LOCKED_API5(_name, _t1, _v1, _t2, _v2, _t3, _v3, _t4, _v4, _t5, _v5) \
+ int _name (_t1 _v1, _t2 _v2, _t3 _v3, _t4 _v4, _t5 _v5) \
+ { \
+ ONLP_API_LOCK(#_name); \
+ int _rv = ONLP_LOCKED_API_NAME(_name) (_v1, _v2, _v3, _v4, _v5); \
+ ONLP_API_UNLOCK(); \
+ return _rv; \
+ }
+
+#define ONLP_LOCKED_VAPI0(_name) \
+ void _name (void) \
+ { \
+ ONLP_API_LOCK(#_name); \
+ ONLP_LOCKED_API_NAME(_name)(); \
+ ONLP_API_UNLOCK(); \
+ }
+
+#define ONLP_LOCKED_VAPI1(_name, _t, _v) \
+ void _name (_t _v) \
+ { \
+ ONLP_API_LOCK(#_name); \
+ ONLP_LOCKED_API_NAME(_name)(_v); \
+ ONLP_API_UNLOCK(); \
+ }
+
+#define ONLP_LOCKED_VAPI2(_name, _t1, _v1, _t2, _v2) \
+ void _name (_t1 _v1, _t2 _v2) \
+ { \
+ ONLP_API_LOCK(#_name); \
+ ONLP_LOCKED_API_NAME(_name) (_v1, _v2); \
+ ONLP_API_UNLOCK(); \
+ }
+
+#define ONLP_LOCKED_VAPI3(_name, _t1, _v1, _t2, _v2, _t3, _v3) \
+ void _name (_t1 _v1, _t2 _v2, _t3 _v3) \
+ { \
+ ONLP_API_LOCK(#_name); \
+ ONLP_LOCKED_API_NAME(_name) (_v1, _v2, _v3); \
+ ONLP_API_UNLOCK(); \
+ }
+
+#define ONLP_LOCKED_VAPI4(_name, _t1, _v1, _t2, _v2, _t3, _v3, _t4, _v4) \
+ void _name (_t1 _v1, _t2 _v2, _t3 _v3, _t4 _v4) \
+ { \
+ ONLP_API_LOCK(#_name); \
+ ONLP_LOCKED_API_NAME(_name) (_v1, _v2, _v3, _v4); \
+ ONLP_API_UNLOCK(); \
+ }
+
+#define ONLP_LOCKED_VAPI5(_name, _t1, _v1, _t2, _v2, _t3, _v3, _t4, _v4, _t5, _v5) \
+ void _name (_t1 _v1, _t2 _v2, _t3 _v3, _t4 _v4, _t5 _v5) \
+ { \
+ ONLP_API_LOCK(#_name); \
+ ONLP_LOCKED_API_NAME(_name) (_v1, _v2, _v3, _v4, _v5); \
+ ONLP_API_UNLOCK(); \
+ }
+
+
+
+
+#endif /* __ONLP_LOCKS_H__ */
diff --git a/packages/base/any/onlp/src/onlp/module/src/onlp_log.c b/packages/base/any/onlp/src/onlp/module/src/onlp_log.c
new file mode 100644
index 00000000..80c87dcf
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/src/onlp_log.c
@@ -0,0 +1,38 @@
+/************************************************************
+ *
+ *
+ * Copyright 2014, 2015 Big Switch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ ************************************************************
+ *
+ *
+ *
+ ***********************************************************/
+
+#include
+
+#include "onlp_log.h"
+/*
+ * onlp log struct.
+ */
+AIM_LOG_STRUCT_DEFINE(
+ ONLP_CONFIG_LOG_OPTIONS_DEFAULT,
+ ONLP_CONFIG_LOG_BITS_DEFAULT,
+ NULL, /* Custom log map */
+ ONLP_CONFIG_LOG_CUSTOM_BITS_DEFAULT
+ );
+
diff --git a/packages/base/any/onlp/src/onlp/module/src/onlp_log.h b/packages/base/any/onlp/src/onlp/module/src/onlp_log.h
new file mode 100644
index 00000000..63b66c51
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/src/onlp_log.h
@@ -0,0 +1,32 @@
+/************************************************************
+ *
+ *
+ * Copyright 2014, 2015 Big Switch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ ************************************************************
+ *
+ *
+ *
+ ***********************************************************/
+
+#ifndef __ONLP_LOG_H__
+#define __ONLP_LOG_H__
+
+#define AIM_LOG_MODULE_NAME onlp
+#include
+
+#endif /* __ONLP_LOG_H__ */
diff --git a/packages/base/any/onlp/src/onlp/module/src/onlp_main.c b/packages/base/any/onlp/src/onlp/module/src/onlp_main.c
new file mode 100644
index 00000000..893d66ea
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/src/onlp_main.c
@@ -0,0 +1,311 @@
+/************************************************************
+ *
+ *
+ * Copyright 2014, 2015 Big Switch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ ************************************************************
+ *
+ *
+ *
+ ***********************************************************/
+#include
+#include
+#include
+#include
+#include
+#include
+
+/**
+ * Human-readable SFP inventory.
+ * This should be moved to common.
+ */
+static void
+show_inventory__(aim_pvs_t* pvs)
+{
+ int port;
+ onlp_sfp_bitmap_t bitmap;
+
+ onlp_sfp_bitmap_t_init(&bitmap);
+ onlp_sfp_bitmap_get(&bitmap);
+
+ if(AIM_BITMAP_COUNT(&bitmap) == 0) {
+ aim_printf(pvs, "No SFPs on this platform.\n");
+ }
+ else {
+ aim_printf(pvs, "Port Type Media Status Len Vendor Model S/N \n");
+ aim_printf(pvs, "---- -------------- ------ ------ ----- ---------------- ---------------- ----------------\n");
+
+ AIM_BITMAP_ITER(&bitmap, port) {
+ int rv;
+ uint8_t* data;
+
+ rv = onlp_sfp_is_present(port);
+
+ if(rv == 0) {
+ aim_printf(pvs, "%4d NONE\n", port);
+ continue;
+ }
+
+ if(rv < 0) {
+ aim_printf(pvs, "%4d Error %{onlp_status}\n", port, rv);
+ continue;
+ }
+
+ rv = onlp_sfp_eeprom_read(port, &data);
+
+ if(rv < 0) {
+ aim_printf(pvs, "%4d Error %{onlp_status}\n", port, rv);
+ continue;
+ }
+
+ sff_info_t sff;
+ char status_str[32] = {0};
+
+ sff_info_init(&sff, data);
+
+ if(!sff.supported) {
+ /* Present but unidentified. */
+ aim_printf(pvs, "%13d UNK\n", port);
+ continue;
+ }
+
+
+ uint32_t status = 0;
+ char* cp = status_str;
+ onlp_sfp_control_flags_get(port, &status);
+ if(status & ONLP_SFP_CONTROL_FLAG_RX_LOS) {
+ *cp++ = 'R';
+ }
+ if(status & ONLP_SFP_CONTROL_FLAG_TX_FAULT) {
+ *cp++ = 'T';
+ }
+ if(status & ONLP_SFP_CONTROL_FLAG_TX_DISABLE) {
+ *cp++ = 'X';
+ }
+ if(status & ONLP_SFP_CONTROL_FLAG_LP_MODE) {
+ *cp++ = 'L';
+ }
+ aim_printf(pvs, "%4d %-14s %-6s %-6.6s %-5.5s %-16.16s %-16.16s %16.16s\n",
+ port,
+ sff.module_type_name,
+ sff.media_type_name,
+ status_str,
+ sff.length_desc,
+ sff.vendor,
+ sff.model,
+ sff.serial);
+ }
+ }
+}
+
+
+static int
+iterate_oids_callback__(onlp_oid_t oid, void* cookie)
+{
+ int type = ONLP_OID_TYPE_GET(oid);
+ int id = ONLP_OID_ID_GET(oid);
+
+ static int thermal = 1;
+ static int fan = 1;
+ static int psu = 1;
+
+ switch(type)
+ {
+ case ONLP_OID_TYPE_THERMAL:
+ printf("thermal,Thermal %d,%d\n", id, thermal++);
+ break;
+ case ONLP_OID_TYPE_FAN:
+ printf("fan,Fan %d,%d\n", id, fan++);
+ break;
+ case ONLP_OID_TYPE_PSU:
+ printf("psu,PSU %d,%d\n", id, psu++);
+ break;
+ }
+ return 0;
+}
+
+
+static void
+iterate_oids__(void)
+{
+ onlp_oid_iterate(ONLP_OID_SYS, 0,
+ iterate_oids_callback__, NULL);
+}
+
+
+
+
+int
+onlpdump_main(int argc, char* argv[])
+{
+ int show = 0;
+ uint32_t showflags = 0;
+ int help = 0;
+ int c;
+ int rv = -1;
+ int j = 0;
+ int o = 0;
+ int m = 0;
+ int i = 0;
+ int p = 0;
+ int x = 0;
+ int S = 0;
+ const char* O = NULL;
+ const char* t = NULL;
+
+ while( (c = getopt(argc, argv, "srehdojmipxSt:O:")) != -1) {
+ switch(c)
+ {
+ case 's': show=1; break;
+ case 'r': show=1; showflags |= ONLP_OID_SHOW_F_RECURSE; break;
+ case 'e': show=1; showflags |= ONLP_OID_SHOW_F_EXTENDED; break;
+ case 'd': show=0; break;
+ case 'h': help=1; rv = 0; break;
+ case 'j': j=1; break;
+ case 'o': o=1; break;
+ case 'x': x=1; break;
+ case 'm': m=1; break;
+ case 'i': i=1; break;
+ case 'p': p=1; show=-1; break;
+ case 't': t = optarg; break;
+ case 'O': O = optarg; break;
+ case 'S': S=1; break;
+ default: help=1; rv = 1; break;
+ }
+ }
+
+ if(help) {
+ printf("Usage: %s [OPTIONS]\n", argv[0]);
+ printf(" -d Use dump(). This is the default.\n");
+ printf(" -s Use show() instead of dump().\n");
+ printf(" -r Recursive show(). Implies -s\n");
+ printf(" -e Extended show(). Implies -s\n");
+ printf(" -o Dump ONIE data only.\n");
+ printf(" -x Dump Platform Info only.\n");
+ printf(" -j Dump ONIE data in JSON format.\n");
+ printf(" -m Run platform manager.\n");
+ printf(" -i Iterate OIDs.\n");
+ printf(" -p Show SFP presence.\n");
+ printf(" -t Decode TlvInfo data.\n");
+ printf(" -O Dump OID.\n");
+ printf(" -S Decode SFP Inventory\n");
+ return rv;
+ }
+
+
+ if(t){
+ int rv;
+ onlp_onie_info_t onie;
+ rv = onlp_onie_decode_file(&onie, t);
+ if(rv >= 0) {
+ onlp_onie_show(&onie, &aim_pvs_stdout);
+ onlp_onie_info_free(&onie);
+ return 0;
+ }
+ else {
+ aim_printf(&aim_pvs_stdout, "Decode failed.");
+ return 1;
+ }
+ }
+
+ onlp_init();
+
+ if(S) {
+ show_inventory__(&aim_pvs_stdout);
+ return 0;
+ }
+
+ if(O) {
+ int oid;
+ if(sscanf(O, "0x%x", &oid) == 1) {
+ onlp_oid_dump(oid, &aim_pvs_stdout,
+ ONLP_OID_DUMP_F_RECURSE |
+ ONLP_OID_DUMP_F_EVEN_IF_ABSENT);
+ }
+ return 0;
+ }
+
+ if(i) {
+ iterate_oids__();
+ return 0;
+ }
+
+ if(o || x) {
+ onlp_sys_info_t si;
+ if(onlp_sys_info_get(&si) < 0) {
+ fprintf(stderr, "onlp_sys_info_get() failed.");
+ return 1;
+ }
+
+ if(o) {
+ if(j) {
+ onlp_onie_show_json(&si.onie_info, &aim_pvs_stdout);
+ }
+ else {
+ onlp_onie_show(&si.onie_info, &aim_pvs_stdout);
+ }
+ }
+
+ if(x) {
+ if(j) {
+ onlp_platform_info_show_json(&si.platform_info, &aim_pvs_stdout);
+ }
+ else {
+ onlp_platform_info_show(&si.platform_info, &aim_pvs_stdout);
+ }
+ }
+
+ onlp_sys_info_free(&si);
+ return 0;
+ }
+
+ if(show >= 0) {
+ if(show == 0) {
+ /* Default to full dump */
+ onlp_platform_dump(&aim_pvs_stdout,
+ ONLP_OID_DUMP_F_RECURSE | ONLP_OID_DUMP_F_EVEN_IF_ABSENT);
+ }
+ else {
+ onlp_platform_show(&aim_pvs_stdout,
+ showflags);
+ }
+ }
+
+
+ if(m) {
+ printf("Running the platform manager for 600 seconds...\n");
+ onlp_sys_platform_manage_start();
+ sleep(600);
+ printf("Stopping the platform manager.\n");
+ onlp_sys_platform_manage_stop();
+ }
+
+ if(p) {
+ onlp_sfp_bitmap_t presence;
+ onlp_sfp_bitmap_t_init(&presence);
+ int rv = onlp_sfp_presence_bitmap_get(&presence);
+ aim_printf(&aim_pvs_stdout, "Presence: ");
+ if(rv < 0) {
+ aim_printf(&aim_pvs_stdout, "Error %{onlp_status}\n", rv);
+ }
+ else {
+ aim_printf(&aim_pvs_stdout, "%{aim_bitmap}\n", &presence);
+ }
+ }
+
+ return 0;
+}
diff --git a/packages/base/any/onlp/src/onlp/module/src/onlp_module.c b/packages/base/any/onlp/src/onlp/module/src/onlp_module.c
new file mode 100644
index 00000000..4d050bd2
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/src/onlp_module.c
@@ -0,0 +1,70 @@
+/************************************************************
+ *
+ *
+ * Copyright 2014, 2015 Big Switch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ ************************************************************
+ *
+ *
+ *
+ ***********************************************************/
+
+#include
+
+#include "onlp_log.h"
+#include
+
+static int
+datatypes_init__(void)
+{
+#define ONLP_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL);
+#include
+
+
+ /*
+ * Register our flag maps.
+ */
+ AIM_DATATYPE_FMAP_REGISTER(onlp_sfp_control_flags, onlp_sfp_control_flag_map, "SFP Control Flags", AIM_LOG_INTERNAL);
+ AIM_DATATYPE_FMAP_REGISTER(onlp_fan_caps_flags, onlp_fan_caps_map, "FAN Capability Flags", AIM_LOG_INTERNAL);
+ AIM_DATATYPE_FMAP_REGISTER(onlp_fan_status_flags, onlp_fan_status_map, "FAN Status Flags", AIM_LOG_INTERNAL);
+ AIM_DATATYPE_FMAP_REGISTER(onlp_thermal_status_flags, onlp_thermal_status_map, "Thermal Status Flags", AIM_LOG_INTERNAL);
+ AIM_DATATYPE_FMAP_REGISTER(onlp_thermal_caps_flags, onlp_thermal_caps_map, "Thermal Capability Flags", AIM_LOG_INTERNAL);
+ AIM_DATATYPE_FMAP_REGISTER(onlp_led_caps_flags, onlp_led_caps_map, "LED Capability Flags", AIM_LOG_INTERNAL);
+ AIM_DATATYPE_FMAP_REGISTER(onlp_led_status_flags, onlp_led_status_map, "LED Status Flags", AIM_LOG_INTERNAL);
+ AIM_DATATYPE_FMAP_REGISTER(onlp_psu_status_flags, onlp_psu_status_map, "PSU Status Flags", AIM_LOG_INTERNAL);
+ AIM_DATATYPE_FMAP_REGISTER(onlp_psu_caps_flags, onlp_psu_caps_map, "PSU Capability Flags", AIM_LOG_INTERNAL);
+
+
+ return 0;
+}
+
+void __onlp_module_init__(void)
+{
+ AIM_LOG_STRUCT_REGISTER();
+ datatypes_init__();
+
+#if ONLP_CONFIG_INCLUDE_SHLOCK_GLOBAL_INIT == 1
+ onlp_shlock_global_init();
+#endif
+
+ {
+ extern int __onlp_platform_version__;
+ extern int __onlp_platform_version_default__;
+ __onlp_platform_version_default__ = __onlp_platform_version__;
+ }
+}
+
diff --git a/packages/base/any/onlp/src/onlp/module/src/onlp_ucli.c b/packages/base/any/onlp/src/onlp/module/src/onlp_ucli.c
new file mode 100644
index 00000000..a9a52401
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/src/onlp_ucli.c
@@ -0,0 +1,82 @@
+/************************************************************
+ *
+ *
+ * Copyright 2014, 2015 Big Switch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ ************************************************************
+ *
+ *
+ *
+ ***********************************************************/
+
+#include
+
+#if ONLP_CONFIG_INCLUDE_UCLI == 1
+
+#include
+#include
+#include
+
+static ucli_status_t
+onlp_ucli_ucli__config__(ucli_context_t* uc)
+{
+ UCLI_HANDLER_MACRO_MODULE_CONFIG(onlp)
+}
+
+/* */
+/******************************************************************************
+ *
+ * These handler table(s) were autogenerated from the symbols in this
+ * source file.
+ *
+ *****************************************************************************/
+static ucli_command_handler_f onlp_ucli_ucli_handlers__[] =
+{
+ onlp_ucli_ucli__config__,
+ NULL
+};
+/******************************************************************************/
+/* */
+
+static ucli_module_t
+onlp_ucli_module__ =
+ {
+ "onlp_ucli",
+ NULL,
+ onlp_ucli_ucli_handlers__,
+ NULL,
+ NULL,
+ };
+
+ucli_node_t*
+onlp_ucli_node_create(void)
+{
+ ucli_node_t* n;
+ ucli_module_init(&onlp_ucli_module__);
+ n = ucli_node_create("onlp", NULL, &onlp_ucli_module__);
+ ucli_node_subnode_add(n, ucli_module_log_node_create("onlp"));
+ return n;
+}
+
+#else
+void*
+onlp_ucli_node_create(void)
+{
+ return NULL;
+}
+#endif
+
diff --git a/packages/base/any/onlp/src/onlp/module/src/onlp_util.c b/packages/base/any/onlp/src/onlp/module/src/onlp_util.c
new file mode 100644
index 00000000..478317dd
--- /dev/null
+++ b/packages/base/any/onlp/src/onlp/module/src/onlp_util.c
@@ -0,0 +1,76 @@
+/************************************************************
+ *
+ *
+ * Copyright 2014, 2015 Big Switch Networks, Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ *
+ *
+ ************************************************************
+ *
+ *
+ *
+ ***********************************************************/
+#include
+#include