summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--doc/html/callbacks.html4
-rw-r--r--doc/html/intro.html8
-rw-r--r--doc/html/openssl-connection.html20
-rw-r--r--doc/html/openssl-rand.html6
-rw-r--r--doc/html/openssl-ssl.html4
-rw-r--r--doc/pyOpenSSL.tex10
-rwxr-xr-xsrc/ssl/connection.c39
-rw-r--r--src/ssl/ssl.c4
9 files changed, 87 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 098bd72..a1981d2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-02-21 Jean-Paul Calderone <exarkun@twistedmatrix.com>
+
+ * src/ssl/connection.c: Expose SSL_get_shutdown and
+ SSL_set_shutdown. (patch from James Knight)
+ * src/ssl/ssl.c: Expose SSL_SENT_SHUTDOWN and SSL_RECEIVED_SHUTDOWN.
+ (patch from James Knight)
+
2008-02-19 Jean-Paul Calderone <exarkun@twistedmatrix.com>
* src/ssl/context.c: Expose SSL_CTX_add_extra_chain_cert.
diff --git a/doc/html/callbacks.html b/doc/html/callbacks.html
index b1cad1a..740caf2 100644
--- a/doc/html/callbacks.html
+++ b/doc/html/callbacks.html
@@ -55,7 +55,7 @@ functions can block if the socket is in blocking mode, and then you want other
Python threads to be able to do other things. The real trouble is if you've
released the thread lock to do a potentially blocking operation, and the
operation calls a callback. Then we must take the thread lock back<A NAME="tex2html6"
- HREF="#foot921"><SUP>5</SUP></A>.
+ HREF="#foot934"><SUP>5</SUP></A>.
</EM></EM></EM>
<P>
<EM><EM><EM>There are two solutions to the first problem, both of which are necessary. The
@@ -83,7 +83,7 @@ before calling a callback.
<P>
<BR><HR><H4>Footnotes</H4>
<DL>
-<DT><A NAME="foot921">... back</A><A
+<DT><A NAME="foot934">... back</A><A
href="callbacks.html#tex2html6"><SUP>5</SUP></A></DT>
<DD>I'm
not sure why this is necessary, but otherwise I get a segmentation violation on
diff --git a/doc/html/intro.html b/doc/html/intro.html
index 59655f6..e57f6f2 100644
--- a/doc/html/intro.html
+++ b/doc/html/intro.html
@@ -60,9 +60,9 @@ The M2Crypto.SSL module does implement a lot of OpenSSL's functionality but
unfortunately its error handling system does not seem to be finished,
especially for non-blocking I/O. I think that much of the reason for this
is that M2Crypto<A NAME="tex2html1"
- HREF="#foot881"><SUP>1</SUP></A> is
+ HREF="#foot894"><SUP>1</SUP></A> is
developed using SWIG<A NAME="tex2html2"
- HREF="#foot882"><SUP>2</SUP></A>. This
+ HREF="#foot895"><SUP>2</SUP></A>. This
makes it awkward to create functions that e.g. can return both an integer and
NULL since (as far as I know) you basically write C functions and SWIG makes
wrapper functions that parses the Python argument list and calls your C
@@ -71,12 +71,12 @@ function, and finally transforms your return value to a Python object.
<P>
<BR><HR><H4>Footnotes</H4>
<DL>
-<DT><A NAME="foot881">... M2Crypto</A><A
+<DT><A NAME="foot894">... M2Crypto</A><A
href="intro.html#tex2html1"><SUP>1</SUP></A></DT>
<DD>See <a class="url" href="http://www.post1.com/home/ngps/m2/">http://www.post1.com/home/ngps/m2/</a>
</DD>
-<DT><A NAME="foot882">... SWIG</A><A
+<DT><A NAME="foot895">... SWIG</A><A
href="intro.html#tex2html2"><SUP>2</SUP></A></DT>
<DD>See <a class="url" href="http://swig.sourceforge.net/">http://swig.sourceforge.net/</a>
diff --git a/doc/html/openssl-connection.html b/doc/html/openssl-connection.html
index fbc2313..fed4d52 100644
--- a/doc/html/openssl-connection.html
+++ b/doc/html/openssl-connection.html
@@ -205,23 +205,35 @@ message exchange is completed and false otherwise (in which case you call
readable/writeable.
</dl>
<P>
-<dl><dt><b><a name='l2h-164'><tt class='method'>sock_shutdown</tt></a></b>(<var>how</var>)
+<dl><dt><b><a name='l2h-164'><tt class='method'>get_shutdown</tt></a></b>()
+<dd>
+Get the shutdown state of the Connection. Returns a bitvector of either or
+both of <var>SENT_SHUTDOWN</var> and <var>RECEIVED_SHUTDOWN</var>.
+</dl>
+<P>
+<dl><dt><b><a name='l2h-165'><tt class='method'>set_shutdown</tt></a></b>(<var>state</var>)
+<dd>
+Set the shutdown state of the Connection. <var>state</var> is a bitvector of
+either or both of <var>SENT_SHUTDOWN</var> and <var>RECEIVED_SHUTDOWN</var>.
+</dl>
+<P>
+<dl><dt><b><a name='l2h-166'><tt class='method'>sock_shutdown</tt></a></b>(<var>how</var>)
<dd>
Call the <tt class="method">shutdown</tt> method of the underlying socket.
</dl>
<P>
-<dl><dt><b><a name='l2h-165'><tt class='method'>state_string</tt></a></b>()
+<dl><dt><b><a name='l2h-167'><tt class='method'>state_string</tt></a></b>()
<dd>
Retrieve a verbose string detailing the state of the Connection.
</dl>
<P>
-<dl><dt><b><a name='l2h-166'><tt class='method'>want_read</tt></a></b>()
+<dl><dt><b><a name='l2h-168'><tt class='method'>want_read</tt></a></b>()
<dd>
Checks if more data has to be read from the transport layer to complete an
operation.
</dl>
<P>
-<dl><dt><b><a name='l2h-167'><tt class='method'>want_write</tt></a></b>()
+<dl><dt><b><a name='l2h-169'><tt class='method'>want_write</tt></a></b>()
<dd>
Checks if there is data to write to the transport layer to complete an
operation.
diff --git a/doc/html/openssl-rand.html b/doc/html/openssl-rand.html
index c958d15..8390880 100644
--- a/doc/html/openssl-rand.html
+++ b/doc/html/openssl-rand.html
@@ -59,14 +59,14 @@ declares the following:
<dd>
Mix bytes from <var>string</var> into the PRNG state. The <var>entropy</var> argument is
(the lower bound of) an estimate of how much randomness is contained in
-<var>string</var>, measured in bytes. For more information, see e.g. <a class="rfc" name="rfcref-1784"
+<var>string</var>, measured in bytes. For more information, see e.g. <a class="rfc" name="rfcref-1801"
href="http://www.ietf.org/rfc/rfc1750.txt">RFC 1750</a>.
</dl>
<P>
<dl><dt><b><a name='l2h-83'><tt class='function'>egd</tt></a></b>(<var>path</var><big>[</big><var>, bytes</var><big>]</big>)
<dd>
Query the Entropy Gathering Daemon<A NAME="tex2html3"
- HREF="#foot903"><SUP>3</SUP></A> on socket <var>path</var> for <var>bytes</var>
+ HREF="#foot916"><SUP>3</SUP></A> on socket <var>path</var> for <var>bytes</var>
bytes of random data and and uses <tt class="function">add</tt> to seed the PRNG. The default
value of <var>bytes</var> is 255.
</dl>
@@ -102,7 +102,7 @@ file can then be used with <tt class="function">load_file</tt> to seed the PRNG
<P>
<BR><HR><H4>Footnotes</H4>
<DL>
-<DT><A NAME="foot903">... Daemon</A><A
+<DT><A NAME="foot916">... Daemon</A><A
href="openssl-rand.html#tex2html3"><SUP>3</SUP></A></DT>
<DD>See
<a class="url" href="http://www.lothar.com/tech/crypto/">http://www.lothar.com/tech/crypto/</a>
diff --git a/doc/html/openssl-ssl.html b/doc/html/openssl-ssl.html
index 1d9ff6a..62e3f16 100644
--- a/doc/html/openssl-ssl.html
+++ b/doc/html/openssl-ssl.html
@@ -113,7 +113,7 @@ A Python type object representing the Connection object type.
<dd>
Factory fucnction that creates a new Connection object given an SSL context and
a socket <A NAME="tex2html5"
- HREF="#foot906"><SUP>4</SUP></A> object.
+ HREF="#foot919"><SUP>4</SUP></A> object.
</dl>
<P>
<dl><dt><b>exception <a name='l2h-98'><tt class='exception'>Error</tt></a></b>
@@ -173,7 +173,7 @@ The parameter to the exception is always a pair <code>(<var>errnum</var>,
<P>
<BR><HR><H4>Footnotes</H4>
<DL>
-<DT><A NAME="foot906">... socket</A><A
+<DT><A NAME="foot919">... socket</A><A
href="openssl-ssl.html#tex2html5"><SUP>4</SUP></A></DT>
<DD>Actually, all that is required is an object that
<i>behaves</i> like a socket, you could even use files, even though it'd be
diff --git a/doc/pyOpenSSL.tex b/doc/pyOpenSSL.tex
index de91545..da4c19b 100644
--- a/doc/pyOpenSSL.tex
+++ b/doc/pyOpenSSL.tex
@@ -949,6 +949,16 @@ message exchange is completed and false otherwise (in which case you call
readable/writeable.
\end{methoddesc}
+\begin{methoddesc}[Connection]{get_shutdown}{}
+Get the shutdown state of the Connection. Returns a bitvector of either or
+both of \var{SENT_SHUTDOWN} and \var{RECEIVED_SHUTDOWN}.
+\end{methoddesc}
+
+\begin{methoddesc}[Connection]{set_shutdown}{state}
+Set the shutdown state of the Connection. \var{state} is a bitvector of
+either or both of \var{SENT_SHUTDOWN} and \var{RECEIVED_SHUTDOWN}.
+\end{methoddesc}
+
\begin{methoddesc}[Connection]{sock_shutdown}{how}
Call the \method{shutdown} method of the underlying socket.
\end{methoddesc}
diff --git a/src/ssl/connection.c b/src/ssl/connection.c
index 96111aa..885f66d 100755
--- a/src/ssl/connection.c
+++ b/src/ssl/connection.c
@@ -756,6 +756,43 @@ ssl_Connection_set_app_data(ssl_ConnectionObj *self, PyObject *args)
return Py_None;
}
+static char ssl_Connection_get_shutdown_doc[] = "\n\
+Get shutdown state\n\
+\n\
+Arguments: self - The Connection object\n\
+ args - The Python argument tuple, should be empty\n\
+Returns: The shutdown state, a bitmask of SENT_SHUTDOWN, RECEIVED_SHUTDOWN.\n\
+";
+static PyObject *
+ssl_Connection_get_shutdown(ssl_ConnectionObj *self, PyObject *args)
+{
+ if (!PyArg_ParseTuple(args, ":get_shutdown"))
+ return NULL;
+
+ return PyInt_FromLong((long)SSL_get_shutdown(self->ssl));
+}
+
+static char ssl_Connection_set_shutdown_doc[] = "\n\
+Set shutdown state\n\
+\n\
+Arguments: self - The Connection object\n\
+ args - The Python argument tuple, should be\n\
+ shutdown state - bitmask of SENT_SHUTDOWN, RECEIVED_SHUTDOWN.\n\
+Returns: None\n\
+";
+static PyObject *
+ssl_Connection_set_shutdown(ssl_ConnectionObj *self, PyObject *args)
+{
+ int shutdown;
+
+ if (!PyArg_ParseTuple(args, "i:set_shutdown", &shutdown))
+ return NULL;
+
+ SSL_set_shutdown(self->ssl, shutdown);
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
static char ssl_Connection_state_string_doc[] = "\n\
Get a verbose state description\n\
\n\
@@ -888,6 +925,8 @@ static PyMethodDef ssl_Connection_methods[] =
ADD_METHOD(makefile),
ADD_METHOD(get_app_data),
ADD_METHOD(set_app_data),
+ ADD_METHOD(get_shutdown),
+ ADD_METHOD(set_shutdown),
ADD_METHOD(state_string),
ADD_METHOD(sock_shutdown),
ADD_METHOD(get_peer_certificate),
diff --git a/src/ssl/ssl.c b/src/ssl/ssl.c
index 9d3abd2..1bd2d9e 100644
--- a/src/ssl/ssl.c
+++ b/src/ssl/ssl.c
@@ -180,6 +180,10 @@ do { \
PyModule_AddIntConstant(module, "OP_NETSCAPE_CA_DN_BUG", SSL_OP_NETSCAPE_CA_DN_BUG);
PyModule_AddIntConstant(module, "OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG", SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG);
+ /* For SSL_set_shutdown */
+ PyModule_AddIntConstant(module, "SENT_SHUTDOWN", SSL_SENT_SHUTDOWN);
+ PyModule_AddIntConstant(module, "RECEIVED_SHUTDOWN", SSL_RECEIVED_SHUTDOWN);
+
dict = PyModule_GetDict(module);
if (!init_ssl_context(dict))
goto error;