/*
 * IS-IS Rout(e)ing protocol - isis_lsp.c
 *                             LSP processing
 *
 * Copyright (C) 2001,2002   Sampo Saaristo
 *                           Tampere University of Technology      
 *                           Institute of Communications Engineering
 *
 * This program is free software; you can redistribute it and/or modify it 
 * under the terms of the GNU General Public Licenseas published by the Free 
 * Software Foundation; either version 2 of the License, or (at your option) 
 * any later version.
 *
 * This program is distributed in the hope that 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., 
 * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
#include <stdlib.h>
#include <stdio.h>
#include <zebra.h>
#include <net/ethernet.h>

#include "linklist.h"
#include "thread.h"
#include "vty.h"
#include "stream.h"
#include "memory.h"
#include "log.h"
#include "prefix.h"
#include "command.h"
#include "hash.h"
#include "if.h"

#include "isisd/dict.h"
#include "isisd/isis_constants.h"
#include "isisd/isis_common.h"
#include "isisd/isis_circuit.h"
#include "isisd/isisd.h"
#include "isisd/isis_tlv.h"
#include "isisd/isis_lsp.h"
#include "isisd/isis_pdu.h"
#include "isisd/isis_dynhn.h"
#include "isisd/isis_misc.h"
#include "isisd/isis_flags.h"
#include "isisd/iso_checksum.h"
#include "isisd/isis_csm.h"
#include "isisd/isis_adjacency.h"
#include "isisd/isis_spf.h"

#ifdef TOPOLOGY_GENERATE
#include "spgrid.h"
#endif

#define LSP_MEMORY_PREASSIGN 

extern struct isis *isis;
extern struct thread_master *master;

int 
lsp_id_cmp (u_char *id1, u_char *id2)
{  
  return memcmp (id1, id2, ISIS_SYS_ID_LEN + 2);
}

dict_t *
lsp_db_init (void) 
{
  dict_t *dict;
  
  dict = dict_create (DICTCOUNT_T_MAX, (dict_comp_t)lsp_id_cmp);
  
  return dict;
}

struct isis_lsp *
lsp_search (u_char *id, dict_t *lspdb)
{
  dnode_t *node;

#ifdef EXTREME_DEBUG 
  dnode_t *dn;

  zlog_warn("searching db");
  for (dn = dict_first(lspdb); dn; dn = dict_next(lspdb, dn)) {
    zlog_warn("%s\t%pX", rawlspid_print((char *) dnode_getkey(dn)), 
              dnode_get(dn));
  }
#endif /* EXTREME DEBUG */

  node = dict_lookup (lspdb, id);
  
  if (node)
    return (struct isis_lsp *)dnode_get (node);

  return NULL;
}

void
lsp_clear_data (struct isis_lsp *lsp)
{
  if (!lsp)
    return;
 
  if (lsp->own_lsp) {
    if (lsp->tlv_data.nlpids)
      XFREE (MTYPE_ISIS_TLV, lsp->tlv_data.nlpids);
    if (lsp->tlv_data.hostname)
      XFREE (MTYPE_ISIS_TLV, lsp->tlv_data.hostname);
  }
  if (lsp->tlv_data.is_neighs)
    list_delete (lsp->tlv_data.is_neighs);
  if (lsp->tlv_data.area_addrs)
    list_delete (lsp->tlv_data.area_addrs);
  if (lsp->tlv_data.es_neighs)
    list_delete (lsp->tlv_data.es_neighs);
  if (lsp->tlv_data.ipv4_addrs)
    list_delete (lsp->tlv_data.ipv4_addrs);
  if (lsp->tlv_data.ipv4_int_reachs)
    list_delete (lsp->tlv_data.ipv4_int_reachs);
  if (lsp->tlv_data.ipv4_ext_reachs)
    list_delete (lsp->tlv_data.ipv4_ext_reachs);
#ifdef HAVE_IPV6
  if (lsp->tlv_data.ipv6_addrs)
    list_delete (lsp->tlv_data.ipv6_addrs);
  if (lsp->tlv_data.ipv6_reachs)
    list_delete (lsp->tlv_data.ipv6_reachs);
#endif /* HAVE_IPV6 */

  memset (&lsp->tlv_data, 0, sizeof (struct tlvs));

  return;
}

void
lsp_destroy (struct isis_lsp *lsp)
{
  if (!lsp)
    return;
  
  lsp_clear_data (lsp);
  
  if (LSP_FRAGMENT (lsp->lsp_header->lsp_id) == 0 && lsp->lspu.frags) {
      list_delete (lsp->lspu.frags);
  }
  
  if (lsp->pdu)
    stream_free (lsp->pdu);
  XFREE (MTYPE_ISIS_LSP, lsp);
}

void 
lsp_db_destroy (dict_t *lspdb)
{
  dnode_t *dnode, *next;
  struct isis_lsp *lsp;
  
  dnode = dict_first (lspdb);
  while (dnode) {
    next = dict_next (lspdb, dnode);
    lsp = dnode_get (dnode);
    lsp_destroy (lsp);
    dict_delete_free (lspdb, dnode);
    dnode = next;
  }
  
  dict_free (lspdb);
  
  return;
}

/*
 * Remove all the frags belonging to the given lsp
 */
void
lsp_remove_frags (struct list *frags, dict_t *lspdb)
{
  dnode_t *dnode;
  struct listnode *lnode;
  struct isis_lsp *lsp;

  for (lnode = listhead (frags); lnode; nextnode (lnode)) {
    lsp = getdata (lnode);
    dnode = dict_lookup (lspdb, lsp->lsp_header->lsp_id);
    lsp_destroy (lsp);
    dnode_destroy (dict_delete(lspdb, dnode));
  }
  
  list_delete_all_node (frags);
  
  return;
}

void
lsp_search_and_destroy (u_char *id, dict_t *lspdb)
{
  dnode_t *node;
  struct isis_lsp *lsp;

  node = dict_lookup (lspdb, id);
  if (node) {
    node = dict_delete (lspdb, node);
    lsp = dnode_get (node);
    /*
     * If this is a zero lsp, remove all the frags now 
     */
    if (LSP_FRAGMENT(lsp->lsp_header->lsp_id) == 0) {
      if (lsp->lspu.frags)
        lsp_remove_frags (lsp->lspu.frags, lspdb);
    } else {
    /* 
     * else just remove this frag, from the zero lsps' frag list
     */
      if (lsp->lspu.zero_lsp && lsp->lspu.zero_lsp->lspu.frags)
        listnode_delete (lsp->lspu.zero_lsp->lspu.frags, lsp);
    }
    lsp_destroy (lsp);
    dnode_destroy (node);
  }
}

/*
 * Compares a LSP to given values
 * Params are given in net order
 */
int 
lsp_compare (char *areatag, struct isis_lsp *lsp, u_int32_t seq_num, 
	     u_int16_t checksum, u_int16_t rem_lifetime)
{
      /* no point in double ntohl on seqnum */
  if (lsp->lsp_header->seq_num == seq_num && 
      lsp->lsp_header->checksum == checksum &&
      /*comparing with 0, no need to do ntohl */
      ((lsp->lsp_header->rem_lifetime == 0 && rem_lifetime == 0) ||
       (lsp->lsp_header->rem_lifetime != 0 && rem_lifetime != 0))) { 
    if (isis->debugs & DEBUG_SNP_PACKETS) {
      zlog_info ("ISIS-Snp (%s): LSP %s seq 0x%08x, cksum 0x%04x,"
                 " lifetime %us",
                 areatag,
                 rawlspid_print (lsp->lsp_header->lsp_id),
                 ntohl(lsp->lsp_header->seq_num),
                 ntohs(lsp->lsp_header->checksum),
                 ntohs(lsp->lsp_header->rem_lifetime) );
      zlog_info ("ISIS-Snp (%s):         is equal to ours seq 0x%08x,"
                 " cksum 0x%04x, lifetime %us",
                 areatag,
                 ntohl(seq_num),
                 ntohs(checksum),
                 ntohs(rem_lifetime));
    }
    return LSP_EQUAL;
  }

  if (ntohl(seq_num) >= ntohl(lsp->lsp_header->seq_num)) {
    if (isis->debugs & DEBUG_SNP_PACKETS) {
      zlog_info ("ISIS-Snp (%s): LSP %s seq 0x%08x, cksum 0x%04x,"
                 " lifetime %us",
                 areatag,
                 rawlspid_print (lsp->lsp_header->lsp_id),
                 ntohl(seq_num),
                 ntohs(checksum),
                 ntohs(rem_lifetime ));
      zlog_info ("ISIS-Snp (%s):       is newer than ours seq 0x%08x, "
                 "cksum 0x%04x, lifetime %us",
                 areatag,
                 ntohl(lsp->lsp_header->seq_num),
                 ntohs(lsp->lsp_header->checksum),
                 ntohs(lsp->lsp_header->rem_lifetime) );
    }
    return LSP_NEWER;
  }
  if (isis->debugs & DEBUG_SNP_PACKETS) {
    zlog_info ("ISIS-Snp (%s): LSP %s seq 0x%08x, cksum 0x%04x, lifetime %us",
	       areatag,
	       rawlspid_print (lsp->lsp_header->lsp_id),
	       ntohl(seq_num),
	       ntohs(checksum),
	       ntohs(rem_lifetime ));
    zlog_info ("ISIS-Snp (%s):       is older than ours seq 0x%08x,"
               " cksum 0x%04x, lifetime %us",
	       areatag,
	       ntohl(lsp->lsp_header->seq_num),
	       ntohs(lsp->lsp_header->checksum),
	       ntohs(lsp->lsp_header->rem_lifetime) );
  }

  return LSP_OLDER;
}

void 
lsp_inc_seqnum (struct isis_lsp *lsp, u_int32_t seq_num)
{
  u_int32_t newseq;
  
  if (seq_num == 0 || ntohl (lsp->lsp_header->seq_num) > seq_num)
    newseq = ntohl (lsp->lsp_header->seq_num) + 1;
  else
    newseq = seq_num ++;
  
  lsp->lsp_header->seq_num = htonl (newseq);
  iso_csum_create (STREAM_DATA (lsp->pdu) + 12, 
                   ntohs(lsp->lsp_header->pdu_len) - 12, 12);

  return;
}

/*
 * Genetates checksum for LSP and its frags
 */
void
lsp_seqnum_update (struct isis_lsp *lsp0)
{
  struct isis_lsp *lsp;
  struct listnode *node;
  
  lsp_inc_seqnum (lsp0, 0);

  if (!lsp0->lspu.frags)
    return;

  for (node = listhead (lsp0->lspu.frags); node; nextnode (node)) {
    lsp = getdata (node);
    lsp_inc_seqnum(lsp, 0);
  }
  
  return;
}

int 
isis_lsp_authinfo_check (struct stream *stream, struct isis_area *area,
			 int  pdulen, struct isis_passwd *passwd)
{
  uint32_t expected = 0, found;
  struct tlvs tlvs;
  int retval = 0;

  expected |= TLVFLAG_AUTH_INFO;
  retval = parse_tlvs (area->area_tag, stream->data +
                       ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN,
                       pdulen - ISIS_FIXED_HDR_LEN 
                       - ISIS_LSP_HDR_LEN, 
		       &expected, &found, &tlvs);
  if (retval || !(found & TLVFLAG_AUTH_INFO))
    return 1; /* Auth fail (parsing failed or no auth-tlv)*/

  return authentication_check (passwd, &tlvs.auth_info);
}

void
lsp_update_data (struct isis_lsp *lsp, struct stream *stream, 
                 struct isis_area *area)
{
  uint32_t expected = 0,found;
  int retval;
  
  /* copying only the relevant part of our stream */
  lsp->pdu = stream_new (stream->endp);
  lsp->pdu->putp = stream->putp;
  lsp->pdu->getp = stream->getp;
  lsp->pdu->endp = stream->endp;
  memcpy (lsp->pdu->data, stream->data, stream->endp);

