72 #include <sys/types.h> 125 Octstr *datagram, *cliaddr;
149 error(errno,
"Failed to receive an UDP");
161 warning(0,
"UDP: Discarding packet from %s, IP is denied.",
165 debug(
"bb.udp", 0,
"datagram received");
172 msg->wdp_datagram.user_data = datagram;
196 msg->wdp_datagram.destination_port);
199 error(0,
"WDP/UDP: could not send UDP datagram");
218 debug(
"bb.udp", 0,
"udp: sending message");
248 udpc = gw_malloc(
sizeof(
Udpc));
254 if (udpc->
addr == NULL) {
255 error(0,
"updc_create: could not resolve interface <%s>",
262 fl = fcntl(udpc->
fd, F_GETFL);
263 fcntl(udpc->
fd, F_SETFL, fl | O_NONBLOCK);
266 debug(
"bb.udp", 0,
"udpc_create: Bound to UDP <%s:%d>",
311 error(0,
"Failed to start UDP receiver/sender thread");
332 debug(
"bb.udp", 0,
"starting UDP sender/receiver module");
337 error(0,
"Missing wdp-interface-name variable, cannot start UDP");
346 allow_wtls = grp != NULL ? 1 : 0;
358 #ifdef HAVE_WTLS_OPENSSL 365 error(0,
"These is a 'wtls' group in configuration, but no WTLS support compiled in!");
388 Udpc *udpc, *def_udpc;
414 if (NULL != def_udpc) {
428 debug(
"bb.thread", 0,
"udp_shutdown: Starting avalanche");
443 debug(
"bb.udp", 0,
"udp_die: removing producers from udp-lists");
void error(int err, const char *fmt,...)
void info(int err, const char *fmt,...)
static int send_udp(int fd, Msg *msg)
gw_assert(wtls_machine->packet_to_send !=NULL)
Counter * incoming_wdp_counter
void gwlist_append(List *list, void *item)
void gwlist_produce(List *list, void *item)
void gwthread_join(long thread)
long gwlist_len(List *list)
int udp_get_port(Octstr *addr)
void * gwlist_get(List *list, long pos)
#define cfg_get(grp, varname)
int udp_outgoing_queue(void)
#define octstr_get_cstr(ostr)
static void udpc_destroy(Udpc *udpc)
unsigned long counter_increase(Counter *counter)
int is_allowed_ip(Octstr *allow_ip, Octstr *deny_ip, Octstr *ip)
Counter * outgoing_wdp_counter
void gwlist_unlock(List *list)
Octstr * octstr_imm(const char *cstr)
int udp_bind(int port, const char *source_addr)
void * gwlist_extract_first(List *list)
void gwlist_remove_producer(List *list)
static void udp_receiver(void *arg)
void msg_destroy(Msg *msg)
void warning(int err, const char *fmt,...)
void octstr_destroy(Octstr *ostr)
#define gwthread_create(func, arg)
#define octstr_create(cstr)
static int add_service(int port, char *interface_name)
void gwlist_lock(List *list)
static Udpc * udpc_create(int port, char *interface_name)
void * gwlist_consume(List *list)
int read_available(int fd, long wait_usec)
void debug(const char *place, int err, const char *fmt,...)
volatile sig_atomic_t bb_status
void gwthread_wakeup(long thread)
static volatile sig_atomic_t udp_running
int udp_sendto(int s, Octstr *datagram, Octstr *addr)
static Octstr * interface_name
CfgGroup * cfg_get_single_group(Cfg *cfg, Octstr *name)
void gwlist_add_producer(List *list)
List * octstr_split(const Octstr *os, const Octstr *sep)
static XMLRPCDocument * msg
static void udp_sender(void *arg)
int udp_recvfrom(int s, Octstr **datagram, Octstr **addr)
Octstr * udp_create_address(Octstr *host_or_ip, int port)
Octstr * udp_get_ip(Octstr *addr)
int octstr_compare(const Octstr *ostr1, const Octstr *ostr2)
void gwlist_destroy(List *list, gwlist_item_destructor_t *destructor)