diff options
Diffstat (limited to 'toxmsi/toxmsi_header.h')
-rw-r--r-- | toxmsi/toxmsi_header.h | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/toxmsi/toxmsi_header.h b/toxmsi/toxmsi_header.h new file mode 100644 index 00000000..599fafa3 --- /dev/null +++ b/toxmsi/toxmsi_header.h | |||
@@ -0,0 +1,99 @@ | |||
1 | #ifndef _MSI_HEADER_ | ||
2 | #define _MSI_HEADER_ | ||
3 | |||
4 | /* Basic format of the unparsed header string | ||
5 | * ( No spaces in field allowed ) | ||
6 | * Version 0.1.1\n\r | ||
7 | * Request INVITE\n\r | ||
8 | * Response\n\r | ||
9 | * Friend-id ( from ip )\n\r | ||
10 | * Call-type AUDIO\n\r | ||
11 | * User-agent phone-v.1.0.0\n\r | ||
12 | */ | ||
13 | |||
14 | |||
15 | /* define raw header terminator */ | ||
16 | static const char* _RAW_TERMINATOR = "\n\r"; | ||
17 | |||
18 | /* define string formats for the identifiers */ | ||
19 | #define _VERSION_FIELD "Version" | ||
20 | #define _REQUEST_FIELD "Request" | ||
21 | #define _RESPONSE_FIELD "Response" | ||
22 | #define _FRIENDID_FIELD "Friend-id" | ||
23 | #define _CALLTYPE_FIELD "Call-type" | ||
24 | #define _USERAGENT_FIELD "User-agent" | ||
25 | #define _INFO_FIELD "INFO" | ||
26 | #define _REASON_FIELD "Reason" | ||
27 | #define _CALL_ID_FIELD "Call-id" | ||
28 | |||
29 | #define HEADER_VALUES \ | ||
30 | /*uint8_t* _header_field */ \ | ||
31 | uint8_t* _header_value; | ||
32 | |||
33 | typedef struct msi_header_s { /* raw header list */ | ||
34 | uint8_t* _header_field; | ||
35 | uint8_t* _header_value; | ||
36 | |||
37 | struct msi_header_s* next; | ||
38 | |||
39 | } msi_header_t; | ||
40 | |||
41 | |||
42 | |||
43 | typedef struct msi_header_version_s { /* Defines our version */ | ||
44 | HEADER_VALUES | ||
45 | |||
46 | } msi_header_version_t; | ||
47 | |||
48 | typedef struct msi_header_request_s { /* Defines our request */ | ||
49 | HEADER_VALUES | ||
50 | |||
51 | } msi_header_request_t; | ||
52 | |||
53 | typedef struct msi_header_response_s { /* Defines our response */ | ||
54 | HEADER_VALUES | ||
55 | |||
56 | } msi_header_response_t; | ||
57 | |||
58 | typedef struct msi_header_friendid_s { /* Defines source that sent the message */ | ||
59 | HEADER_VALUES | ||
60 | |||
61 | } msi_header_friendid_t; | ||
62 | |||
63 | typedef struct msi_header_call_type_s { /* Defines the type of the call */ | ||
64 | HEADER_VALUES | ||
65 | |||
66 | } msi_header_call_type_t; | ||
67 | |||
68 | typedef struct msi_header_user_agent_s { /* Defines the device of the participant */ | ||
69 | HEADER_VALUES | ||
70 | |||
71 | } msi_header_user_agent_t; | ||
72 | |||
73 | |||
74 | typedef struct msi_header_call_id_s { /* Call id that is used to identify the call */ | ||
75 | HEADER_VALUES | ||
76 | |||
77 | } msi_header_call_id_t; | ||
78 | |||
79 | typedef struct msi_header_info_s { /* Defines informational message header */ | ||
80 | HEADER_VALUES | ||
81 | |||
82 | } msi_header_info_t; | ||
83 | |||
84 | typedef struct msi_header_reason_s { /* Defines reason mostly for error messages */ | ||
85 | HEADER_VALUES | ||
86 | |||
87 | } msi_header_reason_t; | ||
88 | |||
89 | struct msi_msg_s; | ||
90 | |||
91 | /* | ||
92 | * Parses the header list to header types | ||
93 | */ | ||
94 | int msi_parse_headers ( struct msi_msg_s* _msg ); | ||
95 | |||
96 | /* Make sure it's null terminated */ | ||
97 | msi_header_t* msi_parse_raw_data ( const uint8_t* _data ); | ||
98 | |||
99 | #endif /* _MSI_HEADER_ */ | ||