Revision fe9f1a6d proto/ospf/ospf.c

View differences:

proto/ospf/ospf.c
107 107
static int ospf_rte_same(struct rte *new, struct rte *old);
108 108
static void ospf_disp(timer *timer);
109 109

  
110
static void
111
ospf_area_initfib(struct fib_node *fn)
112
{
113
  struct area_net *an = (struct area_net *) fn;
114
  an->hidden = 0;
115
  an->active = 0;
116
}
117 110

  
118 111
static void
119 112
add_area_nets(struct ospf_area *oa, struct ospf_area_config *ac)
......
121 114
  struct ospf_proto *p = oa->po;
122 115
  struct area_net_config *anc;
123 116
  struct area_net *an;
117
  net_addr net;
124 118

  
125
  fib_init(&oa->net_fib, p->p.pool, sizeof(struct area_net), 0, ospf_area_initfib);
126
  fib_init(&oa->enet_fib, p->p.pool, sizeof(struct area_net), 0, ospf_area_initfib);
119
  fib_init(&oa->net_fib,  p->p.pool, ospf_is_v2(p) ? NET_IP4 : NET_IP6,
120
	   sizeof(struct area_net), OFFSETOF(struct area_net, fn), 0, NULL);
121
  fib_init(&oa->enet_fib, p->p.pool, ospf_is_v2(p) ? NET_IP4 : NET_IP6,
122
	   sizeof(struct area_net), OFFSETOF(struct area_net, fn), 0, NULL);
127 123

  
128 124
  WALK_LIST(anc, ac->net_list)
129 125
  {
130
    an = (struct area_net *) fib_get(&oa->net_fib, &anc->px.addr, anc->px.len);
126
    /* XXXX we should dispatch by ospf version, not by px.addr */
127
    net_fill_ipa(&net, anc->px.addr, anc->px.len);
128
    an = fib_get(&oa->net_fib, &net);
131 129
    an->hidden = anc->hidden;
132 130
  }
133 131

  
134 132
  WALK_LIST(anc, ac->enet_list)
135 133
  {
136
    an = (struct area_net *) fib_get(&oa->enet_fib, &anc->px.addr, anc->px.len);
134
    /* XXXX ditto */
135
    net_fill_ipa(&net, anc->px.addr, anc->px.len);
136
    an = fib_get(&oa->enet_fib, &net);
137 137
    an->hidden = anc->hidden;
138 138
    an->tag = anc->tag;
139 139
  }
......
154 154
  oa->areaid = ac->areaid;
155 155
  oa->rt = NULL;
156 156
  oa->po = p;
157
  fib_init(&oa->rtr, p->p.pool, sizeof(ort), 0, ospf_rt_initort);
157
  fib_init(&oa->rtr, p->p.pool, NET_IP4, sizeof(ort), OFFSETOF(ort, fn), 0, NULL);
158 158
  add_area_nets(oa, ac);
159 159

  
160 160
  if (oa->areaid == 0)
......
243 243
  p->nhpool = lp_new(P->pool, 12*sizeof(struct mpnh));
244 244
  init_list(&(p->iface_list));
245 245
  init_list(&(p->area_list));
246
  fib_init(&p->rtf, P->pool, sizeof(ort), 0, ospf_rt_initort);
246
  fib_init(&p->rtf, P->pool, p->ospf2 ? NET_IP4 : NET_IP6,
247
	   sizeof(ort), OFFSETOF(ort, fn), 0, NULL);
247 248
  p->areano = 0;
248 249
  p->gr = ospf_top_new(p, P->pool);
249 250
  s_init_list(&(p->lsal));
......
803 804
	cli_msg(-1014, "\t\tArea networks:");
804 805
	firstfib = 0;
805 806
      }
