SyncActions.h

Go to the documentation of this file.
00001 /**
00002  * @file sync/SyncActions.h
00003  *  
00004  * Part of CCNx Sync.
00005  *
00006  * This library is free software; you can redistribute it and/or modify it
00007  * under the terms of the GNU Lesser General Public License version 2.1
00008  * as published by the Free Software Foundation.
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00012  * Lesser General Public License for more details. You should have received
00013  * a copy of the GNU Lesser General Public License along with this library;
00014  * if not, write to the Free Software Foundation, Inc., 51 Franklin Street,
00015  * Fifth Floor, Boston, MA 02110-1301 USA.
00016  */
00017 
00018 #ifndef CCN_SyncActions
00019 #define CCN_SyncActions
00020 
00021 #include <ccn/charbuf.h>
00022 #include "SyncBase.h"
00023 #include "SyncRoot.h"
00024 #include "SyncUtil.h"
00025 
00026 struct SyncTreeWorkerHead;  // from SyncTreeWorker.h
00027 struct SyncCompareData;     // from SyncActions.c
00028 
00029 enum SyncRegisterActionKind {
00030     SRI_Kind_None,
00031     SRI_Kind_AdviseInt,  /**< root advise handler */
00032     SRI_Kind_FetchInt,   /**< node fetch handler */
00033     SRI_Kind_RootAdvise, /**< root advise request */
00034     SRI_Kind_NodeFetch,  /**< node fetch request */
00035     SRI_Kind_RootStats,  /**< root stats request */
00036     SRI_Kind_Content     /**< general content */
00037 };
00038 
00039 enum SyncActionState {
00040     SyncActionState_init,
00041     SyncActionState_sent,
00042     SyncActionState_loose,
00043     SyncActionState_error,
00044     SyncActionState_done
00045 };
00046 
00047 struct SyncActionData {
00048     struct SyncActionData *next;
00049     struct SyncRootStruct *root;
00050     struct SyncHashCacheEntry *ce;
00051     struct SyncCompareData *comp;
00052     void *client_handle;
00053     struct ccn_charbuf *prefix;
00054     struct ccn_charbuf *hash;
00055     int64_t startTime;
00056     enum SyncRegisterActionKind kind;
00057     enum SyncActionState state;
00058     int skipToHash;
00059 };
00060 
00061 /**
00062  * starts a slice enumeration for the root
00063  * @returns < 0 for error, 0 if some enumeration is busy, 1 for success
00064  */
00065 int
00066 SyncStartSliceEnum(struct SyncRootStruct *root);
00067 
00068 /**
00069  * starts a periodic wakeup that maintains state across all roots
00070  * @returns < 0 for error, >= 0 for success
00071  */
00072 int
00073 SyncStartHeartbeat(struct SyncBaseStruct *base);
00074 
00075 /**
00076  * starts a remote fetch of the given node, based on the hash
00077  * comp may be NULL if this is not for a compare
00078  * @returns < 0 for error, >= 0 for success
00079  */
00080 int
00081 SyncStartNodeFetch(struct SyncRootStruct *root,
00082                    struct SyncHashCacheEntry *ce,
00083                    struct SyncCompareData *comp);
00084 
00085 /**
00086  * starts a remote fetch of the given name
00087  * comp may be NULL if this is not for a compare
00088  * @returns < 0 for error, >= 0 for success
00089  */
00090 int
00091 SyncStartContentFetch(struct SyncRootStruct *root,
00092                       struct ccn_charbuf *name,
00093                       struct SyncCompareData *comp);
00094 
00095 /**
00096  * Adds the given name to any applicable roots.
00097  * Use item == 0 to ignore accession number.
00098  * @returns < 0 for failure, number of additions to roots for success.
00099  */
00100 int
00101 SyncAddName(struct SyncBaseStruct *base, struct ccn_charbuf *name, ccnr_accession item);
00102 
00103 /**
00104  * Creates a new slice from a full name.
00105  * The name must start with base->priv->sliceCmdPrefix.
00106  * @returns < 0 if an error occurred, otherwise the new root number.
00107  */
00108 int
00109 SyncHandleSlice(struct SyncBaseStruct *base, struct ccn_charbuf *name);
00110 
00111 /**
00112  * registers interests associated with the given root
00113  * these include %C1.S.RA (Root Advise) and %C1.S.NF (Node Fetch) interests
00114  * additional interests may be registered as the protocol evolves
00115  * @returns < 0 for error, >= 0 for success
00116  */
00117 int
00118 SyncRegisterInterests(struct SyncRootStruct *root);
00119 
00120 /**
00121  * send a root advise request for the given root
00122  * only one at a time may be outstanding
00123  * @returns < 0 for error, >= 0 for OK
00124  */
00125 int
00126 SyncSendRootAdviseInterest(struct SyncRootStruct *root);
00127 
00128 /**
00129  * updates the root with the current root->namesToAdd
00130  * @returns < 0 for error, >= 0 for OK
00131  */
00132 int
00133 SyncUpdateRoot(struct SyncRootStruct *root);
00134 
00135 /**
00136  * initiates a compare action with the given remote hash
00137  * @returns < 0 for error, >= 0 for OK
00138  */
00139 int
00140 SyncStartCompareAction(struct SyncRootStruct *root, struct ccn_charbuf *hashR);
00141 
00142 #endif
Generated on Tue Aug 21 14:54:19 2012 for Content-Centric Networking in C by  doxygen 1.6.3