Revision 0f32f2a6

View differences:

nest/iface.h
102 102
  void *data;				/* Protocol-specific data */
103 103
  unsigned aux;				/* Protocol-specific data */
104 104
  unsigned flags;
105
  unsigned scope;			/* Address scope, SCOPE_HOST when it's our own address */
105 106
} neighbor;
106 107

  
107 108
#define NEF_STICKY 1
nest/neighbor.c
30 30
  struct ifa *b;
31 31

  
32 32
  if (!(i->flags & IF_UP))
33
    return 0;
33
    return -1;
34 34
  WALK_LIST(b, i->addrs)
35 35
    {
36 36
      if (ipa_equal(*a, b->ip))
37
	return -1;
37
	return SCOPE_HOST;
38 38
      if (b->flags & IA_UNNUMBERED)
39 39
	{
40 40
	  if (ipa_equal(*a, b->opposite))
41
	    return 1;
41
	    return b->scope;
42 42
	}
43 43
      else
44 44
	{
......
47 47
	      if (ipa_equal(*a, b->prefix) ||	/* Network address */
48 48
		  ipa_equal(*a, b->brd))	/* Broadcast */
49 49
		return -1;
50
	      return 1;
50
	      return b->scope;
51 51
	    }
52 52
	}
53 53
      }
54
  return 0;
54
  return -1;
55 55
}
56 56

  
57 57
neighbor *
58 58
neigh_find(struct proto *p, ip_addr *a, unsigned flags)
59 59
{
60 60
  neighbor *n;
61
  int class;
61
  int class, scope = SCOPE_HOST;
62 62
  unsigned int h = neigh_hash(p, a);
63 63
  struct iface *i, *j;
64 64

  
......
75 75

  
76 76
  j = NULL;
77 77
  WALK_LIST(i, iface_list)
78
    switch (if_connected(a, i))
78
    if ((scope = if_connected(a, i)) >= 0)
79 79
      {
80
      case -1:
81
	return NULL;
82
      case 1:
83
	if (!j)
84
	  j = i;
85
	/* Fall-thru */
80
	j = i;
81
	break;
86 82
      }
87 83
  if (!j && !(flags & NEF_STICKY))
88 84
    return NULL;
......
101 97
  n->data = NULL;
102 98
  n->aux = 0;
103 99
  n->flags = flags;
100
  n->scope = scope;
104 101
  return n;
105 102
}
106 103

  
......
112 109
    debug("%s ", n->iface->name);
113 110
  else
114 111
    debug("[] ");
115
  debug("%s %p %08x", n->proto->name, n->data, n->aux);
112
  debug("%s %p %08x scope %s", n->proto->name, n->data, n->aux, ip_scope_text(n->scope));
116 113
  if (n->flags & NEF_STICKY)
117 114
    debug(" STICKY");
118 115
  debug("\n");
......
137 134
neigh_if_up(struct iface *i)
138 135
{
139 136
  neighbor *n, *next;
137
  int scope;
140 138

  
141 139
  WALK_LIST_DELSAFE(n, next, sticky_neigh_list)
142
    if (if_connected(&n->addr, i) > 0)
140
    if ((scope = if_connected(&n->addr, i)) >= 0)
143 141
      {
144 142
	n->iface = i;
143
	n->scope = scope;
145 144
	add_tail(&i->neighbors, &n->if_n);
146 145
	rem_node(&n->n);
147 146
	add_tail(&neigh_hash_table[neigh_hash(n->proto, &n->addr)], &n->n);

Also available in: Unified diff