diff options
author | sometwo <dhubdwhhu@yopmail.com> | 2013-07-26 19:10:22 -0300 |
---|---|---|
committer | sometwo <dhubdwhhu@yopmail.com> | 2013-07-26 19:10:22 -0300 |
commit | a3298d2b9e8174f39c8d11f6df8526f360f65592 (patch) | |
tree | 8b66629ececfd949c295e15d75d075730ae38448 /core/network.c | |
parent | 056195be410229dde61286c9f316eaec48a7a550 (diff) |
Fix some indenting
Diffstat (limited to 'core/network.c')
-rw-r--r-- | core/network.c | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/core/network.c b/core/network.c index 6a4d0bce..549427bf 100644 --- a/core/network.c +++ b/core/network.c | |||
@@ -42,8 +42,6 @@ uint64_t current_time() | |||
42 | time = 1000000UL*a.tv_sec + a.tv_usec; | 42 | time = 1000000UL*a.tv_sec + a.tv_usec; |
43 | return time; | 43 | return time; |
44 | #endif | 44 | #endif |
45 | |||
46 | |||
47 | } | 45 | } |
48 | 46 | ||
49 | /* return a random number | 47 | /* return a random number |
@@ -67,7 +65,6 @@ int sendpacket(IP_Port ip_port, uint8_t * data, uint32_t length) | |||
67 | { | 65 | { |
68 | ADDR addr = {AF_INET, ip_port.port, ip_port.ip}; | 66 | ADDR addr = {AF_INET, ip_port.port, ip_port.ip}; |
69 | return sendto(sock,(char *) data, length, 0, (struct sockaddr *)&addr, sizeof(addr)); | 67 | return sendto(sock,(char *) data, length, 0, (struct sockaddr *)&addr, sizeof(addr)); |
70 | |||
71 | } | 68 | } |
72 | 69 | ||
73 | /* Function to receive data, ip and port of sender is put into ip_port | 70 | /* Function to receive data, ip and port of sender is put into ip_port |
@@ -92,7 +89,6 @@ int receivepacket(IP_Port * ip_port, uint8_t * data, uint32_t * length) | |||
92 | ip_port->ip = addr.ip; | 89 | ip_port->ip = addr.ip; |
93 | ip_port->port = addr.port; | 90 | ip_port->port = addr.port; |
94 | return 0; | 91 | return 0; |
95 | |||
96 | } | 92 | } |
97 | 93 | ||
98 | /* initialize networking | 94 | /* initialize networking |
@@ -106,21 +102,18 @@ int init_networking(IP ip, uint16_t port) | |||
106 | #ifdef WIN32 | 102 | #ifdef WIN32 |
107 | WSADATA wsaData; | 103 | WSADATA wsaData; |
108 | if(WSAStartup(MAKEWORD(2,2), &wsaData) != NO_ERROR) | 104 | if(WSAStartup(MAKEWORD(2,2), &wsaData) != NO_ERROR) |
109 | { | ||
110 | return -1; | 105 | return -1; |
111 | } | ||
112 | |||
113 | #else | 106 | #else |
114 | srandom((uint32_t)current_time()); | 107 | srandom((uint32_t)current_time()); |
115 | #endif | 108 | #endif |
116 | srand((uint32_t)current_time()); | 109 | srand((uint32_t)current_time()); |
117 | 110 | ||
118 | /* initialize our socket */ | 111 | /* initialize our socket */ |
119 | sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); | 112 | sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); |
120 | 113 | ||
121 | /* Check for socket error */ | 114 | /* Check for socket error */ |
122 | #ifdef WIN32 | 115 | #ifdef WIN32 |
123 | if (sock == INVALID_SOCKET) //MSDN recommends this | 116 | if (sock == INVALID_SOCKET) /* MSDN recommends this */ |
124 | return -1; | 117 | return -1; |
125 | #else | 118 | #else |
126 | if (sock < 0) | 119 | if (sock < 0) |
@@ -137,11 +130,10 @@ int init_networking(IP ip, uint16_t port) | |||
137 | } | 130 | } |
138 | 131 | ||
139 | if(setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (char*)&n, sizeof(n)) == -1) | 132 | if(setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (char*)&n, sizeof(n)) == -1) |
140 | { | ||
141 | return -1; | 133 | return -1; |
142 | }*/ | 134 | */ |
143 | 135 | ||
144 | /*Enable broadcast on socket*/ | 136 | /* Enable broadcast on socket */ |
145 | int broadcast = 1; | 137 | int broadcast = 1; |
146 | setsockopt(sock, SOL_SOCKET, SO_BROADCAST, (char*)&broadcast, sizeof(broadcast)); | 138 | setsockopt(sock, SOL_SOCKET, SO_BROADCAST, (char*)&broadcast, sizeof(broadcast)); |
147 | 139 | ||
@@ -188,11 +180,9 @@ int resolve_addr(char *address) | |||
188 | 180 | ||
189 | int success = getaddrinfo(address, "7", &hints, &server); | 181 | int success = getaddrinfo(address, "7", &hints, &server); |
190 | if(success != 0) | 182 | if(success != 0) |
191 | { | ||
192 | return -1; | 183 | return -1; |
193 | } | ||
194 | 184 | ||
195 | int resolved = ((struct sockaddr_in*)server->ai_addr)->sin_addr.s_addr; | 185 | int resolved = ((struct sockaddr_in*)server->ai_addr)->sin_addr.s_addr; |
196 | freeaddrinfo(server); | 186 | freeaddrinfo(server); |
197 | return resolved; | 187 | return resolved; |
198 | } \ No newline at end of file | 188 | } |