]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
lib/cpp: LldpCtl supports non default transports
authorPM Holtmo <pm.holtmo@gmail.com>
Tue, 29 Apr 2025 10:44:34 +0000 (12:44 +0200)
committerVincent Bernat <vincent@bernat.ch>
Mon, 12 May 2025 18:51:06 +0000 (20:51 +0200)
added optional arg to lldpd unix socket for constructor

src/lib/lldpctl.hpp

index add03ca8ae420e9e3029d96d89cf420f9738fc9d..7f7eabd6ca001cd2e728d950751cc0896021b736 100644 (file)
@@ -314,7 +314,9 @@ class LldpAtom {
  */
 class LldpCtl {
     public:
-       explicit LldpCtl()
+       explicit LldpCtl(std::string_view ctlname = ::lldpctl_get_default_transport())
+               : conn_ { ::lldpctl_new_name(ctlname.data(), nullptr, nullptr, this),
+                       &::lldpctl_release }
        {
                if (!conn_) {
                        throw std::system_error(std::error_code(LLDPCTL_ERR_NOMEM,
@@ -422,8 +424,7 @@ class LldpCtl {
        }
 
     private:
-       std::shared_ptr<lldpctl_conn_t> conn_ { ::lldpctl_new(nullptr, nullptr, this),
-               &::lldpctl_release };
+       std::shared_ptr<lldpctl_conn_t> conn_;
 };
 
 /**