struct message -> struct lcr_msg
[lcr.git] / crypt.cpp
index 2b75792..92f0c10 100644 (file)
--- a/crypt.cpp
+++ b/crypt.cpp
@@ -293,10 +293,7 @@ unsigned long crc32(unsigned char *data, int len)
        unsigned long crc = 0xffffffff;
 
        if (!crc_initialized)
-       {
-               PERROR("crc not initialized, exitting...");
-               exit(-1);
-       }
+               FATAL("crc not initialized, exitting...");
 
        while (len--)
                crc = (crc >> 8) ^ crc32_table[(crc & 0xFF) ^ *data++];
@@ -577,8 +574,7 @@ static void *keyengine_child(void *arg)
 
        /* exit process */
        apppbx->ea_endpoint->ep_use--;
-       memset(args, 0, sizeof(struct auth_args));
-       free(args);
+       FREE(args, sizeof(struct auth_args));
        amemuse--;
        return(NULL);
 }
@@ -595,14 +591,7 @@ void EndpointAppPBX::cryptman_keyengine(int job)
                return;
        }
 
-       arg = (struct auth_args *)calloc(1, sizeof(struct auth_args));
-       if (!arg)
-       {
-               PERROR("failed to alloc memory.\n");
-               e_crypt_keyengine_return = -1;
-               return;
-       }
-
+       arg = (struct auth_args *)MALLOC(sizeof(struct auth_args));
        arg->apppbx = this;
        arg->job = job;
        e_crypt_keyengine_return = 0;
@@ -1462,7 +1451,7 @@ unsigned char *EndpointAppPBX::cryptman_getinf(unsigned char *buf, int element,
  */
 void EndpointAppPBX::cryptman_msg2peer(unsigned char *buf)
 {
-       struct message *message;
+       struct lcr_msg *message;
        unsigned char *p = buf;
        int len = 0;
        int l;
@@ -1504,7 +1493,7 @@ void EndpointAppPBX::cryptman_msg2peer(unsigned char *buf)
  */
 void EndpointAppPBX::cryptman_msg2crengine(int msg, unsigned char *buf, int len)
 {
-       struct message *message;
+       struct lcr_msg *message;
 
        if (len > (int)sizeof(message->param.crypt.data))
        {
@@ -1533,9 +1522,9 @@ void EndpointAppPBX::cryptman_msg2crengine(int msg, unsigned char *buf, int len)
  */
 void EndpointAppPBX::cryptman_msg2user(int msg, char *text)
 {
-       struct message *message;
+       struct lcr_msg *message;
        /* send message */
-       message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_call_id, EPOINT_TO_CALL, MESSAGE_CRYPT);
+       message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_join_id, EPOINT_TO_JOIN, MESSAGE_CRYPT);
        message->param.crypt.type = msg;
        if (!text)
                text = "";
@@ -1628,7 +1617,7 @@ int cryptman_encode_bch(unsigned char *data, int len, unsigned char *buf, int bu
 void PmISDN::cryptman_listen_bch(unsigned char *p, int l)
 {
        int i;
-       struct message *message;
+       struct lcr_msg *message;
 
        retry:
        if (!l)
@@ -1802,7 +1791,7 @@ void PmISDN::cryptman_listen_bch(unsigned char *p, int l)
  */
 void EndpointAppPBX::encrypt_shared(void)
 {
-       struct message *message;
+       struct lcr_msg *message;
        char *errstr = "";
        class Port *port;
        int type, key_len;
@@ -1814,7 +1803,7 @@ void EndpointAppPBX::encrypt_shared(void)
        if (e_crypt != CRYPT_OFF)
        {
                PDEBUG(DEBUG_EPOINT, "EPOINT(%d) encryption in progress, so we request the current message.\n", ea_endpoint->ep_serial);
-               message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_call_id, EPOINT_TO_CALL, MESSAGE_CRYPT);
+               message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_join_id, EPOINT_TO_JOIN, MESSAGE_CRYPT);
                message->param.crypt.type = CU_INFO_REQ;
                message_put(message);
                return;
@@ -1896,7 +1885,7 @@ void EndpointAppPBX::encrypt_shared(void)
 //     SPRINT(e_crypt_display, "Shared Key");
        e_crypt = CRYPT_SWAIT;
        /* sending activation */
-       message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_call_id, EPOINT_TO_CALL, MESSAGE_CRYPT);
+       message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_join_id, EPOINT_TO_JOIN, MESSAGE_CRYPT);
        message->param.crypt.type = CU_ACTS_REQ;
        message->param.crypt.len = key_len;
        memcpy(message->param.crypt.data, key, key_len);
@@ -1908,7 +1897,7 @@ void EndpointAppPBX::encrypt_shared(void)
  */
 void EndpointAppPBX::encrypt_keyex(void)
 {
-       struct message *message;
+       struct lcr_msg *message;
        char *errstr = "";
        class Port *port;
 
@@ -1916,7 +1905,7 @@ void EndpointAppPBX::encrypt_keyex(void)
        if (e_crypt != CRYPT_OFF)
        {
                PDEBUG(DEBUG_EPOINT, "EPOINT(%d) encryption in progress, so we request the current message.\n", ea_endpoint->ep_serial);
-               message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_call_id, EPOINT_TO_CALL, MESSAGE_CRYPT);
+               message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_join_id, EPOINT_TO_JOIN, MESSAGE_CRYPT);
                message->param.crypt.type = CU_INFO_REQ;
                message_put(message);
                return;
@@ -1948,7 +1937,7 @@ void EndpointAppPBX::encrypt_keyex(void)
        message_put(message);
        e_crypt = CRYPT_KWAIT;
        /* sending activation */
-       message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_call_id, EPOINT_TO_CALL, MESSAGE_CRYPT);
+       message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_join_id, EPOINT_TO_JOIN, MESSAGE_CRYPT);
        message->param.crypt.type = CU_ACTK_REQ;
        message_put(message);
 #endif /* CRYPTO */
@@ -1959,7 +1948,7 @@ void EndpointAppPBX::encrypt_keyex(void)
  */
 void EndpointAppPBX::encrypt_off(void)
 {
-       struct message *message;
+       struct lcr_msg *message;
 
        if (e_crypt!=CRYPT_ON && e_crypt!=CRYPT_OFF)
        {
@@ -1986,7 +1975,7 @@ void EndpointAppPBX::encrypt_off(void)
        message_put(message);
        e_crypt = CRYPT_RELEASE;
        /* sending activation */
-       message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_call_id, EPOINT_TO_CALL, MESSAGE_CRYPT);
+       message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_join_id, EPOINT_TO_JOIN, MESSAGE_CRYPT);
        message->param.crypt.type = CU_DACT_REQ;
        message_put(message);
 }
@@ -1996,7 +1985,7 @@ void EndpointAppPBX::encrypt_off(void)
  */
 void EndpointAppPBX::encrypt_result(int msg, char *text)
 {
-       struct message *message;
+       struct lcr_msg *message;
 
        switch(msg)
        {
@@ -2044,3 +2033,4 @@ void EndpointAppPBX::encrypt_result(int msg, char *text)
        }
 }
 
+