Unfortunately, sptps_logger() cannot know if s->handle is pointing to a
connection_t or a node_t. But it needs to print name and hostname in
both cases. So make sure both types have name and hostname fields at the
start with the same offset.
typedef struct connection_t {
char *name; /* name he claims to have */
+ char *hostname; /* the hostname of its real ip */
union sockaddr_t address; /* his real (internet) ip */
- char *hostname; /* the hostname of its real ip */
int protocol_major; /* used protocol */
int protocol_minor; /* used protocol */
if(message[len - 1] == '\n')
message[--len] = 0;
+ // WARNING: s->handle can point to a connection_t or a node_t,
+ // but both types have the name and hostname fields at the same offsets.
connection_t *c = s->handle;
if(c)
snprintf(message + len, sizeof message - len, " from %s (%s)", c->name, c->hostname);
typedef struct node_t {
char *name; /* name of this node */
+ char *hostname; /* the hostname of its real ip */
node_id_t id; /* unique node ID (name hash) */
uint32_t options; /* options turned on for this node */
int sock; /* Socket to use for outgoing UDP packets */
sockaddr_t address; /* his real (internet) ip to send UDP packets to */
- char *hostname; /* the hostname of its real ip */
node_status_t status;
time_t last_state_change;