From 028164d3b930904de1d56899bd1854f5251a9f4b Mon Sep 17 00:00:00 2001 From: Erez Geva Date: Thu, 21 Apr 2022 01:36:04 +0200 Subject: [PATCH] New name and new version 0.6. Signed-off-by: Erez Geva --- .gitignore | 6 +- .reuse/dep5 | 6 +- Makefile | 80 +++++++++--------- README.md | 17 ++-- archlinux/.gitignore | 2 +- archlinux/Dockerfile | 2 +- archlinux/PKGBUILD.org | 80 +++++++++--------- archlinux/changelog | 43 ++++++++++ astyle.opt | 2 +- bin.h | 6 +- buf.h | 6 +- cfg.cpp | 8 +- cfg.h | 6 +- debian/.gitignore | 6 +- debian/changelog | 56 +++++++++++-- debian/control | 68 +++++++-------- debian/copyright | 4 +- debian/rules | 42 +++++----- doxygen.cfg | 6 +- end.h | 6 +- err.h | 24 +++--- init.cpp | 34 ++++---- init.h | 6 +- json.cpp | 44 +++++----- json.h | 10 +-- libpmc.cbp => libptpmgmt.cbp | 2 +- libpmc.i => libptpmgmt.i | 6 +- lua/.gitignore | 2 +- lua/test.lua | 84 +++++++++---------- mngIds.cc | 6 +- msg.cpp | 6 +- msg.h | 6 +- new_version.sh | 4 +- opt.h | 6 +- perl/.gitignore | 4 +- perl/test.pl | 78 +++++++++--------- php/.gitignore | 6 +- php/php_ini.sh | 2 +- php/test.php | 48 +++++------ pmc.cpp | 2 +- pmc.h | 14 ++-- proc.h | 6 +- ptp.cpp | 16 ++-- ptp.h | 6 +- python/.gitignore | 6 +- python/test.py | 82 +++++++++---------- rpm/.gitignore | 6 +- rpm/Dockerfile | 2 +- rpm/{libpmc.spec => libptpmgmt.spec} | 118 ++++++++++++++++++--------- ruby/.gitignore | 2 +- ruby/test.rb | 80 +++++++++--------- sample/checksync.cpp | 4 +- sample/sync.pl | 34 ++++---- sample/sync_watch.py | 74 ++++++++--------- scripts/lib.ver | 4 +- sig.h | 6 +- sock.cpp | 58 ++++++------- sock.h | 6 +- tcl/.gitignore | 2 +- tcl/test.tcl | 6 +- testJson.pl | 26 +++--- testing.sh | 42 +++++----- update_changelog.pl | 6 +- ver.h | 6 +- version | 2 +- 65 files changed, 790 insertions(+), 656 deletions(-) rename libpmc.cbp => libptpmgmt.cbp (97%) rename libpmc.i => libptpmgmt.i (98%) rename rpm/{libpmc.spec => libptpmgmt.spec} (70%) diff --git a/.gitignore b/.gitignore index 8d2cbe63..4a650926 100644 --- a/.gitignore +++ b/.gitignore @@ -14,10 +14,10 @@ .sw? .*.sw? /.libs/ -/libpmc.a +/libptpmgmt.a /pmc /tags /doc # For codeblocks -/libpmc.depend -/libpmc.layout +/libptpmgmt.depend +/libptpmgmt.layout diff --git a/.reuse/dep5 b/.reuse/dep5 index 54ae2bed..07c019c7 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -1,12 +1,12 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: libpmc +Upstream-Name: libptpmgmt Upstream-Contact: Erez Geva -Source: https://github.com/erezgeva/libpmc.git +Source: https://github.com/erezgeva/libptpmgmt.git Files: *.md */changelog Copyright: 2021 Erez Geva License: GFDL-1.3-no-invariants-or-later -Files: debian/co* debian/source/format libpmc.cbp +Files: debian/co* debian/source/format libptpmgmt.cbp Copyright: 2021 Erez Geva License: GPL-3.0-or-later diff --git a/Makefile b/Makefile index 67fb96cc..82e9ced0 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later # SPDX-FileCopyrightText: Copyright 2021 Erez Geva # -# Makefile Create libpmc and pmc for testing +# Makefile Create libptpmgmt and pmc for testing # # @author Erez Geva # @copyright 2021 Erez Geva @@ -65,7 +65,7 @@ define help # # # SONAME_USE_MAJ Use soname with major version # # # -# DEV_PKG Development package name, default libpmc-dev. # +# DEV_PKG Development package name, default libptpmgmt-dev. # # # # PY_LIBDIR Python libraries folder, default /usr/lib/python # # # @@ -99,9 +99,9 @@ define help # # # NO_TCL Prevent compiling TCL Swig plugin. # # # -# PMC_USE_CJSON Use C JSON for parsing JSON into PTP management message. # +# USE_CJSON Use C JSON for parsing JSON into PTP management message. # # # -# PMC_USE_FCJSON Use C JSON for parsing JSON into PTP management message. # +# USE_FCJSON Use C JSON for parsing JSON into PTP management message. # # Use fast JSON library. # # # # DEB_ARC Specify Debian architectue to build # @@ -210,7 +210,7 @@ LIB_VER:=$(ver_maj).$(ver_min) ifdef SONAME_USE_MAJ SONAME:=.$(ver_maj) endif -LIB_NAME:=libpmc +LIB_NAME:=libptpmgmt LIB_NAME_SO:=$(LIB_NAME).so LIB_FNAME_SO:=$(LIB_NAME_SO).$(LIB_VER) LIB_SNAME_SO:=$(LIB_NAME_SO)$(SONAME) @@ -223,19 +223,19 @@ PMC_OBJS:=$(patsubst %.cpp,%.o,$(wildcard pmc*.cpp)) LIB_OBJS:=$(filter-out $(PMC_OBJS),$(patsubst %.cpp,%.o,$(SRCS))) PMC_NAME:=pmc ver.o: CPPFLAGS+=-DVER_MAJ=$(ver_maj) -DVER_MIN=$(ver_min) -ifdef PMC_USE_CJSON +ifdef USE_CJSON ifneq ($(wildcard /usr/include/json-c/json.h),) -json.o: CPPFLAGS+=-DPMC_USE_CJSON -isystem /usr/include/json-c +json.o: CPPFLAGS+=-DPTPMGMT_USE_CJSON -isystem /usr/include/json-c LDLIBS_LIB+=-ljson-c endif # wildcard json.h -else # PMC_USE_CJSON -ifdef PMC_USE_FCJSON +else # USE_CJSON +ifdef USE_FCJSON ifneq ($(wildcard /usr/include/libfastjson/json.h),) -json.o: CPPFLAGS+=-DPMC_USE_CJSON -isystem /usr/include/libfastjson +json.o: CPPFLAGS+=-DPTPMGMT_USE_CJSON -isystem /usr/include/libfastjson LDLIBS_LIB+=-lfastjson endif # wildcard json.h -endif # PMC_USE_FCJSON -endif # PMC_USE_CJSON +endif # USE_FCJSON +endif # USE_CJSON ifeq ($(call verCheck,$(shell $(CXX) -dumpversion),4.9),) # GCC output colors @@ -311,12 +311,12 @@ define verDef * @copyright 2021 Erez Geva\n *\n * This header is generated automatically.\n *\n */\n\n -#ifndef __PMC_VER_DEFS_H\n -#define __PMC_VER_DEFS_H\n\n -#define LIBPMC_VER_MAJ ($(ver_maj)) /**< Library version major */\n -#define LIBPMC_VER_MIN ($(ver_min)) /**< Library version minor */\n -#define LIBPMC_VER "$(ver_maj).$(ver_min)" /**< Library version string */\n\n -#endif /* __PMC_VER_DEFS_H */\n +#ifndef __PTPMGMT_VER_DEFS_H\n +#define __PTPMGMT_VER_DEFS_H\n\n +#define LIBPTPMGMT_VER_MAJ ($(ver_maj)) /**< Library version major */\n +#define LIBPTPMGMT_VER_MIN ($(ver_min)) /**< Library version minor */\n +#define LIBPTPMGMT_VER "$(ver_maj).$(ver_min)" /**< Library version string */\n\n +#endif /* __PTPMGMT_VER_DEFS_H */\n endef verDef.h: version @@ -356,7 +356,7 @@ swig_ver=$(lastword $(shell swig -version | grep Version)) ifeq ($(call verCheck,$(swig_ver),3.0),) SWIG:=swig SWIG_ALL:= -SWIG_NAME:=PmcLib +SWIG_NAME:=PtpMgmtLib ifndef NO_PERL ifneq ($(call which,perl),) @@ -389,7 +389,7 @@ endif # NO_PERL ifndef NO_LUA ifneq ($(call which,lua),) -LUA_LIB_NAME:=pmc.so +LUA_LIB_NAME:=ptpmgmt.so lua/$(SWIG_NAME).cpp: $(LIB_NAME).i $(HEADERS_ALL) $(Q_SWIG) $Q$(SWIG) -Wall -c++ -I. -outdir lua -o $@ -lua $< @@ -481,7 +481,7 @@ endif ifdef USE_PY PY_BASE:=python/$(SWIG_NAME) -PY_LIB_NAME:=_pmc +PY_LIB_NAME:=_ptpmgmt PY_LIBDIR?=/usr/lib/python ifeq ($(PY_USE_S_THRD),) SWIG_PY_FLAGS:=-threads -DSWIG_USE_MULTITHREADS @@ -491,7 +491,7 @@ $(PY_BASE).cpp: $(LIB_NAME).i $(HEADERS_ALL) $(Q_SWIG) $Q$(SWIG) -Wall -c++ -I. -outdir python -o $@ -python $(SWIG_PY_FLAGS) $< -DISTCLEAN+=$(PY_BASE).cpp $(wildcard python/*.so) python/pmc.py python/pmc.pyc +DISTCLEAN+=$(PY_BASE).cpp $(wildcard python/*.so) python/ptpmgmt.py python/ptpmgmt.pyc DISTCLEAN_DIRS+=python/__pycache__ ifdef USE_PY2 $(eval $(call python,2)) @@ -524,7 +524,7 @@ RUBY_LIB:=$(call rep_arch_f,$(RUBY_LIB)) RUBYDIR:=$(call rep_arch_f,$(RUBYDIR)) endif RUBY_NAME:=ruby/$(SWIG_NAME).cpp -RUBY_LNAME:=ruby/pmc +RUBY_LNAME:=ruby/ptpmgmt $(RUBY_NAME): $(LIB_NAME).i $(HEADERS_ALL) $(Q_SWIG) $Q$(SWIG) -c++ -I. -outdir ruby -o $@ -ruby $< @@ -558,7 +558,7 @@ PHPIDIR:=$(DESTDIR)$(lastword $(subst :, ,$(shell\ php -r 'echo get_include_path();'))) PHP_INC:=-Iphp $(shell $(PHPCFG) --includes) PHP_NAME:=php/$(SWIG_NAME).cpp -PHP_LNAME:=php/pmc +PHP_LNAME:=php/ptpmgmt $(PHP_NAME): $(LIB_NAME).i $(HEADERS_ALL) $(Q_SWIG) $Q$(SWIG) -c++ -I. -outdir php -o $@ -php7 $< @@ -569,7 +569,7 @@ $(PHP_LNAME).so: $(PHP_LNAME).o $(LIB_NAME_SO) $(Q_LD) $Q$(CXX) $(LDFLAGS) -shared $^ $(LOADLIBES) $(LDLIBS) -o $@ SWIG_ALL+=$(PHP_LNAME).so -CLEAN+=$(PHP_NAME) $(foreach e,d o,$(PHP_LNAME).$e) php/php_pmc.h +CLEAN+=$(PHP_NAME) $(foreach e,d o,$(PHP_LNAME).$e) php/php_ptpmgmt.h DISTCLEAN+=$(PHP_LNAME).so $(PHP_LNAME).php php/php.ini else # SWIG 3.0.12 NO_PHP=1 @@ -595,7 +595,7 @@ ifneq ($(call which,tclsh)),) tcl_ver!=echo 'puts $$tcl_version;exit 0' | tclsh ifeq ($(call verCheck,$(tcl_ver),8.0),) TCL_NAME:=tcl/$(SWIG_NAME).cpp -TCL_LNAME:=tcl/pmc +TCL_LNAME:=tcl/ptpmgmt CPPFLAGS_TCL+=-I $(TCL_INC) $(TCL_NAME): $(LIB_NAME).i $(HEADERS_ALL) $(Q_SWIG) @@ -620,11 +620,11 @@ else TCL_LIB:=$(firstword $(shell echo $(tcl_paths) |\ $(SED) 's/ /\n/g' | grep '/usr/lib.*/tcl')) endif -TCLDIR:=$(DESTDIR)$(TCL_LIB)/pmc +TCLDIR:=$(DESTDIR)$(TCL_LIB)/ptpmgmt # TODO how the hell tcl "know" the library version? Why does it think it's 0.0? define pkgIndex if {![package vsatisfies [package provide Tcl] $(tcl_ver)]} {return} -package ifneeded pmc 0.0 [list load [file join $$dir pmc.so]] +package ifneeded ptpmgmt 0.0 [list load [file join $$dir ptpmgmt.so]] endef else # tcl_ver 8.0 NO_TCL=1 @@ -683,7 +683,7 @@ endif # and wildcard debian/rules, which dpkg-buildpackage SRC_FILES:=$(wildcard *.cc *.i */test.* scripts/* *.sh *.pl *.md *.cfg *.opt\ php/*.sh) LICENSE $(wordlist 1,2,$(MAKEFILE_LIST)) $(HEADERS_SRCS) $(SRCS) -SRC_NAME:=libpmc-$(LIB_VER) +SRC_NAME:=libptpmgmt-$(LIB_VER) ####### rpm build ####### RPM_SRC:=rpm/SOURCES/$(SRC_NAME).txz @@ -692,7 +692,7 @@ $(RPM_SRC): $(SRC_FILES) $Q$(TAR) $@ $^ --transform "s#^#$(SRC_NAME)/#S" ifneq ($(call which,rpmbuild),) rpm: $(RPM_SRC) - $(Q)rpmbuild --define "_topdir $(PWD)/rpm" -bb rpm/libpmc.spec + $(Q)rpmbuild --define "_topdir $(PWD)/rpm" -bb rpm/libptpmgmt.spec endif # which rpmbuild rpmsrc: $(RPM_SRC) DISTCLEAN_DIRS+=$(wildcard rpm/[BRS]*) @@ -725,10 +725,10 @@ LIBDIR?=/usr/lib/$(TARGET_ARCH) else LIBDIR?=/usr/lib endif -DEV_PKG?=libpmc-dev +DEV_PKG?=libptpmgmt-dev SBINDIR?=/usr/sbin LUADIR:=$(DESTDIR)$(LIBDIR) -DOCDIR:=$(DESTDIR)/usr/share/doc/libpmc-doc +DOCDIR:=$(DESTDIR)/usr/share/doc/libptpmgmt-doc MANDIR:=$(DESTDIR)/usr/share/man/man8 ifndef PY2_ARCH ifneq ($(TARGET_ARCH),) @@ -744,15 +744,15 @@ ifdef SONAME_USE_MAJ else $Q$(NINST) -D $(LIB_NAME_SO) $(DESTDIR)$(LIBDIR)/$(LIB_NAME_SO) endif - $Q$(NINST) libpmc.a $(DESTDIR)$(LIBDIR) - $Q$(NINST) -D $(HEADERS) verDef.h -t $(DESTDIR)/usr/include/pmc + $Q$(NINST) libptpmgmt.a $(DESTDIR)$(LIBDIR) + $Q$(NINST) -D $(HEADERS) verDef.h -t $(DESTDIR)/usr/include/ptpmgmt $Q$(foreach f,$(HEADERS),$(SED) -i\ - 's!#include\s*\"\([^"]\+\)\"!#include !'\ - $(DESTDIR)/usr/include/pmc/$f;) + 's!#include\s*\"\([^"]\+\)\"!#include !'\ + $(DESTDIR)/usr/include/ptpmgmt/$f;) $Q$(NINST) -D scripts/*.mk -t $(DESTDIR)/usr/share/$(DEV_PKG) - $Q$(BINST) -D pmc $(DESTDIR)$(SBINDIR)/pmc.lib + $Q$(BINST) -D pmc $(DESTDIR)$(SBINDIR)/pmc-ptpmgmt $Q$(DINST) $(MANDIR) - $Q$(LN) pmc.8.gz $(MANDIR)/pmc.lib.8.gz + $Q$(LN) pmc.8.gz $(MANDIR)/pmc-ptpmgmt.8.gz $Q$(RM) doc/html/*.md5 $Q$(DINST) $(DOCDIR) $(Q)cp -a doc/html $(DOCDIR) @@ -777,12 +777,12 @@ endif # NO_LUA ifdef USE_PY2 $Q$(NINST) -D python/2/$(PY_LIB_NAME).so\ $(PY2_DIR)/$(PY_LIB_NAME)$(PY2_ARCH).so - $Q$(NINST) python/pmc.py $(PY2_DIR) + $Q$(NINST) python/ptpmgmt.py $(PY2_DIR) endif ifdef USE_PY3 $Q$(NINST) -D python/3/$(PY_LIB_NAME).so\ $(PY3_DIR)/$(PY_LIB_NAME)$(PY3_EXT) - $Q$(NINST) python/pmc.py $(PY3_DIR) + $Q$(NINST) python/ptpmgmt.py $(PY3_DIR) endif ifndef NO_RUBY $Q$(NINST) -D $(RUBY_LNAME).so -t $(RUBYDIR) diff --git a/README.md b/README.md index 6d4454b8..90b12744 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# libpmc library to communicate with IEEE 1558 PTP clocks +# libptpmgmt library to communicate with IEEE 1558 PTP clocks # Preface @@ -15,7 +15,7 @@ In addition, we support using the Unix network and communicate with linuxptp ptp We support also parsing incoming signaling messages. -# libpmc Library +# libptpmgmt Library The library is written in C++ using a data-oriented model. Each class represent a data object with methods acting on the data. The socket classes are the exception, as they represent a system object. @@ -48,29 +48,30 @@ For now, we support: >             > for example in PHP: Binary::empty is renamed to Binary::c_empty >             -> See remarks in libpmc.i for all changes +> See remarks in libptpmgmt.i for all changes # Library content * Binary in bin.h - class that hold a binary * Buf in buf.h - Allocate buffer for scripting * ConfigFile in cfg.h - Read, parse and provide configuration from configuration file - * Message in msg.h - Create and parse Managment and Signaling PTP messages + * Message in msg.h - Create and parse Management and Signaling PTP messages * IfInfo in ptp.h - Provide information on a network interface * PtpClock in ptp.h - Provide a PTP dynamic clock ID * sockets classes in sock.h - Provide access to UPD IPv4, IPv6 and L2 PTP networks * SockUnix in sock.h - socket to communicate with local linuxptp daemon - * Managment TLVs in proc.h - structures that hold a PTP Managment TLV data + * Management TLVs in proc.h - structures that hold a PTP Management TLV data * Signaling TLVs in sig.h - structures that hold a PTP Signaling TLV data - * Library version in ver.h + * Runtime library version in ver.h + * Library version used during build in verDef.h * Json2msg in json.h - Convert json text to a message, require linking with a JSON library * msg2json in json.h - Convert message to json text * Options in opt.h - parse a pmc tool command line parameters * Init in init.h - Initilize objects for a pmc tool # pmc tool -The project provides a clone to [linuxptp](http://linuxptp.sf.net/) -pmc tool that uses the libpmc library. +The project provides a clone of [LinuxPTP](http://linuxptp.sf.net) +pmc tool using the libptpmgmt library. The project does not provide a manual page to the tool. As the tool mimic the original tool in command line, input and in output. Please refer to the [pmc man page](https://manpages.debian.org/unstable/linuxptp/pmc.8.en.html) diff --git a/archlinux/.gitignore b/archlinux/.gitignore index cd4f7d39..d13eb69a 100644 --- a/archlinux/.gitignore +++ b/archlinux/.gitignore @@ -5,6 +5,6 @@ # @copyright 2021 Erez Geva # ############################################################################### -/libpmc-*.txz +/libptpmgmt-*.txz /PKGBUILD /*.pkg.tar.zst diff --git a/archlinux/Dockerfile b/archlinux/Dockerfile index 9895cc1c..99c7a3c3 100644 --- a/archlinux/Dockerfile +++ b/archlinux/Dockerfile @@ -19,4 +19,4 @@ RUN patched_glibc=glibc-linux4-2.33-4-x86_64.pkg.tar.zst &&\ echo "$USER ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers USER $USER ARG SRC -COPY --chown=builder $SRC /home/$USER/libpmc +COPY --chown=builder $SRC /home/$USER/libptpmgmt diff --git a/archlinux/PKGBUILD.org b/archlinux/PKGBUILD.org index ee269857..5d515f9c 100644 --- a/archlinux/PKGBUILD.org +++ b/archlinux/PKGBUILD.org @@ -7,14 +7,14 @@ # @copyright 2021 Erez Geva # ############################################################################### -pkgver=0.5 +pkgver=0.6 pkgrel=1 -pkgname=(libpmc libpmc-dev libpmc-doc libpmc-perl lua-pmc ruby-pmc tcl-pmc - python2-pmc python3-pmc pmc) +pkgname=(libptpmgmt libptpmgmt-dev libptpmgmt-doc libptpmgmt-perl lua-ptpmgmt + ruby-ptpmgmt tcl-ptpmgmt python2-ptpmgmt python3-ptpmgmt pmc-ptpmgmt) # Source code can be build on most architectures # But as Arch Linux does not support the 'all' keyword arch=(x86_64) -url=https://libpmc.sf.net +url=https://github.com/erezgeva/libptpmgmt license=(LGPL3) source=("$pkgname-$pkgver.txz") build() { @@ -22,90 +22,90 @@ build() { make -j LD_SONAME=1 CPPFLAGS_OPT=-Ofast PMC_USE_LIB=so SONAME_USE_MAJ=1\ NO_PHP=1 --no-print-directory # Place here as make do not use packages! - make -j DESTDIR=install install DEV_PKG=libpmc-dev SBINDIR=/usr/bin\ + make -j DESTDIR=install install DEV_PKG=libptpmgmt-dev SBINDIR=/usr/bin\ NO_PHP=1 SONAME_USE_MAJ=1 LIBDIR=/usr/lib --no-print-directory } makedepends=(doxygen graphviz perl ruby tcl swig lua lua51 lua52 lua53\ python2 python3) -package_libpmc() { - pkgdesc='pmc library, to communicate with ptp4l' +package_libptpmgmt() { + pkgdesc='PTP management library, to communicate with ptp4l' mkdir -p $pkgdir/usr/lib - mv $srcdir/install/usr/lib/libpmc.so.* $pkgdir/usr/lib + mv $srcdir/install/usr/lib/libptpmgmt.so.* $pkgdir/usr/lib } -package_libpmc-dev() { +package_libptpmgmt-dev() { # development package can use static library # But as Arch linux does not use development packages, we add it here options=(staticlibs) pkgdesc=< #include @@ -288,4 +288,4 @@ class Binary } }; -#endif /* __PMC_BIN_H */ +#endif /* __PTPMGMT_BIN_H */ diff --git a/buf.h b/buf.h index ddad8706..640678e9 100644 --- a/buf.h +++ b/buf.h @@ -9,8 +9,8 @@ * */ -#ifndef __PMC_BUF_H -#define __PMC_BUF_H +#ifndef __PTPMGMT_BUF_H +#define __PTPMGMT_BUF_H #include #include @@ -63,4 +63,4 @@ class Buf bool isAlloc() const {return m_size > 0;} }; -#endif /* __PMC_BUF_H */ +#endif /* __PTPMGMT_BUF_H */ diff --git a/cfg.cpp b/cfg.cpp index 2ece8db0..ce86ae08 100644 --- a/cfg.cpp +++ b/cfg.cpp @@ -145,13 +145,13 @@ ConfigFile::ConfigFile() : cfgGlobal(cfgSec[globalSection]) bool ConfigFile::read_cfg(const std::string &_file) { if(_file.empty()) { - PMC_ERROR("Empty file name"); + PTPMGMT_ERROR("Empty file name"); return false; } const char *file = _file.c_str(); FILE *f = fopen(file, "r"); if(f == nullptr) { - PMC_ERRORA("fail to open %s: %m", file); + PTPMGMT_ERRORA("fail to open %s: %m", file); return false; } char buf[512]; @@ -166,14 +166,14 @@ bool ConfigFile::read_cfg(const std::string &_file) cur = skip_spaces(cur + 1); char *end = strchr(cur, ']'); if(end == nullptr) { - PMC_ERRORA("wrong line in %s: '%s'", file, buf); + PTPMGMT_ERRORA("wrong line in %s: '%s'", file, buf); return false; } strip_end_spaces(end); curSection = cur; } else if(*cur != 0 && *cur != '#' && !cfgSec[curSection].set_val(cur)) { - PMC_ERRORA("wrong line in %s: '%s'", file, buf); + PTPMGMT_ERRORA("wrong line in %s: '%s'", file, buf); return false; } } diff --git a/cfg.h b/cfg.h index ec7cd59f..d7e27a0b 100644 --- a/cfg.h +++ b/cfg.h @@ -13,8 +13,8 @@ * */ -#ifndef __PMC_CFG_H -#define __PMC_CFG_H +#ifndef __PTPMGMT_CFG_H +#define __PTPMGMT_CFG_H #include #include @@ -148,4 +148,4 @@ class ConfigFile const Binary &p2p_dst_mac(const std::string §ion = "") const; }; -#endif /* __PMC_CFG_H */ +#endif /* __PTPMGMT_CFG_H */ diff --git a/debian/.gitignore b/debian/.gitignore index 4c588e9c..0c568e1e 100644 --- a/debian/.gitignore +++ b/debian/.gitignore @@ -9,7 +9,7 @@ /*.substvars /.*debhelper* /*debhelper* -/libpmc*/ +/libptpmgmt*/ /tmp/ -/pmc/ -/*-pmc/ +/pmc-ptpmgmt/ +/*-ptpmgmt/ diff --git a/debian/changelog b/debian/changelog index 621b1504..21030d45 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,50 @@ -libpmc (0.5) buster; urgency=medium +libptpmgmt (0.6) bullseye; urgency=medium + + * Improve make file + * - Add missing files to source tar file for RPM and Arch Linux + * - Add Cppcheck code analysis on format rule. + * Compliant with the FSF REUSE Specification 3.0 + * Python SWIG + * - Support multithread, make sure poll() and tpoll() + * do not block other threads + * - Use flag for single thread mode + * Add fileno() interface as it follow POSIX function and + * also supported by Python select module, and probably more. + * Convert C macros for NP_SUBSCRIBE_EVENTS with method + * to support scripting. + * Sample code + * - Add sample/sync_watch.py by Martin Pecka form + * Czech Technical University in Prague + * - Add sample code for probing PTP daemon for synchronization. + * Improve RPM specification. + * Add no return attribute to signal handlers. + * LinuxPTP new management TLVs: + * - PORT_HWCLOCK_NP TLV. + * - UNICAST_MASTER_TABLE_NP TLV. + * Improve copyright. + * Add header with version for compilation. + * in addition to version in run time. + * Improve testing script: + * - Verify Linux PTP configuration file exit. + * - Check that script can use sudo unless we use the root user. + * - Probe Unix socket file location from configuration file. + * - Try to change Linux PTP Unix socket file permissions. + * - Patch Linux PTP daemon if Unix socket file does not exist. + * - Show Linux PTP daemon command line only if we find the folder. + * Message process of float 64 + * - Remove wrong calling to move + * - Improve function syntax + * - Add macro for rare hardware which does not use IEEE 754. + * Add new linuxptp linuxptpPowerProfileVersion_e enumerator + * Fix wrong process of linuxptpTimeStamp_e enumerator in json module. + * Use short string form of clockAccuracy_e enumerator. + * cast characters in Binary::eui48ToEui64(). + * Add constant modifier to configuration file reference + * in the socket classes. + + -- Erez Geva Mon, 18 Apr 2022 18:36:16 +0200 + +libptpmgmt (0.5) buster; urgency=medium * Add equal and less than operators to Binary, ClockIdentity_t, PortIdentity_t and PortAddress_t. @@ -24,7 +70,7 @@ libpmc (0.5) buster; urgency=medium -- Erez Geva Sun, 31 Oct 2021 13:06:17 +0100 -libpmc (0.4) buster; urgency=medium +libptpmgmt (0.4) buster; urgency=medium * Improve check after calling strtol. * Use C++ short loop form. @@ -53,7 +99,7 @@ libpmc (0.4) buster; urgency=medium -- Erez Geva Mon, 14 Jun 2021 13:08:16 +0200 -libpmc (0.3) buster; urgency=medium +libptpmgmt (0.3) buster; urgency=medium * Add licence to Javadoc comments for Doxygen process in addition to SPDX tag. * Set document licence to GNU Free Documentation License version 1.3 @@ -97,7 +143,7 @@ libpmc (0.3) buster; urgency=medium -- Erez Geva Tue, 20 Apr 2021 13:24:29 +0200 -libpmc (0.2) buster; urgency=medium +libptpmgmt (0.2) buster; urgency=medium * Add Ruby to read-me. * Add long options to the pmc tool. @@ -137,7 +183,7 @@ libpmc (0.2) buster; urgency=medium -- Erez Geva Mon, 05 Apr 2021 14:27:07 +0200 -libpmc (0.1) buster; urgency=medium +libptpmgmt (0.1) buster; urgency=medium * Alpha version. diff --git a/debian/control b/debian/control index 269bff11..445c7c1f 100644 --- a/debian/control +++ b/debian/control @@ -1,4 +1,4 @@ -Source: libpmc +Source: libptpmgmt Maintainer: Erez Geva Section: net Priority: optional @@ -9,108 +9,108 @@ Build-Depends-Arch: dh-python, dh-lua, dh-php, libtool, coreutils, liblua5.2-dev, liblua5.3-dev, ruby:native, ruby-dev, python3-dev:native, libpython3-dev, php-dev, tcl-dev Build-Depends-Indep: graphviz, doxygen -Homepage: https://libpmc.sf.net +Homepage: https://github.com/erezgeva/libptpmgmt -Package: libpmc +Package: libptpmgmt Architecture: any Multi-Arch: same Section: libs Pre-Depends: ${misc:Pre-Depends} Depends: ${misc:Depends}, ${shlibs:Depends} Recommends: linuxptp -Description: pmc library, to communicate with ptp4l +Description: PTP management library, to communicate with ptp4l -Package: libpmc-dev +Package: libptpmgmt-dev Architecture: any Multi-Arch: same Section: libdevel Pre-Depends: ${misc:Pre-Depends} -Depends: g++, ${misc:Depends}, libpmc (= ${binary:Version}) -Description: pmc library development +Depends: g++, ${misc:Depends}, libptpmgmt (= ${binary:Version}) +Description: PTP management library development This package provides header files and static library. -Package: libpmc-doc +Package: libptpmgmt-doc Architecture: all Section: libs Pre-Depends: ${misc:Pre-Depends} -Depends: libpmc (= ${binary:Version}) -Description: pmc library documentation, to communicate with ptp4l +Depends: libptpmgmt (= ${binary:Version}) +Description: PTP management library documentation, to communicate with ptp4l -Package: libpmc-perl +Package: libptpmgmt-perl Architecture: any Multi-Arch: same Section: perl Pre-Depends: ${misc:Pre-Depends} Provides: ${perl:Provides} Depends: ${misc:Depends}, ${shlibs:Depends}, ${perl:Depends}, - libpmc (= ${binary:Version}) -Description: pmc library Perl wrapper + libptpmgmt (= ${binary:Version}) +Description: PTP management library Perl wrapper -Package: python-pmc +Package: python-ptpmgmt Architecture: any Multi-Arch: same Section: python Pre-Depends: ${misc:Pre-Depends} Provides: ${python:Provides} Depends: ${misc:Depends}, ${shlibs:Depends}, ${python:Depends}, - libpmc (= ${binary:Version}) -Description: pmc library python version 2 wrapper + libptpmgmt (= ${binary:Version}) +Description: PTP management library python version 2 wrapper -Package: python3-pmc +Package: python3-ptpmgmt Architecture: any Multi-Arch: same Section: python Pre-Depends: ${misc:Pre-Depends} Provides: ${python3:Provides} Depends: ${misc:Depends}, ${shlibs:Depends}, ${python3:Depends}, - libpmc (= ${binary:Version}) -Description: pmc library python version 3 wrapper + libptpmgmt (= ${binary:Version}) +Description: PTP management library python version 3 wrapper -Package: lua-pmc +Package: lua-ptpmgmt Architecture: any Multi-Arch: same Section: interpreters Pre-Depends: ${misc:Pre-Depends} Provides: ${lua:Provides} -Depends: ${misc:Depends}, ${shlibs:Depends}, libpmc (= ${binary:Version}) +Depends: ${misc:Depends}, ${shlibs:Depends}, libptpmgmt (= ${binary:Version}) XB-Lua-Versions: ${lua:Versions} -Description: pmc library Lua wrapper +Description: PTP management library Lua wrapper -Package: ruby-pmc +Package: ruby-ptpmgmt Architecture: any Multi-Arch: same Section: ruby Pre-Depends: ${misc:Pre-Depends} Provides: ${ruby:Provides} Depends: ruby | ruby-interpreter, ${misc:Depends}, ${shlibs:Depends}, - ${ruby:Depends}, libpmc (= ${binary:Version}) -Description: pmc library ruby wrapper + ${ruby:Depends}, libptpmgmt (= ${binary:Version}) +Description: PTP management library ruby wrapper -Package: php-pmc +Package: php-ptpmgmt Architecture: any Section: php Pre-Depends: php-common (>= 2:69), ${misc:Pre-Depends} Provides: ${php:Provides} Depends: ${misc:Depends}, ${shlibs:Depends}, ${php:Depends}, - libpmc (= ${binary:Version}) -Description: pmc library php wrapper + libptpmgmt (= ${binary:Version}) +Description: PTP management library php wrapper -Package: tcl-pmc +Package: tcl-ptpmgmt Architecture: any Multi-Arch: same Section: interpreters Pre-Depends: ${misc:Pre-Depends} Provides: ${tcl:Provides} Depends: ${misc:Depends}, ${shlibs:Depends}, ${tcl:Depends}, tcl, - libpmc (= ${binary:Version}) -Description: pmc library tcl wrapper + libptpmgmt (= ${binary:Version}) +Description: PTP management library tcl wrapper -Package: pmc +Package: pmc-ptpmgmt Architecture: any Section: libs Pre-Depends: ${misc:Pre-Depends} -Depends: ${misc:Depends}, libpmc (= ${binary:Version}) +Depends: ${misc:Depends}, libptpmgmt (= ${binary:Version}) Recommends: linuxptp Description: pmc tool. - new rewrite of linuxptp pmc tool using the libpmc library. + new rewrite of LinuxPTP pmc tool using the PTP management library. This tool is faster than the original linuxptp tool. diff --git a/debian/copyright b/debian/copyright index fd2f4b0e..384cfb77 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,6 +1,6 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: libpmc -Source: https://github.com/erezgeva/libpmc.git +Upstream-Name: libptpmgmt +Source: https://github.com/erezgeva/libptpmgmt.git Files: * Copyright: 2021 Erez Geva diff --git a/debian/rules b/debian/rules index ee994e30..f09537d2 100755 --- a/debian/rules +++ b/debian/rules @@ -25,7 +25,7 @@ export CPPFLAGS_OPT=-Ofast #LDFLAGS+=-Wl,--verbose #export LDFLAGS -# build pmc tool with libpmc.so +# build pmc tool with libptpmgmt.so export PMC_USE_LIB=so %: @@ -44,27 +44,27 @@ SLIBDIR:=debian/tmp$(LIBDIR) # Make create all targets, we just move them from temporary to proper package override_dh_install: - $(Q)install -d $(foreach d,python-pmc/usr/lib python3-pmc/usr/lib\ - libpmc-dev/usr libpmc-dev/usr/share libpmc-doc/usr/share\ - pmc/usr/share php-pmc/usr/lib php-pmc/usr/share tcl-pmc/usr/lib\ - $(foreach n,lua-pmc libpmc-perl libpmc-dev ruby-pmc\ - libpmc,$n$(LIBDIR)),debian/$d) - $(Q)mv $(DSRC)include debian/libpmc-dev/usr - $(Q)mv $(DSRC)share/libpmc-dev debian/libpmc-dev/usr/share - $(Q)mv $(DSRC)share/doc debian/libpmc-doc/usr/share - $(Q)mv $(DSRC)share/man debian/pmc/usr/share - $(Q)mv $(DSRC)sbin debian/pmc/usr + $(Q)install -d $(foreach d,python-ptpmgmt/usr/lib python3-ptpmgmt/usr/lib\ + libptpmgmt-dev/usr libptpmgmt-dev/usr/share libptpmgmt-doc/usr/share\ + pmc-ptpmgmt/usr/share php-ptpmgmt/usr/lib php-ptpmgmt/usr/share tcl-ptpmgmt/usr/lib\ + $(foreach n,lua-ptpmgmt libptpmgmt-perl libptpmgmt-dev ruby-ptpmgmt\ + libptpmgmt,$n$(LIBDIR)),debian/$d) + $(Q)mv $(DSRC)include debian/libptpmgmt-dev/usr + $(Q)mv $(DSRC)share/libptpmgmt-dev debian/libptpmgmt-dev/usr/share + $(Q)mv $(DSRC)share/doc debian/libptpmgmt-doc/usr/share + $(Q)mv $(DSRC)share/man debian/pmc-ptpmgmt/usr/share + $(Q)mv $(DSRC)sbin debian/pmc-ptpmgmt/usr ifneq ($(wildcard $(DSRC)lib/python2*),) - $(Q)mv $(DSRC)lib/python2* debian/python-pmc/usr/lib + $(Q)mv $(DSRC)lib/python2* debian/python-ptpmgmt/usr/lib endif - $(Q)mv $(DSRC)lib/python3* debian/python3-pmc/usr/lib - $(Q)mv $(SLIBDIR)/lua* $(SLIBDIR)/liblua* debian/lua-pmc$(LIBDIR) - $(Q)mv $(SLIBDIR)/perl* debian/libpmc-perl$(LIBDIR) - $(Q)mv $(SLIBDIR)/ruby* debian/ruby-pmc$(LIBDIR) + $(Q)mv $(DSRC)lib/python3* debian/python3-ptpmgmt/usr/lib + $(Q)mv $(SLIBDIR)/lua* $(SLIBDIR)/liblua* debian/lua-ptpmgmt$(LIBDIR) + $(Q)mv $(SLIBDIR)/perl* debian/libptpmgmt-perl$(LIBDIR) + $(Q)mv $(SLIBDIR)/ruby* debian/ruby-ptpmgmt$(LIBDIR) ifneq ($(wildcard $(DSRC)lib/php),) - $(Q)mv $(DSRC)lib/php debian/php-pmc/usr/lib - $(Q)mv $(DSRC)share/php debian/php-pmc/usr/share + $(Q)mv $(DSRC)lib/php debian/php-ptpmgmt/usr/lib + $(Q)mv $(DSRC)share/php debian/php-ptpmgmt/usr/share endif - $(Q)mv $(DSRC)/lib/tcltk debian/tcl-pmc/usr/lib - $(Q)mv $(SLIBDIR)/*.a $(SLIBDIR)/*.so debian/libpmc-dev$(LIBDIR) - $(Q)mv $(SLIBDIR)/* debian/libpmc$(LIBDIR) + $(Q)mv $(DSRC)/lib/tcltk debian/tcl-ptpmgmt/usr/lib + $(Q)mv $(SLIBDIR)/*.a $(SLIBDIR)/*.so debian/libptpmgmt-dev$(LIBDIR) + $(Q)mv $(SLIBDIR)/* debian/libptpmgmt$(LIBDIR) diff --git a/doxygen.cfg b/doxygen.cfg index a3a592e1..a02b6aa5 100644 --- a/doxygen.cfg +++ b/doxygen.cfg @@ -42,7 +42,7 @@ DOXYFILE_ENCODING = UTF-8 # title of most generated pages and in a few other places. # The default value is: My Project. -PROJECT_NAME = libpmc +PROJECT_NAME = libptpmgmt # 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 @@ -54,7 +54,7 @@ PROJECT_NUMBER = # 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 = "libpmc library that provide the functionality of linuxptp pmc" +PROJECT_BRIEF = "libptpmgmt library that provide the functionality of linuxptp pmc" # With the PROJECT_LOGO tag one can specify a logo or an icon that is included # in the documentation. The maximum height of the logo should not exceed 55 @@ -2093,7 +2093,7 @@ DOCBOOK_OUTPUT = docbook #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES, doxygen will generate an -# AutoGen Definitions (see http://autogen.sourceforge.net/) file that captures +# AutoGen Definitions (see http://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. # The default value is: NO. diff --git a/end.h b/end.h index 9bc7f138..e8d515dd 100644 --- a/end.h +++ b/end.h @@ -12,8 +12,8 @@ * host byte order to network byte order */ -#ifndef __PMC_ENDIAN_H -#define __PMC_ENDIAN_H +#ifndef __PTPMGMT_ENDIAN_H +#define __PTPMGMT_ENDIAN_H #include #include @@ -70,4 +70,4 @@ inline uint64_t cpu_to_le64(uint64_t value) {return htole64(value);} */ inline uint64_t le_to_cpu64(uint64_t value) {return le64toh(value);} -#endif /* __PMC_ENDIAN_H */ +#endif /* __PTPMGMT_ENDIAN_H */ diff --git a/err.h b/err.h index 4b257aa1..073a0ba3 100644 --- a/err.h +++ b/err.h @@ -9,42 +9,42 @@ * */ -#ifndef __PMC_ERR_H -#define __PMC_ERR_H +#ifndef __PTPMGMT_ERR_H +#define __PTPMGMT_ERR_H #include #include #include #include -#ifndef PMC_ERROR +#ifndef PTPMGMT_ERROR /** * Print error without parameters * @param[in] format message to print */ -#define PMC_ERROR(format) do\ +#define PTPMGMT_ERROR(format) do\ { fprintf(stderr, "[%s:%d] " format "\n", __FILE__, __LINE__); }\ while(0) -#endif /* PMC_ERROR */ -#ifndef PMC_ERRORA +#endif /* PTPMGMT_ERROR */ +#ifndef PTPMGMT_ERRORA /** * Print error with parameters * @param[in] format message to print * @param[in] ... parameters match for format */ -#define PMC_ERRORA(format, ...) do\ +#define PTPMGMT_ERRORA(format, ...) do\ { fprintf(stderr, "[%s:%d] " format "\n", __FILE__, __LINE__, __VA_ARGS__); }\ while(0) -#endif /* PMC_ERRORA */ -#ifndef PMC_PERROR +#endif /* PTPMGMT_ERRORA */ +#ifndef PTPMGMT_PERROR /** * Print system error * @param[in] msg */ -#define PMC_PERROR(msg) do\ +#define PTPMGMT_PERROR(msg) do\ { fprintf(stderr, "[%s:%d] " msg ": %s\n", __FILE__, __LINE__,\ strerror(errno)); }\ while(0) -#endif /* PMC_PERROR */ +#endif /* PTPMGMT_PERROR */ -#endif /* __PMC_ERR_H */ +#endif /* __PTPMGMT_ERR_H */ diff --git a/init.cpp b/init.cpp index f0c5c55f..69976011 100644 --- a/init.cpp +++ b/init.cpp @@ -36,7 +36,7 @@ int Init::proccess(const Options &opt) MsgParams prms = m_msg.getParams(); if(net_select != 'u') { if(interface.empty()) { - PMC_ERROR("missing interface"); + PTPMGMT_ERROR("missing interface"); return -1; } if(!ifObj.initUsingName(interface)) @@ -64,7 +64,7 @@ int Init::proccess(const Options &opt) case 'u': { SockUnix *sku = new SockUnix; if(sku == nullptr) { - PMC_ERROR("failed to allocate SockUnix"); + PTPMGMT_ERROR("failed to allocate SockUnix"); return -1; } m_sk = sku; @@ -75,7 +75,7 @@ int Init::proccess(const Options &opt) uds_address = m_cfg.uds_address(interface); if(!sku->setDefSelfAddress() || !sku->init() || !sku->setPeerAddress(uds_address)) { - PMC_ERROR("failed to create transport"); + PTPMGMT_ERROR("failed to create transport"); return -1; } prms.self_id.portNumber = getpid() & 0xffff; @@ -86,20 +86,20 @@ int Init::proccess(const Options &opt) case '4': { SockIp4 *sk4 = new SockIp4; if(sk4 == nullptr) { - PMC_ERROR("failed to allocate SockIp4"); + PTPMGMT_ERROR("failed to allocate SockIp4"); return -1; } m_sk = sk4; if(!sk4->setAll(ifObj, m_cfg, interface)) { - PMC_ERROR("failed to set transport"); + PTPMGMT_ERROR("failed to set transport"); return -1; } if(opt.have('T') && !sk4->setUdpTtl(opt.val_i('T'))) { - PMC_ERROR("failed to set udp_ttl"); + PTPMGMT_ERROR("failed to set udp_ttl"); return -1; } if(!sk4->init()) { - PMC_ERROR("failed to init transport"); + PTPMGMT_ERROR("failed to init transport"); return -1; } break; @@ -107,24 +107,24 @@ int Init::proccess(const Options &opt) case '6': { SockIp6 *sk6 = new SockIp6; if(sk6 == nullptr) { - PMC_ERROR("failed to allocate SockIp6"); + PTPMGMT_ERROR("failed to allocate SockIp6"); return -1; } m_sk = sk6; if(!sk6->setAll(ifObj, m_cfg, interface)) { - PMC_ERROR("failed to set transport"); + PTPMGMT_ERROR("failed to set transport"); return -1; } if(opt.have('T') && !sk6->setUdpTtl(opt.val_i('T'))) { - PMC_ERROR("failed to set udp_ttl"); + PTPMGMT_ERROR("failed to set udp_ttl"); return -1; } if(opt.have('S') && !sk6->setScope(opt.val_i('S'))) { - PMC_ERROR("failed to set udp6_scope"); + PTPMGMT_ERROR("failed to set udp6_scope"); return -1; } if(!sk6->init()) { - PMC_ERROR("failed to init transport"); + PTPMGMT_ERROR("failed to init transport"); return -1; } break; @@ -132,27 +132,27 @@ int Init::proccess(const Options &opt) case '2': { SockRaw *skr = new SockRaw; if(skr == nullptr) { - PMC_ERROR("failed to allocate SockRaw"); + PTPMGMT_ERROR("failed to allocate SockRaw"); return -1; } m_sk = skr; if(!skr->setAll(ifObj, m_cfg, interface)) { - PMC_ERROR("failed to set transport"); + PTPMGMT_ERROR("failed to set transport"); return -1; } if(opt.have('P') && !skr->setSocketPriority(opt.val_i('P'))) { - PMC_ERROR("failed to set socket_priority"); + PTPMGMT_ERROR("failed to set socket_priority"); return -1; } Binary mac; if(opt.have('M') && (!mac.fromMac(opt.val('M')) || !skr->setPtpDstMac(mac))) { - PMC_ERROR("failed to set ptp_dst_mac"); + PTPMGMT_ERROR("failed to set ptp_dst_mac"); return -1; } if(!skr->init()) { - PMC_ERROR("failed to init transport"); + PTPMGMT_ERROR("failed to init transport"); return -1; } break; diff --git a/init.h b/init.h index 6cbd61d6..d6fc954b 100644 --- a/init.h +++ b/init.h @@ -9,8 +9,8 @@ * */ -#ifndef __PMC_INIT_H -#define __PMC_INIT_H +#ifndef __PTPMGMT_INIT_H +#define __PTPMGMT_INIT_H #include #include @@ -75,4 +75,4 @@ class Init bool use_uds() const { return m_use_uds; } }; -#endif /* __PMC_INIT_H */ +#endif /* __PTPMGMT_INIT_H */ diff --git a/json.cpp b/json.cpp index 1fc75264..ca65d0df 100644 --- a/json.cpp +++ b/json.cpp @@ -13,7 +13,7 @@ #include #include "json.h" #include "err.h" -#ifdef PMC_USE_CJSON +#ifdef PTPMGMT_USE_CJSON #include // JSON library type #define JSON_POBJ json_object* @@ -45,7 +45,7 @@ // JSON parser functions #define JSON_PARSE(str) json_tokener_parse(str) #define JSON_OBJ_FREE(obj) json_object_put(obj) -#endif /* PMC_USE_CJSON */ +#endif /* PTPMGMT_USE_CJSON */ #ifndef NSEC_PER_SEC #define NSEC_PER_SEC 1000000000L #endif @@ -1054,7 +1054,7 @@ std::string msg2json(const Message &msg, int indent) /** * From JSON part */ -#ifdef PMC_USE_CJSON +#ifdef PTPMGMT_USE_CJSON #undef PROC_VAL #define PROC_VAL(key) procValue(#key, d.key) #define PROC_STR(val) (strcmp(str, #val) == 0) @@ -1221,15 +1221,15 @@ struct JsonProcFromJson : public JsonProc { const char *key = JI_NAME(it); JSON_POBJ val = JI_VAL(it); if(withAllow && allow.count(key) != 1) { - PMC_ERRORA("Key '%s' in not allowed", key); + PTPMGMT_ERRORA("Key '%s' in not allowed", key); return false; } if(val == nullptr) { - PMC_ERRORA("Key '%s' do not have value", key); + PTPMGMT_ERRORA("Key '%s' do not have value", key); return false; } if(found.count(key) != 0) { - PMC_ERRORA("Key '%s' apear twice", key); + PTPMGMT_ERRORA("Key '%s' apear twice", key); return false; } JSON_TYPE type = JG_TYPE(val); @@ -1237,7 +1237,7 @@ struct JsonProcFromJson : public JsonProc { if(withAllow && !found[key].convType(allow[key])) { // Ignore dataField with null if(strcmp("dataField", key) || type != JT_NULL) { - PMC_ERRORA("Key '%s' use wrong type '%s' instead of '%s'", + PTPMGMT_ERRORA("Key '%s' use wrong type '%s' instead of '%s'", key, JG_TNAME(type), JG_TNAME(allow[key])); return false; } @@ -1251,7 +1251,7 @@ struct JsonProcFromJson : public JsonProc { // Optional, if value present verify it #define testOpt(key, val, emsg)\ if(isType(#key, JT_STR) && found[#key].strV.compare(#val)) {\ - PMC_ERRORA("Message must " emsg", not '%s'", found[#key].strV.c_str());\ + PTPMGMT_ERRORA("Message must " emsg", not '%s'", found[#key].strV.c_str());\ return false;\ } testOpt(messageType, Management, "be management") @@ -1259,7 +1259,7 @@ struct JsonProcFromJson : public JsonProc { // Mandatory #define testMand(key, emsg)\ if(!isType(#key, JT_STR)) {\ - PMC_ERROR("message must have " emsg);\ + PTPMGMT_ERROR("message must have " emsg);\ return false;\ } testMand(actionField, "action field") @@ -1273,7 +1273,7 @@ struct JsonProcFromJson : public JsonProc { if(strcmp(str, Message::mng2str_c(id)) == 0) return true; } - PMC_ERRORA("No such managementId '%s'", str); + PTPMGMT_ERRORA("No such managementId '%s'", str); return false; } #undef procType @@ -1643,7 +1643,7 @@ bool Json2msg::fromJson(const std::string &json) { JSON_POBJ jobj = JSON_PARSE(json.c_str()); if(jobj == nullptr) { - PMC_ERROR("JSON parse fail"); + PTPMGMT_ERROR("JSON parse fail"); return false; } bool ret = fromJsonObj(jobj); @@ -1663,7 +1663,7 @@ bool Json2msg::fromJsonObj(const void *jobj) else if(PROC_STR(COMMAND)) m_action = COMMAND; else { - PMC_ERRORA("message must have wrong action field '%s'", str); + PTPMGMT_ERRORA("message must have wrong action field '%s'", str); return false; } const char *mngStrID; @@ -1688,7 +1688,7 @@ bool Json2msg::fromJsonObj(const void *jobj) #define portProc(key, var)\ if(proc.isType(#key, JT_OBJ)) {\ if(!proc.procValue(#key, m_##var)) {\ - PMC_ERROR("Fail parsing " #key);\ + PTPMGMT_ERROR("Fail parsing " #key);\ return false;\ }\ m_have[have_##var] = true;\ @@ -1698,18 +1698,18 @@ bool Json2msg::fromJsonObj(const void *jobj) bool have_data = proc.isType("dataField", JT_OBJ); if(m_action == GET) { if(have_data) { - PMC_ERROR("GET use dataField with zero values only, " + PTPMGMT_ERROR("GET use dataField with zero values only, " "do not send dataField over JSON"); return false; } } else if(Message::isEmpty(m_managementId)) { if(have_data) { - PMC_ERRORA("%s do use dataField", mngStrID); + PTPMGMT_ERRORA("%s do use dataField", mngStrID); return false; } } else { if(!have_data) { - PMC_ERRORA("%s must use dataField", mngStrID); + PTPMGMT_ERRORA("%s must use dataField", mngStrID); return false; } JSON_POBJ dataField = proc.found["dataField"].objV; @@ -1719,24 +1719,24 @@ bool Json2msg::fromJsonObj(const void *jobj) if(!proc.procData(m_managementId, data)) { if(data != nullptr) { delete data; - PMC_ERROR("dataField parse error"); + PTPMGMT_ERROR("dataField parse error"); } else - PMC_ERRORA("Fail allocate %s_t", mngStrID); + PTPMGMT_ERRORA("Fail allocate %s_t", mngStrID); return false; } m_tlvData.reset(const_cast(data)); } return true; } -#else /* No PMC_USE_CJSON */ +#else /* No PTPMGMT_USE_CJSON */ bool Json2msg::fromJson(const std::string &json) { - PMC_ERROR("fromJson need JSON-C library support"); + PTPMGMT_ERROR("fromJson need JSON-C library support"); return false; } bool Json2msg::fromJsonObj(const void *jobj) { - PMC_ERROR("fromJsonObj need JSON-C library support"); + PTPMGMT_ERROR("fromJsonObj need JSON-C library support"); return false; } -#endif /* PMC_USE_CJSON */ +#endif /* PTPMGMT_USE_CJSON */ diff --git a/json.h b/json.h index 5de8e695..30e1fbbc 100644 --- a/json.h +++ b/json.h @@ -9,8 +9,8 @@ * */ -#ifndef __PMC_JSON_H -#define __PMC_JSON_H +#ifndef __PTPMGMT_JSON_H +#define __PTPMGMT_JSON_H #include #include @@ -75,8 +75,8 @@ class Json2msg * @return true if parsing success * @note jobj must be json_object pointer * @attention You must use the same JSON library used by this library! - * with PMC_USE_CJSON use the json-c library - * with PMC_USE_FCJSON use the fast json library + * build with USE_CJSON use the json-c library + * build with USE_FCJSON use the fast json library */ bool fromJsonObj(const void *jobj); /** @@ -186,4 +186,4 @@ class Json2msg bool haveDstPort() const { return m_have[have_dstPort]; } }; -#endif /* __PMC_JSON_H */ +#endif /* __PTPMGMT_JSON_H */ diff --git a/libpmc.cbp b/libptpmgmt.cbp similarity index 97% rename from libpmc.cbp rename to libptpmgmt.cbp index 41f63c4e..adadad64 100644 --- a/libpmc.cbp +++ b/libptpmgmt.cbp @@ -2,7 +2,7 @@ -