Revision 061ab802 lib/ipv6.c

View differences:

lib/ipv6.c
136 136
  return 0;
137 137
}
138 138

  
139
/* From Linux include/net/ipv6.h */
140
#define NEXTHDR_HOP             0       /* Hop-by-hop option header. */
141
#define NEXTHDR_ROUTING         43      /* Routing header. */
142
#define NEXTHDR_FRAGMENT        44      /* Fragmentation/reassembly header. */
143
#define NEXTHDR_DEST            60      /* Destination options header. */
144
#define NEXTHDR_NONE            59      /* No next header */
145

  
146
#define NEXTHDR_ESP             50      /* Encapsulating security payload. */
147
#define NEXTHDR_AUTH            51      /* Authentication header. */
148

  
149

  
150
byte *
151
ipv6_skip_header(byte *pkt, int *len)
152
{
153
  int l = *len;
154
  int q;
155
  u8 nh;
156

  
157
  if (l < 40 || (*pkt & 0xf0) != 0x60)
158
    return NULL;
159

  
160
  /* Skip IPv6 header */
161
  nh = pkt[6];
162
  pkt += 40;
163

  
164
  while ()
165
    {
166
      switch (nw)
167
	{
168
	case NEXTHDR_FRAGMENT:
169

  
170
	case NEXTHDR_HOP:
171
	case NEXTHDR_ROUTING:
172
	case NEXTHDR_DEST:
173

  
174
	case NEXTHDR_AUTH:
175
	  break;
176

  
177
	case NEXTHDR_NONE:
178
	  return NULL;
179

  
180
	default:
181
	  return pkt;
182
	}
183
    }
184

  
185
  q = (*pkt & 0x0f) * 4;
186
  if (q > l)
187
    return NULL;
188
  *len -= q;
189
  return pkt + q;
190
}
191

  
192

  
193 139
/*
194 140
 *  Conversion of IPv6 address to presentation format and vice versa.
195 141
 *  Heavily inspired by routines written by Paul Vixie for the BIND project

Also available in: Unified diff