- TRY(gras_trp_chunk_recv(sock, header, 6));
- for (cpt=0; cpt<4; cpt++)
- if (header[cpt] != GRAS_header[cpt])
- RAISE0(mismatch_error,"Incoming bytes do not look like a GRAS message");
- if (header[4] != GRAS_header[4])
- RAISE2(mismatch_error,"GRAS protocol mismatch (got %d, use %d)",
- (int)header[4], (int)GRAS_header[4]);
- r_arch = (int)header[5];
- DEBUG2("Handle an incoming message using protocol %d (remote is %s)",
- (int)header[4],gras_datadesc_arch_name(r_arch));
-
- TRY(gras_datadesc_recv(sock, string_type, r_arch, &msg_name));
- errcode = gras_set_get_by_name(_gras_msgtype_set,
- msg_name,(gras_set_elm_t**)msgtype);
- if (errcode != no_error)
- RAISE2(errcode,
- "Got error %s while retrieving the type associated to messages '%s'",
- gras_error_name(errcode),msg_name);
- /* FIXME: Survive unknown messages */
- gras_free(msg_name);
-
- *payload_size=gras_datadesc_size((*msgtype)->ctn_type);
- gras_assert2(*payload_size > 0,
- "%s %s",
- "Dynamic array as payload is forbided for now (FIXME?).",
- "Reference to dynamic array is allowed.");
- *payload = gras_malloc(*payload_size);
- TRY(gras_datadesc_recv(sock, (*msgtype)->ctn_type, r_arch, *payload));
-
- return no_error;