Commit f92750a9 authored by Dafydd Harries's avatar Dafydd Harries

fake UDP: simplify Packet struct

darcs-hash:20070120033445-c9803-09408144ece3f71be9f9631501de29bc4fd5aa39.gz
parent 9b2d4301
...@@ -11,8 +11,7 @@ typedef struct _Packet Packet; ...@@ -11,8 +11,7 @@ typedef struct _Packet Packet;
struct _Packet struct _Packet
{ {
struct sockaddr_in from; struct sockaddr_in sin;
struct sockaddr_in to;
guint len; guint len;
gchar buf[1024]; gchar buf[1024];
}; };
...@@ -54,7 +53,7 @@ fake_send ( ...@@ -54,7 +53,7 @@ fake_send (
packet = g_slice_new0 (Packet); packet = g_slice_new0 (Packet);
packet->len = len; packet->len = len;
packet->to = *to; packet->sin = *to;
strncpy (packet->buf, buf, len); strncpy (packet->buf, buf, len);
man = (UDPSocketManager *) sock->priv; man = (UDPSocketManager *) sock->priv;
...@@ -87,7 +86,7 @@ fake_recv ( ...@@ -87,7 +86,7 @@ fake_recv (
len = packet->len; len = packet->len;
memcpy (buf, packet->buf, len); memcpy (buf, packet->buf, len);
memcpy (from, &(packet->from), sizeof (*from)); memcpy (from, &(packet->sin), sizeof (*from));
g_slice_free (Packet, packet); g_slice_free (Packet, packet);
return len; return len;
...@@ -117,7 +116,7 @@ udp_fake_socket_manager_push_recv ( ...@@ -117,7 +116,7 @@ udp_fake_socket_manager_push_recv (
packet = g_slice_new0 (Packet); packet = g_slice_new0 (Packet);
packet->len = len; packet->len = len;
packet->from = *from; packet->sin = *from;
strncpy (packet->buf, buf, len); strncpy (packet->buf, buf, len);
priv = (UDPFakeSocketManagerPriv *) man->priv; priv = (UDPFakeSocketManagerPriv *) man->priv;
...@@ -140,7 +139,7 @@ udp_fake_socket_manager_pop_send ( ...@@ -140,7 +139,7 @@ udp_fake_socket_manager_pop_send (
if (!packet) if (!packet)
return 0; return 0;
*to = packet->to; *to = packet->sin;
return packet->len; return packet->len;
} }
......
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