SIP: Fix incoming re-invite
[lcr.git] / extension.c
index a1c3aa7..72ca1aa 100644 (file)
@@ -68,10 +68,8 @@ int read_extension(struct extension *ext, char *num)
        ext->vbox_codec = CODEC_MONO;
 
        line=0;
-       while((fgets(buffer, sizeof(buffer), fp))) {
+       while((GETLINE(buffer, fp))) {
                line++;
-               buffer[sizeof(buffer)-1] = '\0';
-               if (buffer[0]) buffer[strlen(buffer)-1] = '\0';
                p = buffer;
 
                while(*p <= 32) { /* skip spaces */
@@ -757,6 +755,35 @@ int read_extension(struct extension *ext, char *num)
                        } else {
                                PDEBUG(DEBUG_CONFIG, "unknown param for seconds: %s\n", param);
                        }
+               } else
+               if (!strcmp(option,"otp-ident")) {
+                       SCPY(ext->otp_ident, param);
+                       PDEBUG(DEBUG_CONFIG, "otp-ident: %s\n",param);
+               } else
+               if (!strcmp(option,"dov_ident")) {
+                       if (param[0]) {
+                               SCPY(ext->dov_ident, param);
+                               PDEBUG(DEBUG_CONFIG, "dov_ident string: %s\n",param);
+                       }
+               } else
+               if (!strcmp(option,"dov_log")) {
+                       if (param[0]) {
+                               SCPY(ext->dov_log, param);
+                               PDEBUG(DEBUG_CONFIG, "dov_log filename: %s\n",param);
+                       }
+               } else
+               if (!strcmp(option,"dov_type")) {
+                       if (!strcasecmp(param, "pcm"))
+                               ext->dov_type = DOV_TYPE_PCM;
+                       else
+                               ext->dov_type = DOV_TYPE_PWM;
+                       PDEBUG(DEBUG_CONFIG, "given dov type: %s\n", param);
+               } else
+               if (!strcmp(option,"dov_level")) {
+                       if (atoi(param)) {
+                               ext->dov_level = atoi(param);
+                               PDEBUG(DEBUG_CONFIG, "dov_level: %s\n",param);
+                       }
                } else {
                        PERROR_RUNTIME("Error in %s (line %d): wrong option keyword %s.\n",filename,line,option);
                }
@@ -969,7 +996,7 @@ int write_extension(struct extension *ext, char *number)
        fprintf(fp,"own_cause       %s\n\n",ext_yesno[ext->own_cause]);
 
        fprintf(fp,"# Allow facility information to be transfered to the telephone.\n");
-       fprintf(fp,"# This is equired to receive advice of charge.\n");
+       fprintf(fp,"# This is required to receive advice of charge.\n");
        fprintf(fp,"facility        %s\n\n",ext_yesno[ext->facility]);
 
        fprintf(fp,"# Display clear causes using display messages (Q.850)\n# This must be one of the following:\n");
@@ -1146,6 +1173,9 @@ int write_extension(struct extension *ext, char *number)
        fprintf(fp,"# Include seconds (time) in the connect message. (Should be always enabled.)\n");
        fprintf(fp,"seconds         %s\n\n",ext_yesno[1-ext->no_seconds]);
 
+       fprintf(fp,"# Identity string for VoOTP encryption\n");
+       fprintf(fp,"otp-ident       %s\n\n", ext->otp_ident);
+
        fprintf(fp,"# Last outgoing and incoming numbers (including prefix)\n");
        i = 0;
        while(i < MAX_REMEMBER) {
@@ -1161,6 +1191,18 @@ int write_extension(struct extension *ext, char *number)
        }
        fprintf(fp,"\n");
 
+       fprintf(fp,"# Identify to/from remove via Data-Over-Voice feature.\n");
+       fprintf(fp,"dov_ident       %s\n", ext->dov_ident);
+       fprintf(fp,"dov_log         %s\n", ext->dov_log);
+       switch(ext->dov_type) {
+               case DOV_TYPE_PWM:
+               fprintf(fp,"dov_type        pwm\n");
+               break;
+               case DOV_TYPE_PCM:
+               fprintf(fp,"dov_type        pcm\n");
+               break;
+       }
+       fprintf(fp,"dov_level       %d\n\n", ext->dov_level);
 
        if (fp) fclose(fp);
        return(1);
@@ -1228,10 +1270,8 @@ int parse_phonebook(char *number, char **abbrev_pointer, char **phone_pointer, c
        }
 
        line=0;
-       while((fgets(buffer, sizeof(buffer), fp))) {
+       while((GETLINE(buffer, fp))) {
                line++;
-               buffer[sizeof(buffer)-1] = '\0';
-               if (buffer[0]) buffer[strlen(buffer)-1] = '\0';
                p = buffer;
 
                while(*p <= 32) { /* skip spaces */
@@ -1351,10 +1391,8 @@ int parse_secrets(char *number, char *remote_id, char **auth_pointer, char **cry
        }
 
        line=0;
-       while((fgets(buffer, sizeof(buffer), fp))) {
+       while((GETLINE(buffer, fp))) {
                line++;
-               buffer[sizeof(buffer)-1] = '\0';
-               if (buffer[0]) buffer[strlen(buffer)-1] = '\0';
                p = buffer;
 
                while(*p <= 32) { /* skip spaces */
@@ -1476,10 +1514,8 @@ char *parse_directory(char *number, int type)
        }
 
        line=0;
-       while((fgets(buffer, sizeof(buffer), fp))) {
+       while((GETLINE(buffer, fp))) {
                line++;
-               buffer[sizeof(buffer)-1] = '\0';
-               if (buffer[0]) buffer[strlen(buffer)-1] = '\0';
                p = buffer;
 
                while(*p <= 32) { /* skip spaces */
@@ -1611,10 +1647,8 @@ int parse_callbackauth(char *number, struct caller_info *callerinfo)
        }
 
        line=0;
-       while((fgets(buffer, sizeof(buffer), fp))) {
+       while((GETLINE(buffer, fp))) {
                line++;
-               buffer[sizeof(buffer)-1] = '\0';
-               if (buffer[0]) buffer[strlen(buffer)-1] = '\0';
                p = buffer;
 
                while(*p <= 32) { /* skip spaces */