MCPcopy Create free account
hub / github.com/F-Stack/f-stack / export9_send

Function export9_send

freebsd/netgraph/netflow/netflow_v9.c:200–237  ·  view source on GitHub ↗

We have full datagram in fib data. Send it to export hook. */

Source from the content-addressed store, hash-verified

198
199/* We have full datagram in fib data. Send it to export hook. */
200int
201export9_send(priv_p priv, fib_export_p fe, item_p item, struct netflow_v9_packet_opt *t, int flags)
202{
203 struct mbuf *m = NGI_M(item);
204 struct netflow_v9_export_dgram *dgram = mtod(m,
205 struct netflow_v9_export_dgram *);
206 struct netflow_v9_header *header = &dgram->header;
207 struct timespec ts;
208 int error = 0;
209
210 if (t == NULL) {
211 CTR0(KTR_NET, "export9_send(): V9 export packet without tag");
212 NG_FREE_ITEM(item);
213 return (0);
214 }
215
216 /* Close flowset if not closed already */
217 if (m_pktlen(m) != t->flow_header)
218 close_flowset(m, t);
219
220 /* Fill export header. */
221 header->count = t->count;
222 header->sys_uptime = htonl(MILLIUPTIME(time_uptime));
223 getnanotime(&ts);
224 header->unix_secs = htonl(ts.tv_sec);
225 header->seq_num = htonl(atomic_fetchadd_32(&fe->flow9_seq, 1));
226 header->count = htons(t->count);
227 header->source_id = htonl(fe->domain_id);
228
229 if (priv->export9 != NULL)
230 NG_FWD_ITEM_HOOK_FLAGS(error, item, priv->export9, flags);
231 else
232 NG_FREE_ITEM(item);
233
234 free(t, M_NETFLOW_GENERAL);
235
236 return (error);
237}
238
239/* Add V9 record to dgram. */
240int

Callers 3

expire_flowFunction · 0.85
ng_netflow_cache_flushFunction · 0.85
return_export9_dgramFunction · 0.85

Calls 4

close_flowsetFunction · 0.85
getnanotimeFunction · 0.85
atomic_fetchadd_32Function · 0.50
freeFunction · 0.50

Tested by

no test coverage detected