使用自定义的udp_hdr替换linux的udphdr
This commit is contained in:
@@ -2,12 +2,11 @@
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <linux/if.h>
|
||||
#include <net/if.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <netinet/ether.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <netinet/udp.h>
|
||||
#include <netinet/ether.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "log.h"
|
||||
@@ -161,11 +160,11 @@ static int checksum(u_int16_t *addr, int len)
|
||||
return sum;
|
||||
}
|
||||
|
||||
void build_udp_header(const char *l3_hdr, int l3_hdr_len, struct udphdr *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, u_int16_t udp_sport, u_int16_t udp_dport, int payload_len)
|
||||
{
|
||||
memset(udp_hdr, 0, sizeof(struct udphdr));
|
||||
memset(udp_hdr, 0, sizeof(struct udp_hdr));
|
||||
|
||||
int udp_hlen = sizeof(struct udphdr) + payload_len;
|
||||
int udp_hlen = sizeof(struct udp_hdr) + payload_len;
|
||||
|
||||
udp_hdr->uh_sport = htons(udp_sport);
|
||||
udp_hdr->uh_dport = htons(udp_dport);
|
||||
|
||||
Reference in New Issue
Block a user