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
|
typedef enum {
REGISTER,
INVITE,
ACK,
BYE,
CANCEL,
OPTIONS,
NOTIFY,
SUBSCRIBE,
INFO,
MESSAGE,
UPDATE,
REFER
} SipMethod;
/* rfc3261 § 21 - Response Codes */
typedef enum {
/* 1xx Provisional */
Trying = 100,
Ringing = 180,
CallForwarded = 181,
Queued = 182,
SessionProgress = 183,
/* 2xx Successful */
OK = 200,
/* 3xx Redirection */
MultiChoice = 300,
MovedPerm = 301,
MovedTemp = 302,
UseProxy = 305,
AltService = 380,
/* 4xx Request Failure */
BadRequest = 400,
Unauthorized = 401,
PaymentRequired = 402,
Forbidden = 403,
NotFound = 404,
MethodNotAllowed = 405,
RequestNotAcceptable = 406,
ProxyAuthRequired = 407,
RequestTimeout = 408,
Gone = 410,
EntityTooLarge = 413,
URITooLong = 414,
UnsupportedMedia = 415,
UnsupportedURIScheme = 416,
BadExtension = 420,
ExtensionRequired = 421,
IntervalTooBrief = 423,
TempUnavailable = 480,
CallDoesNotExist = 481,
LoopDetected = 482,
TooManyHops = 483,
AddressIncomplete = 484,
Ambiguous = 485,
BusyHere = 486,
RequestTerminated = 487,
NotAcceptableHere = 488,
RequestPending = 491,
Undecipherable = 493,
/* 5xx Server Failure */
InternalError = 500,
NotImplemented = 501,
BadGateway = 502,
ServiceUnavailable = 503,
ServerTimeout = 504,
VersionNotSupported = 505,
MessageTooLarge = 513,
/* 6xx Global Failures */
BusyEverywhere = 600,
Decline = 603,
DoesNotExistAnywhere = 604,
NotAcceptable = 606,
} SipStatus;
typedef struct Hdr Hdr;
typedef struct Hdrtab Hdrtab;
typedef struct Sipmsg Sipmsg;
typedef struct Sip Sip;
struct Hdr
{
char *name;
char *value;
Hdr *next;
};
struct Hdrtab
{
Hdr *headers[13];
};
struct Sipmsg
{
Hdrtab;
char *version;
SipMethod method;
};
/* SIP UAC (see rfc3261 § 8.1, 12.1.2) */
struct Sip
{
int version;
NetConnInfo *nci;
int fd;
int (*reg)(Sip*, char*, char*);
};
extern int debug;
|