806
      cli_msg(-1014, "\t\t\t%1I/%u\t%s\t%s", anet->fn.prefix, anet->fn.pxlen,
807
      cli_msg(-1014, "\t\t\t%1N\t%s\t%s", anet->fn.addr,
807 808
		anet->hidden ? "Hidden" : "Advertise", anet->active ? "Active" : "");
808 809
    }
809 810
    FIB_WALK_END;
......
817 818
	cli_msg(-1014, "\t\tArea external networks:");
818 819
	firstfib = 0;
819 820
      }
820
      cli_msg(-1014, "\t\t\t%1I/%u\t%s\t%s", anet->fn.prefix, anet->fn.pxlen,
821
      cli_msg(-1014, "\t\t\t%1N\t%s\t%s", anet->fn.addr,
821 822
		anet->hidden ? "Hidden" : "Advertise", anet->active ? "Active" : "");
822 823
    }
823 824
    FIB_WALK_END;
......
1074 1075
static inline void
1075 1076
show_lsa_sum_net(struct top_hash_entry *he, int ospf2)
1076 1077
{
1077
  ip_addr ip;
1078
  int pxlen;
1078
  net_addr net;
1079 1079
  u8 pxopts;
1080 1080
  u32 metric;
1081 1081

  
1082
  lsa_parse_sum_net(he, ospf2, &ip, &pxlen, &pxopts, &metric);
1083
  cli_msg(-1016, "\t\txnetwork %I/%d metric %u", ip, pxlen, metric);
1082
  lsa_parse_sum_net(he, ospf2, &net, &pxopts, &metric);
1083
  cli_msg(-1016, "\t\txnetwork %N metric %u", &net, metric);
1084 1084
}
1085 1085

  
1086 1086
static inline void
......
1113 1113
  if (rt.tag)
1114 1114
    bsprintf(str_tag, " tag %08x", rt.tag);
1115 1115

  
1116
  cli_msg(-1016, "\t\t%s %I/%d metric%s %u%s%s",
1116
  cli_msg(-1016, "\t\t%s %N metric%s %u%s%s",
1117 1117
	  (he->lsa_type == LSA_T_NSSA) ? "nssa-ext" : "external",
1118
	  rt.ip, rt.pxlen, rt.ebit ? "2" : "", rt.metric, str_via, str_tag);
1118
	  &rt.net, rt.ebit ? "2" : "", rt.metric, str_via, str_tag);
1119 1119
}
1120 1120

  
1121 1121
static inline void
1122 1122
show_lsa_prefix(struct top_hash_entry *he, struct top_hash_entry *cnode)
1123 1123
{
1124 1124
  struct ospf_lsa_prefix *px = he->lsa_body;
1125
  ip_addr pxa;
1126
  int pxlen;
1127
  u8 pxopts;
1128
  u16 metric;
1129 1125
  u32 *buf;
1130 1126
  int i;
1131 1127

  
......
1141 1137

  
1142 1138
  buf = px->rest;
1143 1139
  for (i = 0; i < px->pxcount; i++)
1144
    {
1145
      buf = lsa_get_ipv6_prefix(buf, &pxa, &pxlen, &pxopts, &metric);
1140
  {
1141
    net_addr net;
1142
    u8 pxopts;
1143
    u16 metric;
1146 1144

  
1147
      if (px->ref_type == LSA_T_RT)
1148
	cli_msg(-1016, "\t\tstubnet %I/%d metric %u", pxa, pxlen, metric);
1149
      else
1150
	cli_msg(-1016, "\t\taddress %I/%d", pxa, pxlen);
1151
    }
1145
    buf = ospf_get_ipv6_prefix(buf, &net, &pxopts, &metric);
1146

  
1147
    if (px->ref_type == LSA_T_RT)
1148
      cli_msg(-1016, "\t\tstubnet %N metric %u", &net, metric);
1149
    else
1150
      cli_msg(-1016, "\t\taddress %N", &net);
1151
  }
1152 1152
}
1153 1153

  
1154 1154
void

Also available in: Unified diff