summaryrefslogtreecommitdiff
path: root/orkaudio/audiocaptureplugins/voip/PacketHeaderDefs.h
blob: 4eec34d3d133fa15ace51feab8c765e2df0ad634 (plain)
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*
 * Oreka -- A media capture and retrieval platform
 * 
 * Copyright (C) 2005, orecx LLC
 *
 * http://www.orecx.com
 *
 * This program is free software, distributed under the terms of
 * the GNU General Public License.
 * Please refer to http://www.gnu.org/copyleft/gpl.html
 *
 */


#ifndef __PACKETHEADERDEFS_H__
#define __PACKETHEADERDEFS_H__

#include "ace/OS_NS_arpa_inet.h"
#include "StdString.h"


// Structure of Ethernet header
typedef struct
{
	unsigned char sourceMac[6];
	unsigned char destinationMac[6];
	unsigned short length;

} EthernetHeaderStruct;

// Structure of an internet header, naked of options, only valid for LITTLE ENDIAN
typedef struct
{
	unsigned char	ip_hl:4;		// Header length
	unsigned char	ip_v:4;			// IP protocol version
	unsigned char	ip_tos;			// Type of service 
	unsigned short	ip_len;			// Total length 
	unsigned short	ip_id;			// Identification
	unsigned short	ip_off;			// Fragment offset field
	unsigned char	ip_ttl;			// Time to live
	unsigned char	ip_p;			// Protocol
	unsigned short	ip_sum;			// Header checksum
	struct in_addr	ip_src;			// Source address
	struct in_addr	ip_dest;		// Destination address
} IpHeaderStruct;


// Strucutre of a TCP header, only valid for LITTLE ENDIAN
typedef struct
{
    unsigned short source;		// source port
    unsigned short dest;		// destination port
    unsigned long seq;			// sequence number
    unsigned long ack;			// acknowledgement id
    unsigned int x2:4;			// unused
    unsigned int off:4;			// data offset
    unsigned char flags;		// flags field
    unsigned short win;			// window size
    unsigned short sum;			// tcp checksum
    unsigned short urp;			// urgent pointer

} TcpHeaderStruct;
#define TCP_HEADER_LENGTH 20


// Structure of UDP header
typedef struct
{
	unsigned short source;			// Source port
	unsigned short dest;			// Destination port
	unsigned short len;				// UDP length
	unsigned short check;			// UDP Checksum
} UdpHeaderStruct;

#define RTP_PT_PCMU 0
#define RTP_PT_PCMA 8

// Structure of RTP header, only valid for little endian
typedef struct 
{
	unsigned short cc:4;		// CSRC count
	unsigned short x:1;			// header extension flag
	unsigned short p:1;			// padding flag
	unsigned short version:2;	// protocol version
	unsigned short pt:7;		// payload type
	unsigned short m:1;			// marker bit
	unsigned short seq;			// sequence number
	unsigned int ts;			// timestamp
	unsigned int ssrc;			// synchronization source
	//unsigned int csrc[1];		// optional CSRC list
} RtpHeaderStruct;

typedef struct
{
	unsigned long len;
	unsigned long reserved;
	unsigned long messageType;
} SkinnyHeaderStruct;

typedef struct
{
	SkinnyHeaderStruct header;
	unsigned long conferenceId;
	unsigned long passThruPartyId;
	struct in_addr remoteIpAddr;
	unsigned long remoteTcpPort;
	// and some more fields
} SkStartMediaTransmissionStruct;

typedef struct
{
	SkinnyHeaderStruct header;
	unsigned long conferenceId;
	unsigned long passThruPartyId;
} SkStopMediaTransmissionStruct;

typedef struct
{
	SkinnyHeaderStruct header;
	char callingPartyName[40];
	char callingParty[24];
	char calledPartyName[40];
	char calledParty[24];
	unsigned long lineInstance;
	unsigned long callId;
	unsigned long callType;
} SkCallInfoStruct;

typedef struct
{
	SkinnyHeaderStruct header;
	unsigned long unknown1;
	unsigned long callId;
	char unknown2[24];
	char parties[76];
} SkNewCallInfoStruct;

#define SKINNY_CTRL_PORT 2000
#define SKINNY_MIN_MESSAGE_SIZE 12
#define SKINNY_HEADER_LENGTH 8

#define SKINNY_MSG_UNKN "Unkn"
#define SKINNY_MSG_START_MEDIA_TRANSMISSION "StartMediaTransmission"
#define SKINNY_MSG_STOP_MEDIA_TRANSMISSION "StopMediaTransmission"
#define SKINNY_MSG_CALL_INFO_MESSAGE "CallInfoMessage"

#define SKINNY_CALL_TYPE_INBOUND 1
#define SKINNY_CALL_TYPE_OUTBOUND 2
#define SKINNY_CALL_TYPE_FORWARD 3

typedef enum
{
	SkStartMediaTransmission = 0x008A,
	SkStopMediaTransmission = 0x008B,
	SkCallInfoMessage = 0x008F,
	SkUnkn = 0x0
} SkinnyMessageEnum;
int SkinnyMessageToEnum(CStdString& msg);
CStdString SkinnyMessageToString(int msgEnum);

#endif