FreeCalypso > hg > themwi-system-sw
view mncc/gsm_call.c @ 116:3a1f0e13a3ac
sip-in call clearing: time comparison was reversed
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 28 Sep 2022 23:05:38 -0800 |
parents | 660126bd5f59 |
children |
line wrap: on
line source
/* * In this module we implement allocation, freeing and retrieval * of gsm_call structures. */ #include <sys/types.h> #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include <syslog.h> #include "struct.h" #include "gsm_call.h" struct gsm_call *call_list_head; static uint32_t mt_callref; struct gsm_call * find_gsm_callref(callref) uint32_t callref; { struct gsm_call *call; for (call = call_list_head; call; call = call->next) { if (call->gc_flag) continue; if (call->callref == callref) return call; } return 0; } struct gsm_call * find_socket_call(conn, ref) struct socket_conn *conn; uint32_t ref; { struct gsm_call *call; for (call = call_list_head; call; call = call->next) { if (call->gc_flag) continue; if (call->socket == conn && call->socket_ref == ref) return call; } return 0; } struct gsm_call * create_gsm_call(callref) uint32_t callref; { struct gsm_call *call; call = malloc(sizeof(struct gsm_call)); if (call) { bzero(call, sizeof(struct gsm_call)); call->callref = callref; call->next = call_list_head; call_list_head = call; } return call; } uint32_t alloc_mt_callref() { mt_callref++; if (mt_callref > 0x7FFFFFFF) mt_callref = 1; return mt_callref; } struct gsm_call * create_new_mt_call() { uint32_t callref; for (;;) { callref = alloc_mt_callref(); if (!find_gsm_callref(callref)) break; } syslog(LOG_DEBUG, "creating new MT callref 0x%x", callref); return create_gsm_call(callref); } gc_call_list() { struct gsm_call *call, **cp; for (cp = &call_list_head; call = *cp; ) { if (call->gc_flag) { *cp = call->next; free(call); continue; } cp = &call->next; } }