summaryrefslogtreecommitdiff
path: root/mcastseed/src/mcastleech.c
diff options
context:
space:
mode:
Diffstat (limited to 'mcastseed/src/mcastleech.c')
-rw-r--r--mcastseed/src/mcastleech.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/mcastseed/src/mcastleech.c b/mcastseed/src/mcastleech.c
index e07602d..a23e73a 100644
--- a/mcastseed/src/mcastleech.c
+++ b/mcastseed/src/mcastleech.c
@@ -14,8 +14,8 @@
#include <stdlib.h> /* EXIT_SUCCESS */
#include <string.h> /* strncmp() */
#include <fcntl.h> /* fcntl() */
-#include "sockets.h"
-#include "dgrambuf.h"
+#include "sockets.h"
+#include "dgrambuf.h"
#define MTU 1500
#define MULTICAST_RECV_BUF (MTU-20-8)
@@ -28,7 +28,7 @@
/* Cmdline Arguments */
char *prog_name = NULL;
-char *mcast_ip = NULL;
+char *mcast_ip = NULL;
char *port = NULL;
/* Sockets as global, used everywhere, even in die() */
@@ -132,21 +132,21 @@ int wait_hello_and_connect_back() {
mcast_sock = mcast_recv_socket(mcast_ip, port, MULTICAST_SO_RCVBUF_WANTED);
if(mcast_sock < 0) {
usage("Could not setup multicast socket. Wrong args given ?");
- }
+ }
/* Wait for a single datagram from the server (for sync, no check on contain) */
peer_addr_len = sizeof(struct sockaddr_storage);
nread = recvfrom(mcast_sock, recvbuf, MULTICAST_RECV_BUF, 0, (struct sockaddr *) &peer_addr, &peer_addr_len);
- if (nread < 0 ) {
+ if (nread < 0 ) {
perror("recvfrom() failed");
- return -1;
+ return -1;
}
/* Get peer informations as strings from peer_addr */
res = getnameinfo((struct sockaddr *) &peer_addr, peer_addr_len,
hbuf, NI_MAXHOST, sbuf, NI_MAXSERV, NI_NUMERICSERV);
if ( res != 0 ) {
fprintf(stderr, "getnameinfo: %s\n", gai_strerror(res));
- return -2;
+ return -2;
}
/* Connect back to the server, with reliable unicast */
if ( ucast_sock > 0 ) {
@@ -156,7 +156,7 @@ int wait_hello_and_connect_back() {
ucast_sock = ucast_client_socket(hbuf,port);
if(ucast_sock < 0) {
fprintf(stderr, "Could not setup unicast socket or connect to %s:%s\n", hbuf, port);
- return -3;
+ return -3;
}
return 0;
@@ -167,9 +167,9 @@ int wait_start_and_start_job() {
/* Wait for a "start" datagram from the server */
nread = recvfrom(mcast_sock, recvbuf, MULTICAST_RECV_BUF, 0, NULL, 0);
- if (nread < 0 ) {
+ if (nread < 0 ) {
perror("recvfrom() failed");
- return -1;
+ return -1;
}
if ( nread >= 5 && strncmp("start", recvbuf, 5) == 0 ) {
/* Reply "ready" through unicast stream socket */
@@ -186,7 +186,7 @@ int wait_start_and_start_job() {
return 1;
}
- return 0;
+ return 0;
}
/*
@@ -219,7 +219,7 @@ int receive_data() {
}
fprintf(stderr, "receive_data(): nread == %zi, nwrite == %zi\n", nread, nwrite);
-
+
/* XXX Crapy dead state detection */
if ( nread == 0 && nwrite == 0 ) {
if ( noop_calls_count > 10 ) {
@@ -296,7 +296,7 @@ void usage(char *msg) {
void arg_parse(int argc, char* argv[]) {
prog_name = argv[0];
if ( argc > 3 )
- usage("Too many arguments");
+ usage("Too many arguments");
port = (argc >= 2)?argv[1]:DEFAULT_PORT_STR;
mcast_ip = (argc >= 3)?argv[2]:DEFAULT_MCAST_IP_STR;
}
@@ -306,7 +306,7 @@ void fsm_trace(int state) {
if ( state < 0 ) {
fprintf(stderr, "Abnormal exit condition %i (from %s)\n", state, state_str[prev_state]);
- } else if ( prev_state != state) {
+ } else if ( prev_state != state) {
if ( state == 0 ) {
fprintf(stderr, "Normal exit (from %s)\n", state_str[prev_state]);
} else {
@@ -373,7 +373,7 @@ void dgrambuf_init() {
if ( dgrambuf == NULL ) {
perror("dgrambuf_new/malloc");
exit(EXIT_FAILURE);
- }
+ }
fprintf(stderr, "dgrambuf_get_free_count() => %zu\n", dgrambuf_get_free_count(dgrambuf));
dgrambuf_set_validate_func(dgrambuf, validate_data_dgram);