first commit

This commit is contained in:
wdp
2024-12-15 20:42:32 +08:00
commit 986b2fca12
586 changed files with 154149 additions and 0 deletions

View File

@@ -0,0 +1,91 @@
/***************************************************************************************
*
* IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
*
* By downloading, copying, installing or using the software you agree to this license.
* If you do not agree to this license, do not download, install,
* copy or use the software.
*
* Copyright (C) 2014-2022, Happytimesoft Corporation, all rights reserved.
*
* Redistribution and use in binary forms, with or without modification, are permitted.
*
* Unless required by applicable law or agreed to in writing, software distributed
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
****************************************************************************************/
#ifndef SIP_TRANS_H
#define SIP_TRANS_H
#include "sip_inc.h"
#include "ihash.h"
typedef struct sip_trans_node
{
int state; // Transaction status: 0-not initialized, 1-message has been sent,
// 2-response has been received, 4-failed to send/no response when timeout
SIP_MT mt; // message type
void * tx_msg; // Messages sent and retransmitted
char from[64];
char to[64];
char callid[128];
uint32 seq; // message seq
char hash_key[128]; // callid + from + to +seq
uint32 last_tx_time; // Last sending time (seconds of system startup)
uint32 state_timer_interval; // Timer interval
uint32 state_retx_count; // Timer retransmission count
uint32 state_retx_max_times; // Maximum number of timer retransmissions
void * p_wait_sig; // Waiting process/thread signal
int rly_status; // 200,404,...
char rly_ctx_type[64]; // Content-Type: text/plain...
char * rly_ctx_text;
int rly_len;
} STRANSN;
typedef struct sip_trans_class
{
uint32 trans_num;
IHASHCTX * trans_hash; // Transaction node HASH
PPSN_CTX * trans_fl; // Transaction node free list
PPSN_CTX * trans_ul; // Transaction node in use list
} STRANS;
#ifdef __cplusplus
extern "C" {
#endif
STRANSN * sip_trans_get_idle(STRANS * thiz, BOOL b_sig);
BOOL sip_trans_set_msg(STRANSN * p_trans, void * p_msg);
void sip_trans_set_idle(STRANS * thiz, STRANSN * p_trans);
void sip_trans_free_used(STRANS * thiz, STRANSN * p_trans);
STRANSN * sip_trans_lookup_start(STRANS * thiz);
STRANSN * sip_trans_lookup_next(STRANS * thiz, STRANSN * p_trans);
void sip_trans_lookup_stop(STRANS * thiz);
uint32 sip_trans_get_index(STRANS * thiz, STRANSN * p_trans);
STRANSN * sip_trans_get_by_index(STRANS * thiz, uint32 index);
void sip_trans_hash_add(STRANS * thiz, STRANSN * p_trans);
void sip_trans_hash_del(STRANS * thiz, STRANSN * p_trans);
STRANSN * sip_trans_hash_find(STRANS * thiz, const char * hash_key);
void sip_trans_timer(STRANS * thiz, uint32 cur_t);
STRANSN * sip_trans_rly_find(STRANS * thiz, const char * callid, const char * from, const char * to, uint32 seq);
int sip_trans_wait(STRANSN * p_trans, int ms);
void sip_trans_init(STRANS * thiz, int num);
void sip_trans_uninit(STRANS * thiz);
#ifdef __cplusplus
}
#endif
#endif