  /* setting pointers to the correct place */
  lsp->isis_header = (struct isis_fixed_hdr *)(STREAM_DATA(lsp->pdu));
  lsp->lsp_header = (struct isis_link_state_hdr *)(STREAM_DATA(lsp->pdu) + 
						   ISIS_FIXED_HDR_LEN);
  lsp->age_out = ZERO_AGE_LIFETIME;
  lsp->installed = time(NULL);
  /*
   * Get LSP data i.e. TLVs
   */
  expected |= TLVFLAG_AUTH_INFO;
  expected |= TLVFLAG_AREA_ADDRS;
  expected |= TLVFLAG_IS_NEIGHS;
  if ((lsp->lsp_header->lsp_bits & 3) == 3) /* a level 2 LSP */
    expected |= TLVFLAG_PARTITION_DESIG_LEVEL2_IS;
  expected |= TLVFLAG_NLPID;
  if (area->dynhostname)
    expected |= TLVFLAG_DYN_HOSTNAME;
  if (area->newmetric) {
    expected |= TLVFLAG_TE_IS_NEIGHS;
    expected |= TLVFLAG_TE_IPV4_REACHABILITY;
    expected |= TLVFLAG_TE_ROUTER_ID;
  }
  expected |= TLVFLAG_IPV4_ADDR;
  expected |= TLVFLAG_IPV4_INT_REACHABILITY;
  expected |= TLVFLAG_IPV4_EXT_REACHABILITY;
#ifdef HAVE_IPV6
  expected |= TLVFLAG_IPV6_ADDR;
  expected |= TLVFLAG_IPV6_REACHABILITY;
#endif /* HAVE_IPV6 */

  retval = parse_tlvs (area->area_tag, lsp->pdu->data +
                       ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN,
                       ntohs(lsp->lsp_header->pdu_len) - ISIS_FIXED_HDR_LEN 
                       - ISIS_LSP_HDR_LEN, &expected, &found, &lsp->tlv_data);

  if (found & TLVFLAG_DYN_HOSTNAME) {
    if (area->dynhostname)
      isis_dynhn_insert (lsp->lsp_header->lsp_id, lsp->tlv_data.hostname,
                         (lsp->lsp_header->lsp_bits & LSPBIT_IST) == 
                         IS_LEVEL_1_AND_2 ? IS_LEVEL_2 : 
                         (lsp->lsp_header->lsp_bits & LSPBIT_IST));
  }

}

void
lsp_update (struct isis_lsp *lsp, struct isis_link_state_hdr *lsp_hdr,
            struct stream *stream, struct isis_area *area)
{

  /* free the old lsp data*/
  XFREE (MTYPE_STREAM_DATA, lsp->pdu);
  lsp_clear_data (lsp);

  /* rebuild the lsp data */
  lsp_update_data (lsp, stream, area);

  /* set the new values for lsp header */ 
  memcpy (lsp->lsp_header, lsp_hdr, ISIS_LSP_HDR_LEN);

}


/* creation of LSP directly from what we received */
struct isis_lsp *
lsp_new_from_stream_ptr (struct stream *stream, 
                         u_int16_t pdu_len, struct isis_lsp *lsp0,
                         struct isis_area *area)
{
  struct isis_lsp *lsp;

  lsp = XMALLOC (MTYPE_ISIS_LSP, sizeof (struct isis_lsp));
  memset (lsp, 0, sizeof (struct isis_lsp));
  
  lsp_update_data (lsp, stream, area);
  
  if (lsp0 == NULL) {
    /*
     * zero lsp -> create the list for fragments
     */
    lsp->lspu.frags = list_new ();
  } else {
    /*
     * a fragment -> set the backpointer and add this to zero lsps frag list
     */
    lsp->lspu.zero_lsp = lsp0;
    listnode_add (lsp0->lspu.frags, lsp);
  }
  
  return lsp;
}

struct isis_lsp *
lsp_new (u_char *lsp_id, u_int16_t rem_lifetime, u_int32_t seq_num, 
         u_int8_t lsp_bits, u_int16_t checksum, int level)
{
  struct isis_lsp *lsp;

  lsp = XMALLOC (MTYPE_ISIS_LSP, sizeof (struct isis_lsp));
  if (!lsp) {
    /* FIXME: set lspdbol bit */
    zlog_warn ("lsp_new(): out of memory");
    return NULL;
  }
  memset (lsp, 0, sizeof (struct isis_lsp));
#ifdef LSP_MEMORY_PREASSIGN
  lsp->pdu = stream_new (1514); /*Should be minimal mtu? yup...*/
#else
  /* We need to do realloc on TLVs additions*/
  lsp->pdu = malloc (ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN); 
#endif /* LSP_MEMORY_PREASSIGN */
  if (LSP_FRAGMENT (lsp_id) == 0)
    lsp->lspu.frags = list_new ();
  lsp->isis_header = (struct isis_fixed_hdr*)(STREAM_DATA(lsp->pdu));
  lsp->lsp_header = (struct isis_link_state_hdr*)
                    (STREAM_DATA(lsp->pdu) + ISIS_FIXED_HDR_LEN);
  
  /* at first we fill the FIXED HEADER */
  (level == 1) ? fill_fixed_hdr (lsp->isis_header, L1_LINK_STATE):
                 fill_fixed_hdr (lsp->isis_header, L2_LINK_STATE);
  
  /* now for the LSP HEADER */
  /* Minimal LSP PDU size */
  lsp->lsp_header->pdu_len = htons (ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN); 
  memcpy (lsp->lsp_header->lsp_id, lsp_id, ISIS_SYS_ID_LEN + 2);
  lsp->lsp_header->checksum = checksum; /* Provided in network order */
  lsp->lsp_header->seq_num = htonl (seq_num);
  lsp->lsp_header->rem_lifetime = htons (rem_lifetime);
  lsp->lsp_header->lsp_bits = lsp_bits;
  lsp->level = level;
  lsp->age_out = ZERO_AGE_LIFETIME;

  stream_set_putp (lsp->pdu, ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN);

  /* #ifdef EXTREME_DEBUG */
  /* logging */
  zlog_info ("New LSP with ID %s-%02x-%02x seqnum %08x", sysid_print (lsp_id),
             LSP_PSEUDO_ID (lsp->lsp_header->lsp_id),
             LSP_FRAGMENT (lsp->lsp_header->lsp_id),
             ntohl (lsp->lsp_header->seq_num));
  /* #endif  EXTREME DEBUG */

  return lsp;
}

void
lsp_insert (struct isis_lsp *lsp, dict_t *lspdb)
{
  dict_alloc_insert (lspdb, lsp->lsp_header->lsp_id, lsp);
}

/*
 * Build a list of LSPs with non-zero ht bounded by start and stop ids
 */
void 
lsp_build_list_nonzero_ht (u_char *start_id, u_char *stop_id, 
                           struct list *list, dict_t *lspdb)
{
  dnode_t *first, *last, *curr;

  first = dict_lower_bound (lspdb, start_id);
  if (!first)
    return;
  
  last = dict_upper_bound (lspdb, stop_id);
  
  curr = first;
  
  if (((struct isis_lsp *)(curr->dict_data))->lsp_header->rem_lifetime)
    listnode_add (list, first->dict_data);

  while (curr) {
    curr = dict_next (lspdb, curr);
    if (curr && 
        ((struct isis_lsp *)(curr->dict_data))->lsp_header->rem_lifetime)
      listnode_add (list, curr->dict_data);
    if (curr == last)
      break;
  }
  
  return;
}

/*
 * Build a list of all LSPs bounded by start and stop ids
 */
void 
lsp_build_list (u_char *start_id, u_char *stop_id, 
                struct list *list, dict_t *lspdb)
{
  dnode_t *first, *last, *curr;

  first = dict_lower_bound (lspdb, start_id);
  if (!first)
    return;
  
  last = dict_upper_bound (lspdb, stop_id);
  
  curr = first;
  
  listnode_add (list, first->dict_data);

  while (curr) {
    curr = dict_next (lspdb, curr);
    if (curr)
      listnode_add (list, curr->dict_data);
    if (curr == last)
      break;
  }
  
  return;
}

/*
 * Build a list of LSPs with SSN flag set for the given circuit
 */
void
lsp_build_list_ssn (struct isis_circuit *circuit, struct list *list, 
                    dict_t *lspdb)
{
  dnode_t *dnode, *next;
  struct isis_lsp *lsp;
  
  dnode = dict_first (lspdb);
  while (dnode != NULL) {
    next = dict_next (lspdb, dnode);
    lsp = dnode_get (dnode);
    if (ISIS_CHECK_FLAG (lsp->SSNflags, circuit))
      listnode_add (list, lsp);
    dnode = next;
  }
  
  return;
}

void
lsp_set_time (struct isis_lsp *lsp)
{
  assert (lsp);
  
  if (lsp->lsp_header->rem_lifetime == 0) {
    if (lsp->age_out != 0) lsp->age_out--;
    return;
  }

  /* If we are turning 0 */
  /* ISO 10589 - 7.3.16.4 first paragraph */

  if (ntohs (lsp->lsp_header->rem_lifetime) == 1) {
    /* 7.3.16.4 a) set SRM flags on all */
    ISIS_FLAGS_SET_ALL (lsp->SRMflags);
    /* 7.3.16.4 b) retain only the header FIXME  */
    /* 7.3.16.4 c) record the time to purge FIXME (other way to do it)*/
  }

  lsp->lsp_header->rem_lifetime = 
    htons (ntohs (lsp->lsp_header->rem_lifetime) - 1);
}

void
lspid_print (u_char *lsp_id, u_char *trg, char dynhost, char frag)
{
  struct isis_dynhn *dyn = NULL;
  u_char id [SYSID_STRLEN];

  if (dynhost)
    dyn = dynhn_find_by_id (lsp_id);
  else
    dyn = NULL;

  if (dyn)
    sprintf (id, "%.14s", dyn->name.name);
  else if (!memcmp (isis->sysid, lsp_id, ISIS_SYS_ID_LEN) & dynhost)
    sprintf (id, "%.14s", unix_hostname());
   else {
    memcpy(id, sysid_print (lsp_id), 15);
  }
  if (frag)
    sprintf (trg, "%s.%02x-%02x", id, LSP_PSEUDO_ID(lsp_id), 
             LSP_FRAGMENT(lsp_id));
  else
    sprintf (trg, "%s.%02x", id, LSP_PSEUDO_ID(lsp_id));
}

/* Convert the lsp attribute bits to attribute string */ 
char * 
lsp_bits2string (u_char *lsp_bits) {

  char *pos = lsp_bits_string; 

  if(!*lsp_bits)
    return " none";

  /* we only focus on the default metric */
  pos += sprintf (pos, "%d/",
           ISIS_MASK_LSP_ATT_DEFAULT_BIT(*lsp_bits) ?
           1 : 0);

  pos += sprintf (pos, "%d/",
           ISIS_MASK_LSP_PARTITION_BIT(*lsp_bits) ?
           1 : 0);

  pos += sprintf (pos, "%d",
           ISIS_MASK_LSP_OL_BIT(*lsp_bits) ?
           1 : 0);
  
  *(pos) = '\0';
  
  return lsp_bits_string;

}

/* this function prints the lsp on show isis database */
void
lsp_print (dnode_t *node, struct vty *vty, char dynhost)
{
  struct isis_lsp *lsp = dnode_get(node);
  u_char LSPid[255];

  lspid_print (lsp->lsp_header->lsp_id, LSPid, dynhost, 1);
  vty_out (vty, "%-21s%c   ", LSPid,lsp->own_lsp?'*':' ');
  vty_out (vty, "0x%08x   ", ntohl(lsp->lsp_header->seq_num));
  vty_out (vty, "0x%04x      ", ntohs(lsp->lsp_header->checksum));

  if (ntohs(lsp->lsp_header->rem_lifetime) == 0)
    vty_out (vty, " (%2u)",lsp->age_out);
  else
    vty_out (vty, "%5u", ntohs(lsp->lsp_header->rem_lifetime));

  vty_out (vty, "         %s%s",
    lsp_bits2string(&lsp->lsp_header->lsp_bits),	   
    VTY_NEWLINE);
}

