]>
git.proxmox.com Git - mirror_frr.git/blob - isisd/isis_dynhn.c
2 * IS-IS Rout(e)ing protocol - isis_dynhn.c
3 * Dynamic hostname cache
4 * Copyright (C) 2001,2002 Sampo Saaristo
5 * Tampere University of Technology
6 * Institute of Communications Engineering
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public Licenseas published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
13 * This program is distributed in the hope that it will be useful,but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 #include <net/ethernet.h>
35 #include "isisd/dict.h"
36 #include "isisd/isis_constants.h"
37 #include "isisd/isis_common.h"
38 #include "isisd/isis_flags.h"
39 #include "isisd/isis_circuit.h"
40 #include "isisd/isisd.h"
41 #include "isisd/isis_dynhn.h"
42 #include "isisd/isis_misc.h"
43 #include "isisd/isis_constants.h"
45 extern struct isis
*isis
;
46 extern struct host host
;
48 struct list
*dyn_cache
= NULL
;
53 dyn_cache
= list_new ();
58 struct isis_dynhn
*dynhn_find_by_id (u_char
* id
)
60 struct listnode
*node
= NULL
;
61 struct isis_dynhn
*dyn
= NULL
;
63 for (node
= listhead (dyn_cache
); node
; nextnode (node
)) {
65 if (memcmp (dyn
->id
, id
, ISIS_SYS_ID_LEN
) == 0)
73 isis_dynhn_insert (u_char
*id
, struct hostname
*hostname
, int level
)
75 struct isis_dynhn
*dyn
;
77 dyn
= dynhn_find_by_id (id
);
79 memcpy (&dyn
->name
, hostname
, hostname
->namelen
+ 1);
80 memcpy (dyn
->id
, id
, ISIS_SYS_ID_LEN
);
81 dyn
->refresh
= time (NULL
);
84 dyn
= XMALLOC (MTYPE_ISIS_DYNHN
, sizeof (struct isis_dynhn
));
86 zlog_warn ("isis_dynhn_insert(): out of memory!");
89 memset (dyn
,0,sizeof(struct isis_dynhn
));
90 /* we also copy the length */
91 memcpy (&dyn
->name
, hostname
, hostname
->namelen
+ 1);
92 memcpy (dyn
->id
, id
, ISIS_SYS_ID_LEN
);
93 dyn
->refresh
= time (NULL
);
96 listnode_add (dyn_cache
, dyn
);
102 * Level System ID Dynamic Hostname (notag)
103 * 2 0000.0000.0001 foo-gw
104 * 2 0000.0000.0002 bar-gw
105 * * 0000.0000.0004 this-gw
107 void dynhn_print_all (struct vty
*vty
)
109 struct listnode
*node
;
110 struct isis_dynhn
*dyn
;
112 vty_out (vty
, "Level System ID Dynamic Hostname%s", VTY_NEWLINE
);
113 for (node
= listhead (dyn_cache
); node
; nextnode (node
)) {
114 dyn
= getdata (node
);
115 vty_out (vty
, "%-7d", dyn
->level
);
116 vty_out (vty
, "%-15s%-15s%s", sysid_print (dyn
->id
), dyn
->name
.name
,
120 vty_out (vty
, " * %s %s%s", sysid_print (isis
->sysid
), host
.name
,