* Initialize an ie blob with the specified data. If previous * data exists re-use the data block. As a side effect we clear * all references to specific ie's; the caller is required to * recalculate them. */
| 1086 | * recalculate them. |
| 1087 | */ |
| 1088 | int |
| 1089 | ieee80211_ies_init(struct ieee80211_ies *ies, const uint8_t *data, int len) |
| 1090 | { |
| 1091 | /* NB: assumes data+len are the last fields */ |
| 1092 | memset(ies, 0, offsetof(struct ieee80211_ies, data)); |
| 1093 | if (ies->data != NULL && ies->len != len) { |
| 1094 | /* data size changed */ |
| 1095 | IEEE80211_FREE(ies->data, M_80211_NODE_IE); |
| 1096 | ies->data = NULL; |
| 1097 | } |
| 1098 | if (ies->data == NULL) { |
| 1099 | ies->data = (uint8_t *) IEEE80211_MALLOC(len, M_80211_NODE_IE, |
| 1100 | IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); |
| 1101 | if (ies->data == NULL) { |
| 1102 | ies->len = 0; |
| 1103 | /* NB: pointers have already been zero'd above */ |
| 1104 | return 0; |
| 1105 | } |
| 1106 | } |
| 1107 | memcpy(ies->data, data, len); |
| 1108 | ies->len = len; |
| 1109 | return 1; |
| 1110 | } |
| 1111 | |
| 1112 | /* |
| 1113 | * Reclaim storage for an ie blob. |
no test coverage detected