void
lsp_print_detail (dnode_t *node, struct vty *vty, char dynhost)
{
  struct isis_lsp *lsp = dnode_get (node);
  struct area_addr *area_addr;
  char   nlpidstr[2];
  int    i;
  struct listnode *lnode;
  struct is_neigh *is_neigh;
  struct te_is_neigh *te_is_neigh;
  struct ipv4_reachability *ipv4_reach;
  struct in_addr *ipv4_addr;
  struct te_ipv4_reachability *te_ipv4_reach;
#ifdef HAVE_IPV6
  struct ipv6_reachability *ipv6_reach;
  struct in6_addr in6;
#endif
  u_char LSPid[255];
  u_char hostname[255];
  u_char buff[BUFSIZ];
  u_int32_t now,helper;
  u_char ipv4_reach_prefix[20];
  u_char ipv4_reach_mask[20];
  u_char ipv4_address[20];

  lspid_print (lsp->lsp_header->lsp_id, LSPid, dynhost, 1);
  lsp_print(node, vty, dynhost);

  /* for all area address */
  if (lsp->tlv_data.area_addrs) {
    LIST_LOOP (lsp->tlv_data.area_addrs, area_addr, lnode) {
    vty_out (vty, "  Area Address:  %s%s", 
		   isonet_print (area_addr->area_addr, area_addr->addr_len), 
		   VTY_NEWLINE);
    }
  }

  /* for the nlpid tlv */
  if (lsp->tlv_data.nlpids) {
    for (i = 0; i < lsp->tlv_data.nlpids->count; i++) {
      switch (lsp->tlv_data.nlpids->nlpids[i]) {
      case NLPID_IP:
      case NLPID_IPV6:
        vty_out (vty, "  NLPID:         0x%X%s",
               lsp->tlv_data.nlpids->nlpids[i],
               VTY_NEWLINE);
        break;
      default:
        vty_out (vty, "  NLPID:         %s%s",
               "unknown",
               VTY_NEWLINE);
        break;
      }
    } 
  }

  /* for the hostname tlv */
  if (lsp->tlv_data.hostname) {
    bzero (hostname, sizeof (hostname));
    memcpy (hostname, lsp->tlv_data.hostname->name,
            lsp->tlv_data.hostname->namelen);
    vty_out (vty, "  Hostname: %s%s", hostname, VTY_NEWLINE);
  }

  if (lsp->tlv_data.ipv4_addrs) {
    LIST_LOOP(lsp->tlv_data.ipv4_addrs, ipv4_addr, lnode) {
      memcpy (ipv4_address, inet_ntoa (*ipv4_addr), sizeof (ipv4_address));
      vty_out (vty, "  IP:        %s%s",
               ipv4_address,
               VTY_NEWLINE);
    }
  }
  
  /* for the internal reachable tlv */
  if (lsp->tlv_data.ipv4_int_reachs)
    LIST_LOOP(lsp->tlv_data.ipv4_int_reachs, ipv4_reach, lnode) {
      memcpy (ipv4_reach_prefix, inet_ntoa (ipv4_reach->prefix), sizeof (ipv4_reach_prefix));
      memcpy (ipv4_reach_mask, inet_ntoa (ipv4_reach->mask), sizeof (ipv4_reach_mask));
      vty_out (vty, "  Metric: %d IP %s %s%s",
             ipv4_reach->metrics.metric_default,
             ipv4_reach_prefix,
             ipv4_reach_mask,
             VTY_NEWLINE);
  }

  /* for the external reachable tlv */
  if (lsp->tlv_data.ipv4_ext_reachs)
    LIST_LOOP(lsp->tlv_data.ipv4_ext_reachs, ipv4_reach, lnode) {
      memcpy (ipv4_reach_prefix, inet_ntoa (ipv4_reach->prefix), sizeof (ipv4_reach_prefix));
      memcpy (ipv4_reach_mask, inet_ntoa (ipv4_reach->mask), sizeof (ipv4_reach_mask));
      vty_out (vty, "  Metric: %d IP-External %s %s%s",
             ipv4_reach->metrics.metric_default,
             ipv4_reach_prefix,
             ipv4_reach_mask,
             VTY_NEWLINE);
  }

  /* for the IS neighbor tlv */
  if (lsp->tlv_data.is_neighs) {
    LIST_LOOP(lsp->tlv_data.is_neighs,is_neigh,lnode) {
      lspid_print (is_neigh->neigh_id, LSPid, dynhost, 0);
      vty_out (vty, "  Metric: %d IS %s%s",
              is_neigh->metrics.metric_default,
              LSPid,
              VTY_NEWLINE);
    }
  }

  /* IPv6 tlv */
#ifdef HAVE_IPV6
  if (lsp->tlv_data.ipv6_reachs)
    LIST_LOOP(lsp->tlv_data.ipv6_reachs, ipv6_reach, lnode) {
      memset(&in6, 0, sizeof(in6));
      memcpy (in6.s6_addr, ipv6_reach->prefix, PSIZE(ipv6_reach->prefix_len));
      inet_ntop (AF_INET6, &in6, buff, BUFSIZ);
      if ((ipv6_reach->control_info &&
            CTRL_INFO_DISTRIBUTION) == DISTRIBUTION_INTERNAL)
        vty_out (vty, "  Metric: %d IPv6-Intern %s/%d%s",
               ntohl (ipv6_reach->metric),
               buff,
               ipv6_reach->prefix_len,
               VTY_NEWLINE);
      else
        vty_out (vty, "  Metric: %d IPv6-Extern %s/%d%s",
               ntohl (ipv6_reach->metric),
               buff,
               ipv6_reach->prefix_len,
               VTY_NEWLINE);
    }
#endif

/* FIXME: Other tlvs such as te or external tlv will be added later */
#if 0  
  vty_out (vty, "%s  %s %c%s",
	   VTY_NEWLINE,
	   LSPid,
	   lsp->own_lsp ? '*' : ' ',
	   VTY_NEWLINE);

  vty_out (vty, "    Sequence: 0x%08x Checksum: 0x%04x Lifetime: ",
	   ntohl (lsp->lsp_header->seq_num),
	   ntohs (lsp->lsp_header->checksum));

  if (ntohs (lsp->lsp_header->rem_lifetime) == 0)
    vty_out (vty, " (%2u) ", lsp->age_out);
  else
    vty_out (vty, "%5u ", ntohs (lsp->lsp_header->rem_lifetime));

  vty_out (vty, "%s    Attributes:%s",
	   VTY_NEWLINE,
	   lsp_bits2string (&lsp->lsp_header->lsp_bits));

  /* if this is a self originated LSP then print
   * the generation time plus when we sent it last
   * if it is a non self-originated LSP then print the
   * time when the LSP has been installed
   */

  if (lsp->own_lsp) {

    now = time (NULL);
    helper = now - lsp->last_generated;
    if (!lsp->last_generated)
      helper = 0;

    vty_out (vty, ", Generated: %s ago",
	     time2string (helper));

    now = time (NULL);
    helper = now - lsp->last_sent;
    if (!lsp->last_sent)
      helper = 0;

    vty_out (vty, ", Last sent: %s ago",
	     time2string (helper));
  } else {
    now = time (NULL);
    helper = now - lsp->installed;
    if (!lsp->installed)
      helper = 0;

    vty_out (vty, ", Installed: %s ago",
	     time2string (helper));

  }

  vty_out (vty, "%s", VTY_NEWLINE);

  if (lsp->tlv_data.nlpids)  {
    vty_out (vty, "    Speaks: %s%s", nlpid2string (lsp->tlv_data.nlpids), 
             VTY_NEWLINE);
  }

  if (lsp->tlv_data.router_id)  {
    vty_out (vty, "     Router ID: %s%s", 
             inet_ntoa (lsp->tlv_data.router_id->id), VTY_NEWLINE);
  }

  if (lsp->tlv_data.is_neighs)
  LIST_LOOP(lsp->tlv_data.is_neighs,is_neigh,lnode) {
    lspid_print (is_neigh->neigh_id, LSPid, dynhost, 0);
    vty_out (vty, "     IS      %s, Metric: %d%s",
             LSPid,
	     is_neigh->metrics.metric_default,
	     VTY_NEWLINE);
  }

  if (lsp->tlv_data.te_is_neighs)
    LIST_LOOP(lsp->tlv_data.te_is_neighs,te_is_neigh,lnode) {
    /* FIXME: metric display is wrong */
    lspid_print (te_is_neigh->neigh_id, LSPid, dynhost, 0);
    vty_out (vty, "     extd-IS %s, Metric: %d%s",
             LSPid,	     
	     te_is_neigh->te_metric[0],
	     VTY_NEWLINE);
  }

  if (lsp->tlv_data.ipv4_int_reachs)
    LIST_LOOP(lsp->tlv_data.ipv4_int_reachs, ipv4_reach, lnode) {
    vty_out (vty, "     int-IP  %s/%d, Metric: %d%s",
             inet_ntoa (ipv4_reach->prefix),
	     ip_masklen (ipv4_reach->mask),
	     ipv4_reach->metrics.metric_default,
	     VTY_NEWLINE);
  }

  if (lsp->tlv_data.ipv4_ext_reachs)
    LIST_LOOP(lsp->tlv_data.ipv4_ext_reachs,ipv4_reach,lnode) {
    vty_out (vty, "     ext-IP  %s/%d, Metric: %d%s",
             inet_ntoa(ipv4_reach->prefix),
	     ip_masklen(ipv4_reach->mask),
	     ipv4_reach->metrics.metric_default,
	     VTY_NEWLINE);
  }

  if (lsp->tlv_data.te_ipv4_reachs)
    LIST_LOOP(lsp->tlv_data.te_ipv4_reachs,te_ipv4_reach,lnode) {
    vty_out (vty, "     extd-IP %s/%d, Metric: %d%s",
             inet_ntoa ( newprefix2inaddr (&te_ipv4_reach->prefix_start, 
                                           te_ipv4_reach->control)),
             te_ipv4_reach->control & 0x3F,
	     ntohl (te_ipv4_reach->te_metric),
	     VTY_NEWLINE);
  }

#ifdef HAVE_IPV6
  if (lsp->tlv_data.ipv6_reachs)
    LIST_LOOP(lsp->tlv_data.ipv6_reachs, ipv6_reach, lnode) {
    memcpy (in6.s6_addr, ipv6_reach->prefix, 16);
    inet_ntop (AF_INET6, &in6, buff, BUFSIZ);
    if ((ipv6_reach->control_info &&  
        CTRL_INFO_DISTRIBUTION) == DISTRIBUTION_INTERNAL)
      vty_out (vty, "     int-IPv6 %s/%d, Metric: %d%s",
               buff,
               ipv6_reach->prefix_len,
               ntohl (ipv6_reach->metric),
               VTY_NEWLINE);
    else
      vty_out (vty, "     ext-IPv6 %s/%d, Metric: %d%s",
               buff,
               ipv6_reach->prefix_len,
               ntohl (ipv6_reach->metric),
               VTY_NEWLINE);
    
  }
#endif
  if (lsp->tlv_data.hostname) {
    memset (hostname, 0, sizeof (hostname));
    memcpy (hostname, lsp->tlv_data.hostname->name,
            lsp->tlv_data.hostname->namelen);
    vty_out (vty, "    Hostname: %s%s", hostname, VTY_NEWLINE);
  }
#endif
 return;
}

/* print all the lsps info in the local lspdb */
int 
lsp_print_all (struct vty *vty, dict_t *lspdb, char detail, char dynhost)
{

  dnode_t *node = dict_first(lspdb), *next;
  int lsp_count = 0;

  /* print the title, for both modes */
  vty_out (vty, "LSP ID                   LSP Seq Num  LSP Checksum "
             "LSP Holdtime ATT/P/OL%s", VTY_NEWLINE);
             
  if (detail == ISIS_UI_LEVEL_BRIEF) {
    while (node != NULL) {
      /* dict_contains (lspdb, node); */ /* I think it is unnecessary, so I comment it out */
      next = dict_next (lspdb, node);
      lsp_print (node, vty, dynhost);
      node = next;
      lsp_count++;
    }
  } else if (detail == ISIS_UI_LEVEL_DETAIL) {
    while (node != NULL) {
      next = dict_next (lspdb, node);
      lsp_print_detail (node, vty, dynhost);
      node = next;
      lsp_count++;
    }
  }

  return lsp_count;
}

