static void mcp_pppd_delete_all_local_info(void)
{
//    int i;
    
    list_delete_all_node(multilink_if_list);
    list_delete_all_node(remote_userinfo_list);

    //mcp_pppd_init_all_local_interface(); 不能执行这个
}
Example #2
0
int
interface_down (struct thread *thread)
{
  struct ospf6_interface *oi;
  struct listnode *node, *nnode;
  struct ospf6_neighbor *on;

  oi = (struct ospf6_interface *) THREAD_ARG (thread);
  assert (oi && oi->interface);

  if (IS_OSPF6_DEBUG_INTERFACE)
    zlog_debug ("Interface Event %s: [InterfaceDown]",
		oi->interface->name);

  /* Leave AllSPFRouters */
  if (oi->state > OSPF6_INTERFACE_DOWN)
    ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_LEAVE_GROUP);

  ospf6_interface_state_change (OSPF6_INTERFACE_DOWN, oi);

  for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
    ospf6_neighbor_delete (on);
  
  list_delete_all_node (oi->neighbor_list);

  return 0;
}
Example #3
0
File: if.c Project: yubo/quagga
/* Delete interface structure. */
void if_delete_retain(struct interface *ifp)
{
	if (if_master.if_delete_hook)
		(*if_master.if_delete_hook) (ifp);

	/* Free connected address list */
	list_delete_all_node(ifp->connected);
}
Example #4
0
void grpint_destroy(struct grpintnode *grpintn)
{
    if (!grpintn) return;

    /* Empty the subscriber list */
    list_delete_all_node(grpintn->subscriptions);

    /* Free the node */
    free(grpintn);
}
Example #5
0
void
isis_adj_state_change (struct isis_adjacency *adj, enum isis_adj_state state,
		       const char *reason)
{
  int old_state;
  int level = adj->level;
  struct isis_circuit *circuit;

  old_state = adj->adj_state;
  adj->adj_state = state;

  circuit = adj->circuit;

  if (isis->debugs & DEBUG_ADJ_PACKETS)
    {
      zlog_debug ("ISIS-Adj (%s): Adjacency state change %d->%d: %s",
		 circuit->area->area_tag,
		 old_state, state, reason ? reason : "unspecified");
    }

  if (circuit->circ_type == CIRCUIT_T_BROADCAST)
    {
      if (state == ISIS_ADJ_UP)
	circuit->upadjcount[level - 1]++;
      if (state == ISIS_ADJ_DOWN)
	{
	  isis_delete_adj (adj, adj->circuit->u.bc.adjdb[level - 1]);
	  circuit->upadjcount[level - 1]--;
	}

      list_delete_all_node (circuit->u.bc.lan_neighs[level - 1]);
      isis_adj_build_neigh_list (circuit->u.bc.adjdb[level - 1],
				 circuit->u.bc.lan_neighs[level - 1]);
    }
  else if (state == ISIS_ADJ_UP)
    {				/* p2p interface */
      if (adj->sys_type == ISIS_SYSTYPE_UNKNOWN)
	send_hello (circuit, 1);

      /* update counter & timers for debugging purposes */
      adj->last_flap = time (NULL);
      adj->flaps++;

      /* 7.3.17 - going up on P2P -> send CSNP */
      /* FIXME: yup, I know its wrong... but i will do it! (for now) */
      send_csnp (circuit, 1);
      send_csnp (circuit, 2);
    }
  else if (state == ISIS_ADJ_DOWN)
    {				/* p2p interface */
      adj->circuit->u.p2p.neighbor = NULL;
      isis_delete_adj (adj, NULL);
    }
  return;
}
Example #6
0
/* Restore an interface to its pre UP state
   Used from ism_interface_down only */
