-
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
5c027da
commit d38841f
Showing
1 changed file
with
40 additions
and
35 deletions.
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 |
---|---|---|
@@ -1,43 +1,48 @@ | ||
#include <arpa/inet.h> | ||
#include <errno.h> | ||
#include <fcntl.h> | ||
#define _GNU_SOURCE /* program_invocation_name */ | ||
#include <sys/types.h> | ||
#include <sys/socket.h> | ||
|
||
#include <netinet/in.h> | ||
#include <stdint.h> | ||
|
||
#include <arpa/inet.h> | ||
|
||
#include <unistd.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <sys/socket.h> | ||
#include <sys/time.h> | ||
#include <sys/types.h> | ||
#include <unistd.h> | ||
#include <errno.h> | ||
#include <err.h> | ||
|
||
#define BUFFER_SIZE 512 | ||
int | ||
main(int argc, char *argv[]) | ||
{ | ||
struct sockaddr_in sin; | ||
int sock, ch, do_connect; | ||
ssize_t n; | ||
char* inaddr = "127.0.0.1"; | ||
uint64_t buf[] = { | ||
0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, | ||
0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef | ||
}; | ||
|
||
char buffer[BUFFER_SIZE]; | ||
bzero(&sin, sizeof(sin)); | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
int sockfd; | ||
struct sockaddr_in server; | ||
|
||
memset(&buffer, 0xff, 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; | ||
|
||
if (inet_aton(inaddr, &sin.sin_addr) == 0) | ||
errx(1, "inet_aton(%s)", inaddr); | ||
sin.sin_port = htons(53); | ||
sin.sin_family = AF_INET; | ||
|
||
if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1) | ||
err(1, "socket"); | ||
|
||
|
||
n = sendto(sock, buf, sizeof(buf), 0, | ||
(struct sockaddr *)&sin, sizeof(sin)); | ||
if (n == -1) | ||
err(1, "sendto"); | ||
else if (n != sizeof(buf)) | ||
errx(1, "sendto: shortcount"); | ||
|
||
return (0); | ||
} |