diff src/gt_share_state.h @ 0:d39e1d0d75b6

initial add
author paulo@hit-nxdomain.opendns.com
date Sat, 20 Feb 2010 21:18:28 -0800
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/gt_share_state.h	Sat Feb 20 21:18:28 2010 -0800
     1.3 @@ -0,0 +1,72 @@
     1.4 +/*
     1.5 + * $Id: gt_share_state.h,v 1.2 2004/03/31 08:58:24 hipnod Exp $
     1.6 + *
     1.7 + * Copyright (C) 2004 giFT project (gift.sourceforge.net)
     1.8 + *
     1.9 + * This program is free software; you can redistribute it and/or modify it
    1.10 + * under the terms of the GNU General Public License as published by the
    1.11 + * Free Software Foundation; either version 2, or (at your option) any
    1.12 + * later version.
    1.13 + *
    1.14 + * This program is distributed in the hope that it will be useful, but
    1.15 + * WITHOUT ANY WARRANTY; without even the implied warranty of
    1.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.17 + * General Public License for more details.
    1.18 + */
    1.19 +
    1.20 +#ifndef GIFT_GT_SHARE_STATE_H_
    1.21 +#define GIFT_GT_SHARE_STATE_H_
    1.22 +
    1.23 +/******************************************************************************/
    1.24 +
    1.25 +/*
    1.26 + * Keep track of the "hidden" share status on the remote node.  To
    1.27 + * disable sharing, the node is sent a HopsFlow message with a payload of 0,
    1.28 + * telling it not to send us any queries.  If the HopsFlow message isn't
    1.29 + * supported, the query handling code can simply drop the queries
    1.30 + * (alternatively, the QRT could be manipulated, but that's more complicated).
    1.31 + *
    1.32 + * There are two variables to deal with: giftd may have disabled sharing, and
    1.33 + * the plugin may have flow-controlled the remote node.  When either of these
    1.34 + * conditions becomes true, the node is sent the HopsFlow message to disable
    1.35 + * receipt of queries.  Only when both these conditions become false does the
    1.36 + * node receive another HopsFlow with a payload of 8, allowing the node to send
    1.37 + * us queries again.
    1.38 + *
    1.39 + * giftd's hidden state is tracked by gt_share_state.c.  Here, each node's
    1.40 + * hidden state is tracked:
    1.41 + */
    1.42 +struct gt_share_state
    1.43 +{
    1.44 +	BOOL  hidden;                  /* sharing is disabled for this node */
    1.45 +	BOOL  plugin_hidden;           /* plugin disabled it (flow control) */
    1.46 +};
    1.47 +
    1.48 +/*****************************************************************************/
    1.49 +
    1.50 +struct gt_share_state *gt_share_state_new    (void);
    1.51 +void                   gt_share_state_free   (struct gt_share_state *state);
    1.52 +
    1.53 +/*****************************************************************************/
    1.54 +
    1.55 +/* update the node about our sharing status, possibly by sending it a HopsFlow
    1.56 + * message */
    1.57 +void                   gt_share_state_update (struct gt_node *node);
    1.58 +
    1.59 +/* control share disabling on each individual node (as opposed to locally) */
    1.60 +void                   gt_share_state_hide   (struct gt_node *node);
    1.61 +void                   gt_share_state_show   (struct gt_node *node);
    1.62 +
    1.63 +/*****************************************************************************/
    1.64 +
    1.65 +void  gt_share_state_local_init    (void);
    1.66 +void  gt_share_state_local_cleanup (void);
    1.67 +
    1.68 +/*****************************************************************************/
    1.69 +
    1.70 +void  gnutella_share_hide (Protocol *p);
    1.71 +void  gnutella_share_show (Protocol *p);
    1.72 +
    1.73 +/******************************************************************************/
    1.74 +
    1.75 +#endif /* GIFT_GT_SHARE_STATE_H_ */