File: stun.h

package info (click to toggle)
rtpengine 13.5.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,676 kB
  • sloc: ansic: 86,764; perl: 59,422; python: 3,193; sh: 1,030; makefile: 693; asm: 211
file content (55 lines) | stat: -rw-r--r-- 1,052 bytes parent folder | download | duplicates (2)
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
#ifndef _STUN_H_
#define _STUN_H_

#include <string.h>
#include <arpa/inet.h>
#include <sys/types.h>

#include "compat.h"
#include "call.h"
#include "str.h"
#include "socket.h"

#define STUN_COOKIE 0x2112A442UL

struct stun_attrs {
	str username;
	char *msg_integrity_attr;
	str msg_integrity;
	uint32_t priority;
	char *fingerprint_attr;
	uint32_t fingerprint;
	uint64_t tiebreaker;
	endpoint_t mapped;
	unsigned int error_code;
	unsigned int use:1,
	             controlled:1,
	             controlling:1;
};


INLINE int is_stun(const str *s) {
	const unsigned char *b = (const void *) s->s;
	const uint32_t *u;

	if (s->len < 20)
		return 0;
	if ((b[0] & 0xc0) != 0x00)
		return 0;
	if ((b[3] & 0x3) != 0x0)
		return 0;
	u = (const void *) &b[4];
	if (*u != htonl(STUN_COOKIE))
		return 0;

	return 1;
}


int stun(const str *, stream_fd *, const endpoint_t *);

int stun_binding_request(const endpoint_t *dst, uint32_t transaction[3], str *pwd,
		str ufrags[2], int controlling, uint64_t tiebreaker, uint32_t priority,
		socket_t *, int);

#endif