/* this function reallocate memory to an lsp pdu, with an additional
 * size of memory, it scans the lsp and moves all pointers the
 * way they should */
u_char *
lsppdu_realloc (struct isis_lsp *lsp, int memorytype, int size)
{
  u_char *retval;
  
  retval = STREAM_DATA(lsp->pdu) + ntohs(lsp->lsp_header->pdu_len);
#ifdef   LSP_MEMORY_PREASSIGN
  lsp->lsp_header->pdu_len = htons(ntohs(lsp->lsp_header->pdu_len) + size);
  return retval;
#else    /* otherwise we have to move all pointers */
  u_char *newpdu;
  newpdu = stream_new (ntohs (lsp->lsp_header->pdu_len) + size);
  memcpy (STREAM_DATA (newpdu), STREAM_DATA(lsp->pdu), 
          ntohs (lsp->lsp_header->pdu_len));
  XFREE (memorytype, lsp->pdu);
  lsp->pdu = newpdu;
  lsp->isis_header = (struct isis_fixed_hdr*)STREAM_DATA(lsp->pdu);
  lsp->lsp_header = (struct isis_link_state_hdr*)
                    (STREAM_DATA(lsp->pdu) + ISIS_FIXED_HDR_LEN);
  htons (ntohs (lsp->lsp_header->pdu_len) += size);
  return STREAM_DATA(lsp->pdu) + (lsp->lsp_header->pdu_len - size);
#endif /* LSP_MEMORY_PREASSIGN */
}


#if 0 /* Saving the old one just in case :) */
/*
 * Builds the lsp->tlv_data
 * and writes the tlvs into lsp->pdu 
 */
void
lsp_build_nonpseudo (struct isis_lsp *lsp, struct isis_area *area)
{
  struct is_neigh *is_neigh;
  struct listnode *node, *ipnode;
  int level = lsp->level;
  struct isis_circuit *circuit;
  struct prefix_ipv4 *ipv4;
  struct ipv4_reachability *ipreach;
  struct isis_adjacency *nei;
#ifdef HAVE_IPV6
  struct prefix_ipv6 *ipv6;
  struct ipv6_reachability *ip6reach;
#endif /* HAVE_IPV6 */
  
  /*
   * First add the tlvs related to area
   */
  
  /* Area addresses */
  if (lsp->tlv_data.area_addrs == NULL)
    lsp->tlv_data.area_addrs = list_new ();
  list_add_list (lsp->tlv_data.area_addrs, area->area_addrs);
  /* Protocols Supported */
  if (area->ip_circuits > 0 
#ifdef HAVE_IPV6
      || area->ipv6_circuits > 0
#endif /* HAVE_IPV6 */
      )
    {
      lsp->tlv_data.nlpids = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct nlpids));
      lsp->tlv_data.nlpids->count = 0;
      if (area->ip_circuits > 0) { 
        lsp->tlv_data.nlpids->count++;
        lsp->tlv_data.nlpids->nlpids[0] = NLPID_IP;
      }  
#ifdef HAVE_IPV6
      if (area->ipv6_circuits > 0) {  
        lsp->tlv_data.nlpids->count++;
        lsp->tlv_data.nlpids->nlpids[lsp->tlv_data.nlpids->count - 1] = 
        NLPID_IPV6;
      } 
#endif /* HAVE_IPV6 */
    }
  /* Dynamic Hostname */
  if (area->dynhostname) {
    lsp->tlv_data.hostname = XMALLOC (MTYPE_ISIS_TLV, 
                                      sizeof (struct hostname));
    memcpy (&lsp->tlv_data.hostname->name, unix_hostname(),
            strlen(unix_hostname()));
    lsp->tlv_data.hostname->namelen = strlen (unix_hostname());
  }
#ifdef TOPOLOGY_GENERATE
  /*
   * If we have a topology in this area, we need to connect this lsp to
   * the first topology lsp
   */
  if ((area->topology) && (level == 1)) {
    if (lsp->tlv_data.is_neighs == NULL)
      lsp->tlv_data.is_neighs = list_new ();
    is_neigh = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct is_neigh));
    memset (is_neigh, 0, sizeof (struct is_neigh));
    memcpy (&is_neigh->neigh_id, area->topology_baseis, ISIS_SYS_ID_LEN);
    /* connected to the first */
    is_neigh->neigh_id[ISIS_SYS_ID_LEN-1] = (0x01); 
    /* this is actually the same system, why mess the SPT */
    is_neigh->metrics.metric_default = 0; 
    is_neigh->metrics.metric_delay = METRICS_UNSUPPORTED;
    is_neigh->metrics.metric_expense = METRICS_UNSUPPORTED;
    is_neigh->metrics.metric_error = METRICS_UNSUPPORTED;
    listnode_add (lsp->tlv_data.is_neighs, is_neigh);

  }
#endif

  /*
   * Then add tlvs related to circuits
   */
  for (node = listhead (area->circuit_list); node; nextnode (node)) {
    circuit = getdata (node);
    if (circuit->state != C_STATE_UP)
      continue;
    
    /*
     * Add IPv4 internal reachability of this circuit
     */
    if (circuit->ip_router && circuit->ip_addrs && 
        circuit->ip_addrs->count > 0) {
      if (lsp->tlv_data.ipv4_int_reachs == NULL) { 
        lsp->tlv_data.ipv4_int_reachs = list_new ();
        lsp->tlv_data.ipv4_int_reachs->del = free_tlv;
      }
      for (ipnode = listhead (circuit->ip_addrs); ipnode; nextnode (ipnode)) {
        ipv4 = getdata (ipnode);
        ipreach = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct ipv4_reachability));
        ipreach->metrics = circuit->metrics[level - 1];
        ipreach->prefix = ipv4->prefix;
        masklen2ip (ipv4->prefixlen, &ipreach->mask); 
        listnode_add (lsp->tlv_data.ipv4_int_reachs, ipreach);
      }
    }
#ifdef HAVE_IPV6
    /*
     * Add IPv6 reachability of this circuit
     */
    if (circuit->ipv6_router && circuit->ipv6_non_link && 
        circuit->ipv6_non_link->count > 0) {
        if (lsp->tlv_data.ipv6_reachs == NULL) {
            lsp->tlv_data.ipv6_reachs = list_new ();
            lsp->tlv_data.ipv6_reachs->del = free_tlv;
        }
      for (ipnode = listhead (circuit->ipv6_non_link); ipnode; 
           nextnode (ipnode)) {
        ipv6 = getdata (ipnode);
        ip6reach = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct ipv6_reachability));
        memset (ip6reach, 0, sizeof (struct ipv6_reachability));
        ip6reach->metric = htonl(circuit->metrics[level - 1].metric_default);
        ip6reach->control_info = 0;
        ip6reach->prefix_len = ipv6->prefixlen;
        memcpy (&ip6reach->prefix, ipv6->prefix.s6_addr, 
                (ipv6->prefixlen + 7) / 8);
        listnode_add (lsp->tlv_data.ipv6_reachs, ip6reach);
      }
    }
#endif /* HAVE_IPV6 */
    
    switch (circuit->circ_type) {
    case CIRCUIT_T_BROADCAST:
      if (level & circuit->circuit_is_type) {
        if (lsp->tlv_data.is_neighs == NULL) {
          lsp->tlv_data.is_neighs = list_new ();
          lsp->tlv_data.is_neighs->del = free_tlv;
        }
        is_neigh = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct is_neigh));
        memset (is_neigh, 0, sizeof (struct is_neigh));
        if (level == 1)
          memcpy (&is_neigh->neigh_id, 
                  circuit->u.bc.l1_desig_is, ISIS_SYS_ID_LEN + 1);
        else
          memcpy (&is_neigh->neigh_id, 
                  circuit->u.bc.l2_desig_is, ISIS_SYS_ID_LEN + 1);
            is_neigh->metrics = circuit->metrics[level - 1];
        listnode_add (lsp->tlv_data.is_neighs, is_neigh);
      }
      break;
    case CIRCUIT_T_P2P:
      nei = circuit->u.p2p.neighbor; 
        if (nei && (level & nei->circuit_t)) {
          if (lsp->tlv_data.is_neighs == NULL) {
            lsp->tlv_data.is_neighs = list_new ();
            lsp->tlv_data.is_neighs->del = free_tlv;
          }
          is_neigh = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct is_neigh));
          memset (is_neigh, 0, sizeof (struct is_neigh));
          memcpy (&is_neigh->neigh_id, nei->sysid, ISIS_SYS_ID_LEN);
          is_neigh->metrics = circuit->metrics[level - 1];
          listnode_add (lsp->tlv_data.is_neighs, is_neigh);
      }
      break;
    case  CIRCUIT_T_STATIC_IN:
      zlog_warn ("lsp_area_create: unsupported circuit type");
      break;
    case  CIRCUIT_T_STATIC_OUT:
      zlog_warn ("lsp_area_create: unsupported circuit type");
      break;
    case CIRCUIT_T_DA:
      zlog_warn ("lsp_area_create: unsupported circuit type");
      break;
    default:
      zlog_warn ("lsp_area_create: unknown circuit type");
    }
  }
  
  stream_set_putp (lsp->pdu, ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN);
  
  if (lsp->tlv_data.nlpids)
    tlv_add_nlpid (lsp->tlv_data.nlpids, lsp->pdu);
  if (lsp->tlv_data.hostname)
    tlv_add_dynamic_hostname (lsp->tlv_data.hostname, lsp->pdu);
  if (lsp->tlv_data.area_addrs && listcount (lsp->tlv_data.area_addrs) > 0 )
    tlv_add_area_addrs (lsp->tlv_data.area_addrs, lsp->pdu);
  if (lsp->tlv_data.is_neighs && listcount (lsp->tlv_data.is_neighs) > 0)
    tlv_add_is_neighs (lsp->tlv_data.is_neighs, lsp->pdu);
  if (lsp->tlv_data.ipv4_int_reachs  && 
      listcount (lsp->tlv_data.ipv4_int_reachs) > 0)
    tlv_add_ipv4_reachs (lsp->tlv_data.ipv4_int_reachs, lsp->pdu);
#ifdef  HAVE_IPV6 
  if (lsp->tlv_data.ipv6_reachs && 
      listcount (lsp->tlv_data.ipv6_reachs) > 0)
    tlv_add_ipv6_reachs (lsp->tlv_data.ipv6_reachs, lsp->pdu);
#endif /* HAVE_IPV6 */

  lsp->lsp_header->pdu_len = htons (stream_get_putp (lsp->pdu));

  return;
}
#endif

#define FRAG_THOLD(S,T) \
((STREAM_SIZE(S)*T)/100)

/* stream*, area->lsp_frag_threshold, increment */
#define FRAG_NEEDED(S,T,I) \
  (STREAM_SIZE(S)-STREAM_REMAIN(S)+(I) > FRAG_THOLD(S,T))

void
lsp_tlv_fit (struct isis_lsp *lsp, struct list **from, struct list **to,
             int tlvsize, int frag_thold, 
             int tlv_build_func(struct list *, struct stream *))
{
  int count, i;
  
  /* can we fit all ? */
  if (!FRAG_NEEDED(lsp->pdu, frag_thold,
                   listcount(*from) * tlvsize + 2)) {
    tlv_build_func (*from, lsp->pdu);
    *to = *from;
    *from = NULL;
  } else if (!FRAG_NEEDED(lsp->pdu, frag_thold, tlvsize + 2)) {
    /* fit all we can */
    count = FRAG_THOLD(lsp->pdu,frag_thold) - 2 - 
      (STREAM_SIZE(lsp->pdu) - STREAM_REMAIN(lsp->pdu));
    if (count)
      count = count / tlvsize;
    for (i = 0; i < count; i++) {
      listnode_add (*to, getdata(listhead(*from)));
      listnode_delete(*from, getdata(listhead(*from)));
    }
    tlv_build_func (*to, lsp->pdu);
  }
  lsp->lsp_header->pdu_len = htons (stream_get_putp (lsp->pdu));  
  return;
}

