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 "SyncBase.h"
00022 #include "SyncNode.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 SyncCompareData *comp;
00051     struct ccnr_handle *ccnr;
00052     struct ccn_charbuf *prefix;
00053     struct ccn_charbuf *hash;
00054     sync_time startTime;
00055     enum SyncRegisterActionKind kind;
00056     enum SyncActionState state;
00057     int skipToHash;
00058 };
00059 
00060 /**
00061  * starts a slice enumeration for the root
00062  * @returns < 0 for error, 0 if some enumeration is busy, 1 for success
00063  */
00064 int
00065 SyncStartSliceEnum(struct SyncRootStruct *root);
00066 
00067 /**
00068  * starts a periodic wakeup that maintains state across all roots
00069  * @returns < 0 for error, >= 0 for success
00070  */
00071 int
00072 SyncStartHeartbeat(struct SyncBaseStruct *base);
00073 
00074 /**
00075  * starts a remote fetch of the given node, based on the hash
00076  * comp may be NULL if this is not for a compare
00077  * @returns < 0 for error, >= 0 for success
00078  */
00079 int
00080 SyncStartNodeFetch(struct SyncRootStruct *root,
00081                    struct SyncHashCacheEntry *ce,
00082                    struct SyncCompareData *comp);
00083 
00084 /**
00085  * starts a remote fetch of the given name
00086  * comp may be NULL if this is not for a compare
00087  * @returns < 0 for error, >= 0 for success
00088  */
00089 int
00090 SyncStartContentFetch(struct SyncRootStruct *root,
00091                       struct ccn_charbuf *name,
00092                       struct SyncCompareData *comp);
00093 
00094 /**
00095  * Adds the given name to any applicable roots.
00096  * Use item == 0 to ignore accession number.
00097  * @returns < 0 for failure, number of additions to roots for success.
00098  */
00099 int
00100 SyncAddName(struct SyncBaseStruct *base, struct ccn_charbuf *name, ccnr_accession item);
00101 
00102 /**
00103  * Creates a new slice from a full name.
00104  * The name must start with base->priv->sliceCmdPrefix.
00105  * @returns < 0 if an error occured, otherwise the new root number.
00106  */
00107 int
00108 SyncHandleSlice(struct SyncBaseStruct *base, struct ccn_charbuf *name);
00109 
00110 /**
00111  * registers interests associated with the given root
00112  * these include %C1.S.RA (Root Advise) and %C1.S.NF (Node Fetch) interests
00113  * additional interests may be registered as the protocol evolves
00114  * @returns < 0 for error, >= 0 for success
00115  */
00116 int
00117 SyncRegisterInterests(struct SyncRootStruct *root);
00118 
00119 /**
00120  * send a root advise request for the given root
00121  * only one at a time may be outstanding
00122  * @returns < 0 for error, >= 0 for OK
00123  */
00124 int
00125 SyncSendRootAdviseInterest(struct SyncRootStruct *root);
00126 
00127 /**
00128  * updates the root with the current root->namesToAdd
00129  * @returns < 0 for error, >= 0 for OK
00130  */
00131 int
00132 SyncUpdateRoot(struct SyncRootStruct *root);
00133 
00134 /**
00135  * initiates a compare action with the given remote hash
00136  * @returns < 0 for error, >= 0 for OK
00137  */
00138 int
00139 SyncStartCompareAction(struct SyncRootStruct *root, struct ccn_charbuf *hashR);
00140 
00141 #endif

Generated on Thu Feb 16 00:44:01 2012 for Content-Centric Networking in C by  doxygen 1.5.6