projects
/
umurmur.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
37efef0
)
Use defines for version info. uint32_t should be byte-shifted with htonl()
author
fatbob313
<martin@fatbob.nu>
Mon, 4 Jan 2010 17:56:28 +0000
(17:56 +0000)
committer
fatbob313
<martin@fatbob.nu>
Mon, 4 Jan 2010 17:56:28 +0000
(17:56 +0000)
src/client.c
patch
|
blob
|
history
src/messages.h
patch
|
blob
|
history
diff --git
a/src/client.c
b/src/client.c
index ceaacf6eb04e9fc84ed12fcd7a29afc093ecb2ac..2b8934594f68240068e80591df19931a26ff3548 100644
(file)
--- a/
src/client.c
+++ b/
src/client.c
@@
-39,9
+39,7
@@
#include "messagehandler.h"
#include "conf.h"
#include "channel.h"
#include "messagehandler.h"
#include "conf.h"
#include "channel.h"
-
-/* Version 0.2.0 XXX fixme */
-const uint32_t versionBlob = 1<<16 | 2<<8 | 0;
+#include "version.h"
static int Client_read(client_t *client);
static int Client_write(client_t *client);
static int Client_read(client_t *client);
static int Client_write(client_t *client);
@@
-192,9
+190,10
@@
int Client_add(int fd, struct sockaddr_in *remote)
/* Send version message to client */
sendmsg = Msg_create(Version);
sendmsg->payload.version->has_version = true;
/* Send version message to client */
sendmsg = Msg_create(Version);
sendmsg->payload.version->has_version = true;
- sendmsg->payload.version->version = (1 << 16) | (2 << 8) | 0; /* XXX fix */
- sendmsg->payload.version->release = strdup("1.2.0");
- sendmsg->payload.version->os = strdup("Linux/OpenWRT");
+ sendmsg->payload.version->version = PROTOCOL_VERSION;
+ sendmsg->payload.version->release = strdup(UMURMUR_VERSION);
+ /* XXX - set OS to something relevant? */
+ /* sendmsg->payload.version->os = strdup("Linux/OpenWRT"); */
Client_send_message(newclient, sendmsg);
Client_send_message(newclient, sendmsg);
@@
-538,11
+537,11
@@
int Client_read_udp()
/* Ping packet */
if (len == 12 && *encrypted == 0) {
uint32_t *ping = (uint32_t *)encrypted;
/* Ping packet */
if (len == 12 && *encrypted == 0) {
uint32_t *ping = (uint32_t *)encrypted;
- ping[0] = hton
s(versionBlob
);
+ ping[0] = hton
l((uint32_t)PROTOCOL_VERSION
);
// 1 and 2 will be the timestamp, which we return unmodified.
// 1 and 2 will be the timestamp, which we return unmodified.
- ping[3] = hton
s
((uint32_t)clientcount);
- ping[4] = hton
s
((uint32_t)getIntConf(MAX_CLIENTS));
- ping[5] = hton
s
((uint32_t)getIntConf(MAX_BANDWIDTH));
+ ping[3] = hton
l
((uint32_t)clientcount);
+ ping[4] = hton
l
((uint32_t)getIntConf(MAX_CLIENTS));
+ ping[5] = hton
l
((uint32_t)getIntConf(MAX_BANDWIDTH));
sendto(udpsock, encrypted, 6 * sizeof(uint32_t), 0, (struct sockaddr *)&from, fromlen);
return 0;
sendto(udpsock, encrypted, 6 * sizeof(uint32_t), 0, (struct sockaddr *)&from, fromlen);
return 0;
diff --git
a/src/messages.h
b/src/messages.h
index 55a7433990ed1adcdfc9b18697719dbaafad4101..eedf7fd6cbf5e3b84317138656b5b5eb437bb174 100644
(file)
--- a/
src/messages.h
+++ b/
src/messages.h
@@
-39,7
+39,7
@@
#define PROTVER_MAJOR 1
#define PROTVER_MINOR 2
#define PROTVER_PATCH 0
#define PROTVER_MAJOR 1
#define PROTVER_MINOR 2
#define PROTVER_PATCH 0
-#define PROTOCOL_VERSION ((
(PROTVER_MAJOR << 16) | (PROTVER_MINOR << 8) |
PROTVER_PATCH))
+#define PROTOCOL_VERSION ((
PROTVER_MAJOR << 16) | (PROTVER_MINOR << 8) | (
PROTVER_PATCH))
#define MAX_TEXT 512
#define MAX_TEXT 512