From: Vincent Bernat Date: Thu, 26 Aug 2010 13:35:32 +0000 (+0200) Subject: Add a receive-only mode with "-r" switch. X-Git-Tag: 0.5.2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=537a8043c831f45549557e89469f029218f22366;p=thirdparty%2Flldpd.git Add a receive-only mode with "-r" switch. --- diff --git a/CHANGELOG b/CHANGELOG index bc30ad89..a142b13a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ lldpd (0.5.2) * Features: + More flexible smart mode and new default. Manual page has been updated. + + Add a "receive-only" mode with "-r" switch. lldpd (0.5.1) * Features: diff --git a/man/lldpd.8 b/man/lldpd.8 index ae3d8d24..3df1d5d7 100644 --- a/man/lldpd.8 +++ b/man/lldpd.8 @@ -21,7 +21,7 @@ .Nd LLDP daemon .Sh SYNOPSIS .Nm -.Op Fl dxcseikl +.Op Fl dxcseiklr .Op Fl S Ar description .Op Fl X Ar socket .Op Fl m Ar management @@ -106,6 +106,10 @@ Force to send LLDP packets even when there is no LLDP peer detected but there is a peer speaking another protocol detected. By default, LLDP packets are sent when there is a peer speaking LLDP detected or when there is no peer at all. +.It Fl r +Receive-only mode. With this switch, +.Nm +will not send any frame. It will only listen to neighbors. .It Fl m Ar management Specify the management address of this system. .Nm diff --git a/src/lldpd.c b/src/lldpd.c index 1c4b8ef1..3827a11c 100644 --- a/src/lldpd.c +++ b/src/lldpd.c @@ -987,7 +987,8 @@ lldpd_loop(struct lldpd *cfg) lldpd_update_localports(cfg); lldpd_cleanup(cfg); lldpd_update_localchassis(cfg); - lldpd_send_all(cfg); + if (!cfg->g_receiveonly) + lldpd_send_all(cfg); lldpd_recv_all(cfg); } @@ -1066,7 +1067,7 @@ lldpd_main(int argc, char *argv[]) #endif char *mgmtp = NULL; char *popt, opts[] = - "H:hkdxX:m:p:M:S:i@ "; + "H:hkrdxX:m:p:M:S:i@ "; int i, found, advertise_version = 1; #ifdef ENABLE_LLDPMED int lldpmed = 0, noinventory = 0; @@ -1074,6 +1075,7 @@ lldpd_main(int argc, char *argv[]) char *descr_override = NULL; char *lsb_release = NULL; int smart = 15; + int receiveonly = 0; saved_argv = argv; @@ -1092,6 +1094,9 @@ lldpd_main(int argc, char *argv[]) case 'd': debug++; break; + case 'r': + receiveonly = 1; + break; case 'm': mgmtp = optarg; break; @@ -1193,6 +1198,7 @@ lldpd_main(int argc, char *argv[]) cfg->g_mgmt_pattern = mgmtp; cfg->g_smart = smart; + cfg->g_receiveonly = receiveonly; /* Get ioctl socket */ if ((cfg->g_sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1) diff --git a/src/lldpd.h b/src/lldpd.h index 0a58b401..db1b4de9 100644 --- a/src/lldpd.h +++ b/src/lldpd.h @@ -310,6 +310,7 @@ struct lldpd { time_t g_lastsent; int g_lastrid; int g_smart; + int g_receiveonly; #ifdef USE_SNMP int g_snmp; #endif /* USE_SNMP */