struct isis_lsp  *
lsp_next_frag (u_char frag_num, struct isis_lsp *lsp0, struct isis_area *area, 
               int level )
{
  struct isis_lsp *lsp;
  u_char frag_id[ISIS_SYS_ID_LEN + 2]; 
  
  memcpy (frag_id, lsp0->lsp_header->lsp_id, ISIS_SYS_ID_LEN + 1);
  LSP_FRAGMENT (frag_id) = frag_num;
  lsp = lsp_search (frag_id, area->lspdb[level - 1]);
  if (lsp) {
    /*
     * Clear the TLVs, but inherit the authinfo
     */
    lsp_clear_data (lsp);
    if (lsp0->tlv_data.auth_info.type) {
      memcpy (&lsp->tlv_data.auth_info, &lsp->tlv_data.auth_info, 
	      sizeof (struct isis_passwd));
      tlv_add_authinfo (lsp->tlv_data.auth_info.type, 
			lsp->tlv_data.auth_info.len, 
		      lsp->tlv_data.auth_info.passwd, lsp->pdu);
    }
    return lsp;
  } 
  lsp = lsp_new (frag_id, area->max_lsp_lifetime[level - 1], 0, area->is_type,
                 0, level);
  lsp->own_lsp = 1;
  lsp_insert (lsp, area->lspdb[level-1]);
  listnode_add (lsp0->lspu.frags, lsp);
  lsp->lspu.zero_lsp = lsp0;
  /*
   * Copy the authinfo from zero LSP
   */
  if (lsp0->tlv_data.auth_info.type) {
    memcpy (&lsp->tlv_data.auth_info, &lsp->tlv_data.auth_info, 
	    sizeof (struct isis_passwd));
    tlv_add_authinfo (lsp->tlv_data.auth_info.type, 
		      lsp->tlv_data.auth_info.len, 
		      lsp->tlv_data.auth_info.passwd, lsp->pdu);
  }
  return lsp;
}

/*
 * Builds the LSP data part. This func creates a new frag whenever 
 * area->lsp_frag_threshold is exceeded.
 */
#if 1
void
lsp_build_nonpseudo (struct isis_lsp *lsp, struct isis_area *area)
{
  struct is_neigh *is_neigh;
  struct listnode *node, *ipnode;
  int level = lsp->level;
  struct isis_circuit *circuit;
  struct prefix_ipv4 *ipv4;
  struct ipv4_reachability *ipreach;
  struct isis_adjacency *nei;
#ifdef HAVE_IPV6
  struct prefix_ipv6 *ipv6;
  struct ipv6_reachability *ip6reach;
#endif /* HAVE_IPV6 */
  struct tlvs tlv_data;
  struct isis_lsp *lsp0 = lsp;
  struct isis_passwd *passwd;

  /*
   * First add the tlvs related to area
   */
  
  /* Area addresses */
  if (lsp->tlv_data.area_addrs == NULL)
    lsp->tlv_data.area_addrs = list_new ();
  list_add_list (lsp->tlv_data.area_addrs, area->area_addrs);
  /* Protocols Supported */
  if (area->ip_circuits > 0 
#ifdef HAVE_IPV6
      || area->ipv6_circuits > 0
#endif /* HAVE_IPV6 */
      )
    {
      lsp->tlv_data.nlpids = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct nlpids));
      lsp->tlv_data.nlpids->count = 0;
      if (area->ip_circuits > 0) { 
        lsp->tlv_data.nlpids->count++;
        lsp->tlv_data.nlpids->nlpids[0] = NLPID_IP;
      }  
#ifdef HAVE_IPV6
      if (area->ipv6_circuits > 0) {  
        lsp->tlv_data.nlpids->count++;
        lsp->tlv_data.nlpids->nlpids[lsp->tlv_data.nlpids->count - 1] = 
        NLPID_IPV6;
      } 
#endif /* HAVE_IPV6 */
    }
  /* Dynamic Hostname */
  if (area->dynhostname) {
    lsp->tlv_data.hostname = XMALLOC (MTYPE_ISIS_TLV, 
                                      sizeof (struct hostname));

    memcpy (lsp->tlv_data.hostname->name, unix_hostname(),
            strlen (unix_hostname()));
    lsp->tlv_data.hostname->namelen = strlen (unix_hostname());
  }

  /*
   * Building the zero lsp
   */
  stream_set_putp (lsp->pdu, ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN);  
  /*
   * Add the authentication info if its present
   */
  (level == 1) ? (passwd = &area->area_passwd) : 
                 (passwd = &area->domain_passwd);
  if (passwd->type) {
    memcpy (&lsp->tlv_data.auth_info, passwd, sizeof (struct isis_passwd));
    tlv_add_authinfo (passwd->type, passwd->len,
		      passwd->passwd, lsp->pdu);
  }
  if (lsp->tlv_data.nlpids)
    tlv_add_nlpid (lsp->tlv_data.nlpids, lsp->pdu);
  if (lsp->tlv_data.hostname)
    tlv_add_dynamic_hostname (lsp->tlv_data.hostname, lsp->pdu);
  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));
  /*
   * Then build lists of tlvs related to circuits
   */
  for (node = listhead (area->circuit_list); node; nextnode (node)) {
    circuit = getdata (node);
    if (circuit->state != C_STATE_UP)
      continue;
    
    /*
     * Add IPv4 internal reachability of this circuit
     */
    if (circuit->ip_router && circuit->ip_addrs && 
        circuit->ip_addrs->count > 0) {
      if (tlv_data.ipv4_int_reachs == NULL) { 
        tlv_data.ipv4_int_reachs = list_new ();
      }
      for (ipnode = listhead (circuit->ip_addrs); ipnode; nextnode (ipnode)) {
        ipv4 = getdata (ipnode);
        ipreach = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct ipv4_reachability));
        ipreach->metrics = circuit->metrics[level - 1];
        ipreach->prefix = ipv4->prefix;
        masklen2ip (ipv4->prefixlen, &ipreach->mask); 
        listnode_add (tlv_data.ipv4_int_reachs, ipreach);
      }

    }
#ifdef HAVE_IPV6
    /*
     * Add IPv6 reachability of this circuit
     */
    if (circuit->ipv6_router && circuit->ipv6_non_link && 
        circuit->ipv6_non_link->count > 0) {
      
      if (tlv_data.ipv6_reachs == NULL) {
        tlv_data.ipv6_reachs = list_new ();
      }
      for (ipnode = listhead (circuit->ipv6_non_link); ipnode; 
           nextnode (ipnode)) {
        ipv6 = getdata (ipnode);
        ip6reach = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct ipv6_reachability));
        memset (ip6reach, 0, sizeof (struct ipv6_reachability));
        ip6reach->metric = htonl(circuit->metrics[level - 1].metric_default);
        ip6reach->control_info = 0;
        ip6reach->prefix_len = ipv6->prefixlen;
        memcpy (ip6reach->prefix, ipv6->prefix.s6_addr, 
                (ipv6->prefixlen + 7) / 8);
        listnode_add (tlv_data.ipv6_reachs, ip6reach);
      }
    }
#endif /* HAVE_IPV6 */
    
    switch (circuit->circ_type) {
    case CIRCUIT_T_BROADCAST:
      if (level & circuit->circuit_is_type) {
        if (tlv_data.is_neighs == NULL) {
          tlv_data.is_neighs = list_new ();
        }
        is_neigh = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct is_neigh));
        memset (is_neigh, 0, sizeof (struct is_neigh));
        if (level == 1)
          memcpy (is_neigh->neigh_id, 
                  circuit->u.bc.l1_desig_is, ISIS_SYS_ID_LEN + 1);
        else
          memcpy (is_neigh->neigh_id, 
                  circuit->u.bc.l2_desig_is, ISIS_SYS_ID_LEN + 1);
            is_neigh->metrics = circuit->metrics[level - 1];
        listnode_add (tlv_data.is_neighs, is_neigh);
      }
      break;
    case CIRCUIT_T_P2P:
      nei = circuit->u.p2p.neighbor; 
        if (nei && (level & nei->circuit_t)) {
          if (tlv_data.is_neighs == NULL) {
            tlv_data.is_neighs = list_new ();
            tlv_data.is_neighs->del = free_tlv;
          }
          is_neigh = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct is_neigh));
          memset (is_neigh, 0, sizeof (struct is_neigh));
          memcpy (is_neigh->neigh_id, nei->sysid, ISIS_SYS_ID_LEN);
          is_neigh->metrics = circuit->metrics[level - 1];
          listnode_add (tlv_data.is_neighs, is_neigh);
      }
      break;
    case  CIRCUIT_T_STATIC_IN:
      zlog_warn ("lsp_area_create: unsupported circuit type");
      break;
    case  CIRCUIT_T_STATIC_OUT:
      zlog_warn ("lsp_area_create: unsupported circuit type");
      break;
    case CIRCUIT_T_DA:
      zlog_warn ("lsp_area_create: unsupported circuit type");
      break;
    default:
      zlog_warn ("lsp_area_create: unknown circuit type");
    }
  }
  
  while (tlv_data.ipv4_int_reachs && listcount(tlv_data.ipv4_int_reachs)) {
    if (lsp->tlv_data.ipv4_int_reachs == NULL)
      lsp->tlv_data.ipv4_int_reachs = list_new ();
    lsp_tlv_fit (lsp, &tlv_data.ipv4_int_reachs, 
                 &lsp->tlv_data.ipv4_int_reachs,
                 IPV4_REACH_LEN, area->lsp_frag_threshold, 
                 tlv_add_ipv4_reachs);
    if (tlv_data.ipv4_int_reachs && listcount(tlv_data.ipv4_int_reachs))
      lsp = lsp_next_frag (LSP_FRAGMENT(lsp->lsp_header->lsp_id) + 1, 
                           lsp0, area, level);
  }

#ifdef  HAVE_IPV6   
  while (tlv_data.ipv6_reachs && listcount(tlv_data.ipv6_reachs)) {
    if (lsp->tlv_data.ipv6_reachs == NULL)
      lsp->tlv_data.ipv6_reachs = list_new ();
    lsp_tlv_fit (lsp, &tlv_data.ipv6_reachs, 
                 &lsp->tlv_data.ipv6_reachs,
                 IPV6_REACH_LEN, area->lsp_frag_threshold, 
                 tlv_add_ipv6_reachs);
    if (tlv_data.ipv6_reachs && listcount(tlv_data.ipv6_reachs))
      lsp = lsp_next_frag (LSP_FRAGMENT(lsp->lsp_header->lsp_id) +  1, 
                           lsp0, area, level);
  }
#endif /* HAVE_IPV6 */   

  while (tlv_data.is_neighs && listcount(tlv_data.is_neighs)) {
    if (lsp->tlv_data.is_neighs == NULL)
      lsp->tlv_data.is_neighs = list_new ();
    lsp_tlv_fit (lsp, &tlv_data.is_neighs, 
                 &lsp->tlv_data.is_neighs,
                 IS_NEIGHBOURS_LEN, area->lsp_frag_threshold, 
                 tlv_add_is_neighs);
    if (tlv_data.is_neighs && listcount(tlv_data.is_neighs))
      lsp = lsp_next_frag (LSP_FRAGMENT(lsp->lsp_header->lsp_id) + 1, 
                           lsp0, area, level);
  }
  
  
  return;
}
#endif

