Revision 18a0c0bb proto/ospf/iface.c

View differences:

proto/ospf/iface.c
67 67
void
68 68
downint(struct ospf_iface *ifa)
69 69
{
70
  /* FIXME: Delete all neighbors! */
70
  struct ospf_neighbor *n;
71
  struct proto *p=&ifa->proto->proto;
72
  struct proto_ospf *po=ifa->proto;
73

  
74
  WALK_LIST(n,ifa->neigh_list)
75
  {
76
    debug("%s: Removing neighbor %I", p->name, n->ip);
77
    ospf_neigh_remove(n);
78
  }
79
  rem_node(NODE ifa);
80
  if(ifa->hello_sk!=NULL)
81
  {
82
    sk_close(ifa->hello_sk);
83
    rfree(ifa->hello_sk);
84
  }
85
  if(ifa->dr_sk!=NULL)
86
  {
87
    sk_close(ifa->dr_sk);
88
    rfree(ifa->dr_sk);
89
  }
90
  if(ifa->ip_sk!=NULL)
91
  {
92
    sk_close(ifa->ip_sk);
93
    rfree(ifa->ip_sk);
94
  }
95
  if(ifa->wait_timer!=NULL)
96
  {
97
    tm_stop(ifa->wait_timer);
98
    rfree(ifa->wait_timer);
99
  }
100
  mb_free(ifa);
71 101
}
72 102

  
73 103
void
......
150 180

  
151 181
  p=(struct proto *)(ifa->proto);
152 182

  
153

  
154
  /* FIXME: No NBMA and PTP networks */
155

  
156
  if(ifa->iface->flags & IF_MULTICAST)
183
  mcsk=sk_new(p->pool);
184
  mcsk->type=SK_IP_MC;
185
  mcsk->dport=OSPF_PROTO;
186
  mcsk->saddr=AllSPFRouters;
187
  mcsk->daddr=AllSPFRouters;
188
  mcsk->tos=IP_PREC_INTERNET_CONTROL;
189
  mcsk->ttl=1;
190
  mcsk->rx_hook=ospf_rx_hook;
191
  mcsk->tx_hook=ospf_tx_hook;
192
  mcsk->err_hook=ospf_err_hook;
193
  mcsk->iface=ifa->iface;
194
  mcsk->rbsize=ifa->iface->mtu;
195
  mcsk->tbsize=ifa->iface->mtu;
196
  mcsk->data=(void *)ifa;
197
  if(sk_open(mcsk)!=0)
157 198
  {
158
    mcsk=sk_new(p->pool);
159
    mcsk->type=SK_IP_MC;
160
    mcsk->dport=OSPF_PROTO;
161
    mcsk->saddr=AllSPFRouters;
162
    mcsk->daddr=AllSPFRouters;
163
    mcsk->tos=IP_PREC_INTERNET_CONTROL;
164
    mcsk->ttl=1;
165
    mcsk->rx_hook=ospf_rx_hook;
166
    mcsk->tx_hook=ospf_tx_hook;
167
    mcsk->err_hook=ospf_err_hook;
168
    mcsk->iface=ifa->iface;
169
    mcsk->rbsize=ifa->iface->mtu;
170
    mcsk->tbsize=ifa->iface->mtu;
171
    mcsk->data=(void *)ifa;
172
    if(sk_open(mcsk)!=0)
173
    {
174
      DBG("%s: SK_OPEN: mc open failed.\n",p->name);
175
      return(NULL);
176
    }
177
    DBG("%s: SK_OPEN: mc opened.\n",p->name);
178
    return(mcsk);
199
    DBG("%s: SK_OPEN: mc open failed.\n",p->name);
200
    return(NULL);
179 201
  }
180
  else return(NULL);
202
  DBG("%s: SK_OPEN: mc opened.\n",p->name);
203
  return(mcsk);
181 204
}
182 205

  
183 206
sock *
......
323 346
  {
324 347
    debug("%s: using interface %s.\n", p->name, iface->name);
325 348
    /* FIXME: Latter I'll use config - this is incorrect */
326
    ifa=mb_alloc(p->pool, sizeof(struct ospf_iface));
349
    ifa=mb_allocz(p->pool, sizeof(struct ospf_iface));
327 350
    ifa->proto=(struct proto_ospf *)p;
328 351
    ifa->iface=iface;
329 352
    ospf_iface_default(ifa);

Also available in: Unified diff