diff --git a/code/bngblaster/src/bbl_interface.h b/code/bngblaster/src/bbl_interface.h index 3a29133c..2951b26a 100644 --- a/code/bngblaster/src/bbl_interface.h +++ b/code/bngblaster/src/bbl_interface.h @@ -56,6 +56,7 @@ typedef struct bbl_interface_ uint16_t read; /* current read slot */ uint16_t write; /* current write slot */ uint16_t next; /* next write slot */ + uint32_t full; } send; uint32_t ifindex; /* interface index */ diff --git a/code/bngblaster/src/bbl_io.c b/code/bngblaster/src/bbl_io.c index 6882367b..fc9d083b 100644 --- a/code/bngblaster/src/bbl_io.c +++ b/code/bngblaster/src/bbl_io.c @@ -279,7 +279,7 @@ bbl_io_raw_tx_job(timer_s *timer) { if(!interface->io.tx_len) { tx_result = bbl_tx(ctx, interface, interface->io.tx_buf, &interface->io.tx_len); } - if (tx_result == PROTOCOL_SUCCESS) { + if(tx_result == PROTOCOL_SUCCESS) { if (sendto(interface->io.fd_tx, interface->io.tx_buf, interface->io.tx_len, 0, (struct sockaddr*)&interface->io.addr, sizeof(struct sockaddr_ll)) <0 ) { LOG(IO, "Sendto failed with errno: %i\n", errno); interface->stats.sendto_failed++; diff --git a/code/bngblaster/src/bbl_send.c b/code/bngblaster/src/bbl_send.c index cf87ac02..5cc5d015 100644 --- a/code/bngblaster/src/bbl_send.c +++ b/code/bngblaster/src/bbl_send.c @@ -12,8 +12,7 @@ #include "bbl_session.h" bool -bbl_send_init_interface(bbl_interface_s *interface, uint16_t size) -{ +bbl_send_init_interface(bbl_interface_s *interface, uint16_t size) { interface->send.ring = malloc(size * sizeof(bbl_send_slot_t)); if(!interface->send.ring) { return false; @@ -26,8 +25,7 @@ bbl_send_init_interface(bbl_interface_s *interface, uint16_t size) } bool -bbl_send_is_empty(bbl_interface_s *interface) -{ +bbl_send_is_empty(bbl_interface_s *interface) { if(interface->send.read == interface->send.write) { return true; } @@ -35,8 +33,7 @@ bbl_send_is_empty(bbl_interface_s *interface) } bool -bbl_send_is_full(bbl_interface_s *interface) -{ +bbl_send_is_full(bbl_interface_s *interface) { if(interface->send.read == interface->send.next) { return true; } @@ -52,8 +49,7 @@ bbl_send_is_full(bbl_interface_s *interface) * @return number of bytes copied */ uint16_t -bbl_send_from_buffer(bbl_interface_s *interface, uint8_t *buf) -{ +bbl_send_from_buffer(bbl_interface_s *interface, uint8_t *buf) { bbl_send_slot_t *slot; if(interface->send.read == interface->send.write) { @@ -79,11 +75,11 @@ bbl_send_from_buffer(bbl_interface_s *interface, uint8_t *buf) * @return bbl_send_result_t */ bbl_send_result_t -bbl_send_to_buffer(bbl_interface_s *interface, bbl_ethernet_header_t *eth) -{ +bbl_send_to_buffer(bbl_interface_s *interface, bbl_ethernet_header_t *eth) { bbl_send_slot_t *slot; if(interface->send.read == interface->send.next) { + interface->send.full++; return BBL_SEND_FULL; } slot = interface->send.ring + interface->send.write; @@ -100,24 +96,21 @@ bbl_send_to_buffer(bbl_interface_s *interface, bbl_ethernet_header_t *eth) } static void -swap_eth_src_dst(bbl_ethernet_header_t *eth) -{ +swap_eth_src_dst(bbl_ethernet_header_t *eth) { uint8_t *dst = eth->dst; eth->dst = eth->src; eth->src = dst; } static void -swap_ipv4_src_dst(bbl_ipv4_t *ipv4) -{ +swap_ipv4_src_dst(bbl_ipv4_t *ipv4) { uint32_t dst = ipv4->dst; ipv4->dst = ipv4->src; ipv4->src = dst; } static void -swap_ipv6_src_dst(bbl_ipv6_t *ipv6) -{ +swap_ipv6_src_dst(bbl_ipv6_t *ipv6) { uint8_t *dst = ipv6->dst; ipv6->dst = ipv6->src; ipv6->src = dst; @@ -126,8 +119,7 @@ swap_ipv6_src_dst(bbl_ipv6_t *ipv6) static void update_eth(bbl_interface_s *interface, bbl_session_s *session, - bbl_ethernet_header_t *eth) -{ + bbl_ethernet_header_t *eth) { eth->mpls = NULL; if(session) { swap_eth_src_dst(eth); @@ -149,8 +141,7 @@ bbl_send_result_t bbl_send_arp_reply(bbl_interface_s *interface, bbl_session_s *session, bbl_ethernet_header_t *eth, - bbl_arp_t *arp) -{ + bbl_arp_t *arp) { update_eth(interface, session, eth); arp->code = ARP_REPLY; arp->sender = interface->mac; @@ -165,8 +156,7 @@ bbl_send_icmpv6_na(bbl_interface_s *interface, bbl_session_s *session, bbl_ethernet_header_t *eth, bbl_ipv6_t *ipv6, - bbl_icmpv6_t *icmpv6) -{ + bbl_icmpv6_t *icmpv6) { update_eth(interface, session, eth); ipv6->dst = ipv6->src; if(session) { @@ -190,8 +180,7 @@ bbl_send_icmp_reply(bbl_interface_s *interface, bbl_session_s *session, bbl_ethernet_header_t *eth, bbl_ipv4_t *ipv4, - bbl_icmp_t *icmp) -{ + bbl_icmp_t *icmp) { update_eth(interface, session, eth); swap_ipv4_src_dst(ipv4); ipv4->ttl = 64; @@ -204,8 +193,7 @@ bbl_send_icmpv6_echo_reply(bbl_interface_s *interface, bbl_session_s *session, bbl_ethernet_header_t *eth, bbl_ipv6_t *ipv6, - bbl_icmpv6_t *icmpv6) -{ + bbl_icmpv6_t *icmpv6) { update_eth(interface, session, eth); swap_ipv6_src_dst(ipv6); ipv6->ttl = 255; diff --git a/code/bngblaster/src/bbl_send.h b/code/bngblaster/src/bbl_send.h index 20e45c0b..395430e0 100644 --- a/code/bngblaster/src/bbl_send.h +++ b/code/bngblaster/src/bbl_send.h @@ -14,7 +14,7 @@ #ifndef __BBL_TXQ_H__ #define __BBL_TXQ_H__ -#define BBL_SEND_DEFAULT_SIZE 2048 +#define BBL_SEND_DEFAULT_SIZE 4096 typedef enum bbl_send_result_ { BBL_SEND_OK = 0,