First working release
[sip-router] / main.c
diff --git a/main.c b/main.c
index 564dfd5..1ad999c 100644 (file)
--- a/main.c
+++ b/main.c
@@ -5,15 +5,17 @@
 #include <stdio.h>
 #include <errno.h>
 #include <string.h>
+#include <netdb.h>
 
+#include "config.h"
 #include "dprint.h"
 #include "route.h"
+#include "udp_server.h"
 
-#define CFG_FILE "./sip_router.cfg"
 
 
 /* debuging function */
-
+/*
 void receive_stdin_loop()
 {
        #define BSIZE 1024
@@ -27,7 +29,9 @@ void receive_stdin_loop()
                printf("-------------------------\n");
        }
 }
+*/
 
+#define NAME "dorian.fokus.gmd.de"
 
 
 int main(int argc, char** argv)
@@ -35,12 +39,29 @@ int main(int argc, char** argv)
 
        char * cfg_file;
        FILE* cfg_stream;
+       struct hostent* he;
 
        cfg_file=CFG_FILE;
        
        /* process command line (get port no, cfg. file path etc) */
        /* ...*/
 
+       our_port=SIP_PORT;
+       our_name=NAME;
+       /* get ip */
+       he=gethostbyname(our_name);
+       if (he==0){
+               DPrint("ERROR: could not resolve %s\n", our_name);
+               goto error;
+       }
+       our_address=*((long*)he->h_addr_list[0]);
+       printf("Listening on %s[%x]:%d\n",our_name,
+                               (unsigned long)our_address,
+                               (unsigned short)our_port);
+               
+       
+       
+
        /* load config file or die */
        cfg_stream=fopen (cfg_file, "r");
        if (cfg_stream==0){
@@ -57,12 +78,12 @@ int main(int argc, char** argv)
        print_rl();
 
 
-
+       /* init_daemon? */
+       if (udp_init(our_address,our_port)==-1) goto error;
        /* start/init other processes/threads ? */
 
        /* receive loop */
-
-       receive_stdin_loop();
+       udp_rcv_loop();
 
 
 error: