00001 /** 00002 * @file ccnr_sync.h 00003 * 00004 * Part of ccnr - CCNx Repository Daemon. 00005 * 00006 * Copyright (C) 2011 Palo Alto Research Center, Inc. 00007 * 00008 * This work is free software; you can redistribute it and/or modify it under 00009 * the terms of the GNU General Public License version 2 as published by the 00010 * Free Software Foundation. 00011 * This work is distributed in the hope that it will be useful, but WITHOUT ANY 00012 * WARRANTY; without even the implied warranty of MERCHANTABILITY or 00013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00014 * for more details. You should have received a copy of the GNU General Public 00015 * License along with this program; if not, write to the 00016 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 * Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef CCNR_SYNC_DEFINED 00021 #define CCNR_SYNC_DEFINED 00022 00023 #include "ccnr_private.h" 00024 00025 /** Notify repo of starting point for new names to be passed to sync. 00026 * Use item = 0 as the initial value. 00027 * Following a call to r_sync_notify_after, the repository will call 00028 * SyncNotifyContent(struct SyncBaseStruct *, 00029 * int enumeration, 00030 * ccnr_accession item, 00031 * struct ccn_charbuf *name); 00032 * periodically while there are no un-notified objects. 00033 * enumeration is 0 for "time-based" notifications, or the value passed 00034 * in when the enumeration was started. This may not end up an int. 00035 * if the call is for an explicit enumeration, and there are no more 00036 * objects, name and content_comps will be NULL. 00037 * If SyncNotifyContent returns -1 then the active enumeration, or the 00038 * r_sync_notify_after() will be cancelled. 00039 */ 00040 void 00041 r_sync_notify_after(struct ccnr_handle *ccnr, ccnr_hwm item); 00042 00043 /** Request that a SyncNotifyContent call is made for each content object 00044 * matching the interest. 00045 * returns -1 for error, or an enumeration number which will also be passed 00046 * in the SyncNotifyContent 00047 */ 00048 int 00049 r_sync_enumerate(struct ccnr_handle *ccnr, struct ccn_charbuf *interest); 00050 00051 /** Look up a content object that is stored locally in the repository 00052 * based on the supplied interest. 00053 * appends the content object to the content_ccnb. 00054 * returns 0 for success, -1 for error. 00055 */ 00056 int 00057 r_sync_lookup(struct ccnr_handle *ccnr, struct ccn_charbuf *interest, 00058 struct ccn_charbuf *content_ccnb); 00059 00060 /** 00061 * Called when a content object is received by sync and needs to be 00062 * committed to stable storage by the repo. 00063 */ 00064 enum ccn_upcall_res 00065 r_sync_upcall_store(struct ccnr_handle *ccnr, enum ccn_upcall_kind kind, 00066 struct ccn_upcall_info *info); 00067 00068 /** 00069 * Called when a content object has been constructed locally by sync 00070 * and needs to be committed to stable storage by the repo. 00071 * returns 0 for success, -1 for error. 00072 */ 00073 00074 int 00075 r_sync_local_store(struct ccnr_handle *ccnr, struct ccn_charbuf *content_cb); 00076 00077 int 00078 r_sync_notify_content(struct ccnr_handle *ccnr, int e, struct content_entry *content); 00079 00080 00081 #endif