#include "tclink.h"#include <stdio.h>#include <memory.h>#include <errno.h>#include <string.h>#include <strings.h>#include <sys/time.h>#include <sys/types.h>#include <sys/socket.h>#include <netinet/in.h>#include <arpa/inet.h>#include <netdb.h>#include <unistd.h>#include <stdlib.h>#include <fcntl.h>#include <signal.h>#include <openssl/crypto.h>#include <openssl/x509.h>#include <openssl/pem.h>#include <openssl/ssl.h>#include <openssl/err.h>#include <openssl/rand.h>

Go to the source code of this file.
Classes | |
| struct | param_data |
| struct | _TCLinkCon |
Defines | |
| #define | OPENSSL_NO_KRB5 1 |
| #define | closesocket(x) close(x) |
| #define | DEFAULT_HOST "gateway2048.trustcommerce.com" |
| #define | TIMEOUT 40 |
| #define | TC_BUFF_MAX 16000 |
| #define | TC_LINE_MAX ((PARAM_MAX_LEN * 2) + 2) |
| #define | SAFE_COPY(d, s) safe_copy((d), (s), sizeof(d)); |
| #define | SAFE_APPEND(d, s) safe_append((d), (s), sizeof(d)); |
Typedefs | |
| typedef struct param_data | param |
| typedef struct _TCLinkCon | TCLinkCon |
Enumerations | |
| enum | { TC_CERT_SIZE = 952 } |
Functions | |
| static int | number (int min, int max) |
| void | safe_copy (char *dst, const char *src, int size) |
| void | safe_append (char *dst, const char *src, int size) |
| static void | AddRecvParam (TCLinkCon *c, const char *name, const char *value) |
| static int | AddRecvString (TCLinkCon *c, char *string) |
| static void | ClearSendList (TCLinkCon *c) |
| static void | ClearRecvList (TCLinkCon *c) |
| static int | BeginConnection (TCLinkCon *c, int host_ip) |
| static int | FinishConnection (TCLinkCon *c, int sd) |
| static int | CheckConnection (TCLinkCon *c, int *sd, int num_sd) |
| void | do_SSL_randomize () |
| static int | Connect (TCLinkCon *c, int host_hash) |
| static int | Send (TCLinkCon *c, const char *string) |
| static int | ReadLine (TCLinkCon *c, char *buffer, char *destbuf) |
| static int | Close (TCLinkCon *c) |
| TCLinkHandle | TCLinkCreate () |
| void | TCLinkPushParam (TCLinkHandle handle, const char *name, const char *value) |
| void | TCLinkSend (TCLinkHandle handle) |
| char * | TCLinkGetResponse (TCLinkHandle handle, const char *name, char *value) |
| static void | stuff_string (char *buf, int *len, int size, const char *add) |
| char * | TCLinkGetEntireResponse (TCLinkHandle handle, char *buf, int size) |
| void | TCLinkDestroy (TCLinkHandle handle) |
| char * | TCLinkGetVersion (char *buf) |
Variables | |
| char * | tclink_version = TCLINK_VERSION |
| char * | tclink_host = DEFAULT_HOST |
| int | tclink_port = 443 |
| unsigned char | cert_data [TC_CERT_SIZE] |
| #define SAFE_APPEND | ( | d, | |||
| s | ) | safe_append((d), (s), sizeof(d)); |
| typedef struct param_data param |
| typedef struct _TCLinkCon TCLinkCon |
| static void AddRecvParam | ( | TCLinkCon * | c, | |
| const char * | name, | |||
| const char * | value | |||
| ) | [static] |
Definition at line 200 of file tclink.c.
References param_data::name, param_data::next, _TCLinkCon::recv_param_list, and param_data::value.
| static int AddRecvString | ( | TCLinkCon * | c, | |
| char * | string | |||
| ) | [static] |
| static int BeginConnection | ( | TCLinkCon * | c, | |
| int | host_ip | |||
| ) | [static] |
| static int CheckConnection | ( | TCLinkCon * | c, | |
| int * | sd, | |||
| int | num_sd | |||
| ) | [static] |
| static void ClearRecvList | ( | TCLinkCon * | c | ) | [static] |
Definition at line 243 of file tclink.c.
References param_data::name, param_data::next, _TCLinkCon::recv_param_list, and param_data::value.
| static void ClearSendList | ( | TCLinkCon * | c | ) | [static] |
Definition at line 228 of file tclink.c.
References param_data::name, param_data::next, _TCLinkCon::send_param_list, _TCLinkCon::send_param_tail, and param_data::value.
| static int Close | ( | TCLinkCon * | c | ) | [static] |
Definition at line 684 of file tclink.c.
References _TCLinkCon::ctx, _TCLinkCon::sd, and _TCLinkCon::ssl.
| static int Connect | ( | TCLinkCon * | c, | |
| int | host_hash | |||
| ) | [static] |
Definition at line 477 of file tclink.c.
References BeginConnection(), cert_data, CheckConnection(), _TCLinkCon::ctx, _TCLinkCon::dns, do_SSL_randomize(), _TCLinkCon::ip, _TCLinkCon::is_error, _TCLinkCon::meth, _TCLinkCon::num_ips, number(), _TCLinkCon::pass, _TCLinkCon::sd, _TCLinkCon::start_time, _TCLinkCon::tc_cert, TC_CERT_SIZE, tclink_host, and TIMEOUT.
| static int FinishConnection | ( | TCLinkCon * | c, | |
| int | sd | |||
| ) | [static] |
Definition at line 294 of file tclink.c.
References _TCLinkCon::ctx, _TCLinkCon::ssl, and _TCLinkCon::tc_cert.
| static int ReadLine | ( | TCLinkCon * | c, | |
| char * | buffer, | |||
| char * | destbuf | |||
| ) | [static] |
Definition at line 635 of file tclink.c.
References _TCLinkCon::is_error, safe_copy(), _TCLinkCon::sd, _TCLinkCon::ssl, TC_BUFF_MAX, TC_LINE_MAX, and TIMEOUT.
| void safe_append | ( | char * | dst, | |
| const char * | src, | |||
| int | size | |||
| ) |
| static int Send | ( | TCLinkCon * | c, | |
| const char * | string | |||
| ) | [static] |
| static void stuff_string | ( | char * | buf, | |
| int * | len, | |||
| int | size, | |||
| const char * | add | |||
| ) | [static] |
| TCLinkHandle TCLinkCreate | ( | ) |
Definition at line 713 of file tclink.c.
References _TCLinkCon::ctx, _TCLinkCon::dns, _TCLinkCon::ip, _TCLinkCon::is_error, _TCLinkCon::meth, _TCLinkCon::num_ips, _TCLinkCon::pass, _TCLinkCon::recv_param_list, _TCLinkCon::sd, _TCLinkCon::send_param_list, _TCLinkCon::send_param_tail, _TCLinkCon::ssl, _TCLinkCon::start_time, _TCLinkCon::tc_cert, and TCLinkHandle.
Referenced by main(), and ocTCLink::ocTCLink().
| void TCLinkDestroy | ( | TCLinkHandle | handle | ) |
Definition at line 902 of file tclink.c.
References ClearRecvList(), ClearSendList(), Close(), _TCLinkCon::ip, and _TCLinkCon::tc_cert.
Referenced by ocTCLink::Close().
| char* TCLinkGetEntireResponse | ( | TCLinkHandle | handle, | |
| char * | buf, | |||
| int | size | |||
| ) |
Definition at line 886 of file tclink.c.
References param_data::name, param_data::next, _TCLinkCon::recv_param_list, stuff_string(), and param_data::value.
Referenced by main(), and ocTCLink::setTransactionInfo().
| char* TCLinkGetResponse | ( | TCLinkHandle | handle, | |
| const char * | name, | |||
| char * | value | |||
| ) |
Definition at line 860 of file tclink.c.
References param_data::name, param_data::next, PARAM_MAX_LEN, _TCLinkCon::recv_param_list, safe_copy(), and param_data::value.
Referenced by main(), and ocTCLink::Send().
| char* TCLinkGetVersion | ( | char * | buf | ) |
| void TCLinkPushParam | ( | TCLinkHandle | handle, | |
| const char * | name, | |||
| const char * | value | |||
| ) |
Definition at line 738 of file tclink.c.
References param_data::name, param_data::next, _TCLinkCon::send_param_list, _TCLinkCon::send_param_tail, and param_data::value.
Referenced by main(), and ocTCLink::PushParam().
| void TCLinkSend | ( | TCLinkHandle | handle | ) |
Definition at line 767 of file tclink.c.
References AddRecvParam(), AddRecvString(), ClearRecvList(), Close(), Connect(), _TCLinkCon::dns, _TCLinkCon::is_error, LOG_TIME(), param_data::name, param_data::next, _TCLinkCon::pass, ReadLine(), SAFE_APPEND, SAFE_COPY, Send(), _TCLinkCon::send_param_list, _TCLinkCon::send_param_tail, _TCLinkCon::start_time, TC_BUFF_MAX, TC_LINE_MAX, tclink_version, and param_data::value.
Referenced by main(), and ocTCLink::Send().
| char* tclink_host = DEFAULT_HOST |
| int tclink_port = 443 |
| char* tclink_version = TCLINK_VERSION |
1.5.5