* isis_tlv.[ch]: New function tlv_add_in_addr() to put just one IPv4
	  address into TLV. Used for IPv4 address TLV (in case of LSP) and TE
	  router ID TLV.
	* isis_lsp.c: Use tlv_add_in_addr() and include router ID in LSP.
diff --git a/isisd/ChangeLog b/isisd/ChangeLog
index 87a9c9e..521df90 100644
--- a/isisd/ChangeLog
+++ b/isisd/ChangeLog
@@ -1,5 +1,12 @@
 2005-09-26 Hasso Tepper <hasso at quagga.net>
 
+	* isis_tlv.[ch]: New function tlv_add_in_addr() to put just one IPv4
+	  address into TLV. Used for IPv4 address TLV (in case of LSP) and TE
+	  router ID TLV.
+	* isis_lsp.c: Use tlv_add_in_addr() and include router ID in LSP.
+
+2005-09-26 Hasso Tepper <hasso at quagga.net>
+
 	* isis_lsp.c: Support for originating TE IS and IPv4 TLV's. No any sub
 	  TLV handling yet.
 
diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c
index 882c857..81d189d 100644
--- a/isisd/isis_lsp.c
+++ b/isisd/isis_lsp.c
@@ -1100,11 +1100,9 @@
   if (lsp->tlv_data.area_addrs && listcount (lsp->tlv_data.area_addrs) > 0)
     tlv_add_area_addrs (lsp->tlv_data.area_addrs, lsp->pdu);
 
-  memset (&tlv_data, 0, sizeof (struct tlvs));
-  /*
-   * IPv4 address TLV. We don't follow "C" vendor, but "J" vendor behavior -
-   * one IPv4 address is put into LSP and this address is same as router id.
-   */
+  /* IPv4 address and TE router ID TLVs. In case of the first one we don't
+   * follow "C" vendor, but "J" vendor behavior - one IPv4 address is put into
+   * LSP and this address is same as router id. */
   if (router_id_zebra.s_addr != 0)
     {
       if (lsp->tlv_data.ipv4_addrs == NULL)
@@ -1115,18 +1113,22 @@
 
       routerid = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct in_addr));
       routerid->s_addr = router_id_zebra.s_addr;
-
       listnode_add (lsp->tlv_data.ipv4_addrs, routerid);
+      tlv_add_in_addr (routerid, lsp->pdu, IPV4_ADDR);
 
-      /* 
-       * FIXME: Using add_tlv() directly is hack, but tlv_add_ip_addrs()
-       * expects list of prefix_ipv4 structures, but we have list of
-       * in_addr structures.
-       */
-      add_tlv (IPV4_ADDR, IPV4_MAX_BYTELEN, (u_char *) &routerid->s_addr,
-	       lsp->pdu);
+      /* Exactly same data is put into TE router ID TLV, but only if new style
+       * TLV's are in use. */
+      if (area->newmetric)
+	{
+	  lsp->tlv_data.router_id = XMALLOC (MTYPE_ISIS_TLV,
+					     sizeof (struct in_addr));
+	  lsp->tlv_data.router_id->id.s_addr = router_id_zebra.s_addr;
+	  tlv_add_in_addr (&lsp->tlv_data.router_id->id, lsp->pdu, TE_ROUTER_ID);
+	}
     }
 
+  memset (&tlv_data, 0, sizeof (struct tlvs));
+
 #ifdef TOPOLOGY_GENERATE
   /* If topology exists (and we create topology for level 1 only), create
    * (hardcoded) link to topology. */
diff --git a/isisd/isis_tlv.c b/isisd/isis_tlv.c
index f430724..4f8ab39 100644
--- a/isisd/isis_tlv.c
+++ b/isisd/isis_tlv.c
@@ -927,6 +927,20 @@
   return add_tlv (IPV4_ADDR, pos - value, value, stream);
 }
 
+/* Used to add TLV containing just one IPv4 address - either IPv4 address TLV
+ * (in case of LSP) or TE router ID TLV. */
+int
+tlv_add_in_addr (struct in_addr *addr, struct stream *stream, u_char tag)
+{
+  u_char value[255];
+  u_char *pos = value;
+  
+  memcpy (pos, addr, IPV4_MAX_BYTELEN);
+  pos += IPV4_MAX_BYTELEN;
+
+  return add_tlv (tag, pos - value, value, stream);
+}
+
 int
 tlv_add_dynamic_hostname (struct hostname *hostname, struct stream *stream)
 {
diff --git a/isisd/isis_tlv.h b/isisd/isis_tlv.h
index 1dc030e..951a254 100644
--- a/isisd/isis_tlv.h
+++ b/isisd/isis_tlv.h
@@ -276,7 +276,6 @@
 		u_int32_t * expected, u_int32_t * found, struct tlvs *tlvs);
 void free_tlv (void *val);
 
-int add_tlv (u_char, u_char, u_char *, struct stream *);
 int tlv_add_area_addrs (struct list *area_addrs, struct stream *stream);
 int tlv_add_is_neighs (struct list *is_neighs, struct stream *stream);
 int tlv_add_te_is_neighs (struct list *te_is_neighs, struct stream *stream);
@@ -286,6 +285,7 @@
 int tlv_add_authinfo (char auth_type, char authlen, u_char *auth_value,
 		      struct stream *stream);
 int tlv_add_ip_addrs (struct list *ip_addrs, struct stream *stream);
+int tlv_add_in_addr (struct in_addr *, struct stream *stream, u_char tag);
 int tlv_add_dynamic_hostname (struct hostname *hostname,
 			      struct stream *stream);
 int tlv_add_lsp_entries (struct list *lsps, struct stream *stream);