summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sources/ogAdmServer.cpp34
1 files changed, 25 insertions, 9 deletions
diff --git a/sources/ogAdmServer.cpp b/sources/ogAdmServer.cpp
index 8e1173e..6ec9c2d 100644
--- a/sources/ogAdmServer.cpp
+++ b/sources/ogAdmServer.cpp
@@ -3572,30 +3572,46 @@ static int og_client_state_recv_hdr(struct og_client *cli)
return 1;
}
-static int og_client_state_process_payload(struct og_client *cli)
+static TRAMA *og_msg_alloc(char *data, unsigned int len)
{
TRAMA *ptrTrama;
- char *data;
- int len;
-
- len = cli->msg_len - (LONGITUD_CABECERATRAMA + LONHEXPRM);
- data = &cli->buf[LONGITUD_CABECERATRAMA + LONHEXPRM];
ptrTrama = (TRAMA *)reservaMemoria(sizeof(TRAMA));
if (!ptrTrama) {
syslog(LOG_ERR, "OOM\n");
- return -1;
+ return NULL;
}
initParametros(ptrTrama, len);
- memcpy(ptrTrama, cli->buf, LONGITUD_CABECERATRAMA);
+ memcpy(ptrTrama, "@JMMLCAMDJ_MCDJ", LONGITUD_CABECERATRAMA);
memcpy(ptrTrama->parametros, data, len);
ptrTrama->lonprm = len;
- gestionaTrama(ptrTrama, cli);
+ return ptrTrama;
+}
+static void og_msg_free(TRAMA *ptrTrama)
+{
liberaMemoria(ptrTrama->parametros);
liberaMemoria(ptrTrama);
+}
+
+static int og_client_state_process_payload(struct og_client *cli)
+{
+ TRAMA *ptrTrama;
+ char *data;
+ int len;
+
+ len = cli->msg_len - (LONGITUD_CABECERATRAMA + LONHEXPRM);
+ data = &cli->buf[LONGITUD_CABECERATRAMA + LONHEXPRM];
+
+ ptrTrama = og_msg_alloc(data, len);
+ if (!ptrTrama)
+ return -1;
+
+ gestionaTrama(ptrTrama, cli);
+
+ og_msg_free(ptrTrama);
return 1;
}