Revision edc34dc9 proto/ospf/ospf.c

View differences:

proto/ospf/ospf.c
350 350
    default: return GA_UNKNOWN;
351 351
    }
352 352
}
353
static int
354
ospf_patt_compare(struct ospf_iface_patt *a, struct ospf_iface_patt *b)
355
{
356
  return ((a->cost==b->cost)&&(a->type==b->type)&&(a->priority==b->priority));
357
}
353 358

  
354 359
static int
355 360
ospf_reconfigure(struct proto *p, struct proto_config *c)
356 361
{
357
  return 0;	/* Alway down :-( */
362
  struct ospf_config *old=(struct ospf_config *)(p->cf);
363
  struct ospf_config *new=(struct ospf_config *)c;
364
  struct ospf_area_config *ac1,*ac2;
365
  struct proto_ospf *po=( struct proto_ospf *)p;
366
  struct ospf_iface_patt *ip1,*ip2;
367
  struct ospf_iface *ifa;
368
  struct nbma_node *nb1,*nb2,*nbnx;
369
  struct ospf_area *oa;
370
  int found;
371

  
372
  po->rfc1583=new->rfc1583;	/* FIXME but if differs schedule RT calc */
373

  
374
  ac1=HEAD(old->area_list);
375
  ac2=HEAD(new->area_list);
376

  
377
  /* I should get it in same order */
378
  
379
  while(((NODE (ac1))->next!=NULL) && ((NODE (ac2))->next!=NULL))
380
  {
381
    if(ac1->areaid!=ac2->areaid) return 0;
382
    if(ac1->stub!=ac2->stub) return 0;
383
    if(ac1->tick!=ac2->tick)
384
    {
385
      WALK_LIST(oa,po->area_list)
386
      {
387
        if(oa->areaid==ac2->areaid)
388
	{
389
	  oa->tick=ac2->tick;
390
	  tm_start(oa->disp_timer,oa->tick);
391
	  OSPF_TRACE(D_EVENTS,
392
	    "Changing tick interval on area %I from %d to %d",
393
	    oa->areaid, ac1->tick, ac2->tick);
394
	  break;
395
	}
396
      }
397
    }
398

  
399
    if(!iface_patts_equal(&ac1->patt_list, &ac2->patt_list,
400
      (void *) ospf_patt_compare))
401
        return 0;
402

  
403
    WALK_LIST(ifa, po->iface_list)
404
    {
405
      if(ip1=(struct ospf_iface_patt *)
406
        iface_patt_match(&ac1->patt_list, ifa->iface))
407
      {
408
        /* Now reconfigure interface */
409
	if(!(ip2=(struct ospf_iface_patt *)
410
	  iface_patt_match(&ac2->patt_list, ifa->iface))) return 0;
411

  
412
	/* HELLO TIMER */
413
	if(ip1->helloint!=ip2->helloint)
414
	{
415
	  ifa->helloint=ip2->helloint;
416
	  ifa->hello_timer->recurrent=ifa->helloint;
417
	  tm_start(ifa->hello_timer,ifa->helloint);
418
	  OSPF_TRACE(D_EVENTS,
419
	    "Changing hello interval on interface %s from %d to %d",
420
	    ifa->iface->name,ip1->helloint,ip2->helloint);
421
	}
422

  
423
	/* AUTHETICATION */
424
	if(ip1->autype!=ip2->autype)
425
	{
426
	  ifa->autype=ip2->autype;
427
	  OSPF_TRACE(D_EVENTS,
428
	    "Changing autentication type on interface %s",
429
	    ifa->iface->name);
430
	}
431
	if(strncmp(ip1->password,ip2->password,8)!=0)
432
	{
433
	  memcpy(ifa->aukey,ip2->password,8);
434
	  OSPF_TRACE(D_EVENTS,
435
	    "Changing password on interface %s",
436
	    ifa->iface->name);
437
	}
438

  
439
	/* RXMT */
440
	if(ip1->rxmtint!=ip2->rxmtint)
441
	{
442
	  ifa->rxmtint=ip2->rxmtint;
443
	  OSPF_TRACE(D_EVENTS,
444
	    "Changing retransmit interval on interface %s from %d to %d",
445
	    ifa->iface->name,ip1->rxmtint,ip2->rxmtint);
446
	}
447

  
448
	/* WAIT */
449
	if(ip1->waitint!=ip2->waitint)
450
	{
451
	  ifa->waitint=ip2->waitint;
452
	  if(ifa->wait_timer->expires!=0)
453
	    tm_start(ifa->wait_timer,ifa->waitint);
454
	  OSPF_TRACE(D_EVENTS,
455
	    "Changing wait interval on interface %s from %d to %d",
456
	    ifa->iface->name,ip1->waitint,ip2->waitint);
457
	}
458

  
459
	/* INFTRANS */
460
	if(ip1->inftransdelay!=ip2->inftransdelay)
461
	{
462
	  ifa->inftransdelay=ip2->inftransdelay;
463
	  OSPF_TRACE(D_EVENTS,
464
	    "Changing transmit delay on interface %s from %d to %d",
465
	    ifa->iface->name,ip1->inftransdelay,ip2->inftransdelay);
466
	}
467

  
468
	/* DEAD COUNT */
469
	if(ip1->deadc!=ip2->deadc)
470
	{
471
	  ifa->deadc=ip2->deadc;
472
	  OSPF_TRACE(D_EVENTS,
473
	    "Changing dead count on interface %s from %d to %d",
474
	    ifa->iface->name,ip1->deadc,ip2->deadc);
475
	}
476

  
477
	/* NBMA LIST */
478
	/* First remove old */
479
	WALK_LIST_DELSAFE(nb1, nbnx, ifa->nbma_list)
480
	{
481
	  found=0;
482
	  WALK_LIST(nb2, ip2->nbma_list)
483
	    if(ipa_compare(nb1->ip,nb2->ip)==0)
484
	    {
485
	      found=1;
486
	      break;
487
	    }
488

  
489
	  if(!found)
490
	  {
491
	    OSPF_TRACE(D_EVENTS,
492
	      "Removing NBMA neighbor %I on interface %s",
493
	      nb1->ip,ifa->iface->name);
494
	    rem_node(NODE nb1);
495
	    mb_free(nb1);
496
	  }
497
        }
498
	/* And then add new */
499
	WALK_LIST(nb2, ip2->nbma_list)
500
	{
501
	  found=0;
502
	  WALK_LIST(nb1, ifa->nbma_list)
503
	    if(ipa_compare(nb1->ip,nb2->ip)==0)
504
	    {
505
	      found=1;
506
	      break;
507
	    }
508
	  if(!found)
509
	  {
510
	    nb1=mb_alloc(p->pool,sizeof(struct nbma_node));
511
	    nb1->ip=nb2->ip;
512
	    add_tail(&ifa->nbma_list, NODE nb1);
513
	    OSPF_TRACE(D_EVENTS,
514
	      "Adding NBMA neighbor %I on interface %s",
515
	      nb1->ip,ifa->iface->name);
516
	  }
517
        }
518
      }
519
    }
520

  
521
    NODE ac1=(NODE (ac1))->next;
522
    NODE ac2=(NODE (ac2))->next;
523
  }
524

  
525
  if(((NODE (ac1))->next)!=((NODE (ac2))->next))
526
    return 0;	/* One is not null */
527

  
528
  return 1;	/* Everythink OK :-) */
358 529
}
359 530

  
360 531
void

Also available in: Unified diff