forked from vt/sipsak-ipv6
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helper.h
93 lines (72 loc) · 2.29 KB
/
helper.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
* $Id: helper.h 397 2006-01-28 21:11:50Z calrissian $
*
* Copyright (C) 2002-2004 Fhg Fokus
* Copyright (C) 2004-2005 Nils Ohlmeier
*
* This file belongs to sipsak, a free sip testing tool.
*
* sipsak 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.
*
* sipsak 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.
*/
#ifndef SIPSAK_HELPER_H
#define SIPSAK_HELPER_H
#include "sipsak.h"
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#else
# include <time.h>
#endif
#ifdef HAVE_SYS_SELECT_H
# include <sys/socket.h>
#endif
#ifdef HAVE_CARES_H
# define HAVE_SRV
#else
# ifdef HAVE_RULI_H
# define HAVE_SRV
# endif
#endif
#ifdef HAVE_CARES_H
# define CARES_TYPE_A 1
# define CARES_TYPE_AAAA 28
# define CARES_TYPE_CNAME 5
# define CARES_TYPE_SRV 33
# define CARES_CLASS_C_IN 1
/* copied from ares_dns.h */
# define DNS__16BIT(p) (((p)[0] << 8) | (p)[1])
# define DNS_HEADER_ANCOUNT(h) DNS__16BIT((h) + 6)
# define DNS_HEADER_NSCOUNT(h) DNS__16BIT((h) + 8)
# define DNS_HEADER_ARCOUNT(h) DNS__16BIT((h) + 10)
# define DNS_RR_TYPE(r) DNS__16BIT(r)
# define DNS_RR_CLASS(r) DNS__16BIT((r) + 2)
# define DNS_RR_LEN(r) DNS__16BIT((r) + 8)
#endif
#ifdef HAVE_SRV
# define SRV_SIP_TLS "_sip._tls"
# define SRV_SIP_TCP "_sip._tcp"
# define SRV_SIP_UDP "_sip._udp"
#endif
int is_ip(char *str);
ip_addr_t getaddress(char *host);
ip_addr_t getsrvadr(char *host, int *port, unsigned int *transport);
void get_fqdn();
void replace_string(char *mes, char *search, char *replacement);
void replace_strings(char *mes, char *strings);
void insert_cr(char *mes);
void swap_buffers(char *fst, char *snd);
void swap_ptr(char **fst, char **snd);
void trash_random(char *message);
double deltaT(struct timeval *t1p, struct timeval *t2p);
int is_number(char *number);
int str_to_int(char *num);
int read_stdin(char *buf, int size, int ret);
void *str_alloc(size_t size);
#endif