key.h

Go to the documentation of this file.
00001 /*
00002 ** AUTHORS:
00003 ** Rama Alebouyeh (rama[at]cs.ucsb.edu)
00004 ** Matthew S Allen (msa[at]cs.ucsb.edu)
00005 */
00006 #ifndef _CHIMERA_KEY_H_
00007 #define _CHIMERA_KEY_H_
00008 
00009 #include <limits.h>
00010 #include <stdio.h>
00011 #include <openssl/evp.h>
00012 #include <string.h>
00013 
00014 typedef struct {
00015   unsigned long t[5];
00016   char keystr[64];     /* string representation of key in hex */
00017  } Key;
00018 
00019 #define KEY_SIZE 160
00020 #define BASE_B 4       /* Base representation of key digits */
00021 
00022 /* global variables!! that are set in key_init function */
00023 Key Key_Max;
00024 Key Key_Half;
00025 /* key_makehash: hashed, s
00026 ** assign sha1 hash of the string #s# to #hashed# */
00027 
00028 void key_makehash(void * logs, Key *hashed, char *s);
00029 
00030 
00031 /* key_init: 
00032 ** initializes Key_Max and Key_Half */
00033 
00034 void key_init();
00035 
00036 /* key_distance:k1,k2
00037 ** calculate the distance between k1 and k2 in the keyspace and assign that to #diff# */
00038 
00039 void key_distance(void * logs, Key *diff, Key k1, Key k2);
00040 
00041  
00042 /* key_between: test, left, right
00043 ** check to see if the value in #test# falls in the range from #left# clockwise
00044 ** around the ring to #right#. */
00045 
00046 int key_between(void * logs, Key test, Key left, Key right);
00047 
00048 
00049 /* key_midpoint: mid, key
00050 ** calculates the midpoint of the namespace from the #key#  */
00051 
00052 void key_midpoint(void * logs, Key *mid, Key key);
00053 
00054 
00055 /* key_index: mykey, key
00056 ** returns the lenght of the longest prefix match between #mykey# and #k# */
00057 
00058 int key_index(void * logs, Key mykey, Key k);
00059 
00060 void key_print(Key k);
00061 
00062 void key_to_str(char *str, Key k);
00063 void str_to_key(char *str, Key *k);
00064 
00065 /* key_assign: k1, k2
00066 ** copies value of #k2# to #k1# */
00067 
00068 void key_assign(Key *k1, Key k2);
00069 
00070 /* key_assign_ui: k1, ul
00071 ** copies #ul# to the least significant 32 bits of #k# */
00072 
00073 void key_assign_ui(Key *k,unsigned long ul);
00074 
00075 /* key_equal:k1, k2 
00076 ** return 1 if #k1#==#k2# 0 otherwise*/
00077 
00078 int key_equal(Key k1,Key k2);
00079 
00080 /* key_equal_ui:k1, ul
00081 ** return 1 if the least significat 32 bits of #k1#==#ul# 0 otherwise */
00082 
00083 int key_equal_ui(Key k, unsigned long ul);
00084 
00085 /*key_comp: k1, k2
00086 ** returns >0 if k1>k2, <0 if k1<k2, and 0 if k1==k2 */
00087 
00088 int key_comp(Key k1, Key k2);
00089 
00090 #endif /* _CHIMERA_KEY_H_ */

Generated on Sat Nov 12 16:43:13 2005 for Chimera by  doxygen 1.4.5