void
ospf_if_cleanup (struct ospf_interface *oi)
{
  struct route_node *rn;
  struct listnode *node, *nnode;
  struct ospf_neighbor *nbr;
  struct ospf_nbr_nbma *nbr_nbma;
  struct ospf_lsa *lsa;

  /* oi->nbrs and oi->nbr_nbma should be deleted on InterfaceDown event */
  /* delete all static neighbors attached to this interface */
  for (ALL_LIST_ELEMENTS (oi->nbr_nbma, node, nnode, nbr_nbma))
    {
      OSPF_POLL_TIMER_OFF (nbr_nbma->t_poll);

      if (nbr_nbma->nbr)
	{
	  nbr_nbma->nbr->nbr_nbma = NULL;
	  nbr_nbma->nbr = NULL;
	}

      nbr_nbma->oi = NULL;
      
      listnode_delete (oi->nbr_nbma, nbr_nbma);
    }

  /* send Neighbor event KillNbr to all associated neighbors. */
  for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
    if ((nbr = rn->info) != NULL)
      if (nbr != oi->nbr_self)
	OSPF_NSM_EVENT_EXECUTE (nbr, NSM_KillNbr);

  /* Cleanup Link State Acknowlegdment list. */
  for (ALL_LIST_ELEMENTS (oi->ls_ack, node, nnode, lsa))
    ospf_lsa_unlock (&lsa); /* oi->ls_ack */
  list_delete_all_node (oi->ls_ack);

  oi->crypt_seqnum = 0;
  
  /* Empty link state update queue */
  ospf_ls_upd_queue_empty (oi);
  
  /* Reset pseudo neighbor. */
  ospf_nbr_delete (oi->nbr_self);
  oi->nbr_self = ospf_nbr_new (oi);
  ospf_nbr_add_self (oi);
  
  ospf_lsa_unlock (&oi->network_lsa_self);
  oi->network_lsa_self = NULL;
  OSPF_TIMER_OFF (oi->t_network_lsa_self);
#ifdef HAVE_GRACEFUL_RESTART
  THREAD_TIMER_OFF(oi->t_opaque_lsa_refresh);
  oi->v_opaque_lsa_count = 0 ;
#endif
}
Example #7
0
/* Display configuration to file pointer. */
void
vtysh_config_dump (FILE *fp)
{
  struct listnode *node, *nnode;
  struct listnode *mnode, *mnnode;
  struct config *config;
  struct list *master;
  char *line;
  unsigned int i;

  for (ALL_LIST_ELEMENTS (config_top, node, nnode, line))
    {
      fprintf (fp, "%s\n", line);
      fflush (fp);
    }
  fprintf (fp, "!\n");
  fflush (fp);

  for (i = 0; i < vector_active (configvec); i++)
    if ((master = vector_slot (configvec, i)) != NULL)
      {
	for (ALL_LIST_ELEMENTS (master, node, nnode, config))
	  {
	    fprintf (fp, "%s\n", config->name);
	    fflush (fp);

	    for (ALL_LIST_ELEMENTS (config->line, mnode, mnnode, line))
	      {
		fprintf  (fp, "%s\n", line);
		fflush (fp);
	      }
	    if (! NO_DELIMITER (i))
	      {
		fprintf (fp, "!\n");
		fflush (fp);
	      }
	  }
	if (NO_DELIMITER (i))
	  {
	    fprintf (fp, "!\n");
	    fflush (fp);
	  }
      }

  for (i = 0; i < vector_active (configvec); i++)
    if ((master = vector_slot (configvec, i)) != NULL)
      {
	list_delete (master);
	vector_slot (configvec, i) = NULL;
      }
  list_delete_all_node (config_top);
}
Example #8
0
void finalStringOutput(struct list * tokens,u8 * ori, u32 len, char *out,int size)
{
    u32    pos = 0 ;
    u32    act = 0 ;
    struct listnode * node;
    RwRecord * rec ;
    u32    cnt = 0 ;

    u32    _ps = 0 ;

#define OUTPUT_WRITE(_src,_len)\
	do{if( _ps + _len < (u32)size ){\
		memcpy(out+_ps,_src,_len);\
		_ps+=(_len) ;\
	   }\
	}while(0)

    for(ALL_LIST_ELEMENTS_RO(tokens,node,rec) )
    {
        act = rec->position ;
        cnt ++ ;
        if( cnt >= listcount(tokens) - 2 )
            cnt = 0 ;
        if( act > pos )
        {
            OUTPUT_WRITE(ori+pos,act-pos);
            //fwrite(ori+pos,1,act-pos,out);
            pos=act;
        }
        // delete
        if( rec->insert == NULL )
        {
            pos+=rec->length;
        }
        // insert
        else
        {
            OUTPUT_WRITE(rec->insert,rec->length);
            //fwrite(rec->insert,1,rec->length,out);
        }
    }

    if(  pos < len )
    {
        OUTPUT_WRITE(ori+pos,len-pos);
        //fwrite(ori+pos,1,len-pos,out);
    }

    out[_ps] = 0 ;
    list_delete_all_node(tokens, IS_TOKEN);
}
Example #9
0
void
ospf6_interface_disable (struct ospf6_interface *oi)
{
  struct listnode *node, *nnode;
  struct ospf6_neighbor *on;

  SET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);

  for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
      ospf6_neighbor_delete (on);

  list_delete_all_node (oi->neighbor_list);

  ospf6_lsdb_remove_all (oi->lsdb);
  ospf6_lsdb_remove_all (oi->lsupdate_list);
  ospf6_lsdb_remove_all (oi->lsack_list);

  THREAD_OFF (oi->thread_send_hello);
  THREAD_OFF (oi->thread_send_lsupdate);
  THREAD_OFF (oi->thread_send_lsack);
}
Example #10
0
/*******************************************************************************
 函数名称  : bgp_mp_list_clear
 功能描述  : mpath list清空
 输入参数  : 
 输出参数  : 
 返 回 值  : 无
--------------------------------------------------------------------------------
 最近一次修改记录 :
 修改作者   :      
 修改目的   :      新添加函数
 修改日期   :       2012-8-15
*******************************************************************************/
void bgp_mp_list_clear (struct list *mp_list)
{
	list_delete_all_node (mp_list);
}
/* Restore an interface to its pre UP state
   Used from ism_interface_down only */
