Navigation


Changeset 440:f38bff0bf3e9 in freeDiameter


Ignore:
Timestamp:
Jul 28, 2010, 4:17:29 PM (14 years ago)
Author:
Alexandre Westfahl <awestfahl@freediameter.net>
Branch:
default
Phase:
public
Message:

Added dynamic port choice for app_sip

Files:
8 edited

Legend:

Unmodified
Added
Removed
  • doc/app_sip.conf.sample

    r432 r440  
    33#You must have at least in your network a Diameter SIP server and a Subscriber Locator (on different nodes)
    44mode = DSSERVER;
     5
     6
     7# Administrator commands port (port should be provided with "-p" in remote line)
     8ppr_port=90;
     9rtr_port=91;
    510
    611
  • extensions/app_sip/app_sip.h

    r434 r440  
    6666        char mysql_prefix[10]; //default: as_
    6767        uint16_t  mysql_port; //if 0, default port will be used
    68        
     68        uint16_t rtr_port;
     69        uint16_t ppr_port;
    6970};
    7071extern struct as_conf * as_conf;
     
    135136int app_sip_RTR_cb(struct rtrsipaor structure);
    136137int app_sip_PPR_cb(struct pprsipaor structure);
    137 #define PORT 666 //TODO:put in conf file
     138
    138139
    139140int ds_entry();
  • extensions/app_sip/app_sip.l

    r433 r440  
    121121                                return ASMYSQL_PORT;
    122122                        }
    123                        
     123(?i:"rtr_port")         {
     124                                return RTR_PORT;
     125                        }
     126(?i:"ppr_port")         {
     127                                return PPR_PORT;
     128                        }
    124129(?i:"mode")             {
    125130                                return MODE;
  • extensions/app_sip/app_sip.y

    r433 r440  
    124124%token          ASMYSQL_SERVER
    125125%token          ASMYSQL_PORT
     126%token          RTR_PORT
     127%token          PPR_PORT
    126128
    127129/* Tokens and types for routing table definition */
     
    146148                        | conffile mysql_server
    147149                        | conffile mysql_port
     150                        | conffile rtr_port
     151                        | conffile ppr_port
    148152                        ;
    149153
     
    193197                        }
    194198                        ;
     199rtr_port:               RTR_PORT '=' INTEGER ';'
     200                        {
     201                                as_conf->rtr_port = (uint16_t)$3;
     202                        }
     203                        ;
     204ppr_port:               PPR_PORT '=' INTEGER ';'
     205                        {
     206                                as_conf->ppr_port = (uint16_t)$3;
     207                        }
     208                        ;
  • extensions/app_sip/pushprofile.c

    r433 r440  
    4747void *ppr_socket(void *arg)
    4848{
    49         /*
     49       
    5050        SOCKET sock;
    5151    SOCKADDR_IN sin, csin;
    52     struct rtrsipaor rtrsip;
     52    struct pprsipaor pprsip;
    5353    int rcvbytes=0;
    5454        sock = socket(AF_INET, SOCK_STREAM, 0);
    5555        sin.sin_addr.s_addr = inet_addr("127.0.0.1");
    5656    sin.sin_family = AF_INET;
    57     sin.sin_port = htons(PORT);
     57        sin.sin_port = htons(as_conf->ppr_port);
    5858    socklen_t sinsize = sizeof(csin);
    5959        int accepted=0;
     
    7272                        if(accepted>-1)
    7373                        {
    74                                 rcvbytes=recv(accepted, &rtrsip, sizeof(struct rtrsipaor),0);
     74                                rcvbytes=recv(accepted, &pprsip, sizeof(struct pprsipaor),0);
    7575                               
    7676                                if(rcvbytes>-1)
     
    8686        else
    8787                TRACE_DEBUG(INFO,"Can't create socket!");
    88 */     
     88
    8989       
    9090        pthread_exit(NULL);
  • extensions/app_sip/registrationtermination.c

    r433 r440  
    5454        sin.sin_addr.s_addr = inet_addr("127.0.0.1");
    5555        sin.sin_family = AF_INET;
    56         sin.sin_port = htons(PORT);
     56        sin.sin_port = htons(as_conf->rtr_port);
    5757        socklen_t sinsize = sizeof(csin);
    5858        int accepted=0;
     
    251251       
    252252        //TODO:remove for debug
    253         fd_msg_dump_walk(INFO,message);
     253        //fd_msg_dump_walk(INFO,message);
    254254        CHECK_FCT( fd_msg_send( &message, NULL, NULL ));
    255255       
  • extensions/app_sip/tools/app_sip_ppr.c

    r435 r440  
    4848#include <stdlib.h>
    4949#include <string.h>
    50 #define PORT 667
     50
    5151#include <errno.h>
    5252
     
    6666    struct pprsipaor pprsip;
    6767    int numdatatype=0,i=0;
    68    
     68    int port=667;
     69       
    6970        sock = socket(AF_INET, SOCK_STREAM, 0);
    7071        sin.sin_addr.s_addr = inet_addr("127.0.0.1");
    7172    sin.sin_family = AF_INET;
    72     sin.sin_port = htons(PORT);
     73   
    7374   
    7475    //We initialize the structure
     
    158159                                pprsip.accounting=1;
    159160                               
     161                               
     162                        }
     163                        else if(strcmp(argv[i],"-p")==0)
     164                        {
     165                               
     166                                if(sscanf(argv[i+1],"%d", &port)!=1)
     167                                {
     168                                        fprintf(stderr,"Incorrect port number!\n");
     169                                        return 1;
     170                                }
     171                               
     172                               
    160173                                i++;
    161174                        }
     
    170183        }
    171184       
     185        //We set the port number
     186        sin.sin_port = htons(port);
    172187       
    173188       
     
    180195       
    181196   
    182    
     197    fprintf(stderr,"%d!\n",port);
    183198   
    184199    /*
  • extensions/app_sip/tools/app_sip_rtr.c

    r433 r440  
    4848#include <stdlib.h>
    4949#include <string.h>
    50 #define PORT 666
    5150#include <errno.h>
    5251
     
    6867    struct rtrsipaor rtrsip;
    6968    int numaor=0,i=0;
    70    
     69        int port=666;
     70       
    7171        sock = socket(AF_INET, SOCK_STREAM, 0);
    7272        sin.sin_addr.s_addr = inet_addr("127.0.0.1");
    7373    sin.sin_family = AF_INET;
    74     sin.sin_port = htons(PORT);
     74   
    7575   
    7676    //We initialize the structure
     
    215215                                rtrsip.reason=3;
    216216                        }
     217                        else if(strcmp(argv[i],"-p")==0)
     218                        {
     219                               
     220                                if(sscanf(argv[i+1],"%d", &port)!=1)
     221                                {
     222                                        fprintf(stderr,"Incorrect port number!\n");
     223                                        return 1;
     224                                }
     225                               
     226                               
     227                                i++;
     228                        }
    217229                        else
    218230                        {
     
    247259        }
    248260   
    249    
     261    //We set the port number
     262    sin.sin_port = htons(port);
    250263   
    251264   
Note: See TracChangeset for help on using the changeset viewer.