void
build_lsp_data (struct isis_lsp *lsp, struct isis_area *area)
{
  struct list *circuit_list = area->circuit_list;
  struct isis_circuit *circuit;
  u_char *tlv_ptr;
  struct is_neigh *is_neigh;

   
  /* add our nlpids */
  /* the 2 is for the TL plus 1 for the nlpid*/
  tlv_ptr = lsppdu_realloc (lsp,MTYPE_ISIS_TLV, 3);
  *tlv_ptr = PROTOCOLS_SUPPORTED; /* Type */
  *(tlv_ptr+1) = 1; /* one protocol */
#ifdef HAVE_IPV6 /*dunno if its right*/
  *(tlv_ptr+2) =  NLPID_IPV6;
#else
  *(tlv_ptr+2) =  NLPID_IP;
#endif /* HAVE_IPV6 */

  /* we should add our areas here
   * FIXME: we need to figure out which should be added? Adj? All? First? */

  /* first, lets add ourselves to the IS neighbours info */
  /* the 2 is for the TL plus 1 for the virtual field*/
  tlv_ptr = lsppdu_realloc(lsp,MTYPE_ISIS_TLV, 3);
  *tlv_ptr = IS_NEIGHBOURS; /* Type */
  *(tlv_ptr+2) = 0; /* virtual is zero */
  lsp->tlv_data.is_neighs = list_new (); /* new list of is_neighbours */
  /* assign space for the is_neigh at the pdu end */
  is_neigh = (struct is_neigh*) lsppdu_realloc(lsp,MTYPE_ISIS_TLV, 
					       sizeof(struct is_neigh)); 
  /* add this node to our list */
  listnode_add (lsp->tlv_data.is_neighs, is_neigh); 
  /* FIXME: Do we need our designated address here? */
  memcpy (&is_neigh->neigh_id, isis->sysid, ISIS_SYS_ID_LEN + 1); 
  /* FIXME: Where should we really get our own LSPs metrics from? */
  circuit = (struct isis_circuit*)listhead(circuit_list);
  /* is_neigh->metrics = circuit->metrics[lsp->level -1];*/
  /* Length */
  *(tlv_ptr+1)=(lsp->tlv_data.is_neighs->count * sizeof(struct is_neigh) +1); 

  /* FIXME: scan for adjencecies and add them */

  /* FIXME: add reachability info */

  /* adding dynamic hostname if needed*/
  if (area->dynhostname) {
    tlv_ptr = lsppdu_realloc (lsp,MTYPE_ISIS_TLV, 2); /* the 2 is for the TL */
    *tlv_ptr = DYNAMIC_HOSTNAME; /* Type */
    *(tlv_ptr+1) = strlen (unix_hostname()); /* Length */
    lsp->tlv_data.hostname = (struct hostname *)
      (lsppdu_realloc(lsp,
		      MTYPE_ISIS_TLV,
		      /* the -1 is to fit the length in the struct */
		      strlen (unix_hostname())) - 1); 
    memcpy (lsp->tlv_data.hostname->name, unix_hostname(),
            strlen(unix_hostname()));
  }

}

/*
 * 7.3.7 Generation on non-pseudonode LSPs
 */
int
lsp_generate_non_pseudo (struct isis_area *area, int level) {

  struct isis_lsp *oldlsp, *newlsp;
  u_int32_t seq_num = 0;
  u_char lspid[ISIS_SYS_ID_LEN + 2];

  memset (&lspid, 0, ISIS_SYS_ID_LEN + 2);
  memcpy (&lspid, isis->sysid, ISIS_SYS_ID_LEN);

  /* only builds the lsp if the area shares the level */
  if ((area->is_type & level) == level) { 
    oldlsp = lsp_search (lspid, area->lspdb[level-1]);
    if (oldlsp) {
      seq_num = ntohl (oldlsp->lsp_header->seq_num);
      lsp_search_and_destroy (oldlsp->lsp_header->lsp_id, 
                              area->lspdb[level-1]);
      /* FIXME: we should actually initiate a purge */
    }
    newlsp = lsp_new (lspid, area->max_lsp_lifetime[level-1], seq_num, 
                      area->is_type, 0, level);
    newlsp->own_lsp = 1;
    
    lsp_insert (newlsp, area->lspdb[level-1]);
    /* build_lsp_data (newlsp, area); */
    lsp_build_nonpseudo (newlsp, area);
    /* time to calculate our checksum */
    lsp_seqnum_update (newlsp);
  }


  /* DEBUG_ADJ_PACKETS */
  if (isis->debugs & DEBUG_ADJ_PACKETS) {
    /* FIXME: is this place right? fix missing info */
    zlog_info ("ISIS-Upd (%s): Building L%d LSP",
               area->area_tag, level);
  }

  return ISIS_OK;
}

/*
 * 7.3.9 Generation of level 1 LSPs (non-pseudonode)
 */
int
lsp_l1_generate (struct isis_area *area)
{
  THREAD_TIMER_ON(master, area->t_lsp_refresh[0], lsp_refresh_l1, area,
                                             MAX_LSP_GEN_INTERVAL);

  return lsp_generate_non_pseudo (area, 1);
}


/*
 * 7.3.9 Generation of level 2 LSPs (non-pseudonode)
 */
int
lsp_l2_generate (struct isis_area *area)
{
  THREAD_TIMER_ON(master, area->t_lsp_refresh[1], lsp_refresh_l2, area,
                                             MAX_LSP_GEN_INTERVAL);

  return lsp_generate_non_pseudo (area, 2);
}

int
lsp_non_pseudo_regenerate (struct isis_area *area, int level)
{
  dict_t *lspdb = area->lspdb[level - 1];
  struct isis_lsp *lsp, *frag;
  struct listnode *node;
  u_char lspid[ISIS_SYS_ID_LEN + 2];

  memset (lspid, 0, ISIS_SYS_ID_LEN + 2);
  memcpy (lspid, isis->sysid, ISIS_SYS_ID_LEN);
  
  lsp = lsp_search (lspid, lspdb);
  
  if (!lsp) {
    zlog_err ("ISIS-Upd (%s): lsp_non_pseudo_regenerate(): no L%d LSP found!",
              area->area_tag,	      
	      level);

    return ISIS_ERROR;
  }

  lsp_clear_data (lsp);  
  lsp_build_nonpseudo (lsp, area);
  lsp->lsp_header->rem_lifetime = htons (isis_jitter 
                                         (area->max_lsp_lifetime[level-1],
                                          MAX_AGE_JITTER));
  lsp_seqnum_update (lsp);
    
  if (isis->debugs & DEBUG_UPDATE_PACKETS) {
    zlog_info ("ISIS-Upd (%s): refreshing our L%d LSP %s, "
	       "seq 0x%08x, cksum 0x%04x lifetime %us",
	       area->area_tag,
	       level,
               rawlspid_print (lsp->lsp_header->lsp_id),
	       ntohl(lsp->lsp_header->seq_num),
	       ntohs(lsp->lsp_header->checksum),
	       ntohs(lsp->lsp_header->rem_lifetime)); 
  }

  lsp->last_generated = time (NULL);
  area->lsp_regenerate_pending[level - 1] = 0;
  ISIS_FLAGS_SET_ALL (lsp->SRMflags);
  for (node = listhead (lsp->lspu.frags); node; nextnode(node)) {
    frag = getdata (node);
    frag->lsp_header->rem_lifetime = htons (isis_jitter 
                                         (area->max_lsp_lifetime[level-1],
                                          MAX_AGE_JITTER));
    ISIS_FLAGS_SET_ALL (frag->SRMflags);
  }

  if (area->ip_circuits)
    isis_spf_schedule (area, level);
#ifdef HAVE_IPV6
  if (area->ipv6_circuits)
    isis_spf_schedule6 (area, level);
#endif
  return ISIS_OK;
}


/*
 * Done at least every MAX_LSP_GEN_INTERVAL. Search own LSPs, update holding
 * time and set SRM
 */
int 
lsp_refresh_l1 (struct thread *thread)
{
  struct isis_area *area;
  unsigned long ref_time;

  area = THREAD_ARG (thread);
  assert (area);
  
  area->t_lsp_refresh[0] = NULL;
  if (area->is_type & IS_LEVEL_1) 
    lsp_non_pseudo_regenerate (area, 1);
  
  ref_time =  area->lsp_refresh[0] > MAX_LSP_GEN_INTERVAL ? 
    MAX_LSP_GEN_INTERVAL : area->lsp_refresh[0];

  THREAD_TIMER_ON(master, area->t_lsp_refresh[0], lsp_refresh_l1, area,
      isis_jitter(ref_time, MAX_AGE_JITTER));

  return ISIS_OK;
}

int 
lsp_refresh_l2 (struct thread *thread)
{
  struct isis_area *area;
  unsigned long ref_time;

  area = THREAD_ARG (thread);
  assert (area);
  
  area->t_lsp_refresh[1] = NULL;
  if (area->is_type & IS_LEVEL_2) 
    lsp_non_pseudo_regenerate (area, 2);

  ref_time =  area->lsp_refresh[1] > MAX_LSP_GEN_INTERVAL ? 
    MAX_LSP_GEN_INTERVAL : area->lsp_refresh[1];

  THREAD_TIMER_ON(master, area->t_lsp_refresh[1], lsp_refresh_l2, area,
      isis_jitter(ref_time, MAX_AGE_JITTER));

  return ISIS_OK;
}


/*
 * Something has changed -> regenerate LSP
 */

int
lsp_l1_regenerate (struct thread *thread)
{
  struct isis_area *area;

  area = THREAD_ARG (thread);
  area->lsp_regenerate_pending[0] = 0;

  return lsp_non_pseudo_regenerate (area, 1);
}

int
lsp_l2_regenerate (struct thread *thread)
{
  struct isis_area *area;

  area = THREAD_ARG (thread);
  area->lsp_regenerate_pending[1] = 0;
  
  return lsp_non_pseudo_regenerate (area, 2);
}

int 
lsp_regenerate_schedule (struct isis_area *area)
{
  struct isis_lsp *lsp;
  u_char id[ISIS_SYS_ID_LEN + 2];
  time_t now, diff;
  memcpy(id, isis->sysid, ISIS_SYS_ID_LEN);
  LSP_PSEUDO_ID(id) = LSP_FRAGMENT(id) = 0;
  now = time (NULL);
  /*
   * First level 1
   */
  if (area->is_type & IS_LEVEL_1) {
    lsp = lsp_search (id, area->lspdb[0]);
    if (!lsp || area->lsp_regenerate_pending[0])
      goto L2;
    /*
     * Throttle avoidance
     */
    diff = now - lsp->last_generated;
    if (diff < MIN_LSP_GEN_INTERVAL) {
      area->lsp_regenerate_pending[0] = 1;
      thread_add_timer (master, lsp_l1_regenerate, area, 
                        MIN_LSP_GEN_INTERVAL - diff);
      return ISIS_OK;
    } else
      lsp_non_pseudo_regenerate (area, 1);
  }
  /*
   * then 2
   */
 L2:
  if (area->is_type & IS_LEVEL_2) {
    lsp = lsp_search (id, area->lspdb[1]);
    if (!lsp || area->lsp_regenerate_pending[1])
      return ISIS_OK;
    /*
     * Throttle avoidance
     */
    diff = now - lsp->last_generated;
    if (diff < MIN_LSP_GEN_INTERVAL) {
      area->lsp_regenerate_pending[1] = 1;
      thread_add_timer (master, lsp_l2_regenerate, area, 
                        MIN_LSP_GEN_INTERVAL - diff);
      return ISIS_OK;
    } else
      lsp_non_pseudo_regenerate (area, 2); 
  }
    
  return ISIS_OK; 
}

/*
 * Funcs for pseudonode LSPs
 */

/*
 * 7.3.8 and 7.3.10 Generation of level 1 and 2 pseudonode LSPs 
 */
void
lsp_build_pseudo (struct isis_lsp *lsp, struct isis_circuit *circuit, 
                  int level)
{
  struct isis_adjacency *adj;
  struct is_neigh *is_neigh;
  struct es_neigh *es_neigh;
  struct list *adj_list;
  struct listnode *node;
  struct isis_passwd *passwd;

  assert (circuit);
  assert (circuit->circ_type == CIRCUIT_T_BROADCAST);
  
  if (!circuit->u.bc.is_dr[level - 1])
    return; /* we are not DIS on this circuit */
  
  lsp->level = level;
  if (level == 1)
    lsp->lsp_header->lsp_bits |= IS_LEVEL_1;
  else
    lsp->lsp_header->lsp_bits |= IS_LEVEL_2;

  /*
   * add self to IS neighbours 
   */
  if (lsp->tlv_data.is_neighs == NULL) {
    lsp->tlv_data.is_neighs = list_new ();
    lsp->tlv_data.is_neighs->del = free_tlv;
  }
  is_neigh = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct is_neigh));
  memset (is_neigh, 0, sizeof (struct is_neigh));
  memcpy (&is_neigh->neigh_id, isis->sysid, ISIS_SYS_ID_LEN);
  listnode_add (lsp->tlv_data.is_neighs, is_neigh);
  
  adj_list = list_new();
  isis_adj_build_up_list (circuit->u.bc.adjdb[level-1], adj_list);
  
  for (node = listhead (adj_list); node; nextnode (node)){
    adj = getdata (node);
    if (adj->circuit_t & level) {
      if ((level == 1 && adj->sys_type == ISIS_SYSTYPE_L1_IS) ||
          (level == 1 && adj->sys_type == ISIS_SYSTYPE_L2_IS &&
           adj->adj_usage == ISIS_ADJ_LEVEL1AND2) ||
          (level == 2 && adj->sys_type == ISIS_SYSTYPE_L2_IS)) {
        /* an IS neighbour -> add it */
        is_neigh = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct is_neigh));
        memset (is_neigh, 0, sizeof (struct is_neigh));
        memcpy (&is_neigh->neigh_id, adj->sysid, ISIS_SYS_ID_LEN);
        listnode_add (lsp->tlv_data.is_neighs, is_neigh);
      } else if (level == 1 && adj->sys_type == ISIS_SYSTYPE_ES) {
        /* an ES neigbour add it, if we are building level 1 LSP */
        /* FIXME: the tlv-format is hard to use here */
        if (lsp->tlv_data.es_neighs == NULL) {
          lsp->tlv_data.es_neighs = list_new ();
          lsp->tlv_data.es_neighs->del = free_tlv;
        }
        es_neigh = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct es_neigh));
        memset (es_neigh, 0, sizeof (struct es_neigh));
        memcpy (&es_neigh->first_es_neigh, adj->sysid, ISIS_SYS_ID_LEN);
        listnode_add (lsp->tlv_data.es_neighs, is_neigh);
      }
    }
  }
  
  stream_set_putp (lsp->pdu, ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN);
  /*
   * Add the authentication info if it's present
   */
  (level == 1) ? (passwd = &circuit->area->area_passwd) : 
                 (passwd = &circuit->area->domain_passwd);
  if (passwd->type) {
    memcpy (&lsp->tlv_data.auth_info, passwd, sizeof (struct isis_passwd));
    tlv_add_authinfo (passwd->type, passwd->len,
		      passwd->passwd, lsp->pdu);
  }

  if (lsp->tlv_data.is_neighs && listcount (lsp->tlv_data.is_neighs) > 0)
    tlv_add_is_neighs (lsp->tlv_data.is_neighs, lsp->pdu);

  if (lsp->tlv_data.es_neighs && listcount (lsp->tlv_data.es_neighs) > 0)
    tlv_add_is_neighs (lsp->tlv_data.es_neighs, lsp->pdu);

  lsp->lsp_header->pdu_len = htons (stream_get_putp (lsp->pdu));
  iso_csum_create (STREAM_DATA (lsp->pdu) + 12, 
                   ntohs(lsp->lsp_header->pdu_len) - 12, 12);
  
  list_delete (adj_list);

  return;
}

int
lsp_pseudo_regenerate (struct isis_circuit *circuit, int level)
{
  dict_t *lspdb = circuit->area->lspdb[level - 1];
  struct isis_lsp *lsp;
  u_char lsp_id[ISIS_SYS_ID_LEN + 2];
  
  memcpy (lsp_id, isis->sysid, ISIS_SYS_ID_LEN);
  LSP_PSEUDO_ID(lsp_id) = circuit->circuit_id;
  LSP_FRAGMENT(lsp_id) = 0;
  
  lsp = lsp_search (lsp_id, lspdb);
  
  if (!lsp) {
    zlog_err ("lsp_pseudo_regenerate(): no l%d LSP %s found!", level,
              rawlspid_print(lsp_id));
    return ISIS_ERROR;
  }
  lsp_clear_data (lsp);  

  lsp_build_pseudo (lsp, circuit, level);

  lsp->lsp_header->rem_lifetime = 
    htons (isis_jitter (circuit->area->max_lsp_lifetime[level - 1],
                        MAX_AGE_JITTER));

  lsp_inc_seqnum (lsp, 0);
    
  if (isis->debugs & DEBUG_UPDATE_PACKETS) {
    zlog_info ("ISIS-Upd (%s): refreshing pseudo LSP L%d %s", 
               circuit->area->area_tag, level,
               rawlspid_print (lsp->lsp_header->lsp_id)); 
  }

  lsp->last_generated = time (NULL);
  ISIS_FLAGS_SET_ALL (lsp->SRMflags);
    
  return ISIS_OK;
}


int
lsp_l1_refresh_pseudo (struct thread *thread)
{
  struct isis_circuit *circuit;
  int retval;
  unsigned long ref_time;

  circuit = THREAD_ARG(thread);
  
  if (!circuit->u.bc.is_dr[0])
    return ISIS_ERROR; /* FIXME: purge and such */
  
  retval = lsp_pseudo_regenerate (circuit, 1);
  
  ref_time =  circuit->area->lsp_refresh[0] > MAX_LSP_GEN_INTERVAL ? 
    MAX_LSP_GEN_INTERVAL : circuit->area->lsp_refresh[0];

  THREAD_TIMER_ON(master, circuit->u.bc.t_refresh_pseudo_lsp[0],
      lsp_l1_refresh_pseudo, circuit, isis_jitter (ref_time, MAX_AGE_JITTER));
  
  return retval;
}

int 
lsp_l1_pseudo_generate (struct isis_circuit *circuit)
{
  struct isis_lsp *lsp;
  u_char id[ISIS_SYS_ID_LEN + 2];
  unsigned long ref_time;

  memcpy(id, isis->sysid, ISIS_SYS_ID_LEN);
  LSP_FRAGMENT(id) = 0;
  LSP_PSEUDO_ID(id) = circuit->circuit_id;

  /*
   * If for some reason have a pseudo LSP in the db already -> regenerate
   */
  if (lsp_search (id, circuit->area->lspdb[0]))
    return lsp_pseudo_regenerate (circuit, 1);
  lsp = lsp_new (id, circuit->area->max_lsp_lifetime[0],
                 1, circuit->area->is_type, 0, 1);
  
  lsp_build_pseudo (lsp, circuit, 1);
  
  lsp->own_lsp = 1;
  lsp_insert (lsp, circuit->area->lspdb[0]);
  ISIS_FLAGS_SET_ALL (lsp->SRMflags);

  ref_time =  circuit->area->lsp_refresh[0] > MAX_LSP_GEN_INTERVAL ? 
    MAX_LSP_GEN_INTERVAL : circuit->area->lsp_refresh[0];

  THREAD_TIMER_ON(master, circuit->u.bc.t_refresh_pseudo_lsp[0],
      lsp_l1_refresh_pseudo, circuit, isis_jitter (ref_time, MAX_AGE_JITTER));

  return lsp_regenerate_schedule (circuit->area);
}

int
lsp_l2_refresh_pseudo (struct thread *thread)
{
  struct isis_circuit *circuit;
  int retval;
  unsigned long ref_time;
  circuit = THREAD_ARG(thread);
  
  if (!circuit->u.bc.is_dr[1])
    return ISIS_ERROR; /* FIXME: purge and such */
  
  retval = lsp_pseudo_regenerate (circuit, 2);

  ref_time =  circuit->area->lsp_refresh[1] > MAX_LSP_GEN_INTERVAL ? 
    MAX_LSP_GEN_INTERVAL : circuit->area->lsp_refresh[1];

  THREAD_TIMER_ON(master, circuit->u.bc.t_refresh_pseudo_lsp[1],
      lsp_l2_refresh_pseudo, circuit, isis_jitter (ref_time, MAX_AGE_JITTER));

  return retval;
}


int 
lsp_l2_pseudo_generate (struct isis_circuit *circuit)
{
  struct isis_lsp *lsp;
  u_char id[ISIS_SYS_ID_LEN + 2];
  unsigned long ref_time;

  memcpy(id, isis->sysid, ISIS_SYS_ID_LEN);
  LSP_FRAGMENT(id) = 0;
  LSP_PSEUDO_ID(id) = circuit->circuit_id;

  if (lsp_search (id, circuit->area->lspdb[1]))
    return lsp_pseudo_regenerate (circuit, 2);

  lsp = lsp_new (id, circuit->area->max_lsp_lifetime[1],
                 1, circuit->area->is_type, 0, 2);

  lsp_build_pseudo (lsp, circuit, 2);
  
  ref_time =  circuit->area->lsp_refresh[1] > MAX_LSP_GEN_INTERVAL ? 
    MAX_LSP_GEN_INTERVAL : circuit->area->lsp_refresh[1];


  lsp->own_lsp = 1;
  lsp_insert (lsp, circuit->area->lspdb[1]);
  ISIS_FLAGS_SET_ALL (lsp->SRMflags);
      
  THREAD_TIMER_ON(master, circuit->u.bc.t_refresh_pseudo_lsp[1],
      lsp_l2_refresh_pseudo, circuit, isis_jitter (ref_time, MAX_AGE_JITTER));
  
  return lsp_regenerate_schedule (circuit->area);
}



/*
 * Walk through LSPs for an area
 *  - set remaining lifetime
 *  - set LSPs with SRMflag set for sending
 */
int 
lsp_tick (struct thread *thread)
{
  struct isis_area *area;
  struct isis_circuit *circuit;
  struct isis_lsp *lsp;
  struct list *lsp_list;
  struct listnode *lspnode, *cnode;
  dnode_t *dnode, *dnode_next;
  int level;

  lsp_list = list_new ();
  
  area = THREAD_ARG (thread);
  assert (area);
  THREAD_TIMER_ON(master, area->t_tick, lsp_tick, area, 1);

  /*
   * Build a list of LSPs with (any) SRMflag set
   * and removed the ones that have aged out
   */
  for (level = 0; level < ISIS_LEVELS; level++) {
    if (area->lspdb[level] && dict_count (area->lspdb[level]) > 0) {
      dnode = dict_first (area->lspdb[level]);
      while (dnode != NULL) {
        dnode_next = dict_next (area->lspdb[level], dnode);
        lsp = dnode_get (dnode);
        lsp_set_time (lsp);
        if (lsp->age_out == 0) {

          zlog_info ("ISIS-Upd (%s): L%u LSP %s seq 0x%08x aged out",
		     area->area_tag,
		     lsp->level,
		     rawlspid_print (lsp->lsp_header->lsp_id),
		     ntohl(lsp->lsp_header->seq_num));

          lsp_destroy (lsp);
          dict_delete (area->lspdb[level], dnode);
        } else if (flags_any_set (lsp->SRMflags))
          listnode_add (lsp_list, lsp);
        dnode = dnode_next;
      }

      /*
       * Send LSPs on circuits indicated by the SRMflags
       */
      if (listcount (lsp_list) > 0) {
        for (cnode = listhead (area->circuit_list); cnode; nextnode (cnode)) {
          circuit = getdata (cnode);
          for (lspnode = listhead (lsp_list); lspnode; nextnode (lspnode)) {
            lsp = getdata (lspnode);
            if (ISIS_CHECK_FLAG (lsp->SRMflags, circuit)) {
							/* FIXME: if same or elder lsp is already in lsp queue */
							listnode_add (circuit->lsp_queue, lsp);			
              thread_add_event (master, send_lsp, circuit, 0);
            }
          }
        }
      }
      list_delete_all_node (lsp_list);
    }
  }

  list_delete (lsp_list);

  return ISIS_OK;
}