void
ospf_if_cleanup (struct ospf_interface *oi)
{
  struct route_node *rn;
  struct listnode *node;
  struct ospf_neighbor *nbr;

  /* oi->nbrs and oi->nbr_nbma should be deletete on InterafceDown event */
  /* delete all static neighbors attached to this interface */
  for (node = listhead (oi->nbr_nbma); node; )
    {
      struct ospf_nbr_nbma *nbr_nbma = getdata (node);
      nextnode (node);

      OSPF_POLL_TIMER_OFF (nbr_nbma->t_poll);

      if (nbr_nbma->nbr)
	{
	  nbr_nbma->nbr->nbr_nbma = NULL;
	  nbr_nbma->nbr = NULL;
	}

      nbr_nbma->oi = NULL;
      
      listnode_delete (oi->nbr_nbma, nbr_nbma);
    }

  /* send Neighbor event KillNbr to all associated neighbors. */
  for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
    if ((nbr = rn->info) != NULL)
      if (nbr != oi->nbr_self)
	OSPF_NSM_EVENT_EXECUTE (nbr, NSM_KillNbr);

  /* Cleanup Link State Acknowlegdment list. */
  for (node = listhead (oi->ls_ack); node; nextnode (node))
    ospf_lsa_unlock (node->data);
  list_delete_all_node (oi->ls_ack);

  oi->crypt_seqnum = 0;
  
  /* Empty link state update queue */
  ospf_ls_upd_queue_empty (oi);
  
 /* Handle pseudo neighbor. */
  ospf_nbr_delete (oi->nbr_self);
  oi->nbr_self = ospf_nbr_new (oi);
  oi->nbr_self->state = NSM_TwoWay;
  oi->nbr_self->priority = OSPF_IF_PARAM (oi, priority);

  switch (oi->area->external_routing)
    {
    case OSPF_AREA_DEFAULT:
      SET_FLAG (oi->nbr_self->options, OSPF_OPTION_E);
      break;
    case OSPF_AREA_STUB:
      UNSET_FLAG (oi->nbr_self->options, OSPF_OPTION_E);
      break;
    case OSPF_AREA_NSSA:
      UNSET_FLAG (oi->nbr_self->options, OSPF_OPTION_E);
      SET_FLAG (oi->nbr_self->options, OSPF_OPTION_NP);
      break;
    }

  ospf_lsa_unlock (oi->network_lsa_self);
  oi->network_lsa_self = NULL;
  OSPF_TIMER_OFF (oi->t_network_lsa_self);
}
Example #12
0
void
isis_adj_state_change (struct isis_adjacency *adj, enum isis_adj_state new_state,
		       const char *reason)
{
  int old_state;
  int level;
  struct isis_circuit *circuit;

  old_state = adj->adj_state;
  adj->adj_state = new_state;

  circuit = adj->circuit;

  if (isis->debugs & DEBUG_ADJ_PACKETS)
    {
      zlog_debug ("ISIS-Adj (%s): Adjacency state change %d->%d: %s",
		 circuit->area->area_tag,
		 old_state, new_state, reason ? reason : "unspecified");
    }

  if (circuit->area->log_adj_changes)
    {
      const char *adj_name;
      struct isis_dynhn *dyn;

      dyn = dynhn_find_by_id (adj->sysid);
      if (dyn)
	adj_name = (const char *)dyn->name.name;
      else
	adj_name = adj->sysid ? sysid_print (adj->sysid) : "unknown";

      zlog_info ("%%ADJCHANGE: Adjacency to %s (%s) changed from %s to %s, %s",
		 adj_name,
		 adj->circuit->interface->name,
		 adj_state2string (old_state),
		 adj_state2string (new_state),
		 reason ? reason : "unspecified");
    }

  if (circuit->circ_type == CIRCUIT_T_BROADCAST)
    {
      for (level = IS_LEVEL_1; level <= IS_LEVEL_2; level++)
      {
        if ((adj->level & level) == 0)
          continue;
        if (new_state == ISIS_ADJ_UP)
        {
          circuit->upadjcount[level - 1]++;
          isis_event_adjacency_state_change (adj, new_state);
          /* update counter & timers for debugging purposes */
          adj->last_flap = time (NULL);
          adj->flaps++;
        }
        else if (new_state == ISIS_ADJ_DOWN)
        {
          listnode_delete (circuit->u.bc.adjdb[level - 1], adj);
          circuit->upadjcount[level - 1]--;
          if (circuit->upadjcount[level - 1] == 0)
            {
              /* Clean lsp_queue when no adj is up. */
              if (circuit->lsp_queue)
                list_delete_all_node (circuit->lsp_queue);
            }
          isis_event_adjacency_state_change (adj, new_state);
          isis_delete_adj (adj);
        }

        if (circuit->u.bc.lan_neighs[level - 1])
          {
            list_delete_all_node (circuit->u.bc.lan_neighs[level - 1]);
            isis_adj_build_neigh_list (circuit->u.bc.adjdb[level - 1],
                                       circuit->u.bc.lan_neighs[level - 1]);
          }

        /* On adjacency state change send new pseudo LSP if we are the DR */
        if (circuit->u.bc.is_dr[level - 1])
          lsp_regenerate_schedule_pseudo (circuit, level);
      }
    }
  else if (circuit->circ_type == CIRCUIT_T_P2P)
    {
      for (level = IS_LEVEL_1; level <= IS_LEVEL_2; level++)
      {
        if ((adj->level & level) == 0)
          continue;
        if (new_state == ISIS_ADJ_UP)
        {
          circuit->upadjcount[level - 1]++;
          isis_event_adjacency_state_change (adj, new_state);

          if (adj->sys_type == ISIS_SYSTYPE_UNKNOWN)
            send_hello (circuit, level);

          /* update counter & timers for debugging purposes */
          adj->last_flap = time (NULL);
          adj->flaps++;

          /* 7.3.17 - going up on P2P -> send CSNP */
          /* FIXME: yup, I know its wrong... but i will do it! (for now) */
          send_csnp (circuit, level);
        }
        else if (new_state == ISIS_ADJ_DOWN)
        {
          if (adj->circuit->u.p2p.neighbor == adj)
            adj->circuit->u.p2p.neighbor = NULL;
          circuit->upadjcount[level - 1]--;
          if (circuit->upadjcount[level - 1] == 0)
            {
              /* Clean lsp_queue when no adj is up. */
              if (circuit->lsp_queue)
                list_delete_all_node (circuit->lsp_queue);
            }
          isis_event_adjacency_state_change (adj, new_state);
          isis_delete_adj (adj);
        }
      }
    }

  return;
}
Example #13
0
static u_char *
ospfv3WwLsdbEntry (struct variable *v, oid *name, size_t *length,
                     int exact, size_t *var_len, WriteMethod **write_method)
{
  struct ospf6_lsa *lsa = NULL;
  u_int32_t ifindex, area_id, id, instid, adv_router;
  u_int16_t type;
  int len;
  oid *offset;
  int offsetlen;
  char a[16], b[16], c[16];
  struct ospf6_area *oa;
  struct listnode *node;
  struct interface *iif;
  struct ospf6_interface *oi = NULL;
  struct list *ifslist;

  if (smux_header_table(v, name, length, exact, var_len, write_method)
      == MATCH_FAILED)
    return NULL;

  instid = ifindex = area_id = type = id = adv_router = 0;

  /* Check OSPFv3 instance. */
  if (ospf6 == NULL)
    return NULL;

  /* Get variable length. */
  offset = name + v->namelen;
  offsetlen = *length - v->namelen;

  if (exact && (v->magic & OSPFv3WWASTABLE) && offsetlen != 3)
    return NULL;
  if (exact && (v->magic & OSPFv3WWAREATABLE) && offsetlen != 4)
    return NULL;
  if (exact && (v->magic & OSPFv3WWLINKTABLE) && offsetlen != 5)
    return NULL;

  if (v->magic & OSPFv3WWLINKTABLE)
    {
      /* Parse ifindex */
      len = (offsetlen < 1 ? 0 : 1);
      if (len)
        ifindex = *offset;
      offset += len;
      offsetlen -= len;

      /* Parse instance ID */
      len = (offsetlen < 1 ? 0 : 1);
      if (len)
        instid = *offset;
      offset += len;
      offsetlen -= len;
    }
  else if (v->magic & OSPFv3WWAREATABLE)
    {
      /* Parse area-id */
      len = (offsetlen < 1 ? 0 : 1);
      if (len)
        area_id = htonl (*offset);
      offset += len;
      offsetlen -= len;
    }

  /* Parse type */
  len = (offsetlen < 1 ? 0 : 1);
  if (len)
    type = htons (*offset);
  offset += len;
  offsetlen -= len;

  /* Parse Router-ID */
  len = (offsetlen < 1 ? 0 : 1);
  if (len)
    adv_router = htonl (*offset);
  offset += len;
  offsetlen -= len;

  /* Parse LS-ID */
  len = (offsetlen < 1 ? 0 : 1);
  if (len)
    id = htonl (*offset);
  offset += len;
  offsetlen -= len;

  if (exact)
    {
      if (v->magic & OSPFv3WWASTABLE)
        {
          lsa = ospf6_lsdb_lookup (type, id, adv_router, ospf6->lsdb);
        }
      else if (v->magic & OSPFv3WWAREATABLE)
        {
          oa = ospf6_area_lookup (area_id, ospf6);
          if (!oa) return NULL;
          lsa = ospf6_lsdb_lookup (type, id, adv_router, oa->lsdb);
        }
      else if (v->magic & OSPFv3WWLINKTABLE)
        {
          oi = ospf6_interface_lookup_by_ifindex (ifindex);
          if (!oi || oi->instance_id != instid) return NULL;
          lsa = ospf6_lsdb_lookup (type, id, adv_router, oi->lsdb);
        }
    }
  else
    {
      if (v->magic & OSPFv3WWASTABLE)
	{
	  if (ospf6->lsdb->count)
	    lsa = ospf6_lsdb_lookup_next (type, id, adv_router,
					  ospf6->lsdb);
	}
      else if (v->magic & OSPFv3WWAREATABLE)
	for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
          {
            if (oa->area_id < area_id)
              continue;

            if (oa->lsdb->count)
              lsa = ospf6_lsdb_lookup_next (type, id, adv_router,
                                            oa->lsdb);
            if (lsa) break;
            type = 0;
            id = 0;
            adv_router = 0;
          }
      else if (v->magic & OSPFv3WWLINKTABLE)
        {
          /* We build a sorted list of interfaces */
          ifslist = list_new ();
          if (!ifslist) return NULL;
          ifslist->cmp = (int (*)(void *, void *))if_icmp_func;
          for (ALL_LIST_ELEMENTS_RO (iflist, node, iif))
            listnode_add_sort (ifslist, iif);
          
          for (ALL_LIST_ELEMENTS_RO (ifslist, node, iif))
            {
              if (!iif->ifindex) continue;
              oi = ospf6_interface_lookup_by_ifindex (iif->ifindex);
              if (!oi) continue;
              if (iif->ifindex < ifindex) continue;
              if (oi->instance_id < instid) continue;
              
              if (oi->lsdb->count)
                lsa = ospf6_lsdb_lookup_next (type, id, adv_router,
                                            oi->lsdb);
              if (lsa) break;
              type = 0;
              id = 0;
              adv_router = 0;
              oi = NULL;
            }

          list_delete_all_node (ifslist);
        }