-
Notifications
You must be signed in to change notification settings - Fork 909
/
peer.h
75 lines (64 loc) · 2 KB
/
peer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/**
* dmq module - distributed message queue
*
* Copyright (C) 2011 Bucur Marius - Ovidiu
*
* This file is part of Kamailio, a free SIP server.
*
* Kamailio is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version
*
* Kamailio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _PEER_H_
#define _PEER_H_
#include <string.h>
#include <stdlib.h>
#include "dmqnode.h"
#include "../../core/lock_ops.h"
#include "../../core/str.h"
#include "../../core/mem/mem.h"
#include "../../core/mem/shm_mem.h"
#include "../../core/parser/msg_parser.h"
typedef struct peer_response
{
int resp_code;
str content_type;
str reason;
str body;
} peer_reponse_t;
typedef int (*peer_callback_t)(
struct sip_msg *, peer_reponse_t *resp, dmq_node_t *node);
typedef int (*init_callback_t)();
typedef struct dmq_peer
{
str peer_id;
str description;
peer_callback_t callback;
init_callback_t init_callback;
struct dmq_peer *next;
} dmq_peer_t;
typedef struct dmq_peer_list
{
gen_lock_t lock;
dmq_peer_t *peers;
int count;
} dmq_peer_list_t;
extern dmq_peer_list_t *dmq_peer_list;
dmq_peer_list_t *init_peer_list();
dmq_peer_t *search_peer_list(dmq_peer_list_t *peer_list, dmq_peer_t *peer);
typedef dmq_peer_t *(*register_dmq_peer_t)(dmq_peer_t *);
dmq_peer_t *add_peer(dmq_peer_list_t *peer_list, dmq_peer_t *peer);
dmq_peer_t *find_peer(str peer_id);
int empty_peer_callback(
struct sip_msg *msg, peer_reponse_t *resp, dmq_node_t *dmq_node);
#endif