TSG-14351 tsg-service-chaining-engine通过Mock Mrzcpd进行单元测试
This commit is contained in:
@@ -159,12 +159,12 @@ void throughput_metrics_inc(struct throughput_metrics *iterm, uint64_t n_pkts, u
|
||||
|
||||
#define CHECKSUM_CARRY(x) (x = (x >> 16) + (x & 0xffff), (~(x + (x >> 16)) & 0xffff))
|
||||
|
||||
static int checksum(u_int16_t *addr, int len)
|
||||
static int checksum(uint16_t *addr, int len)
|
||||
{
|
||||
int sum = 0;
|
||||
int nleft = len;
|
||||
u_int16_t ans = 0;
|
||||
u_int16_t *w = addr;
|
||||
uint16_t ans = 0;
|
||||
uint16_t *w = addr;
|
||||
|
||||
while (nleft > 1)
|
||||
{
|
||||
@@ -181,7 +181,7 @@ static int checksum(u_int16_t *addr, int len)
|
||||
return sum;
|
||||
}
|
||||
|
||||
void build_udp_header(const char *l3_hdr, int l3_hdr_len, struct udp_hdr *udp_hdr, u_int16_t udp_sport, u_int16_t udp_dport, int payload_len)
|
||||
void build_udp_header(const char *l3_hdr, int l3_hdr_len, struct udp_hdr *udp_hdr, uint16_t udp_sport, uint16_t udp_dport, int payload_len)
|
||||
{
|
||||
memset(udp_hdr, 0, sizeof(struct udp_hdr));
|
||||
|
||||
@@ -193,13 +193,13 @@ void build_udp_header(const char *l3_hdr, int l3_hdr_len, struct udp_hdr *udp_hd
|
||||
udp_hdr->uh_ulen = htons(udp_hlen);
|
||||
udp_hdr->uh_sum = 0;
|
||||
|
||||
int sum = checksum((u_int16_t *)l3_hdr, l3_hdr_len);
|
||||
int sum = checksum((uint16_t *)l3_hdr, l3_hdr_len);
|
||||
sum += ntohs(IPPROTO_UDP + udp_hlen);
|
||||
sum += checksum((u_int16_t *)udp_hdr, udp_hlen);
|
||||
sum += checksum((uint16_t *)udp_hdr, udp_hlen);
|
||||
udp_hdr->uh_sum = CHECKSUM_CARRY(sum);
|
||||
}
|
||||
|
||||
void build_ip_header(struct ip *ip_hdr, u_int8_t next_protocol, const char *src_addr, const char *dst_addr, uint16_t payload_len)
|
||||
void build_ip_header(struct ip *ip_hdr, uint8_t next_protocol, const char *src_addr, const char *dst_addr, uint16_t payload_len)
|
||||
{
|
||||
memset(ip_hdr, 0, sizeof(struct ip));
|
||||
|
||||
@@ -215,7 +215,7 @@ void build_ip_header(struct ip *ip_hdr, u_int8_t next_protocol, const char *src_
|
||||
ip_hdr->ip_off = htons(0); /* fragmentation flags */
|
||||
ip_hdr->ip_sum = 0; /* do this later */
|
||||
|
||||
int sum = checksum((u_int16_t *)ip_hdr, 20);
|
||||
int sum = checksum((uint16_t *)ip_hdr, 20);
|
||||
ip_hdr->ip_sum = CHECKSUM_CARRY(sum);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user