| 1 | #ifndef SH_TOOLS_H | 
|---|
| 2 | #define SH_TOOLS_H | 
|---|
| 3 |  | 
|---|
| 4 | #define SH_DO_WRITE 0 | 
|---|
| 5 | #define SH_DO_READ  1 | 
|---|
| 6 |  | 
|---|
| 7 | /* protocols | 
|---|
| 8 | */ | 
|---|
| 9 | #define SH_PROTO_SRP (1 << 0) | 
|---|
| 10 | #define SH_PROTO_IVA (1 << 1) | 
|---|
| 11 | #define SH_PROTO_MSG (1 << 2) | 
|---|
| 12 | #define SH_PROTO_BIG (1 << 3) | 
|---|
| 13 | #define SH_PROTO_END (1 << 4) | 
|---|
| 14 | #define SH_PROTO_EN1 (1 << 5) | 
|---|
| 15 | #define SH_PROTO_EN2 (1 << 6) | 
|---|
| 16 | #define SH_PROTO_ENC (SH_PROTO_EN1|SH_PROTO_EN2) | 
|---|
| 17 | #define SH_MASK_ENC (SH_PROTO_ENC|SH_PROTO_EN2) | 
|---|
| 18 |  | 
|---|
| 19 | #ifdef SH_ENCRYPT | 
|---|
| 20 | /* returns pointer to errbuf | 
|---|
| 21 | */ | 
|---|
| 22 | char * errorExplain (int err_num, char * errbuf, size_t len); | 
|---|
| 23 | #endif | 
|---|
| 24 |  | 
|---|
| 25 | /* Returns non-zero if interface exists | 
|---|
| 26 | */ | 
|---|
| 27 | int sh_tools_iface_is_present(char *str); | 
|---|
| 28 |  | 
|---|
| 29 | /* returns allocated buffer | 
|---|
| 30 | */ | 
|---|
| 31 | char * sh_tools_safe_name(const char * str, int flag); | 
|---|
| 32 |  | 
|---|
| 33 | int connect_port (char * address, int port, | 
|---|
| 34 | char * ecall, int * errnum, char * errmsg, int errsiz); | 
|---|
| 35 | int connect_port_2 (char * address1, char * address2, int port, | 
|---|
| 36 | char * ecall, int * errnum, char * errmsg, int errsiz); | 
|---|
| 37 | void delete_cache(void); | 
|---|
| 38 |  | 
|---|
| 39 | /* returns pointer to errbuf | 
|---|
| 40 | */ | 
|---|
| 41 | char * sh_tools_errmessage (int tellme, char * errbuf, size_t len); | 
|---|
| 42 |  | 
|---|
| 43 |  | 
|---|
| 44 | void   sh_tools_show_header (unsigned char * head, char sign); | 
|---|
| 45 |  | 
|---|
| 46 | #if defined (SH_WITH_SERVER) | 
|---|
| 47 |  | 
|---|
| 48 | unsigned char sh_tools_probe_store(unsigned char protocol, int * probe_flag); | 
|---|
| 49 |  | 
|---|
| 50 | int get_open_max (void); | 
|---|
| 51 |  | 
|---|
| 52 | void put_header (/*@out@*/unsigned char * head, const int protocol, | 
|---|
| 53 | unsigned long * length, char * u); | 
|---|
| 54 |  | 
|---|
| 55 | int check_request_s (char * have, char * need, char * clt); | 
|---|
| 56 | int check_request_nerr (char * have, char * need); | 
|---|
| 57 |  | 
|---|
| 58 | /* returns allocated buffer | 
|---|
| 59 | */ | 
|---|
| 60 | char * hash_me (char * key, char * buf,   int buflen); | 
|---|
| 61 | int sh_tools_hash_vfy(char * key, char * buf, int buflen); | 
|---|
| 62 |  | 
|---|
| 63 | /* returns allocated buffer | 
|---|
| 64 | */ | 
|---|
| 65 | char * get_client_conf_file (const char * peer, unsigned long * length); | 
|---|
| 66 |  | 
|---|
| 67 | /* returns allocated buffer | 
|---|
| 68 | */ | 
|---|
| 69 | char * get_client_data_file (const char * peer, unsigned long * length); | 
|---|
| 70 |  | 
|---|
| 71 | /* returns allocated buffer | 
|---|
| 72 | */ | 
|---|
| 73 | char * get_client_uuid_file (const char * peer, unsigned long * length, const char * uuid); | 
|---|
| 74 | #endif | 
|---|
| 75 |  | 
|---|
| 76 |  | 
|---|
| 77 | unsigned long read_port (int sockfd, char *buf, unsigned long nbytes, | 
|---|
| 78 | int * w_error, int timeout); | 
|---|
| 79 |  | 
|---|
| 80 |  | 
|---|
| 81 | #if defined (SH_WITH_CLIENT) || defined(SH_WITH_SERVER) | 
|---|
| 82 |  | 
|---|
| 83 | void sh_tools_probe_reset(); | 
|---|
| 84 |  | 
|---|
| 85 | unsigned long write_port (int sockfd, char *buf, unsigned long nbytes, | 
|---|
| 86 | int * w_error, int timeout); | 
|---|
| 87 |  | 
|---|
| 88 | int check_request (char * have, char * need); | 
|---|
| 89 | int check_request_nerr (char * have, char * need); | 
|---|
| 90 |  | 
|---|
| 91 | void get_header (unsigned char * head, unsigned long * bytes, char * u); | 
|---|
| 92 | void put_header (unsigned char * head, int protocol, | 
|---|
| 93 | unsigned long * length, char * u); | 
|---|
| 94 |  | 
|---|
| 95 | /* | 
|---|
| 96 | SL_TICKET open_tmp (void); | 
|---|
| 97 | int close_tmp (SL_TICKET fd); | 
|---|
| 98 | int rewind_tmp (SL_TICKET fd); | 
|---|
| 99 | */ | 
|---|
| 100 |  | 
|---|
| 101 | void sh_tools_server_cmd(const char * srvcmd); | 
|---|
| 102 |  | 
|---|
| 103 | int hash_check(char * key, | 
|---|
| 104 | char * buf,   int buflen); | 
|---|
| 105 |  | 
|---|
| 106 | int sh_tools_hash_add(char * key, char * buf, int buflen); | 
|---|
| 107 | #endif | 
|---|
| 108 |  | 
|---|
| 109 | #if defined(SH_WITH_CLIENT) || defined(SH_WITH_SERVER) || defined(SH_STEALTH) || defined(WITH_GPG) || defined(WITH_PGP) | 
|---|
| 110 | SL_TICKET open_tmp (void); | 
|---|
| 111 | int close_tmp (SL_TICKET fd); | 
|---|
| 112 | int rewind_tmp (SL_TICKET fd); | 
|---|
| 113 | #endif | 
|---|
| 114 |  | 
|---|
| 115 | #endif | 
|---|