1 /** 2 * dmq module - distributed message queue 3 * 4 * Copyright (C) 2011 Bucur Marius - Ovidiu 5 * 6 * This file is part of Kamailio, a free SIP server. 7 * 8 * Kamailio is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 2 of the License, or 11 * (at your option) any later version 12 * 13 * Kamailio is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 */ 22 23 24 #ifndef _DMQNODE_H_ 25 #define _DMQNODE_H_ 26 27 #include <string.h> 28 #include <stdlib.h> 29 #include "../../core/lock_ops.h" 30 #include "../../core/str.h" 31 #include "../../core/mem/mem.h" 32 #include "../../core/mem/shm_mem.h" 33 #include "../../core/parser/parse_uri.h" 34 #include "../../core/parser/parse_param.h" 35 36 #define NBODY_LEN 1024 37 #define DMQ_NODE_ACTIVE 1 << 1 38 #define DMQ_NODE_TIMEOUT 1 << 2 39 #define DMQ_NODE_DISABLED 1 << 3 40 #define DMQ_NODE_PENDING 1 << 4 41 42 typedef struct dmq_node 43 { 44 int local; /* local type set means the dmq dmqnode == self */ 45 str orig_uri; /* original uri string - e.g. sip:127.0.0.1:5060;passive=true */ 46 struct sip_uri uri; /* parsed uri string */ 47 struct ip_addr ip_address; /* resolved IP address */ 48 int status; /* reserved - maybe something like active,timeout,disabled */ 49 int last_notification; /* last notificatino receied from the node */ 50 struct dmq_node *next; /* pointer to the next struct dmq_node */ 51 } dmq_node_t; 52 53 typedef struct dmq_node_list 54 { 55 gen_lock_t 56 lock; /* lock for the list - must acquire before manipulating it */ 57 struct dmq_node *nodes; /* the nodes in the list */ 58 int count; /* the number of nodes in the list */ 59 } dmq_node_list_t; 60 61 extern str dmq_node_status_str; 62 extern dmq_node_list_t *dmq_node_list; 63 64 dmq_node_list_t *init_dmq_node_list(); 65 dmq_node_t *build_dmq_node(str *uri, int shm); 66 int update_node_list(dmq_node_list_t *remote_list); 67 dmq_node_t *add_dmq_node(dmq_node_list_t *list, str *uri); 68 dmq_node_t *find_dmq_node(dmq_node_list_t *list, dmq_node_t *node); 69 dmq_node_t *find_dmq_node_uri(dmq_node_list_t *list, str *uri); 70 dmq_node_t *find_dmq_node_uri2(str *uri); 71 int del_dmq_node(dmq_node_list_t *list, dmq_node_t *node); 72 int cmp_dmq_node(dmq_node_t *node, dmq_node_t *cmpnode); 73 int update_dmq_node_status(dmq_node_list_t *list, dmq_node_t *node, int status); 74 dmq_node_t *shm_dup_node(dmq_node_t *node); 75 void destroy_dmq_node(dmq_node_t *node, int shm); 76 void shm_free_node(dmq_node_t *node); 77 void pkg_free_node(dmq_node_t *node); 78 int set_dmq_node_params(dmq_node_t *node, param_t *params); 79 80 str *dmq_get_status_str(int status); 81 int build_node_str(dmq_node_t *node, char *buf, int buflen); 82 83 extern dmq_node_t *dmq_self_node; 84 extern dmq_node_t *dmq_notification_node; 85 86 #endif 87