chiark / gitweb /
server/peer.c: Abstract out updating a peer's address.
[tripe] / server / tripe.h
index d07823b83a659fa54b369f4107be5141df482e67..e7c47ecdc44156afdf634407429071b64d9cae36 100644 (file)
@@ -202,7 +202,7 @@ typedef struct dhops {
   int (*ldpriv)(key_file */*kf*/, key */*k*/, key_data */*d*/,
                kdata */*kd*/, dstr */*t*/, dstr */*e*/);
        /* Load a private key from @d@, storing the data in @kd@.  The key's
-        * file and key object are in @kf@ and @k, mostly in case its
+        * file and key object are in @kf@ and @k@, mostly in case its
         * attributes are interesting; the key tag is in @t@; errors are
         * reported by writing tokens to @e@ and returning nonzero.
         */
@@ -210,7 +210,7 @@ typedef struct dhops {
   int (*ldpub)(key_file */*kf*/, key */*k*/, key_data */*d*/,
               kdata */*kd*/, dstr */*t*/, dstr */*e*/);
        /* Load a public key from @d@, storing the data in @kd@.  The key's
-        * file and key object are in @kf@ and @k, mostly in case its
+        * file and key object are in @kf@ and @k@, mostly in case its
         * attributes are interesting; the key tag is in @t@; errors are
         * reported by writing tokens to @e@ and returning nonzero.
         */
@@ -595,7 +595,6 @@ typedef struct peerspec {
   const tunnel_ops *tops;              /* Tunnel operations */
   unsigned long t_ka;                  /* Keep alive interval */
   addr sa;                             /* Socket address to speak to */
-  size_t sasz;                         /* Socket address size */
   unsigned f;                          /* Flags for the peer */
 #define PSF_KXMASK 255u                        /*   Key-exchange flags to set */
 #define PSF_MOBILE 256u                        /*   Address may change rapidly */
@@ -1410,6 +1409,19 @@ extern void ps_quit(void);
 
 /*----- Peer management ---------------------------------------------------*/
 
+/* --- @p_updateaddr@ --- *
+ *
+ * Arguments:  @peer *p@ = pointer to peer block
+ *             @const addr *a@ = address to associate with this peer
+ *
+ * Returns:    Zero if the address was changed; @+1@ if it was already
+ *             right.
+ *
+ * Use:                Updates our idea of @p@'s address.
+ */
+
+extern int p_updateaddr(peer */*p*/, const addr */*a*/);
+
 /* --- @p_txstart@ --- *
  *
  * Arguments:  @peer *p@ = pointer to peer block
@@ -1730,6 +1742,15 @@ extern const char *timestr(time_t /*t*/);
 
 extern int mystrieq(const char */*x*/, const char */*y*/);
 
+/* --- @addrsz@ --- *
+ *
+ * Arguments:  @const addr *a@ = a network address
+ *
+ * Returns:    The size of the address, for passing into the sockets API.
+ */
+
+extern socklen_t addrsz(const addr */*a*/);
+
 /* --- @seq_reset@ --- *
  *
  * Arguments:  @seqwin *s@ = sequence-checking window