Added GSM IMSI dialing by using dialing "imsi-<number>".
[lcr.git] / crypt.cpp
index 92f0c10..87a5dde 100644 (file)
--- a/crypt.cpp
+++ b/crypt.cpp
@@ -140,14 +140,10 @@ the message type is encoded as element
 
 */
 
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sys/types.h>
+#include "main.h"
 #ifdef CRYPTO
 #include <openssl/rsa.h>
 #endif
-#include "main.h"
 
 
 /* convert key string to binary key vector
@@ -210,7 +206,7 @@ unsigned char *crypt_key(unsigned char *key, int *binary_len)
 /*
  * support routine to get cpu speed
  */
-static unsigned long get_bogomips(void)
+static unsigned int get_bogomips(void)
 {
        FILE *fp;
        char buffer[64], *p;
@@ -248,9 +244,9 @@ static unsigned long get_bogomips(void)
 /*
  * crc 32 stuff
  */
-static unsigned long crc_reflect(unsigned long ref, char ch)
+static unsigned int crc_reflect(unsigned int ref, char ch)
 {
-       unsigned long value = 0;
+       unsigned int value = 0;
        int i;
 
        i = 1;
@@ -264,12 +260,12 @@ static unsigned long crc_reflect(unsigned long ref, char ch)
        return(value);
 }
 
-static unsigned long crc32_table[256];
+static unsigned int crc32_table[256];
 static int crc_initialized = 0;
 
 void crc_init(void)
 {
-       unsigned long ulPolynomial = 0x04c11db7;
+       unsigned int ulPolynomial = 0x04c11db7;
        int i, j;
 
        i = 0;
@@ -288,9 +284,9 @@ void crc_init(void)
        crc_initialized = 1;
 }
 
-unsigned long crc32(unsigned char *data, int len)
+unsigned int crc32(unsigned char *data, int len)
 {
-       unsigned long crc = 0xffffffff;
+       unsigned int crc = 0xffffffff;
 
        if (!crc_initialized)
                FATAL("crc not initialized, exitting...");
@@ -304,7 +300,7 @@ unsigned long crc32(unsigned char *data, int len)
 CM_ST_NAMES
 
 /* give name of state */
-static char *statename(int state)
+static const char *statename(int state)
 {
        if (state>=0 && state<cm_st_num)
                return(cm_st_name[state]);
@@ -660,7 +656,7 @@ void EndpointAppPBX::cryptman_handler(void)
 void EndpointAppPBX::cr_ident(int message, unsigned char *param, int len)
 {
        unsigned char buf[4], *p;
-       unsigned long bogomips = 0, ran;
+       unsigned int bogomips = 0, ran;
        int l;
 
        l = CM_SIZEOFINF(CM_INFO_RANDOM);
@@ -1145,7 +1141,7 @@ CM_MSG_NAMES
 
 void EndpointAppPBX::cryptman_message(int message, unsigned char *param, int len)
 {
-       char *msgtext = "<<UNKNOWN MESSAGE>>";
+       const char *msgtext = "<<UNKNOWN MESSAGE>>";
 
        if (message>=0 && message<cm_msg_num)
                msgtext = cm_msg_name[message];
@@ -1510,7 +1506,7 @@ void EndpointAppPBX::cryptman_msg2crengine(int msg, unsigned char *buf, int len)
 
        if (options.deb & DEBUG_CRYPT)
        {
-               char *msgtext = "<<UNKNOWN MESSAGE>>";
+               const char *msgtext = "<<UNKNOWN MESSAGE>>";
 
                if (msg>=0 && msg<cm_msg_num)
                        msgtext = cm_msg_name[msg];
@@ -1520,7 +1516,7 @@ void EndpointAppPBX::cryptman_msg2crengine(int msg, unsigned char *buf, int len)
 
 /* send message to user
  */
-void EndpointAppPBX::cryptman_msg2user(int msg, char *text)
+void EndpointAppPBX::cryptman_msg2user(int msg, const char *text)
 {
        struct lcr_msg *message;
        /* send message */
@@ -1538,7 +1534,7 @@ void EndpointAppPBX::cryptman_msg2user(int msg, char *text)
 
        if (options.deb & DEBUG_CRYPT)
        {
-               char *msgtext = "<<UNKNOWN MESSAGE>>";
+               const char *msgtext = "<<UNKNOWN MESSAGE>>";
 
                if (msg>=0 && msg<cm_msg_num)
                        msgtext = cm_msg_name[msg];
@@ -1576,7 +1572,7 @@ void EndpointAppPBX::cryptman_timeout(int secs)
  */
 int cryptman_encode_bch(unsigned char *data, int len, unsigned char *buf, int buf_len)
 {
-       unsigned long crc;
+       unsigned int crc;
        int overhead = 18;
 
        len--; /* without null-termination */
@@ -1792,7 +1788,7 @@ void PmISDN::cryptman_listen_bch(unsigned char *p, int l)
 void EndpointAppPBX::encrypt_shared(void)
 {
        struct lcr_msg *message;
-       char *errstr = "";
+       const char *errstr = "";
        class Port *port;
        int type, key_len;
        unsigned char *key;
@@ -1831,7 +1827,7 @@ void EndpointAppPBX::encrypt_shared(void)
                        errstr = "No Remote ID";
                        goto reject;
                }
-               ret = parse_secrets((char *)e_ext.number, (char *)numberrize_callerinfo(port->p_callerinfo.id, port->p_callerinfo.ntype), &auth_pointer, &crypt_pointer, &key_pointer);
+               ret = parse_secrets((char *)e_ext.number, (char *)numberrize_callerinfo(port->p_callerinfo.id, port->p_callerinfo.ntype, options.national, options.international), &auth_pointer, &crypt_pointer, &key_pointer);
        }
        if (!ret)
        {
@@ -1898,7 +1894,7 @@ void EndpointAppPBX::encrypt_shared(void)
 void EndpointAppPBX::encrypt_keyex(void)
 {
        struct lcr_msg *message;
-       char *errstr = "";
+       const char *errstr = "";
        class Port *port;
 
        /* redisplay current crypt display */