Commit 04b2d8b1 authored by Dafydd Harries's avatar Dafydd Harries

name the BSD socket implementation of UDP sockets as such; tidy up header files

darcs-hash:20070201110341-c9803-08173e15f091a90623d648547dfb8e0eca567171.gz
parent 5a5a28e7
......@@ -68,7 +68,7 @@ handle_connection (guint sock)
g_debug ("got candidate");
udp_socket_manager_init (&man);
udp_socket_manager_bsd_init (&man);
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = INADDR_ANY;
......
......@@ -81,7 +81,7 @@ handle_connection (guint fileno, const struct sockaddr_in *sin, gpointer data)
inet_ntop (AF_INET, &(sin->sin_addr), ip_str, INET_ADDRSTRLEN);
g_debug ("got connection from %s:%d", ip_str, ntohs (sin->sin_port));
udp_socket_manager_init (&mgr);
udp_socket_manager_bsd_init (&mgr);
if (!make_agent ((gchar *) data, &mgr, &agent, &sock))
return;
......
......@@ -3,6 +3,7 @@
#define _NICE_H
#include "udp.h"
#include "udp-bsd.h"
#include "udp-fake.h"
#include "agent.h"
#include "random.h"
......
......@@ -7,8 +7,9 @@ noinst_LTLIBRARIES = libudp.la
libudp_la_SOURCES = \
udp.h \
udp.c \
udp-generic.c \
udp-bsd.h \
udp-bsd.c \
udp-fake.h \
udp-fake.c
......
/*
* convenience API for UDP sockets
*
* easily:
*
* - create sockets and bind them to an interface
* - send and receive packets
* - know who packets are received from
* - select on a number of sockets
*
* also allows faking UDP sockets for testing purposes
* Implementation of UDP socket interface using Berkeley sockets. (See
* http://en.wikipedia.org/wiki/Berkeley_sockets.)
*/
#include <arpa/inet.h>
#include <sys/socket.h>
#include <unistd.h>
#include <glib.h>
#include <udp.h>
#include "udp-bsd.h"
/*** UDPSocket ***/
......@@ -104,7 +92,7 @@ socket_manager_close (UDPSocketManager *man)
}
void
udp_socket_manager_init (UDPSocketManager *man)
udp_socket_manager_bsd_init (UDPSocketManager *man)
{
man->init = socket_manager_init_socket;
man->select = socket_manager_select;
......
#ifndef _UDP_BSD_H
#define _UDP_BSD_H
#include "udp.h"
G_BEGIN_DECLS
void
udp_socket_manager_bsd_init (UDPSocketManager *man);
G_END_DECLS
#endif /* _UDP_BSD_H */
......@@ -2,11 +2,7 @@
#include <string.h>
#include <stdio.h>
#include <arpa/inet.h>
#include <glib.h>
#include <udp.h>
#include "udp-bsd.h"
gint
main (void)
......@@ -15,7 +11,7 @@ main (void)
UDPSocket sock;
struct sockaddr_in sin;
udp_socket_manager_init (&man);
udp_socket_manager_bsd_init (&man);
if (!udp_socket_manager_alloc_socket (&man, &sock, NULL))
g_assert_not_reached ();
......
#include <arpa/inet.h>
#include <glib.h>
#include <udp.h>
#include "udp-bsd.h"
gint
main (void)
......@@ -12,7 +8,7 @@ main (void)
UDPSocket sock;
struct sockaddr_in sin;
udp_socket_manager_init (&man);
udp_socket_manager_bsd_init (&man);
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = INADDR_ANY;
sin.sin_port = htons (9999);
......
......@@ -2,10 +2,6 @@
#ifndef _UDP_FAKE_H
#define _UDP_FAKE_H
#include <arpa/inet.h>
#include <glib.h>
#include "udp.h"
G_BEGIN_DECLS
......
......@@ -36,8 +36,6 @@ struct _UDPSocketManager
void *priv;
};
void
udp_socket_manager_init (UDPSocketManager *man);
/**
* If sin is not NULL, the new socket will be bound to that IP address/port.
* If sin->sin_port is 0, a port will be assigned at random. In all cases, the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment