<!doctype refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [

<!-- Process this file with docbook-to-man to generate an nroff manual
     page: `docbook-to-man manpage.sgml > manpage.1'.  You may view
     the manual page with: `docbook-to-man manpage.sgml | nroff -man |
     less'.  A typical entry in a Makefile or Makefile.am is:

manpage.1: manpage.sgml
	docbook-to-man $< > $@


	The docbook-to-man binary is found in the docbook-to-man package.
	Please remember that if you create the nroff version in one of the
	debian/rules file targets (such as build), you will need to include
	docbook-to-man in your Build-Depends control field.

  -->

  <!-- Fill in your name for FIRSTNAME and SURNAME. -->
  <!ENTITY dhfirstname "<firstname>Sergiusz</firstname>">
  <!ENTITY dhsurname   "<surname>Pawlowicz</surname>">
  <!-- Please adjust the date whenever revising the manpage. -->
  <!ENTITY dhdate      "<date>January  9, 2012</date>">
  <!-- SECTION should be 1-8, maybe w/ subsection other parameters are
       allowed: see man(7), man(1). -->
  <!ENTITY dhsection   "<manvolnum>1</manvolnum>">
  <!ENTITY dhemail     "<email>debian@pawlowicz.name</email>">
  <!ENTITY dhusername  "Sergiusz Pawlowicz">
  <!ENTITY dhucpackage "<refentrytitle>NaCl</refentrytitle>">
  <!ENTITY dhpackage   "CurveCP">
  <!ENTITY debian      "<productname>Debian</productname>">
]>

<refentry>
  <refentryinfo>
    <address>
      &dhemail;
    </address>
    <author>
      &dhfirstname;
      &dhsurname;
    </author>
    <copyright>
      <year>2012</year>
      <holder>&dhusername;</holder>
    </copyright>
    &dhdate;
  </refentryinfo>
  <refmeta>
    &dhucpackage;

    &dhsection;
  </refmeta>
  <refnamediv>
    <refname>&dhpackage;</refname>

    <refpurpose>Message-handling programs</refpurpose>
  </refnamediv>
  <refsynopsisdiv>

<cmdsynopsis>
	<command>curvecpclient</command>
      <arg><option>-q <replaceable>(optional)</replaceable></option></arg>
      <arg><option>-Q <replaceable>(optional)</replaceable></option></arg>
      <arg><option>-v <replaceable>(optional)</replaceable></option></arg>
      <arg><option>-c keydir<replaceable>(optional)</replaceable></option></arg>
      <arg>sname</arg>
      <arg>pk</arg>
      <arg>ip</arg>
      <arg>port</arg>
      <arg>ext</arg>
      <arg>prog</arg>
</cmdsynopsis>

  </refsynopsisdiv>
  <refsect1>
    <title>DESCRIPTION</title>

    <para>This manual page documents briefly the 
      <command>&dhpackage;</command> commands.</para>

    <para>A traditional UNIX-style server such as ftpd handles just 
one network connection, reading input from stdin and writing output
to stdout. A "superserver" such as inetd or tcpserver listens for 
network connections and starts a separate server process for 
each connection.</para>

    <para>The <command>&dhpackage;</command> command-line tools have
 an extra level of modularity. The <command>curvecpserver</command>
 superserver listens for network connections. For each connection, 
<command>curvecpserver</command> starts the 
<command>curvecpmessage</command> message handler; 
<command>curvecpmessage</command> then starts a server such as ftpd.
Then ftpd sends a stream of data to <command>curvecpmessage</command>, 
which in turn sends messages to <command>curvecpserver</command>, 
which encrypts and authenticates the messages and sends them inside
network packets. At the same time <command>curvecpclient</command>
receives network packets, verifies and decrypts messages inside the 
packets, and passes the messages to <command>curvecpmessage</command>;
<command>curvecpmessage</command> sends a stream of data to ftpd. 
The same curvecpmessage tool is also used by 
<command>curvecpclient</command>.</para>

<para><command>curvecpserver</command> and 
<command>curvecpclient</command> can use programs other than 
<command>curvecpmessage</command>. Those programs can directly
generate messages in the CurveCP message format without talking to 
separate tools such as ftpd; or they can support a completely 
different protocol that reuses CurveCP's cryptographic layer 
but transmits different kinds of messages.</para>

<para>This page explains what programmers have to do to write 
<command>curvecpmessage</command> replacements that talk to 
<command>curvecpserver</command> and 
<command>curvecpclient.</command></para>

 </refsect1>
  <refsect1>
    <title>Incoming messagess</title>

<para>File descriptor 8 is a pipe. Read from this pipe a length
byte n, between 1 and 68, and a 16*n-byte message. Repeat. 
The pipe is set to non-blocking mode; be prepared for EAGAIN
and EWOULDBLOCK, even in the middle of a message.</para>

<para>This pipe reading must always be active. The 
<command>curvecpclient</command> and 
<command>curvecpserver</command> programs assume that every
message is read immediately. If you can't handle a message
immediately, read it and put it onto a queue. If you don't
have queue space, throw the message away; this shouldn't cause
trouble, since you have to be able to handle missing
messages in any case.</para>

  </refsect1>

<refsect1>
    <title>Outgoing messagess</title>               
    
<para>File descriptor 9 is a pipe. Write to this pipe a length
byte n, between 1 and 68, and a 16*n-byte message. Repeat.
The pipe is set to non-blocking mode; be prepared for EAGAIN
and EWOULDBLOCK, even in the middle of a message.</para>

<para>As a client, do not use length bytes above 40 until a message
has arrived from the server. (The messages inside CurveCP
Initiate packets are limited to 640 bytes.)</para>

<para>The CurveCP server does not start until it has received
a message from the client. Furthermore, the CurveCP server
must receive this message within 60 seconds of the client
starting up. (The CurveCP Initiate packet is valid for only
60 seconds after the corresponding CurveCP Cookie packet.)
This does not mean that the client must start sending
messages immediately, but it does mean that waiting for
more than a second to send a message is a bad idea.</para>
    
  </refsect1>   

  <refsect1>
    <title>OPTIONS</title>

    <para>How to use <command>curvecpclient</command>:</para>

<variablelist>

      <varlistentry>
        <term><option>-q</option>
          <option>optional</option>
        </term>
        <listitem>
          <para>no error messages</para>
        </listitem>
      </varlistentry>
      <varlistentry>

        <term><option>-Q</option>
          <option>optional</option>
        </term>
        <listitem>
          <para>print error messages (default)</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><option>-v</option>
          <option>optional</option>
        </term>
        <listitem>
          <para>print extra information</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><option>-c keydir</option>
          <option>optional</option>
        </term>
        <listitem>
          <para>use this public-key directory</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><option>sname</option>
        </term>
        <listitem>
          <para>server's name</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><option>pk</option>
        </term>
        <listitem>
          <para>server's public key</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><option>ip</option>
        </term>
        <listitem>
          <para>server's IP address</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><option>port</option>
        </term>
        <listitem>
          <para>server's UDP port</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><option>ext</option>
        </term>
        <listitem>
          <para>server's extension</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><option>prog</option>
        </term>
        <listitem>
          <para>run this client</para>
        </listitem>
      </varlistentry>

</variablelist>

  </refsect1>
  <refsect1>
    <title>SEE ALSO</title>

    <para>curvecpserver (1), curvecpmessage (1), inetd (8), tcpserver (1).</para>

  </refsect1>
  <refsect1>
    <title>AUTHOR</title>

    <para>This manual page was written by &dhusername; &dhemail; for
      the &debian; system (and may be used by others). The source
			of this page is a webpage http://curvecp.org/messageapi.html .
      Permission is granted to copy, distribute and/or modify this
      document under public domain.
    </para>

    <para>This manual page was rewritten for the &debian; distribution
      because the original program does not have a manual page.</para>

  </refsect1>
</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:2
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:nil
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->
