* Detach export datagram from priv, if there is any. * If there is no, allocate a new one. */
| 166 | * If there is no, allocate a new one. |
| 167 | */ |
| 168 | static item_p |
| 169 | get_export_dgram(priv_p priv, fib_export_p fe) |
| 170 | { |
| 171 | item_p item = NULL; |
| 172 | |
| 173 | mtx_lock(&fe->export_mtx); |
| 174 | if (fe->exp.item != NULL) { |
| 175 | item = fe->exp.item; |
| 176 | fe->exp.item = NULL; |
| 177 | } |
| 178 | mtx_unlock(&fe->export_mtx); |
| 179 | |
| 180 | if (item == NULL) { |
| 181 | struct netflow_v5_export_dgram *dgram; |
| 182 | struct mbuf *m; |
| 183 | |
| 184 | m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); |
| 185 | if (m == NULL) |
| 186 | return (NULL); |
| 187 | item = ng_package_data(m, NG_NOFLAGS); |
| 188 | if (item == NULL) |
| 189 | return (NULL); |
| 190 | dgram = mtod(m, struct netflow_v5_export_dgram *); |
| 191 | dgram->header.count = 0; |
| 192 | dgram->header.version = htons(NETFLOW_V5); |
| 193 | dgram->header.pad = 0; |
| 194 | } |
| 195 | |
| 196 | return (item); |
| 197 | } |
| 198 | |
| 199 | /* |
| 200 | * Re-attach incomplete datagram back to priv. |
no test coverage detected