00001 /***************************************************************************** 00002 * Copyright 2005 Daniel Ferullo * 00003 * * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); * 00005 * you may not use this file except in compliance with the License. * 00006 * You may obtain a copy of the License at * 00007 * * 00008 * http://www.apache.org/licenses/LICENSE-2.0 * 00009 * * 00010 * Unless required by applicable law or agreed to in writing, software * 00011 * distributed under the License is distributed on an "AS IS" BASIS, * 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 00013 * See the License for the specific language governing permissions and * 00014 * limitations under the License. * 00015 * * 00016 *****************************************************************************/ 00017 00018 /** 00019 * @file helperfsm_private.h 00020 * @author Daniel Ferullo (ferullo@cmu.edu) 00021 * 00022 * @brief prototypes for private helperfsm functions 00023 */ 00024 00025 #ifndef __HELPERFSM_PRIVATE_H__ 00026 #define __HELPERFSM_PRIVATE_H__ 00027 00028 /** 00029 * @brief the state to deal with a hello message 00030 * 00031 * @param list a pointer to the connection info list 00032 * @param item a pointer to the connection info item for this connection 00033 * 00034 * @return SUCCESS, errorcode on failure 00035 */ 00036 errorcode helper_fsm_hello(connlist_t *list, connlist_item_t *item); 00037 00038 /** 00039 * @brief handles the second connection state 00040 * 00041 * @param list a pointer to the connection list 00042 * @param item a pointer to the item for this connection 00043 * 00044 * @return SUCCESS, errorcode on failure 00045 */ 00046 errorcode helper_fsm_conn2(connlist_t *list, connlist_item_t *item); 00047 00048 /** 00049 * @brief handles sending a message with buddy info to peers 00050 * 00051 * @param list a pointer to the connection list 00052 * @param item a pointer to the item for this connection 00053 * 00054 * @return SUCCESS, errorcode on failure 00055 */ 00056 errorcode helper_fsm_buddy_alloc(connlist_t *list, connlist_item_t *item); 00057 00058 /** 00059 * @brief handles sending a message with buddy port to peers, or determing 00060 * port through birthday paradox 00061 * 00062 * @param list a pointer to the connection list 00063 * @param peer a pointer to the peer item for this connection 00064 * @param buddy a pointer to the buddy item for this connection 00065 * 00066 * @return SUCCESS, errorcode on failure 00067 */ 00068 errorcode helper_fsm_buddy_port(connlist_t *list, connlist_item_t *peer, 00069 connlist_item_t *buddy); 00070 00071 /** 00072 * @brief handles starting direct connection 00073 * 00074 * @param list a pointer to the connection list 00075 * @param peer a pointer to the peer item for this connection 00076 * @param buddy a pointer to the buddy item for this connection 00077 * 00078 * @return SUCCESS, errorcode on failure 00079 */ 00080 errorcode helper_fsm_start_direct_conn(connlist_t *list, connlist_item_t *peer, 00081 connlist_item_t *buddy); 00082 00083 /** 00084 * @brief final state to recieve the peer's goodbye message 00085 * 00086 * @param list a pointer to the connection list 00087 * @param peer a pointer to the peer item for this connection 00088 * @param buddy a pointer to the buddy item for this connection 00089 * 00090 * @return SUCCESS, errorcode on failure 00091 */ 00092 errorcode helper_fsm_goodbye(connlist_t *list, connlist_item_t *peer, 00093 connlist_item_t *buddy); 00094 00095 /** 00096 * @brief optional state that handles starting birthday paradox when the peer 00097 * is the random one. 00098 * 00099 * @param list a pointer to the connection list 00100 * @param peer a pointer to the peer item for this connection 00101 * @param buddy a pointer to the buddy item for this connection 00102 * 00103 * @return SUCCESS, errorcode on failure 00104 */ 00105 errorcode helper_fsm_start_peer_bday(connlist_t *list, connlist_item_t *peer, 00106 connlist_item_t *buddy); 00107 00108 00109 /** 00110 * @brief optional state that handles ending birthday paradox when the peer is 00111 * the random one. 00112 * 00113 * @param list a pointer to the connection list 00114 * @param peer a pointer to the peer item for this connection 00115 * @param buddy a pointer to the buddy item for this connection 00116 * 00117 * @return SUCCESS, errorcode on failure 00118 */ 00119 errorcode helper_fsm_end_peer_bday(connlist_t *list, connlist_item_t *peer, 00120 connlist_item_t *buddy); 00121 00122 /** 00123 * @brief optional state that handles starting birthday paradox when the buddy 00124 * is the random one. 00125 * 00126 * @param list a pointer to the connection list 00127 * @param peer a pointer to the peer item for this connection 00128 * @param buddy a pointer to the buddy item for this connection 00129 * 00130 * @return SUCCESS, errorcode on failure 00131 */ 00132 errorcode helper_fsm_start_buddy_bday(connlist_t *list, connlist_item_t *peer, 00133 connlist_item_t *buddy); 00134 00135 /** 00136 * @brief optional state that handles ending birthday paradox when the buddy is 00137 * the random one. 00138 * 00139 * @param list a pointer to the connection list 00140 * @param peer a pointer to the peer item for this connection 00141 * @param buddy a pointer to the buddy item for this connection 00142 * 00143 * @return SUCCESS, errorcode on failure 00144 */ 00145 errorcode helper_fsm_end_buddy_bday(connlist_t *list, connlist_item_t *peer, 00146 connlist_item_t *buddy); 00147 00148 #endif /* __HELPERFSM_PRIVATE_H__ */ 00149