-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
318f491
commit 1f55596
Showing
2 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters