gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r18197 - in libmwmodem/src: include main


From: gnunet
Subject: [GNUnet-SVN] r18197 - in libmwmodem/src: include main
Date: Fri, 18 Nov 2011 00:41:16 +0100

Author: ruppa
Date: 2011-11-18 00:41:16 +0100 (Fri, 18 Nov 2011)
New Revision: 18197

Modified:
   libmwmodem/src/include/libmwmodem.h
   libmwmodem/src/main/libmwmodem.c
Log:


author: Christian Rupp
date:   2011-11-12 0040


Modified: libmwmodem/src/include/libmwmodem.h
===================================================================
--- libmwmodem/src/include/libmwmodem.h 2011-11-17 19:18:52 UTC (rev 18196)
+++ libmwmodem/src/include/libmwmodem.h 2011-11-17 23:41:16 UTC (rev 18197)
@@ -168,7 +168,7 @@
 
 /**
  * Initialisation of this library. 
- * @param port number of port for use to receive the package
+ * @param port number of port for use to receive the package. If you want to 
use the default port set this 0.
  * @param cb higher function for information Callback
  * @param cb_cls user function
  * @param af_int int from AF_INET or AF_INET6

Modified: libmwmodem/src/main/libmwmodem.c
===================================================================
--- libmwmodem/src/main/libmwmodem.c    2011-11-17 19:18:52 UTC (rev 18196)
+++ libmwmodem/src/main/libmwmodem.c    2011-11-17 23:41:16 UTC (rev 18197)
@@ -22,25 +22,36 @@
 #include <sys/socket.h>
 #include <stdint.h>
 
-struct MWMODEM_Content * MWMODEM_init (uint16_t port, 
MWMODEM_Information_Callback cb, void *cb_cls)
+struct MWMODEM_Content * MWMODEM_init (uint16_t port, int af_int, 
MWMODEM_Information_Callback cb, void *cb_cls)
 {
-       struct MWMODEM_Content content;
+       static struct MWMODEM_Content *content;
+       content = malloc(sizeof(struct MWMODEM_Content));
        content.cb = cb;
-       content.socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+
+       if (af_int==AF_INET||af_int==AF_INET6)content.socket = socket(af_int, 
SOCK_DGRAM, IPPROTO_UDP);
+       else;//TODO Error Message
+
        if (content.socket==-1);//TODO Error Message
+
        struct sockaddr_in adress;
-       adress.sin_family = AF_INET;
-
+       adress= malloc(sizeof(struct sockaddr_in));
+       memset( &adress, 0, sizeof (adress));
+       adress.sin_family = af_int;
+       
        if (port == 0)
        {
-               
-               //do everytthing with standard port
+               adress.sin_port = htons(MWMODEM_PORT);
        }
        else
        {
-               
+               adress.sin_port = htons(port);
        }
-       return *content;
+
+       bind(content.socket, adress, sizeof(adress));
+
+       free(adress);   
+
+       return content;
 }
 
 int MWMODEM_get_select_socket(struct MWMODEM_Context *fc)
@@ -51,6 +62,7 @@
 void MWMODEM_run (struct MWMODEM_Content *fc)
 {
        MWMODEM_Package package;
+       package = malloc(sizeof(struct MWMODEM_Package));
        //TODO
        fc.cb(fc.cls, package);
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]