void
lsp_purge_dr (u_char *id, struct isis_circuit *circuit, int level)
{
  struct isis_lsp *lsp;
  
  lsp = lsp_search (id, circuit->area->lspdb[level - 1]);
  
  if (lsp && lsp->purged == 0) {
    lsp->lsp_header->rem_lifetime = htons (0);
    lsp->lsp_header->pdu_len = htons (ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN);
    lsp->purged = 0;
    iso_csum_create (STREAM_DATA (lsp->pdu) + 12, 
                     ntohs(lsp->lsp_header->pdu_len) - 12, 12);
    ISIS_FLAGS_SET_ALL(lsp->SRMflags);
  } 
    
    
  return;
}

/*
 * Purge own LSP that is received and we don't have. 
 * -> Do as in 7.3.16.4
 */
void
lsp_purge_non_exist (struct isis_link_state_hdr *lsp_hdr, 
                     struct isis_area *area)
{
  struct isis_lsp *lsp;

  /*
   * We need to create the LSP to be purged 
   */
  zlog_info ("LSP PURGE NON EXIST");
  lsp = XMALLOC (MTYPE_ISIS_LSP, sizeof (struct isis_lsp));
  memset (lsp, 0, sizeof (struct isis_lsp));
  /*FIXME: BUG BUG BUG! the lsp doesn't exist here!*/
  /*did smt here, maybe good probably not*/
  lsp->level = ((lsp_hdr->lsp_bits & LSPBIT_IST) == IS_LEVEL_1) ? 1 : 2;
  lsp->pdu = stream_new (ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN);
  lsp->isis_header = (struct isis_fixed_hdr*)STREAM_DATA(lsp->pdu);
  fill_fixed_hdr (lsp->isis_header, (lsp->level == 1) ? L1_LINK_STATE
                  : L2_LINK_STATE);
  lsp->lsp_header = (struct isis_link_state_hdr*)(STREAM_DATA(lsp->pdu) +
                                                  ISIS_FIXED_HDR_LEN);  
  memcpy (lsp->lsp_header, lsp_hdr, ISIS_LSP_HDR_LEN);
  
  /*
   * Retain only LSP header
   */
  lsp->lsp_header->pdu_len = htons (ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN);
  /*
   * Set the remaining lifetime to 0
   */
  lsp->lsp_header->rem_lifetime = 0;
  /*
   * Put the lsp into LSPdb
   */
  lsp_insert (lsp, area->lspdb[lsp->level-1]);

  /*
   * Send in to whole area
   */
  ISIS_FLAGS_SET_ALL (lsp->SRMflags);
  
  return;
}

#ifdef TOPOLOGY_GENERATE
int
top_lsp_refresh (struct thread *thread)
{
  struct isis_lsp  *lsp;

  lsp = THREAD_ARG (thread);
  assert (lsp);

  lsp->t_lsp_top_ref = NULL;

  lsp->lsp_header->rem_lifetime = htons (isis_jitter(MAX_AGE,MAX_AGE_JITTER));
  lsp->lsp_header->seq_num = htonl(ntohl(lsp->lsp_header->seq_num) +1);

  ISIS_FLAGS_SET_ALL (lsp->SRMflags);
  if (isis->debugs & DEBUG_UPDATE_PACKETS) {
    zlog_info ("ISIS-Upd (): refreshing Topology L1 %s", 
               rawlspid_print (lsp->lsp_header->lsp_id));
  }

  /* time to calculate our checksum */
  iso_csum_create (STREAM_DATA (lsp->pdu) + 12,
                   ntohs(lsp->lsp_header->pdu_len) - 12, 12);
  THREAD_TIMER_ON(master, lsp->t_lsp_top_ref, top_lsp_refresh, lsp,
      isis_jitter (MAX_LSP_GEN_INTERVAL, MAX_LSP_GEN_JITTER));

  return ISIS_OK;
}

void
generate_topology_lsps (struct isis_area *area)
{
  struct listnode *node;
  int i, max = 0;
  struct arc *arc;
  u_char lspid[ISIS_SYS_ID_LEN + 2];
  struct isis_lsp *lsp;

  /* first we find the maximal node */
  LIST_LOOP (area->topology, arc, node) {
    if (arc->from_node > max) max = arc->from_node;
    if (arc->to_node > max) max = arc->to_node;
  }


  for (i = 1; i < (max+1); i++) {
    memcpy (lspid,area->topology_baseis,ISIS_SYS_ID_LEN);
    LSP_PSEUDO_ID (lspid) = 0x00;
    LSP_FRAGMENT (lspid) = 0x00;
    lspid[ISIS_SYS_ID_LEN-1] = (i & 0xFF);
    lspid[ISIS_SYS_ID_LEN-2] = ((i >> 8) & 0xFF);

    lsp = lsp_new (lspid, isis_jitter (area->max_lsp_lifetime[0],
				       MAX_AGE_JITTER), 1, IS_LEVEL_1, 0, 1);
    lsp->from_topology = 1;
    /* creating data based on topology */
    build_topology_lsp_data (lsp,area,i);
    /* time to calculate our checksum */
    iso_csum_create (STREAM_DATA (lsp->pdu) + 12,
		     ntohs(lsp->lsp_header->pdu_len) - 12, 12);
    THREAD_TIMER_ON(master, lsp->t_lsp_top_ref, top_lsp_refresh, lsp,
        isis_jitter(MAX_LSP_GEN_INTERVAL, MAX_LSP_GEN_JITTER));

    ISIS_FLAGS_SET_ALL(lsp->SRMflags);
    lsp_insert (lsp,area->lspdb[0]);

  }
}

void
remove_topology_lsps (struct isis_area *area)
{
  struct isis_lsp *lsp;
  dnode_t *dnode, *dnode_next;

  dnode = dict_first (area->lspdb[0]);
  while (dnode != NULL) {
    dnode_next = dict_next (area->lspdb[0], dnode);
    lsp = dnode_get (dnode);
    if (lsp->from_topology) {
      THREAD_TIMER_OFF(lsp->t_lsp_top_ref);
      lsp_destroy (lsp);
      dict_delete (area->lspdb[0], dnode);
    }
    dnode = dnode_next;
  }
}

void
build_topology_lsp_data (struct isis_lsp *lsp, struct isis_area *area, 
			 int lsp_top_num)
{
  struct listnode *node;
  struct arc *arc;
  u_char *tlv_ptr;
  struct is_neigh *is_neigh;
  int to_lsp = 0;
  char buff[200];

  /* add our nlpids */
  /* the 2 is for the TL plus 1 for the nlpid*/
  tlv_ptr = lsppdu_realloc (lsp,MTYPE_ISIS_TLV, 3); 
  *tlv_ptr = PROTOCOLS_SUPPORTED; /* Type */
  *(tlv_ptr+1) = 1; /* one protocol */
  *(tlv_ptr+2) =  NLPID_IP;
  lsp->tlv_data.nlpids = (struct nlpids*)(tlv_ptr+1); 

  /* first, lets add the tops */
  /* the 2 is for the TL plus 1 for the virtual field*/
  tlv_ptr = lsppdu_realloc (lsp ,MTYPE_ISIS_TLV, 3);
  *tlv_ptr = IS_NEIGHBOURS; /* Type */
  *(tlv_ptr+1) = 1; /* this is the virtual char len*/
  *(tlv_ptr+2) = 0; /* virtual is zero */
  lsp->tlv_data.is_neighs = list_new (); /* new list of is_neighbours */

  /* add reachability for this IS for simulated 1 */
  if (lsp_top_num == 1) {
    /* assign space for the is_neigh at the pdu end */
    is_neigh = (struct is_neigh*) lsppdu_realloc(lsp, MTYPE_ISIS_TLV, 
						 sizeof(struct is_neigh)); 
    /* add this node to our list */
    listnode_add (lsp->tlv_data.is_neighs, is_neigh); 
    memcpy (&is_neigh->neigh_id, isis->sysid, ISIS_SYS_ID_LEN);
    LSP_PSEUDO_ID (is_neigh->neigh_id) = 0x00;
    is_neigh->metrics.metric_default = 0x00; /* no special reason */
    is_neigh->metrics.metric_delay = METRICS_UNSUPPORTED;
    is_neigh->metrics.metric_expense = METRICS_UNSUPPORTED;
    is_neigh->metrics.metric_error = METRICS_UNSUPPORTED;
    /* don't forget the length */
    *(tlv_ptr+1) += IS_NEIGHBOURS_LEN; /* the -1 is the virtual */
    /* no need to check for fragging here, it is a lonely is_reach */
  }

  /* addding is reachabilities */
  LIST_LOOP (area->topology, arc, node) {
    if ((arc->from_node == lsp_top_num) ||
        (arc->to_node   == lsp_top_num)) {
      if (arc->to_node   == lsp_top_num) to_lsp = arc->from_node;
      if (arc->from_node == lsp_top_num) to_lsp = arc->to_node;

      /* if the length here is about to cross the FF limit, we reTLV */
      if (*(tlv_ptr+1) >= (0xFF - IS_NEIGHBOURS_LEN)) {
        /* retlv */
	/* the 2 is for the TL plus 1 for the virtual field*/
        tlv_ptr = lsppdu_realloc(lsp,MTYPE_ISIS_TLV, 3); 
        *tlv_ptr = IS_NEIGHBOURS; /* Type */
        *(tlv_ptr+1) = 1; /* this is the virtual char len*/
        *(tlv_ptr+2) = 0; /* virtual is zero */
      }
      /* doing this here assures us that we won't add an "empty" tlv */
      /* assign space for the is_neigh at the pdu end */
      is_neigh = (struct is_neigh*) lsppdu_realloc (lsp, MTYPE_ISIS_TLV, 
						    sizeof(struct is_neigh));
      /* add this node to our list */
      listnode_add (lsp->tlv_data.is_neighs, is_neigh); 
      memcpy (&is_neigh->neigh_id, area->topology_baseis, ISIS_SYS_ID_LEN);
      LSP_PSEUDO_ID (is_neigh->neigh_id) = 0x00;
      is_neigh->neigh_id[ISIS_SYS_ID_LEN-1] = (to_lsp & 0xFF);
      is_neigh->neigh_id[ISIS_SYS_ID_LEN-2] = ((to_lsp >> 8) & 0xFF);
      is_neigh->metrics.metric_default = arc->distance;
      is_neigh->metrics.metric_delay = METRICS_UNSUPPORTED;
      is_neigh->metrics.metric_expense = METRICS_UNSUPPORTED;
      is_neigh->metrics.metric_error = METRICS_UNSUPPORTED;
      /* don't forget the length */
      *(tlv_ptr+1) += IS_NEIGHBOURS_LEN; /* the -1 is the virtual */
    }
  }

  /* adding dynamic hostname if needed*/
  if (area->dynhostname) {
    memset (buff,0x00,200);
    sprintf (buff,"feedme%d",lsp_top_num);
    tlv_ptr = lsppdu_realloc (lsp,MTYPE_ISIS_TLV, 2); /* the 2 is for the TL */
    *tlv_ptr = DYNAMIC_HOSTNAME; /* Type */
    *(tlv_ptr+1) = strlen (buff); /* Length */
    /* the -1 is to fit the length in the struct */
    lsp->tlv_data.hostname = (struct hostname *)
      (lsppdu_realloc (lsp, MTYPE_ISIS_TLV, strlen(buff)) - 1);
    memcpy (lsp->tlv_data.hostname->name, buff, strlen(buff));
  }

  /* thanks to hannes, another bug bites the dust */
  lsp->pdu->putp = ntohs(lsp->lsp_header->pdu_len);
  lsp->pdu->endp = ntohs(lsp->lsp_header->pdu_len);
}
#endif /* TOPOLOGY_GENERATE */
