aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-tcp-stream-raw.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-01-15 06:48:09 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-01-15 06:48:09 +0800
commit24a2d4baa8137fa990fff01b8e751538311d4de2 (patch)
tree9c6f87eac22ceed5b818425ef4598f0804373f54 /camel/camel-tcp-stream-raw.c
parent80b2b2222ea67c50e0e3f9fdeb1797fb7874f862 (diff)
downloadgsoc2013-evolution-24a2d4baa8137fa990fff01b8e751538311d4de2.tar.gz
gsoc2013-evolution-24a2d4baa8137fa990fff01b8e751538311d4de2.tar.zst
gsoc2013-evolution-24a2d4baa8137fa990fff01b8e751538311d4de2.zip
Implemented. (stream_setsockopt): Implemented.
2001-01-14 Jeffrey Stedfast <fejj@ximian.com> * camel-tcp-stream-ssl.c (stream_getsockopt): Implemented. (stream_setsockopt): Implemented. * camel-tcp-stream-raw.c (stream_getsockopt): Implemented. (stream_setsockopt): Implemented. * camel-tcp-stream.c (camel_tcp_stream_getsockopt): New method. (camel_tcp_stream_setsockopt): Another new method. I think you get the idea of what these are for so I won't explain them. svn path=/trunk/; revision=7491
Diffstat (limited to 'camel/camel-tcp-stream-raw.c')
-rw-r--r--camel/camel-tcp-stream-raw.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/camel/camel-tcp-stream-raw.c b/camel/camel-tcp-stream-raw.c
index 4a547a2f6f..5c884fd136 100644
--- a/camel/camel-tcp-stream-raw.c
+++ b/camel/camel-tcp-stream-raw.c
@@ -42,6 +42,8 @@ static int stream_close (CamelStream *stream);
static int stream_connect (CamelTcpStream *stream, struct hostent *host, int port);
static int stream_disconnect (CamelTcpStream *stream);
+static int stream_getsockopt (CamelTcpStream *stream, CamelSockOptData *data);
+static int stream_setsockopt (CamelTcpStream *stream, const CamelSockOptData *data);
static void
camel_tcp_stream_raw_class_init (CamelTcpStreamRawClass *camel_tcp_stream_raw_class)
@@ -61,6 +63,8 @@ camel_tcp_stream_raw_class_init (CamelTcpStreamRawClass *camel_tcp_stream_raw_cl
camel_tcp_stream_class->connect = stream_connect;
camel_tcp_stream_class->disconnect = stream_disconnect;
+ camel_tcp_stream_class->getsockopt = stream_getsockopt;
+ camel_tcp_stream_class->setsockopt = stream_setsockopt;
}
static void
@@ -194,3 +198,73 @@ stream_disconnect (CamelTcpStream *stream)
{
return close (((CamelTcpStreamRaw *)stream)->sockfd);
}
+
+
+static int
+get_sockopt_level (const CamelSockOptData *data)
+{
+ switch (data->option) {
+ case CAMEL_SOCKOPT_MAXSEGMENT:
+ case CAMEL_SOCKOPT_NODELAY:
+ return IPPROTO_TCP;
+ default:
+ return SOL_SOCKET;
+ }
+}
+
+static int
+get_sockopt_optname (const CamelSockOptData *data)
+{
+ switch (data->option) {
+ case CAMEL_SOCKOPT_MAXSEGMENT:
+ return TCP_MAXSEG;
+ case CAMEL_SOCKOPT_NODELAY:
+ return TCP_NODELAY;
+ case CAMEL_SOCKOPT_BROADCAST:
+ return SO_BROADCAST;
+ case CAMEL_SOCKOPT_KEEPALIVE:
+ return SO_KEEPALIVE;
+ case CAMEL_SOCKOPT_LINGER:
+ return SO_LINGER;
+ case CAMEL_SOCKOPT_RECVBUFFERSIZE:
+ return SO_RCVBUF;
+ case CAMEL_SOCKOPT_SENDBUFFERSIZE:
+ return SO_SNDBUF;
+ case CAMEL_SOCKOPT_REUSEADDR:
+ return SO_REUSEADDR;
+ case CAMEL_SOCKOPT_IPTYPEOFSERVICE:
+ return SO_TYPE;
+ default:
+ return -1;
+ }
+}
+
+static int
+stream_getsockopt (CamelTcpStream *stream, CamelSockOptData *data)
+{
+ int optname, optlen;
+
+ if ((optname = get_sockopt_optname (data)) == -1)
+ return -1;
+
+ return getsockopt (((CamelTcpStreamRaw *)stream)->sockfd,
+ get_sockopt_level (data),
+ optname,
+ (void *) &data->value,
+ &optlen);
+}
+
+static int
+stream_setsockopt (CamelTcpStream *stream, const CamelSockOptData *data)
+{
+ int optname, optlen;
+
+ if ((optname = get_sockopt_optname (data)) == -1)
+ return -1;
+
+ return setsockopt (((CamelTcpStreamRaw *)stream)->sockfd,
+ get_sockopt_level (data),
+ optname,
+ (void *) &data->value,
+ sizeof (data->value));
+}