Changeset View
Changeset View
Standalone View
Standalone View
sys/net80211/ieee80211_output.c
Show First 20 Lines • Show All 1,074 Lines • ▼ Show 20 Lines | |||||
* Drivers and cipher modules assume we have done the necessary work | * Drivers and cipher modules assume we have done the necessary work | ||||
* and fail rudely if they don't find the space they need. | * and fail rudely if they don't find the space they need. | ||||
*/ | */ | ||||
struct mbuf * | struct mbuf * | ||||
ieee80211_mbuf_adjust(struct ieee80211vap *vap, int hdrsize, | ieee80211_mbuf_adjust(struct ieee80211vap *vap, int hdrsize, | ||||
struct ieee80211_key *key, struct mbuf *m) | struct ieee80211_key *key, struct mbuf *m) | ||||
{ | { | ||||
#define TO_BE_RECLAIMED (sizeof(struct ether_header) - sizeof(struct llc)) | #define TO_BE_RECLAIMED (sizeof(struct ether_header) - sizeof(struct llc)) | ||||
int needed_space = vap->iv_ic->ic_headroom + hdrsize; | struct ieee80211com *ic = vap->iv_ic; | ||||
int needed_space = ic->ic_headroom + hdrsize; | |||||
int reserved_space; | |||||
if (key != NULL) { | if (key != NULL) { | ||||
/* XXX belongs in crypto code? */ | /* XXX belongs in crypto code? */ | ||||
needed_space += key->wk_cipher->ic_header; | needed_space += key->wk_cipher->ic_header; | ||||
/* XXX frags */ | /* XXX frags */ | ||||
/* | /* | ||||
* When crypto is being done in the host we must insure | * When crypto is being done in the host we must insure | ||||
* the data are writable for the cipher routines; clone | * the data are writable for the cipher routines; clone | ||||
Show All 14 Lines | #define TO_BE_RECLAIMED (sizeof(struct ether_header) - sizeof(struct llc)) | ||||
* We know we are called just before stripping an Ethernet | * We know we are called just before stripping an Ethernet | ||||
* header and prepending an LLC header. This means we know | * header and prepending an LLC header. This means we know | ||||
* there will be | * there will be | ||||
* sizeof(struct ether_header) - sizeof(struct llc) | * sizeof(struct ether_header) - sizeof(struct llc) | ||||
* bytes recovered to which we need additional space for the | * bytes recovered to which we need additional space for the | ||||
* 802.11 header and any crypto header. | * 802.11 header and any crypto header. | ||||
*/ | */ | ||||
/* XXX check trailing space and copy instead? */ | /* XXX check trailing space and copy instead? */ | ||||
if (M_LEADINGSPACE(m) < needed_space - TO_BE_RECLAIMED) { | reserved_space = needed_space - TO_BE_RECLAIMED; | ||||
if (M_LEADINGSPACE(m) < reserved_space) { | |||||
struct mbuf *n = m_gethdr(M_NOWAIT, m->m_type); | struct mbuf *n = m_gethdr(M_NOWAIT, m->m_type); | ||||
if (n == NULL) { | if (n == NULL) { | ||||
IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT, | IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT, | ||||
"%s: cannot expand storage\n", __func__); | "%s: cannot expand storage\n", __func__); | ||||
vap->iv_stats.is_tx_nobuf++; | vap->iv_stats.is_tx_nobuf++; | ||||
m_freem(m); | m_freem(m); | ||||
return NULL; | return NULL; | ||||
} | } | ||||
Show All 20 Lines | if (M_LEADINGSPACE(m) < reserved_space) { | ||||
m->m_len -= sizeof(struct ether_header); | m->m_len -= sizeof(struct ether_header); | ||||
m->m_data += sizeof(struct ether_header); | m->m_data += sizeof(struct ether_header); | ||||
/* | /* | ||||
* Replace the head of the chain. | * Replace the head of the chain. | ||||
*/ | */ | ||||
n->m_next = m; | n->m_next = m; | ||||
m = n; | m = n; | ||||
} | } | ||||
if (ic->ic_seglimit != 0) { | |||||
/* Adjust length of the mbuf chain. */ | |||||
m = ieee80211_mbuf_defrag(m, reserved_space, ic->ic_seglimit); | |||||
if (m == NULL) { | |||||
vap->iv_stats.is_tx_nobuf++; | |||||
return NULL; | |||||
} | |||||
} | |||||
return m; | return m; | ||||
#undef TO_BE_RECLAIMED | #undef TO_BE_RECLAIMED | ||||
} | } | ||||
/* | /* | ||||
* Return the transmit key to use in sending a unicast frame. | * Return the transmit key to use in sending a unicast frame. | ||||
* If a unicast key is set we use that. When no unicast key is set | * If a unicast key is set we use that. When no unicast key is set | ||||
* we fall back to the default transmit key. | * we fall back to the default transmit key. | ||||
▲ Show 20 Lines • Show All 2,338 Lines • Show Last 20 Lines |