Statistics
| Branch: | Revision:

iof-bird-daemon / proto / ospf / ospf.c @ edc34dc9

History | View | Annotate | Download (16 KB)

1
/*
2
 *        BIRD -- OSPF
3
 *
4
 *        (c) 1999 Ondrej Filip <feela@network.cz>
5
 *
6
 *        Can be freely distributed and used under the terms of the GNU GPL.
7
 */
8

    
9
#include "ospf.h"
10

    
11
static int
12
ospf_start(struct proto *p)
13
{
14
  struct proto_ospf *po=(struct proto_ospf *)p;
15
  struct ospf_config *c=(struct ospf_config *)(p->cf);
16
  struct ospf_area_config *ac;
17
  struct ospf_area *oa;
18

    
19
  OSPF_TRACE(D_EVENTS, "Start");
20

    
21
  fib_init(&po->efib,p->pool,sizeof(struct extfib),16,init_efib);
22
  init_list(&(po->iface_list));
23
  init_list(&(po->area_list));
24
  po->areano=0;
25
  if(EMPTY_LIST(c->area_list))
26
  {
27
    log("%s: Cannot start, no OSPF areas configured", p->name);
28
    return PS_DOWN;
29
  }
30

    
31
  WALK_LIST(ac,c->area_list)
32
  {
33
    oa=mb_allocz(po->proto.pool, sizeof(struct ospf_area));
34
    add_tail(&po->area_list,NODE oa);
35
    po->areano++;
36
    oa->stub=ac->stub;
37
    oa->tick=ac->tick;
38
    oa->areaid=ac->areaid;
39
    oa->gr=ospf_top_new(po);
40
    s_init_list(&(oa->lsal));
41
    oa->rt=NULL;
42
    oa->po=po;
43
    oa->disp_timer=tm_new(po->proto.pool);
44
    oa->disp_timer->data=oa;
45
    oa->disp_timer->randomize=0;
46
    oa->disp_timer->hook=area_disp;
47
    oa->disp_timer->recurrent=oa->tick;
48
    oa->lage=now;
49
    tm_start(oa->disp_timer,oa->tick);
50
    oa->calcrt=0;
51
    oa->origrt=0;
52
    fib_init(&oa->infib,po->proto.pool,sizeof(struct infib),16,init_infib);
53
  }
54
  return PS_UP;
55
}
56

    
57
static void
58
ospf_dump(struct proto *p)
59
{
60
  char areastr[20];
61
  struct ospf_iface *ifa;
62
  struct ospf_neighbor *n;
63
  struct ospf_config *c = (void *) p->cf;
64
  struct proto_ospf *po=(struct proto_ospf *)p;
65
  struct ospf_area *oa;
66

    
67
  OSPF_TRACE(D_EVENTS, "Area number: %d", po->areano);
68

    
69
  WALK_LIST(ifa, po->iface_list)
70
  {
71
    OSPF_TRACE(D_EVENTS, "Interface: %s", ifa->iface->name);
72
    OSPF_TRACE(D_EVENTS, "state: %u", ifa->state);
73
    OSPF_TRACE(D_EVENTS, "DR:  %I", ifa->drid);
74
    OSPF_TRACE(D_EVENTS, "BDR: %I", ifa->bdrid);
75
    WALK_LIST(n, ifa->neigh_list)
76
    {
77
      OSPF_TRACE(D_EVENTS, "  neighbor %I in state %u", n->rid, n->state);
78
    }
79
  }
80

    
81
  WALK_LIST(NODE oa,po->area_list)
82
  {
83
    OSPF_TRACE(D_EVENTS, "LSA graph dump for area \"%I\" start:", oa->areaid);
84
    ospf_top_dump(oa->gr,p);
85
    OSPF_TRACE(D_EVENTS, "LSA graph dump for area \"%I\" finished", oa->areaid);
86
  }
87
  neigh_dump_all();
88
}
89

    
90
static struct proto *
91
ospf_init(struct proto_config *c)
92
{
93
  struct proto *p = proto_new(c, sizeof(struct proto_ospf));
94
  struct proto_ospf *po=(struct proto_ospf *)p;
95
  struct ospf_config *oc=(struct ospf_config *)c;
96
  struct ospf_area_config *ac;
97
  struct ospf_iface_patt *patt;
98

    
99
  p->import_control = ospf_import_control;
100
  p->make_tmp_attrs = ospf_make_tmp_attrs;
101
  p->store_tmp_attrs = ospf_store_tmp_attrs;
102
  p->rt_notify = ospf_rt_notify;
103
  p->if_notify = ospf_if_notify;
104
  p->rte_better = ospf_rte_better;
105
  p->rte_same = ospf_rte_same;
106

    
107
  po->rfc1583=oc->rfc1583;
108
  return p;
109
}
110

    
111
/* If new is better return 1 */
112
static int
113
ospf_rte_better(struct rte *new, struct rte *old)
114
{
115
  struct proto *p = new->attrs->proto;
116

    
117
  if(new->u.ospf.metric1=LSINFINITY) return 0;
118

    
119
  if(((new->attrs->source==RTS_OSPF) || (new->attrs->source==RTS_OSPF_IA))
120
    && (old->attrs->source==RTS_OSPF_EXT)) return 1;
121

    
122
  if(((old->attrs->source==RTS_OSPF) || (old->attrs->source==RTS_OSPF_IA))
123
    && (new->attrs->source==RTS_OSPF_EXT)) return 0;
124

    
125
  if(new->u.ospf.metric2!=0)
126
  {
127
    if(old->u.ospf.metric2==0) return 0;
128
    if(new->u.ospf.metric2<old->u.ospf.metric2) return 1;
129
    return 0;
130
  }
131
  else
132
  {
133
    if(old->u.ospf.metric2!=0) return 1;
134
    if(new->u.ospf.metric1<old->u.ospf.metric1) return 1;
135
    return 0;
136
  }
137
}
138

    
139
static int
140
ospf_rte_same(struct rte *new, struct rte *old)
141
{
142
  /* new->attrs == old->attrs always */
143
  return
144
    new->u.ospf.metric1 == old->u.ospf.metric1 &&
145
    new->u.ospf.metric2 == old->u.ospf.metric2 &&
146
    new->u.ospf.tag     == old->u.ospf.tag;
147
}
148

    
149
static ea_list *
150
ospf_build_attrs(ea_list *next, struct linpool *pool, u32 m1, u32 m2, u32 tag)
151
{
152
  struct ea_list *l = lp_alloc(pool, sizeof(struct ea_list) + 3*sizeof(eattr));
153

    
154
  l->next = next;
155
  l->flags = EALF_SORTED;
156
  l->count = 3;
157
  l->attrs[0].id = EA_OSPF_METRIC1;
158
  l->attrs[0].flags = 0;
159
  l->attrs[0].type = EAF_TYPE_INT | EAF_TEMP;
160
  l->attrs[0].u.data = m1;
161
  l->attrs[1].id = EA_OSPF_METRIC2;
162
  l->attrs[1].flags = 0;
163
  l->attrs[1].type = EAF_TYPE_INT | EAF_TEMP;
164
  l->attrs[1].u.data = m2;
165
  l->attrs[2].id = EA_OSPF_TAG;
166
  l->attrs[2].flags = 0;
167
  l->attrs[2].type = EAF_TYPE_INT | EAF_TEMP;
168
  l->attrs[2].u.data = tag;
169
  return l;
170
}
171

    
172
void
173
schedule_rt_lsa(struct ospf_area *oa)
174
{
175
  struct proto_ospf *po=oa->po;
176
  struct proto *p=&po->proto;
177

    
178
  OSPF_TRACE(D_EVENTS, "Scheduling RT lsa origination for area %I.",
179
    oa->areaid);
180
  oa->origrt=1;
181
}
182

    
183
void
184
schedule_rtcalc(struct ospf_area *oa)
185
{
186
  struct proto_ospf *po=oa->po;
187
  struct proto *p=&po->proto;
188

    
189
  OSPF_TRACE(D_EVENTS, "Scheduling RT calculation for area %I.", 
190
    oa->areaid);
191
  oa->calcrt=1;
192
}
193

    
194
void
195
area_disp(timer *timer)
196
{
197
  struct ospf_area *oa=timer->data;
198
  struct top_hash_entry *en,*nxt;
199

    
200
  /* First of all try to age LSA DB */
201
  ospf_age(oa);
202

    
203
  /* Now try to originage rt_lsa */
204
  if(oa->origrt) originate_rt_lsa(oa);
205
  oa->origrt=0;
206

    
207
  if(oa->calcrt) ospf_rt_spfa(oa);
208
  oa->calcrt=0;
209
}
210

    
211
int
212
ospf_import_control(struct proto *p, rte **new, ea_list **attrs, struct linpool *pool)
213
{
214
  rte *e=*new;
215
  struct proto_ospf *po=(struct proto_ospf *)p;
216

    
217
  if(p==e->attrs->proto) return -1;        /* Reject our own routes */
218
  *attrs = ospf_build_attrs(*attrs, pool, LSINFINITY, 10000, 0);
219
  return 0;                                /* Leave decision to the filters */
220
}
221

    
222
struct ea_list *
223
ospf_make_tmp_attrs(struct rte *rt, struct linpool *pool)
224
{
225
  return ospf_build_attrs(NULL, pool, rt->u.ospf.metric1, rt->u.ospf.metric2, rt->u.ospf.tag);
226
}
227

    
228
void
229
ospf_store_tmp_attrs(struct rte *rt, struct ea_list *attrs)
230
{
231
  rt->u.ospf.metric1 = ea_get_int(attrs, EA_OSPF_METRIC1, LSINFINITY);
232
  rt->u.ospf.metric2 = ea_get_int(attrs, EA_OSPF_METRIC2, 10000);
233
  rt->u.ospf.tag     = ea_get_int(attrs, EA_OSPF_TAG,     0);
234
}
235

    
236
static int
237
ospf_shutdown(struct proto *p)
238
{
239
  struct proto_ospf *po=(struct proto_ospf *)p;
240
  struct ospf_iface *ifa;
241
  struct ospf_neighbor *n;
242
  struct ospf_area *oa;
243
  OSPF_TRACE(D_EVENTS, "Shutdown requested");
244

    
245
  /* And send to all my neighbors 1WAY */
246
  WALK_LIST(ifa, po->iface_list)
247
  {
248
    init_list(&ifa->neigh_list);
249
    hello_timer_hook(ifa->hello_timer);
250
  }
251
  
252
  return PS_DOWN;
253
}
254

    
255
void
256
ospf_rt_notify(struct proto *p, net *n, rte *new, rte *old, ea_list *attrs)
257
{
258
  struct proto_ospf *po=(struct proto_ospf *)p;
259

    
260
  OSPF_TRACE(D_EVENTS, "Got route %I/%d %s", p->name, n->n.prefix,
261
    n->n.pxlen, new ? "up" : "down");
262

    
263
  if(new)                /* Got some new route */
264
  {
265
    originate_ext_lsa(n, new, po, attrs);
266
  }
267
  else
268
  {
269
    u32 rtid=po->proto.cf->global->router_id;
270
    struct ospf_area *oa;
271
    struct top_hash_entry *en;
272
    u32 pr=ipa_to_u32(n->n.prefix);
273
    struct ospf_lsa_ext *ext;
274
    int i;
275

    
276
    /* Flush old external LSA */
277
    WALK_LIST(oa, po->area_list)
278
    {
279
      for(i=0;i<MAXNETS;i++,pr++)
280
      {
281
        if(en=ospf_hash_find(oa->gr, pr, rtid, LSA_T_EXT))
282
        {
283
          ext=en->lsa_body;
284
          if(ipa_compare(ext->netmask, ipa_mkmask(n->n.pxlen))==0)
285
          {
286
            net_flush_lsa(en,po,oa);
287
            break;
288
          }
289
        }
290
      }
291
    }
292
  }
293
}
294

    
295
static void
296
ospf_get_status(struct proto *p, byte *buf)
297
{
298
  struct proto_ospf *po=(struct proto_ospf *)p;
299

    
300
  if (p->proto_state == PS_DOWN) buf[0] = 0;
301
  else
302
  {
303
    struct ospf_iface *ifa;
304
    struct ospf_neighbor *n;
305
    int adj=0;
306

    
307
    WALK_LIST(ifa,po->iface_list)
308
      WALK_LIST(n,ifa->neigh_list)
309
        if(n->state==NEIGHBOR_FULL) adj=1;
310

    
311
    if(adj==0) strcpy(buf, "Alone");
312
    else strcpy(buf, "Running");
313
  }
314
}
315

    
316
static void
317
ospf_get_route_info(rte *rte, byte *buf, ea_list *attrs)
318
{
319
  char met=' ';
320
  char type=' ';
321

    
322
  if(rte->attrs->source==RTS_OSPF_EXT)
323
  {
324
    met='1';
325
    type='E';
326

    
327
  }
328
  if(rte->u.ospf.metric2!=LSINFINITY) met='2';
329
  if(rte->attrs->source==RTS_OSPF_IA) type='A';
330
  if(rte->attrs->source==RTS_OSPF) type='I';
331
  buf += bsprintf(buf, " %c", type);
332
  if(met!=' ') buf += bsprintf(buf, "%c", met);
333
  buf += bsprintf(buf, " (%d/%d)", rte->pref,
334
    (rte->u.ospf.metric2==LSINFINITY) ? rte->u.ospf.metric1 :
335
    rte->u.ospf.metric2);
336
  if(rte->attrs->source==RTS_OSPF_EXT && rte->u.ospf.tag)
337
  {
338
    buf += bsprintf(buf, " [%x]", rte->u.ospf.tag);
339
  }
340
}
341

    
342
static int
343
ospf_get_attr(eattr *a, byte *buf)
344
{
345
  switch (a->id)
346
    {
347
    case EA_OSPF_METRIC1: bsprintf(buf, "metric1"); return GA_NAME;
348
    case EA_OSPF_METRIC2: bsprintf(buf, "metric2"); return GA_NAME;
349
    case EA_OSPF_TAG: bsprintf(buf, "tag: %08x", a->u.data); return GA_FULL;
350
    default: return GA_UNKNOWN;
351
    }
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
}
358

    
359
static int
360
ospf_reconfigure(struct proto *p, struct proto_config *c)
361
{
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 :-) */
529
}
530

    
531
void
532
ospf_sh_neigh(struct proto *p, char *iff)
533
{
534
  struct ospf_iface *ifa=NULL,*f;
535
  struct ospf_neighbor *n;
536
  struct proto_ospf *po=(struct proto_ospf *)p;
537

    
538
  if(p->proto_state != PS_UP)
539
  {
540
    cli_msg(-1013,"%s: is not up", p->name);
541
    cli_msg(0,"");
542
    return;
543
  }
544
  
545
  if(iff!=NULL)
546
  {
547
    WALK_LIST(f, po->iface_list)
548
    {
549
      if(strcmp(iff,f->iface->name)==0)
550
      {
551
        ifa=f;
552
        break;
553
      }
554
    }
555
    if(ifa==NULL)
556
    {
557
      cli_msg(0,"");
558
      return;
559
    }
560
    cli_msg(-1013,"%s:", p->name);
561
    cli_msg(-1013,"%-12s\t%3s\t%-15s\t%-5s\t%-12s\t%-10s","Router ID","Pri",
562
      "     State", "DTime", "Router IP", "Interface");
563
    WALK_LIST(n, ifa->neigh_list) ospf_sh_neigh_info(n);
564
    cli_msg(0,"");
565
    return;
566
  }
567

    
568
  cli_msg(-1013,"%s:", p->name);
569
  cli_msg(-1013,"%-12s\t%3s\t%-15s\t%-5s\t%-12s\t%-10s","Router ID","Pri",
570
    "     State", "DTime", "Router IP", "Interface");
571
  WALK_LIST(ifa,po->iface_list)
572
    WALK_LIST(n, ifa->neigh_list)
573
      ospf_sh_neigh_info(n);
574
  cli_msg(0,"");
575
}
576

    
577
void
578
ospf_sh(struct proto *p)
579
{
580
  struct ospf_area *oa;
581
  struct proto_ospf *po=(struct proto_ospf *)p;
582
  struct ospf_iface *ifa;
583
  struct ospf_neighbor *n;
584
  int ifano;
585
  int nno;
586
  int adjno;
587

    
588
  if(p->proto_state != PS_UP)
589
  {
590
    cli_msg(-1014,"%s: is not up", p->name);
591
    cli_msg(0,"");
592
    return;
593
  }
594

    
595
  cli_msg(-1014,"%s:", p->name);
596
  cli_msg(-1014,"Number of areas: %u", po->areano);
597
  
598
  WALK_LIST(oa,po->area_list)
599
  {
600
    cli_msg(-1014,"\tArea: %I (%u) %s", oa->areaid, oa->areaid,
601
      oa->areaid==0 ? "[BACKBONE]" : "");
602
    ifano=0;
603
    nno=0;
604
    adjno=0;
605
    WALK_LIST(ifa, po->iface_list)
606
    {
607
      if(oa==ifa->oa) ifano++;
608
      WALK_LIST(n, ifa->neigh_list)
609
      {
610
        nno++;
611
        if(n->state==NEIGHBOR_FULL) adjno++;
612
      }
613
    }
614
    cli_msg(-1014,"\t\tStub:\t%s", oa->stub ? "Yes" : "No");
615
    cli_msg(-1014,"\t\tRT scheduler tick:\t%u", oa->tick);
616
    cli_msg(-1014,"\t\tNumber of interfaces:\t%u", ifano);
617
    cli_msg(-1014,"\t\tNumber of LSAs in DB:\t%u", oa->gr->hash_entries);
618
    cli_msg(-1014,"\t\tNumber of neighbors:\t%u", nno);
619
    cli_msg(-1014,"\t\tNumber of adjacent neighbors:\t%u", adjno);
620
  }
621
  cli_msg(0,"");
622
}
623

    
624
void
625
ospf_sh_iface(struct proto *p, char *iff)
626
{
627
  struct ospf_area *oa;
628
  struct proto_ospf *po=(struct proto_ospf *)p;
629
  struct ospf_iface *ifa=NULL,*f;
630
  struct ospf_neighbor *n;
631
  int ifano;
632
  int nno;
633
  int adjno;
634

    
635
  if(p->proto_state != PS_UP)
636
  {
637
    cli_msg(-1015,"%s: is not up", p->name);
638
    cli_msg(0,"");
639
    return;
640
  }
641

    
642
  if(iff!=NULL)
643
  {
644
    WALK_LIST(f, po->iface_list)
645
    {
646
      if(strcmp(iff,f->iface->name)==0)
647
      {
648
        ifa=f;
649
        break;
650
      }
651
    }
652

    
653
    if(ifa==NULL)
654
    {
655
      cli_msg(0,"");
656
      return;
657
    }
658
    cli_msg(-1015,"%s:", p->name);
659
    ospf_iface_info(ifa);
660
    cli_msg(0,"");
661
    return;
662
  }
663
  cli_msg(-1015,"%s:", p->name);
664
  WALK_LIST(ifa, po->iface_list) ospf_iface_info(ifa);
665
  cli_msg(0,"");
666
}
667

    
668
struct protocol proto_ospf = {
669
  name:                 "OSPF",
670
  template:                "ospf%d",
671
  attr_class:                EAP_OSPF,
672
  init:                        ospf_init,
673
  dump:                        ospf_dump,
674
  start:                ospf_start,
675
  shutdown:                ospf_shutdown,
676
  get_route_info:        ospf_get_route_info,
677
  get_attr:                ospf_get_attr,
678
  get_status:                ospf_get_status,
679
  reconfigure:                ospf_reconfigure
680
};
681