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
Showing
8 changed files
with
1,081 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
BasedOnStyle: LLVM | ||
IndentWidth: 8 | ||
UseTab: Always | ||
BreakBeforeBraces: Linux | ||
AllowShortIfStatementsOnASingleLine: false | ||
IndentCaseLabels: false | ||
AlwaysBreakBeforeMultilineStrings: true | ||
AllowShortBlocksOnASingleLine: false | ||
|
||
ContinuationIndentWidth: 8 |
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,13 @@ | ||
#!/bin/sh | ||
set +e | ||
|
||
|
||
clang -O3 -Wall -Wextra -Wno-unused-parameter -Wpointer-arith -Wl,-z,now -Wl,-z,relro -pie -fPIC -D_FORTIFY_SOURCE=2\ | ||
-ggdb -g -pthread \ | ||
-o udpserver \ | ||
udpserver.c net.c | ||
|
||
clang -O3 -Wall -Wextra -Wno-unused-parameter -Wpointer-arith -Wl,-z,now -Wl,-z,relro -pie -fPIC -D_FORTIFY_SOURCE=2\ | ||
-ggdb -g -pthread -lm \ | ||
-o udpclient \ | ||
udpclient.c net.c |
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,58 @@ | ||
#define ERRORF(x...) fprintf(stderr, x) | ||
|
||
#define FATAL(x...) \ | ||
do { \ | ||
ERRORF("[-] PROGRAM ABORT : " x); \ | ||
ERRORF("\n\tLocation : %s(), %s:%u\n\n", __FUNCTION__, \ | ||
__FILE__, __LINE__); \ | ||
exit(EXIT_FAILURE); \ | ||
} while (0) | ||
|
||
#define PFATAL(x...) \ | ||
do { \ | ||
ERRORF("[-] SYSTEM ERROR : " x); \ | ||
ERRORF("\n\tLocation : %s(), %s:%u\n", __FUNCTION__, __FILE__, \ | ||
__LINE__); \ | ||
perror(" OS message "); \ | ||
ERRORF("\n"); \ | ||
exit(EXIT_FAILURE); \ | ||
} while (0) | ||
|
||
#define TIMESPEC_NSEC(ts) ((ts)->tv_sec * 1000000000ULL + (ts)->tv_nsec) | ||
#define TIMEVAL_NSEC(ts) \ | ||
((ts)->tv_sec * 1000000000ULL + (ts)->tv_usec * 1000ULL) | ||
#define NSEC_TIMESPEC(ns) \ | ||
(struct timespec) { (ns) / 1000000000ULL, (ns) % 1000000000ULL } | ||
#define NSEC_TIMEVAL(ns) \ | ||
(struct timeval) \ | ||
{ \ | ||
(ns) / 1000000000ULL, ((ns) % 1000000000ULL) / 1000ULL \ | ||
} | ||
#define MSEC_NSEC(ms) ((ms)*1000000ULL) | ||
|
||
/* net.c */ | ||
struct net_addr | ||
{ | ||
int ipver; | ||
struct sockaddr_in sin4; | ||
struct sockaddr_in6 sin6; | ||
struct sockaddr *sockaddr; | ||
int sockaddr_len; | ||
}; | ||
|
||
void parse_addr(struct net_addr *netaddr, const char *addr); | ||
const char *addr_to_str(struct net_addr *addr); | ||
int net_bind_udp(struct net_addr *addr, int reuseport, int busy_poll); | ||
void net_set_buffer_size(int cd, int max, int send); | ||
void net_gethostbyname(struct net_addr *shost, const char *host, int port); | ||
int net_connect_udp(struct net_addr *addr, int src_port, int busy_poll); | ||
|
||
struct thread; | ||
struct thread *thread_spawn(void (*callback)(void *), void *userdata); | ||
|
||
uint64_t realtime_now(); | ||
|
||
const char *optstring_from_long_options(const struct option *opt); | ||
|
||
int net_connect_tcp(struct net_addr *shost, int src_port, int busy_poll); | ||
int net_bind_tcp(struct net_addr *addr, int reuseport); |
Oops, something went wrong.