Skip to content

Commit

Permalink
test with a special binary...
Browse files Browse the repository at this point in the history
  • Loading branch information
fearful-symmetry committed Sep 18, 2024
1 parent 318f491 commit 1f55596
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
55 changes: 55 additions & 0 deletions testing/test_bins/udp_send.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <fcntl.h>
#include <sys/time.h>
#include <arpa/inet.h>
#include <errno.h>


#define BUFFER_SIZE 512

char buffer[BUFFER_SIZE];

void create_buffer(uint8_t* buffer, size_t length)
{
for (size_t i = 0; i < length; i++)
{
buffer[i] = 0xff;
}
}

int main(int argc, char **argv)
{
int sockfd;
struct sockaddr_in server;

create_buffer(buffer, sizeof(buffer));


sockfd = socket(AF_INET, SOCK_DGRAM, 0);
if (sockfd < 0)
{
fprintf(stderr, "Error opening socket");
return -1;
}

bzero((char*)&server, sizeof(server));
server.sin_family = AF_INET;
server.sin_addr.s_addr = inet_addr("127.0.0.1");
server.sin_port = htons(53);
printf("sending...\n");
if (sendto(sockfd, &buffer, BUFFER_SIZE, 0,(const struct sockaddr*)&server, sizeof(server)) < 0)
{
fprintf(stderr, "Error in sendto()\n");
return -1;
}


return 0;
}
2 changes: 1 addition & 1 deletion testing/testrunner/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func TestForkExec(et *EventsTraceInstance) {
}

func TestDNSMonitor(et *EventsTraceInstance) {
runTestCmd([]string{"/usr/bin/sh", "-c", "host github.com"})
runTestBin("udp_send")

type dnsOutput struct {
Data []uint8 `json:"data"`
Expand Down

0 comments on commit 1f55596

Please sign in to comment.