- Implement OskitTCPSetSockOpt and OskitTCPGetSockOpt (currently unused)
authorCameron Gutman <aicommander@gmail.com>
Sat, 31 Oct 2009 00:24:38 +0000 (00:24 +0000)
committerCameron Gutman <aicommander@gmail.com>
Sat, 31 Oct 2009 00:24:38 +0000 (00:24 +0000)
svn path=/trunk/; revision=43861

reactos/lib/drivers/oskittcp/include/oskittcp.h
reactos/lib/drivers/oskittcp/oskittcp/interface.c

index c3d1c00..647aecf 100644 (file)
@@ -150,6 +150,18 @@ void OskitTCPGetAddress( void *socket,
                         OSK_UINT *RemoteAddress,
                         OSK_UI16 *RemotePort );
 
+int OskitTCPGetSockOpt(void *socket,
+                       int level,
+                       int optname,
+                       char *buffer,
+                       int *size);
+
+int OskitTCPSetSockOpt(void *socket,
+                       int level,
+                       int optname,
+                       char *buffer,
+                       int size);
+
 #undef errno
 
 void *fbsd_malloc( unsigned int bytes, char *file, unsigned line, ... );
index 9109fe7..e69859b 100644 (file)
@@ -428,6 +428,57 @@ void OskitTCPReceiveDatagram( OSK_PCHAR Data, OSK_UINT Len,
     /* The buffer Ip is freed by tcp_input */
 }
 
+int OskitTCPSetSockOpt(void *socket,
+                       int level,
+                       int optname,
+                       char *buffer,
+                       int size)
+{
+    struct mbuf *m;
+
+    if (size >= MLEN)
+        return OSK_EINVAL;
+
+    m = m_get(M_WAIT, MT_SOOPTS);
+    if (!m)
+        return OSK_ENOMEM;
+
+    m->m_len = size;
+
+    memcpy(m->m_data, buffer, size);
+
+    /* m is freed by sosetopt */
+    return sosetopt(socket, level, optname, m);
+}   
+
+int OskitTCPGetSockOpt(void *socket,
+                       int level,
+                       int optname,
+                       char *buffer,
+                       int *size)
+{
+    int error, oldsize = *size;
+    struct mbuf *m;
+
+    error = sogetopt(socket, level, optname, &m);
+    if (!error)
+    {
+        *size = m->m_len;
+
+        if (!buffer || oldsize < m->m_len)
+        {
+            m_freem(m);
+            return OSK_EINVAL;
+        }
+
+        memcpy(buffer, m->m_data, m->m_len);
+
+        m_freem(m);
+    }
+
+    return error;
+}
+
 int OskitTCPListen( void *socket, int backlog ) {
     int error;