-
Notifications
You must be signed in to change notification settings - Fork 43
/
lldp_mand.c
707 lines (621 loc) · 17.3 KB
/
lldp_mand.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
/*******************************************************************************
LLDP Agent Daemon (LLDPAD) Software
Copyright(c) 2007-2010 Intel Corporation.
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.
This program is distributed in the hope it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
The full GNU General Public License is included in this distribution in
the file called "COPYING".
Contact Information:
open-lldp Mailing List <[email protected]>
*******************************************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <net/if.h>
#include <sys/queue.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <errno.h>
#include "config.h"
#include "ctrl_iface.h"
#include "lldp.h"
#include "lldp_mand.h"
#include "lldp_mand_clif.h"
#include "lldp_mand_cmds.h"
#include "lldpad_shm.h"
#include "messages.h"
#include "lldp/l2_packet.h"
#include "lldp_tlv.h"
static const struct lldp_mod_ops mand_ops = {
.lldp_mod_register = mand_register,
.lldp_mod_unregister = mand_unregister,
.lldp_mod_gettlv = mand_gettlv,
.lldp_mod_ifup = mand_ifup,
.lldp_mod_ifdown = mand_ifdown,
.client_cmd = mand_clif_cmd,
.get_arg_handler = mand_get_arg_handlers,
};
struct mand_data *mand_data(const char *ifname, enum agent_type type)
{
struct mand_user_data *mud;
struct mand_data *md = NULL;
mud = find_module_user_data_by_id(&lldp_mod_head, LLDP_MOD_MAND);
if (mud) {
LIST_FOREACH(md, &mud->head, entry) {
if (!strncmp(ifname, md->ifname, IFNAMSIZ) &&
(type == md->agenttype))
return md;
}
}
return NULL;
}
/*
* mand_bld_end_tlv - build mandatory End TLV
* @md: the mand data struct
*
* Returns 0 for success or error code for failure
*
*/
static int mand_bld_end_tlv(struct mand_data *md)
{
int rc = EINVAL;
struct unpacked_tlv *tlv;
if (md->end)
return 0;
tlv = create_tlv();
if(tlv) {
tlv->type = END_OF_LLDPDU_TLV;
tlv->length = 0;
tlv->info = NULL;
md->end = tlv;
rc = 0;
}
return rc;
}
static int mand_bld_mac_chassis(struct mand_data *md,
struct tlv_info_chassis *chassis)
{
get_mac(md->ifname, chassis->id.mac, false);
if (is_valid_mac(chassis->id.mac))
chassis->sub = CHASSIS_ID_MAC_ADDRESS;
return sizeof(chassis->id.mac) + sizeof(chassis->sub);
}
static int mand_bld_ip_chassis(struct mand_data *md,
struct tlv_info_chassis *chassis)
{
unsigned int len;
void *v4_ptr = &chassis->id.na.ip.v4;
void *v6_ptr = &chassis->id.na.ip.v6;
if (!get_ipaddr(md->ifname, v4_ptr)) {
chassis->sub = CHASSIS_ID_NETWORK_ADDRESS;
chassis->id.na.type = MANADDR_IPV4;
len = sizeof(chassis->id.na.ip.v4);
} else if (!get_ipaddr6(md->ifname, v6_ptr)) {
chassis->sub = CHASSIS_ID_NETWORK_ADDRESS;
chassis->id.na.type = MANADDR_IPV6;
len = sizeof(chassis->id.na.ip.v6);
} else
return -1;
return sizeof(chassis->id.na.type) + len + sizeof(chassis->sub);
}
static int mand_bld_ifname_chassis(struct mand_data *md,
struct tlv_info_chassis *chassis)
{
chassis->sub = CHASSIS_ID_INTERFACE_NAME;
strncpy((char *)chassis->id.ifname, md->ifname, IFNAMSIZ);
return strlen(md->ifname) + sizeof(chassis->sub);
}
/*
* mand_bld_chassis_tlv - build mandatory End TLV
* @md: the mand data struct
*
* Returns 0 for success or error code for failure
*
* Load from config if is configured, otherwise build from
* scratc. Note that for LLDP-MED,
* - Mandatory for LLDP-MED Network Connectivity w/ default to MAC
* - Mandatory for LLDP-MED Endpoint w/ default to network addr
*
* In the case of MED being enabled w/ undefined or invalid devtype?
* we will just use network addr, assuming Endpoint device.
*
* If MED is not enabled, the order, as spec says, is:
* - CHASSIS_ID_CHASSIS_COMPONENT: only from config
* - CHASSIS_ID_INTERFACE_ALIAS : only from config
* - CHASSIS_ID_PORT_COMPONENT : only from config
* - CHASSIS_ID_MAC_ADDRESS : first from config, then built from scratch
* - CHASSIS_ID_NETWORK_ADDRESS : first from config, then built from scratch
* - CHASSIS_ID_INTERFACE_NAME : first from config, then built from scratch
* - CHASSIS_ID_LOCALLY_ASSIGNED: only load from config
*
* TODO:
* - Specs says chassis should remain constant for all LLDPUs
* while the connection remains operational, so this is built only
* once.
* - No validation on data loaded from config other than the subtype
*
*/
static int mand_bld_chassis_tlv(struct mand_data *md, struct lldp_agent *agent)
{
int rc = EINVAL;
int devtype, subtype;
size_t length;
char arg_path[512] = { 0 };
struct unpacked_tlv *tlv;
struct tlv_info_chassis chassis;
/* build only once */
if ((!md->rebuild_chassis) && (md->chassis)) {
rc = 0;
goto out_err;
}
/* free before building it */
md->rebuild_chassis = 1;
FREE_UNPKD_TLV(md, chassis);
memset(&chassis, 0, sizeof(chassis));
/* check for value in shared memory first */
if (!md->read_shm && agent->type == NEAREST_BRIDGE &&
lldpad_shm_get_msap(md->ifname,
CHASSIS_ID_TLV,
(char *)&chassis,
&length))
goto bld_tlv;
/* subtype may differ when LLDP-MED is enabled */
if (!is_tlv_txenabled(md->ifname, agent->type,
TLVID_MED(LLDP_MED_RESERVED))) {
int err;
snprintf(arg_path, sizeof(arg_path), "%s%08x.%s",
TLVID_PREFIX,
TLVID_NOUI(CHASSIS_ID_TLV),
ARG_MAND_SUBTYPE);
err = get_config_setting(md->ifname, agent->type, arg_path,
&subtype, CONFIG_TYPE_INT);
if (err)
subtype = 0;
switch (subtype) {
case CHASSIS_ID_INTERFACE_NAME:
length = mand_bld_ifname_chassis(md, &chassis);
break;
case CHASSIS_ID_NETWORK_ADDRESS:
length = mand_bld_ip_chassis(md, &chassis);
if (length > 0)
break;
/* Fall through on IP error */
/* FALLTHROUGH */
case CHASSIS_ID_MAC_ADDRESS:
default:
length = mand_bld_mac_chassis(md, &chassis);
}
} else {
devtype = get_med_devtype(md->ifname, agent->type);
LLDPAD_DBG("%s:%s:MED enabled w/ devtype=%d)\n",
__func__, md->ifname, devtype);
switch (devtype) {
case LLDP_MED_DEVTYPE_ENDPOINT_CLASS_I:
case LLDP_MED_DEVTYPE_ENDPOINT_CLASS_II:
case LLDP_MED_DEVTYPE_ENDPOINT_CLASS_III:
length = mand_bld_ip_chassis(md, &chassis);
if (length > 0)
break;
/* Fall through on IP error */
/* FALLTHROUGH */
case LLDP_MED_DEVTYPE_NETWORK_CONNECTIVITY:
default:
length = mand_bld_ifname_chassis(md, &chassis);
break;
}
}
bld_tlv:
tlv = create_tlv();
if (!tlv)
goto out_err;
tlv->type = CHASSIS_ID_TLV;
tlv->length = length;
tlv->info = (u8 *)malloc(length);
if(!tlv->info){
free(tlv);
goto out_err;
}
memset(tlv->info, 0, tlv->length);
memcpy(tlv->info, &chassis, tlv->length);
md->chassis = tlv;
md->rebuild_chassis = 0;
/* write this back */
if (agent->type == NEAREST_BRIDGE)
lldpad_shm_set_msap(md->ifname,
CHASSIS_ID_TLV,
(char *)tlv->info,
tlv->length);
set_config_tlvinfo_bin(md->ifname, agent->type,
TLVID_NOUI(CHASSIS_ID_TLV),
tlv->info, tlv->length);
rc = 0;
out_err:
return rc;
}
/*
* mand_bld_portid_tlv - build mandatory End TLV
* @md: the mand data struct
*
* Returns 0 for success or error code for failure
*
* Load from config if is configured, otherwise build from
* scratc. Note that for LLDP-MED,
* - Mandatory and default to MAC for Network Connectivity, and
* Endpoint Devices
*
* In the case of MED being enabled w/ undefined or invalid devtype?
* we will just use mac
*
* If MED is not enabled, the order, as spec says, is:
* - PORT_ID_INTERFACE_ALIAS : only from config
* - PORT_ID_PORT_COMPONENT : only from config
* - PORT_ID_MAC_ADDRESS : first from config, then built from scratch
* - PORT_ID_NETWORK_ADDRESS : first from config, then built from scratch
* - PORT_ID_INTERFACE_NAME : first from config, then built from scratch
* - PORT_ID_AGENT_CIRCUIT_ID : only from config
* - PORT_ID_LOCALLY_ASSIGNED : only load from config
*
* TODO:
* - The port id should remain constant for all LLDPUs while the connection
* remains operational, so this is built only once.
* - No validation on data loaded from config other than the subtype
*
*/
static int mand_bld_portid_tlv(struct mand_data *md, struct lldp_agent *agent)
{
int rc = EINVAL;
int devtype, subtype;
size_t length;
char arg_path[512] = { 0 };
struct unpacked_tlv *tlv;
struct tlv_info_portid portid;
/* build only once */
if ((!md->rebuild_portid) && (md->portid)) {
rc = 0;
goto out_err;
}
/* free before building it */
md->rebuild_portid = 1;
FREE_UNPKD_TLV(md, portid);
memset(&portid, 0, sizeof(portid));
/* check for value in shared memory first */
if (!md->read_shm && agent->type == NEAREST_BRIDGE &&
lldpad_shm_get_msap(md->ifname,
PORT_ID_TLV,
(char *)&(portid),
&length))
goto bld_tlv;
/* subtype may differ when LLDP-MED is enabled */
devtype = get_med_devtype(md->ifname, agent->type);
if (LLDP_MED_DEVTYPE_DEFINED(devtype) &&
is_tlv_txenabled(md->ifname, agent->type,
TLVID_MED(LLDP_MED_RESERVED))) {
subtype = PORT_ID_MAC_ADDRESS;
LLDPAD_INFO("%s:%s: MED set portID=PORT_ID_MAC_ADDRESS\n",
__func__, md->ifname);
} else {
int err;
snprintf(arg_path, sizeof(arg_path), "%s%08x.%s",
TLVID_PREFIX,
TLVID_NOUI(PORT_ID_TLV),
ARG_MAND_SUBTYPE);
err = get_config_setting(md->ifname, agent->type, arg_path,
&subtype, CONFIG_TYPE_INT);
if (err)
subtype = 0;
}
/* If build from scratch, try mac, then ip, then ifname.
* This switch statement falls through case stmts until
* a good address is found. Notice if user specified
* fail order may change I think this is OK.
*/
switch (subtype) {
default:
case PORT_ID_MAC_ADDRESS:
get_mac(md->ifname, portid.id.mac, true);
if (is_valid_mac(portid.id.mac)) {
portid.sub = PORT_ID_MAC_ADDRESS;
length = sizeof(portid.id.mac) +
sizeof(portid.sub);
break;
}
/* FALLTHROUGH */
case PORT_ID_NETWORK_ADDRESS: {
/* uses ipv4 first */
void *v4_ptr = &portid.id.na.ip.v4;
if (!get_ipaddr(md->ifname, v4_ptr)) {
portid.sub = PORT_ID_NETWORK_ADDRESS;
portid.id.na.type = MANADDR_IPV4;
length = sizeof(portid.id.na.type) +
sizeof(portid.id.na.ip.v4) +
sizeof(portid.sub);
break;
}
/* ipv4 fails, get ipv6 */
void *v6_ptr = &portid.id.na.ip.v6;
if (!get_ipaddr6(md->ifname, v6_ptr)) {
portid.sub = PORT_ID_NETWORK_ADDRESS;
portid.id.na.type = MANADDR_IPV6;
length = sizeof(portid.id.na.type) +
sizeof(portid.id.na.ip.v6) +
sizeof(portid.sub);
break;
}
}
/* FALLTHROUGH */
case PORT_ID_INTERFACE_NAME:
portid.sub = PORT_ID_INTERFACE_NAME;
strncpy((char *)portid.id.ifname, md->ifname, IFNAMSIZ);
length = strlen(md->ifname) + sizeof(portid.sub);
break;
}
bld_tlv:
tlv = create_tlv();
if (!tlv)
goto out_err;
tlv->type = PORT_ID_TLV;
tlv->length = length;
tlv->info = (u8 *)malloc(length);
if(!tlv->info){
free(tlv);
goto out_err;
}
memset(tlv->info, 0, tlv->length);
memcpy(tlv->info, &portid, tlv->length);
md->portid = tlv;
md->rebuild_portid = 0;
/* write this back */
if (agent->type == NEAREST_BRIDGE)
lldpad_shm_set_msap(md->ifname,
PORT_ID_TLV,
(char *)tlv->info,
tlv->length);
set_config_tlvinfo_bin(md->ifname, agent->type,
TLVID_NOUI(PORT_ID_TLV),
tlv->info, tlv->length);
rc = 0;
out_err:
return rc;
}
static int mand_bld_ttl_tlv(struct mand_data *md, struct lldp_agent *agent)
{
int rc = EINVAL;
u16 ttl;
struct unpacked_tlv *tlv;
if (md->ttl)
free_unpkd_tlv(md->ttl);
tlv = create_tlv();
if (!tlv)
goto out_err;
tlv->type = TIME_TO_LIVE_TLV;
tlv->length = 2;
tlv->info = (u8 *)malloc(tlv->length);
if(!tlv->info) {
free(tlv);
goto out_err;
}
memset(tlv->info, 0, tlv->length);
ttl = htons(agent->tx.txTTL);
memcpy(tlv->info, &ttl, tlv->length);
LLDPAD_DBG("%s:%s:done:type=%d length=%d ttl=%d\n", __func__,
md->ifname, tlv->type, tlv->length, ntohs(ttl));
md->ttl = tlv;
rc = 0;
out_err:
return rc;
}
/* build unpacked tlvs */
static int mand_bld_tlv(struct mand_data *md, struct lldp_agent *agent)
{
int rc = EPERM;
int ifindex = get_ifidx(md->ifname);
if (!port_find_by_ifindex(ifindex)) {
rc = EEXIST;
goto out_err;
}
if (mand_bld_chassis_tlv(md, agent)) {
LLDPAD_DBG("%s:%s:mand_bld_chassis_tlv() failed\n",
__func__, md->ifname);
goto out_err;
}
if (mand_bld_portid_tlv(md, agent)) {
LLDPAD_DBG("%s:%s:mand_bld_portid_tlv() failed\n",
__func__, md->ifname);
goto out_err;
}
if (mand_bld_ttl_tlv(md, agent)) {
LLDPAD_DBG("%s:%s:mand_bld_ttl_tlv() failed\n",
__func__, md->ifname);
goto out_err;
}
if (mand_bld_end_tlv(md)) {
LLDPAD_DBG("%s:%s:mand_bld_end_tlv() failed\n",
__func__, md->ifname);
goto out_err;
}
rc = 0;
out_err:
return rc;
}
struct packed_tlv *mand_gettlv(struct port *port, struct lldp_agent *agent)
{
struct mand_data *md;
struct packed_tlv *ptlv = NULL;
size_t size;
int err;
md = mand_data(port->ifname, agent->type);
if (!md) {
LLDPAD_DBG("%s:%s: not found port\n", __func__, port->ifname);
goto out_err;
}
err = mand_bld_tlv(md, agent);
if (err) {
LLDPAD_DBG("%s:%s: building mandotory TLV error.\n",
__func__, port->ifname);
goto out_err;
}
size = TLVSIZE(md->chassis)
+ TLVSIZE(md->portid)
+ TLVSIZE(md->ttl);
if (!size)
goto out_err;
ptlv = create_ptlv();
if (!ptlv)
goto out_err;
ptlv->tlv = malloc(size);
if (!ptlv->tlv)
goto out_free;
ptlv->size = 0;
PACK_TLV_AFTER(md->chassis, ptlv, size, out_free);
PACK_TLV_AFTER(md->portid, ptlv, size, out_free);
PACK_TLV_AFTER(md->ttl, ptlv, size, out_free);
return ptlv;
out_free:
free_pkd_tlv(ptlv);
out_err:
LLDPAD_DBG("%s:%s: failed\n", __func__, port->ifname);
return NULL;
}
static void mand_free_tlv(struct mand_data *md)
{
if (md) {
FREE_UNPKD_TLV(md, chassis);
FREE_UNPKD_TLV(md, portid);
FREE_UNPKD_TLV(md, ttl);
FREE_UNPKD_TLV(md, end);
}
}
static void mand_free_data(struct mand_user_data *mud)
{
struct mand_data *md;
if (mud) {
while (!LIST_EMPTY(&mud->head)) {
md = LIST_FIRST(&mud->head);
LIST_REMOVE(md, entry);
mand_free_tlv(md);
free(md);
}
}
}
void mand_ifdown(char *ifname, struct lldp_agent *agent)
{
struct mand_data *md;
md = mand_data(ifname, agent->type);
if (!md)
goto out_err;
md->rebuild_chassis = 1;
md->rebuild_portid = 1;
mand_free_tlv(md);
LLDPAD_INFO("%s:port %s removed\n", __func__, ifname);
return;
out_err:
LLDPAD_INFO("%s:port %s adding failed\n", __func__, ifname);
return;
}
void mand_ifup(char *ifname, struct lldp_agent *agent)
{
struct mand_data *md;
struct mand_user_data *mud;
md = mand_data(ifname, agent->type);
if (!md) {
/* not found, alloc/init per-port tlv data */
md = (struct mand_data *) malloc(sizeof(*md));
if (!md) {
LLDPAD_WARN("%s:%s malloc %zu failed\n",
__func__, ifname, sizeof(*md));
return;
}
memset(md, 0, sizeof(struct mand_data));
STRNCPY_TERMINATED(md->ifname, ifname, IFNAMSIZ);
md->agenttype = agent->type;
mud = find_module_user_data_by_id(&lldp_mod_head, LLDP_MOD_MAND);
LIST_INSERT_HEAD(&mud->head, md, entry);
}
if (mand_bld_tlv(md, agent)) {
LLDPAD_INFO("%s:%s mand_bld_tlv failed\n", __func__, ifname);
LIST_REMOVE(md, entry);
mand_free_tlv(md);
free(md);
return;
}
/* Only read shared memory on first ifup */
md->read_shm = 1;
LLDPAD_INFO("%s:port %s added\n", __func__, ifname);
return;
}
struct lldp_module *mand_register(void)
{
struct lldp_module *mod;
struct mand_user_data *mud;
mod = malloc(sizeof(*mod));
if (!mod) {
LLDPAD_ERR("failed to malloc LLDP Mandatory module data\n");
goto out_err;
}
mud = malloc(sizeof(struct mand_user_data));
if (!mud) {
free(mod);
LLDPAD_ERR("failed to malloc LLDP Mandatory module user data\n");
goto out_err;
}
LIST_INIT(&mud->head);
mod->id = LLDP_MOD_MAND;
mod->data = mud;
mod->ops = &mand_ops;
LLDPAD_INFO("%s:done\n", __func__);
return mod;
out_err:
LLDPAD_INFO("%s:failed\n", __func__);
return NULL;
}
void mand_unregister(struct lldp_module *mod)
{
struct if_nameindex *nameidx, *p;
struct port *port;
struct lldp_agent *agent;
struct mand_data *md;
nameidx = if_nameindex();
if (!nameidx) {
LLDPAD_DBG("error calling if_nameindex()\n");
return;
}
for (p = nameidx; p->if_index != 0; p++) {
port = port_find_by_ifindex(p->if_index);
if (!port)
continue;
LIST_FOREACH(agent, &port->agent_head, entry) {
md = mand_data(p->if_name, agent->type);
if (!md)
continue;
LIST_REMOVE(md, entry);
mand_free_tlv(md);
free(md);
}
}
if_freenameindex(nameidx);
if (mod->data) {
mand_free_data((struct mand_user_data *) mod->data);
free(mod->data);
}
free(mod);
LLDPAD_INFO("%s:done\n", __func__);
}
void mand_update_ttl(const char *ifname, u16 ttl_val)
{
struct port *port = port_find_by_ifindex(get_ifidx(ifname));
struct lldp_agent *agent;
if (!port)
return;
LIST_FOREACH(agent, &port->agent_head, entry) {
agent->tx.txTTL = ttl_val;
agent->tx.localChange = 1;
agent->tx.txFast = agent->timers.txFastInit;
}
}