[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r20441 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r20441 - gnunet/src/transport |
Date: |
Sun, 11 Mar 2012 23:46:21 +0100 |
Author: grothoff
Date: 2012-03-11 23:46:21 +0100 (Sun, 11 Mar 2012)
New Revision: 20441
Modified:
gnunet/src/transport/plugin_transport_udp.c
Log:
-LRN: Add UDP StA function
Modified: gnunet/src/transport/plugin_transport_udp.c
===================================================================
--- gnunet/src/transport/plugin_transport_udp.c 2012-03-11 22:45:56 UTC (rev
20440)
+++ gnunet/src/transport/plugin_transport_udp.c 2012-03-11 22:46:21 UTC (rev
20441)
@@ -364,6 +364,53 @@
/**
+ * Function called to convert a string address to
+ * a binary address.
+ *
+ * @param cls closure ('struct Plugin*')
+ * @param addr string address
+ * @param addrlen length of the address
+ * @param buf location to store the buffer
+ * @param added location to store the number of bytes in the buffer.
+ * If the function returns GNUNET_SYSERR, its contents are undefined.
+ * @return GNUNET_OK on success, GNUNET_SYSERR on failure
+ */
+int
+udp_string_to_address (void *cls, const char *addr, uint16_t addrlen,
+ void **buf, size_t *added)
+{
+ struct sockaddr_storage socket_address;
+ int ret = GNUNET_STRINGS_to_address_ip (addr, addrlen,
+ &socket_address);
+
+ if (ret != GNUNET_OK)
+ return GNUNET_SYSERR;
+
+ if (socket_address.ss_family == AF_INET)
+ {
+ struct IPv4UdpAddress *u4;
+ struct sockaddr_in *in4 = (struct sockaddr_in *) &socket_address;
+ u4 = GNUNET_malloc (sizeof (struct IPv4UdpAddress));
+ u4->ipv4_addr = in4->sin_addr.s_addr;
+ u4->u4_port = in4->sin_port;
+ *buf = u4;
+ *added = sizeof (struct IPv4UdpAddress);
+ }
+ else if (socket_address.ss_family == AF_INET6)
+ {
+ struct IPv6UdpAddress *u6;
+ struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) &socket_address;
+ u6 = GNUNET_malloc (sizeof (struct IPv6UdpAddress));
+ u6->ipv6_addr = in6->sin6_addr;
+ u6->u6_port = in6->sin6_port;
+ *buf = u6;
+ *added = sizeof (struct IPv6UdpAddress);
+ }
+ return GNUNET_SYSERR;
+}
+
+
+/**
* Append our port and forward the result.
*
* @param cls a 'struct PrettyPrinterContext'
@@ -2061,7 +2108,7 @@
api->cls = NULL;
api->address_pretty_printer = &udp_plugin_address_pretty_printer;
api->address_to_string = &udp_address_to_string;
- api->string_to_address = NULL; // FIXME!
+ api->string_to_address = &udp_string_to_address;
return api;
}
@@ -2170,7 +2217,7 @@
api->disconnect = &udp_disconnect;
api->address_pretty_printer = &udp_plugin_address_pretty_printer;
api->address_to_string = &udp_address_to_string;
- api->string_to_address = NULL; // FIXME!
+ api->string_to_address = &udp_string_to_address;
api->check_address = &udp_plugin_check_address;
api->get_session = &udp_plugin_get_session;
api->send = &udp_plugin_send;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r20441 - gnunet/src/transport,
gnunet <=