Add V9 record to dgram. */
| 238 | |
| 239 | /* Add V9 record to dgram. */ |
| 240 | int |
| 241 | export9_add(item_p item, struct netflow_v9_packet_opt *t, struct flow_entry *fle) |
| 242 | { |
| 243 | size_t len = 0; |
| 244 | struct netflow_v9_flowset_header fsh; |
| 245 | struct netflow_v9_record_general rg; |
| 246 | struct mbuf *m = NGI_M(item); |
| 247 | uint16_t flow_type; |
| 248 | struct flow_entry_data *fed; |
| 249 | #ifdef INET6 |
| 250 | struct flow6_entry_data *fed6; |
| 251 | #endif |
| 252 | if (t == NULL) { |
| 253 | CTR0(KTR_NET, "ng_netflow: V9 export packet without tag!"); |
| 254 | return (0); |
| 255 | } |
| 256 | |
| 257 | /* Prepare flow record */ |
| 258 | fed = (struct flow_entry_data *)&fle->f; |
| 259 | #ifdef INET6 |
| 260 | fed6 = (struct flow6_entry_data *)&fle->f; |
| 261 | #endif |
| 262 | /* We can use flow_type field since fle6 offset is equal to fle */ |
| 263 | flow_type = fed->r.flow_type; |
| 264 | |
| 265 | switch (flow_type) { |
| 266 | case NETFLOW_V9_FLOW_V4_L4: |
| 267 | { |
| 268 | /* IPv4 TCP/UDP/[SCTP] */ |
| 269 | struct netflow_v9_record_ipv4_tcp *rec = &rg.rec.v4_tcp; |
| 270 | |
| 271 | rec->src_addr = fed->r.r_src.s_addr; |
| 272 | rec->dst_addr = fed->r.r_dst.s_addr; |
| 273 | rec->next_hop = fed->next_hop.s_addr; |
| 274 | rec->i_ifx = htons(fed->fle_i_ifx); |
| 275 | rec->o_ifx = htons(fed->fle_o_ifx); |
| 276 | rec->i_packets = htonl(fed->packets); |
| 277 | rec->i_octets = htonl(fed->bytes); |
| 278 | rec->o_packets = htonl(0); |
| 279 | rec->o_octets = htonl(0); |
| 280 | rec->first = htonl(MILLIUPTIME(fed->first)); |
| 281 | rec->last = htonl(MILLIUPTIME(fed->last)); |
| 282 | rec->s_port = fed->r.r_sport; |
| 283 | rec->d_port = fed->r.r_dport; |
| 284 | rec->flags = fed->tcp_flags; |
| 285 | rec->prot = fed->r.r_ip_p; |
| 286 | rec->tos = fed->r.r_tos; |
| 287 | rec->dst_mask = fed->dst_mask; |
| 288 | rec->src_mask = fed->src_mask; |
| 289 | |
| 290 | /* Not supported fields. */ |
| 291 | rec->src_as = rec->dst_as = 0; |
| 292 | |
| 293 | len = sizeof(struct netflow_v9_record_ipv4_tcp); |
| 294 | break; |
| 295 | } |
| 296 | #ifdef INET6 |
| 297 | case NETFLOW_V9_FLOW_V6_L4: |
no test coverage detected