Fri Dec 31 11:29:34 2010 UTC ()
show in neighbour information if peer is MD5 authenticated


(kefren)
diff -r1.3 -r1.4 src/usr.sbin/ldpd/ldp_command.c

cvs diff -r1.3 -r1.4 src/usr.sbin/ldpd/ldp_command.c (expand / switch to unified diff)

--- src/usr.sbin/ldpd/ldp_command.c 2010/12/30 11:29:21 1.3
+++ src/usr.sbin/ldpd/ldp_command.c 2010/12/31 11:29:33 1.4
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ldp_command.c,v 1.3 2010/12/30 11:29:21 kefren Exp $ */ 1/* $NetBSD: ldp_command.c,v 1.4 2010/12/31 11:29:33 kefren Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2010 The NetBSD Foundation, Inc. 4 * Copyright (c) 2010 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Mihai Chelaru <kefren@NetBSD.org> 8 * by Mihai Chelaru <kefren@NetBSD.org>
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -22,26 +22,27 @@ @@ -22,26 +22,27 @@
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <arpa/inet.h> 32#include <arpa/inet.h>
33 33
34#include <netinet/in.h> 34#include <netinet/in.h>
 35#include <netinet/tcp.h>
35 36
36#include <sys/socket.h> 37#include <sys/socket.h>
37#include <sys/queue.h> 38#include <sys/queue.h>
38 39
39#include <errno.h> 40#include <errno.h>
40#include <pwd.h> 41#include <pwd.h>
41#include <stdio.h> 42#include <stdio.h>
42#include <stdlib.h> 43#include <stdlib.h>
43#include <string.h> 44#include <string.h>
44#include <unistd.h> 45#include <unistd.h>
45 46
46#include "label.h" 47#include "label.h"
47#include "ldp.h" 48#include "ldp.h"
@@ -370,26 +371,28 @@ exit_func(int s, char *recvspace) @@ -370,26 +371,28 @@ exit_func(int s, char *recvspace)
370 return 0; 371 return 0;
371} 372}
372 373
373/* 374/*
374 * Show functions 375 * Show functions
375 */ 376 */
376int 377int
377show_neighbours(int s, char *recvspace) 378show_neighbours(int s, char *recvspace)
378{ 379{
379 struct ldp_peer *p; 380 struct ldp_peer *p;
380 struct ldp_peer_address *wp; 381 struct ldp_peer_address *wp;
381 struct sockaddr_in ssin; 382 struct sockaddr_in ssin;
382 socklen_t sin_len = sizeof(struct sockaddr_in); 383 socklen_t sin_len = sizeof(struct sockaddr_in);
 384 int enc;
 385 socklen_t enclen = sizeof(enc);
383 386
384 SLIST_FOREACH(p, &ldp_peer_head, peers) { 387 SLIST_FOREACH(p, &ldp_peer_head, peers) {
385 snprintf(sendspace, MAXSEND, "LDP peer: %s\n", 388 snprintf(sendspace, MAXSEND, "LDP peer: %s\n",
386 inet_ntoa(p->ldp_id)); 389 inet_ntoa(p->ldp_id));
387 writestr(s, sendspace); 390 writestr(s, sendspace);
388 snprintf(sendspace, MAXSEND, "Transport address: %s\n", 391 snprintf(sendspace, MAXSEND, "Transport address: %s\n",
389 inet_ntoa(p->transport_address)); 392 inet_ntoa(p->transport_address));
390 writestr(s, sendspace); 393 writestr(s, sendspace);
391 snprintf(sendspace, MAXSEND, "Next-hop address: %s\n", 394 snprintf(sendspace, MAXSEND, "Next-hop address: %s\n",
392 inet_ntoa(p->address)); 395 inet_ntoa(p->address));
393 writestr(s, sendspace); 396 writestr(s, sendspace);
394 snprintf(sendspace, MAXSEND, "State: %s\n", 397 snprintf(sendspace, MAXSEND, "State: %s\n",
395 ldp_state_to_name(p->state)); 398 ldp_state_to_name(p->state));
@@ -400,26 +403,35 @@ show_neighbours(int s, char *recvspace) @@ -400,26 +403,35 @@ show_neighbours(int s, char *recvspace)
400 writestr(s, sendspace); 403 writestr(s, sendspace);
401 } 404 }
402 snprintf(sendspace, MAXSEND, "Holdtime: %d\nTimeout: %d\n", 405 snprintf(sendspace, MAXSEND, "Holdtime: %d\nTimeout: %d\n",
403 p->holdtime, p->timeout); 406 p->holdtime, p->timeout);
404 writestr(s, sendspace); 407 writestr(s, sendspace);
405 408
406 switch(p->state) { 409 switch(p->state) {
407 case LDP_PEER_CONNECTING: 410 case LDP_PEER_CONNECTING:
408 case LDP_PEER_CONNECTED: 411 case LDP_PEER_CONNECTED:
409 case LDP_PEER_ESTABLISHED: 412 case LDP_PEER_ESTABLISHED:
410 if (getsockname(p->socket,(struct sockaddr *) &ssin, 413 if (getsockname(p->socket,(struct sockaddr *) &ssin,
411 &sin_len)) 414 &sin_len))
412 break; 415 break;
 416
 417 if (getsockopt(p->socket, IPPROTO_TCP, TCP_MD5SIG,
 418 &enc, &enclen) == 0) {
 419 snprintf(sendspace, MAXSEND,
 420 "Authenticated: %s\n",
 421 enc != 0 ? "YES" : "NO");
 422 writestr(s, sendspace);
 423 }
 424
413 snprintf(sendspace, MAXSEND,"Socket: %d\nLocal %s:%d\n", 425 snprintf(sendspace, MAXSEND,"Socket: %d\nLocal %s:%d\n",
414 p->socket, inet_ntoa(ssin.sin_addr), 426 p->socket, inet_ntoa(ssin.sin_addr),
415 ntohs(ssin.sin_port)); 427 ntohs(ssin.sin_port));
416 writestr(s, sendspace); 428 writestr(s, sendspace);
417 429
418 if (getpeername(p->socket,(struct sockaddr *) &ssin, 430 if (getpeername(p->socket,(struct sockaddr *) &ssin,
419 &sin_len)) 431 &sin_len))
420 break; 432 break;
421 snprintf(sendspace, MAXSEND, "Remote %s:%d\n", 433 snprintf(sendspace, MAXSEND, "Remote %s:%d\n",
422 inet_ntoa(ssin.sin_addr), ntohs(ssin.sin_port)); 434 inet_ntoa(ssin.sin_addr), ntohs(ssin.sin_port));
423 writestr(s, sendspace); 435 writestr(s, sendspace);
424 } 436 }
425 437