ieee80211_input.c (59aa14a91db84e940b6732cd1ff069f0268793bf) ieee80211_input.c (519f677aff17ce417e74f2f2727313b5b3fed687)
1/*-
2 * Copyright (c) 2001 Atsushi Onoe
3 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 271 unchanged lines hidden (view full) ---

280 break;
281 case IEEE80211_FC1_DIR_DSTODS:
282 IEEE80211_ADDR_COPY(eh->ether_dhost, wh.i_addr3);
283 IEEE80211_ADDR_COPY(eh->ether_shost, wh.i_addr4);
284 break;
285 }
286#ifdef ALIGNED_POINTER
287 if (!ALIGNED_POINTER(mtod(m, caddr_t) + sizeof(*eh), uint32_t)) {
1/*-
2 * Copyright (c) 2001 Atsushi Onoe
3 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 271 unchanged lines hidden (view full) ---

280 break;
281 case IEEE80211_FC1_DIR_DSTODS:
282 IEEE80211_ADDR_COPY(eh->ether_dhost, wh.i_addr3);
283 IEEE80211_ADDR_COPY(eh->ether_shost, wh.i_addr4);
284 break;
285 }
286#ifdef ALIGNED_POINTER
287 if (!ALIGNED_POINTER(mtod(m, caddr_t) + sizeof(*eh), uint32_t)) {
288 struct mbuf *n, *n0, **np;
289 caddr_t newdata;
290 int off, pktlen;
291
292 n0 = NULL;
293 np = &n0;
294 off = 0;
295 pktlen = m->m_pkthdr.len;
296 while (pktlen > off) {
297 if (n0 == NULL) {
298 MGETHDR(n, M_DONTWAIT, MT_DATA);
299 if (n == NULL) {
300 m_freem(m);
301 return NULL;
302 }
303 M_MOVE_PKTHDR(n, m);
304 n->m_len = MHLEN;
305 } else {
306 MGET(n, M_DONTWAIT, MT_DATA);
307 if (n == NULL) {
308 m_freem(m);
309 m_freem(n0);
310 return NULL;
311 }
312 n->m_len = MLEN;
313 }
314 if (pktlen - off >= MINCLSIZE) {
315 MCLGET(n, M_DONTWAIT);
316 if (n->m_flags & M_EXT)
317 n->m_len = n->m_ext.ext_size;
318 }
319 if (n0 == NULL) {
320 newdata =
321 (caddr_t)ALIGN(n->m_data + sizeof(*eh)) -
322 sizeof(*eh);
323 n->m_len -= newdata - n->m_data;
324 n->m_data = newdata;
325 }
326 if (n->m_len > pktlen - off)
327 n->m_len = pktlen - off;
328 m_copydata(m, off, n->m_len, mtod(n, caddr_t));
329 off += n->m_len;
330 *np = n;
331 np = &n->m_next;
332 }
333 m_freem(m);
334 m = n0;
288 m = ieee80211_realign(vap, m, sizeof(*eh));
289 if (m == NULL)
290 return NULL;
335 }
336#endif /* ALIGNED_POINTER */
337 if (llc != NULL) {
338 eh = mtod(m, struct ether_header *);
339 eh->ether_type = htons(m->m_pkthdr.len - sizeof(*eh));
340 }
341 return m;
342#undef wh

--- 557 unchanged lines hidden ---
291 }
292#endif /* ALIGNED_POINTER */
293 if (llc != NULL) {
294 eh = mtod(m, struct ether_header *);
295 eh->ether_type = htons(m->m_pkthdr.len - sizeof(*eh));
296 }
297 return m;
298#undef wh

--- 557 unchanged lines hidden ---