Files
@ 27eb6c6418f6
Branch filter:
Location: DistRen/src/common/protocol.c - annotation
27eb6c6418f6
2.9 KiB
text/plain
Handle resolving hostnames gracefully.
Fix support for hostname:port in remoteio.
Added timeout parameter to multiio_poll().
Fix stupid mistakes in distrenslave's read handler.
The server and client may not sit and play table tennis at last :-D.
Fix support for hostname:port in remoteio.
Added timeout parameter to multiio_poll().
Fix stupid mistakes in distrenslave's read handler.
The server and client may not sit and play table tennis at last :-D.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | 4ca5ce00932e abcf8952747b 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e c6a12058c9da 4ca5ce00932e 4ca5ce00932e a3306320d953 7d1fd1fe48fc 4ca5ce00932e eb391af42d62 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e c6a12058c9da c6a12058c9da c6a12058c9da c6a12058c9da c6a12058c9da c6a12058c9da c6a12058c9da c6a12058c9da c6a12058c9da c6a12058c9da c6a12058c9da c6a12058c9da c6a12058c9da c6a12058c9da c6a12058c9da c6a12058c9da c6a12058c9da c6a12058c9da c6a12058c9da c6a12058c9da ef03a563218c ef03a563218c c6a12058c9da c6a12058c9da c6a12058c9da c6a12058c9da c6a12058c9da 7d1fd1fe48fc 7d1fd1fe48fc 7d1fd1fe48fc 7d1fd1fe48fc 27eb6c6418f6 27eb6c6418f6 27eb6c6418f6 27eb6c6418f6 27eb6c6418f6 7d1fd1fe48fc 7d1fd1fe48fc 7d1fd1fe48fc 7d1fd1fe48fc 7d1fd1fe48fc 27eb6c6418f6 27eb6c6418f6 27eb6c6418f6 27eb6c6418f6 27eb6c6418f6 27eb6c6418f6 27eb6c6418f6 27eb6c6418f6 27eb6c6418f6 27eb6c6418f6 27eb6c6418f6 7d1fd1fe48fc 7d1fd1fe48fc 7d1fd1fe48fc 7d1fd1fe48fc 7d1fd1fe48fc 7d1fd1fe48fc 7d1fd1fe48fc 7d1fd1fe48fc 7d1fd1fe48fc 7d1fd1fe48fc 7d1fd1fe48fc 7d1fd1fe48fc 7d1fd1fe48fc 7d1fd1fe48fc 7d1fd1fe48fc 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e 4ca5ce00932e | /*
Copyright 2010 Nathan Phillip Brink
This file is a part of DistRen.
DistRen is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DistRen is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with DistRen. If not, see <http://www.gnu.org/licenses/>.
*/
#include "protocol.h"
#include "remoteio.h"
#include <malloc.h>
#include <stdio.h>
#include <string.h>
#define DISTREN_REQUEST_MAGIC ((uint32_t)0x32423434)
int distren_request_new(struct distren_request **req, uint32_t len, enum distren_request_type type)
{
struct distren_request *newreq;
newreq = malloc(sizeof(struct distren_request));
if(!newreq)
{
(*req) = NULL;
return 1;
}
newreq->magic = DISTREN_REQUEST_MAGIC;
newreq->len = len;
newreq->type = type;
(*req) = newreq;
return 0;
}
int distren_request_send(struct remoteio *rem, struct distren_request *req, void *data)
{
void *packet;
size_t len;
int write_err;
if(req->magic != DISTREN_REQUEST_MAGIC)
fprintf(stderr, "distren_request_send got a bad req\n");
len = sizeof(struct distren_request) + req->len;
packet = malloc(len);
if(!packet)
{
fprintf(stderr, "Error allocating memory for packet\n");
return 1;
}
memcpy(packet, req, sizeof(struct distren_request));
memcpy(packet + sizeof(struct distren_request), data, req->len);
write_err = remoteio_write(rem, packet, len);
free(packet);
return 0;
}
int distren_request_new_fromdata(struct distren_request **req, void *data, size_t len)
{
struct distren_request *newreq;
#if 0
size_t counter;
uint32_t debugtmp;
#endif
if(len < sizeof(struct distren_request))
return 1;
if( ((struct distren_request *)data)->magic != DISTREN_REQUEST_MAGIC )
{
fprintf(stderr, "packet doesn't match magic stuffs");
#if 0
fputs("\n\tmagic=`", stderr);
debugtmp = DISTREN_REQUEST_MAGIC;
for(counter = 0; counter < sizeof(uint32_t); counter ++)
putc(((char *)&debugtmp)[counter], stderr);
fputs("'\n\t`", stderr);
for(counter = 0; counter < sizeof(struct distren_request); counter ++)
putc(((char *)data)[counter], stderr);
fputs("'\n", stderr);
#endif
return 1;
}
newreq = malloc(sizeof(struct distren_request));
if(!newreq)
{
fprintf(stderr, "OOM\n");
return 1;
}
memcpy(newreq, data, sizeof(struct distren_request));
(*req) = newreq;
return 0;
}
int distren_request_free(struct distren_request *req)
{
free(req);
return 0;
}
|