Mercurial > pidgin
comparison libpurple/protocols/msn/p2p.h @ 31558:ce968e115c95
propagate from branch 'im.pidgin.cpw.masca.p2p' (head 33ca865dacb9e5bcf763d06f6a42cbaca337cc64)
to branch 'im.pidgin.pidgin' (head 92f47f4e8b0cbb107fd97e1ab814d1cedbf109ad)
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Fri, 06 May 2011 06:25:14 +0000 |
parents | f021d93a1f9b b8e076d51817 |
children | 23f2c4dfc93d |
comparison
equal
deleted
inserted
replaced
31557:f021d93a1f9b | 31558:ce968e115c95 |
---|---|
43 guint64 ack_size; | 43 guint64 ack_size; |
44 /* guint8 body[1]; */ | 44 /* guint8 body[1]; */ |
45 } MsnP2PHeader; | 45 } MsnP2PHeader; |
46 #define P2P_PACKET_HEADER_SIZE (6 * 4 + 3 * 8) | 46 #define P2P_PACKET_HEADER_SIZE (6 * 4 + 3 * 8) |
47 | 47 |
48 /* Used for DCs to store nonces */ | |
49 #define P2P_HEADER_ACK_ID_OFFSET (2*4 + 2*8 + 2*4) | |
50 | |
51 typedef struct { | 48 typedef struct { |
52 guint8 header_len; | 49 guint8 header_len; |
53 guint8 opcode; | 50 guint8 opcode; |
54 guint16 message_len; | 51 guint16 message_len; |
55 guint32 base_id; | 52 guint32 base_id; |
56 GSList *tlv; | 53 GSList *header_tlv; |
57 char *data; | 54 guint8 data_header_len; |
55 guint8 data_tf; | |
56 guint16 package_number; | |
57 guint32 session_id; | |
58 GSList *data_tlv; | |
59 /* guint8 body[1]; */ | |
58 } MsnP2Pv2Header; | 60 } MsnP2Pv2Header; |
59 | 61 |
60 typedef struct { | 62 typedef struct { |
61 guint8 length; | 63 guint16 protocol_version; |
62 guint8 TF; /**< Type-First combination */ | 64 guint16 implementation_id; |
63 guint16 package_num; | 65 guint16 version; |
64 guint32 session; | 66 guint16 reserved; |
65 GSList *tlv; | 67 guint32 caps; |
66 char *data; | |
67 } MsnP2Pv2DataHeader; | |
68 | |
69 typedef struct { | |
70 guint16 protocol_version; | |
71 guint16 implementation_id; | |
72 guint16 version; | |
73 guint16 reserved; | |
74 guint32 caps; | |
75 } PeerInfo; | 68 } PeerInfo; |
76 | 69 |
77 typedef enum | 70 typedef enum |
78 { | 71 { |
79 OP_NONE = 0x00, /**< None, Nothing required. */ | 72 TF_FIRST = 0x01, /**< The first package. */ |
80 OP_SYN = 0x01, /**< SYN, just like TCP. */ | 73 TF_MSNOBJ = 0x04, /**< Payload contains binary data for MsnObject. */ |
81 OP_RAK = 0x02 /**< Request for Ack. */ | 74 TF_FILE = 0x06 /**< Payload contains binary data. */ |
82 } OpCode; | |
83 | |
84 typedef enum | |
85 { | |
86 TF_FIRST = 0x01, /**< The first package. */ | |
87 TF_OBJ = 0x04, /**< Payload contains binary data for MsnObject. */ | |
88 TF_FILE = 0x06 /**< Payload contains binary data. */ | |
89 } TF; | 75 } TF; |
90 | 76 |
91 typedef enum | 77 typedef enum |
92 { | 78 { |
93 TLP_PEER_INFO = 0x01, /**< Client peer info */ | 79 TLP_PEER_INFO = 0x01, /**< Client peer info */ |
94 TLP_ACK = 0x02, /**< ACK */ | 80 TLP_ACK = 0x02, /**< ACK */ |
95 TLP_NAK = 0x03 /**< NAK */ | 81 TLP_NAK = 0x03 /**< NAK */ |
96 } TLP; | 82 } TLP; |
97 | 83 |
98 typedef enum | 84 typedef enum |
99 { | 85 { |
100 TLP_LEN_PEER_INFO = 12, | 86 TLP_LEN_PEER_INFO = 12, |
101 TLP_LEN_ACK = 4, | 87 TLP_LEN_ACK = 4, |
102 TLP_LEN_NAK = 4 | 88 TLP_LEN_NAK = 4 |
103 } TLPLength; | 89 } TLPLength; |
104 | 90 |
105 typedef enum | 91 typedef enum |
106 { | 92 { |
107 PI_PVER = 0x0200, | 93 PI_PVER = 0x0200, |
108 PI_IMP_ID = 0, | 94 PI_IMP_ID = 0, |
109 PI_VER = 0x0e00, | 95 PI_VER = 0x0e00, |
110 PI_RES = 0, | 96 PI_RES = 0, |
111 PI_CAPS = 0x0000010f | 97 PI_CAPS = 0x0000010f |
112 } PeerInfoVal; | 98 } PeerInfoVal; |
113 | |
114 | 99 |
115 #define DLP_REMAINING 0x01; /**< Indicates the remaining data to transfer.*/ | 100 #define DLP_REMAINING 0x01; /**< Indicates the remaining data to transfer.*/ |
116 #define DLP_REMAINING_LEN 8 | 101 #define DLP_REMAINING_LEN 8 |
117 | 102 |
118 typedef struct | 103 typedef struct |
119 { | 104 { |
120 guint32 value; | 105 guint32 value; |
121 } MsnP2PFooter; | 106 } MsnP2PFooter; |
122 #define P2P_PACKET_FOOTER_SIZE (1 * 4) | 107 #define P2P_PACKET_FOOTER_SIZE (1 * 4) |
108 | |
109 typedef enum | |
110 { | |
111 MSN_P2P_VERSION_ONE = 0, | |
112 MSN_P2P_VERSION_TWO = 1, | |
113 } MsnP2PVersion; | |
114 | |
115 typedef struct { | |
116 MsnP2PVersion version; | |
117 union { | |
118 MsnP2PHeader v1; | |
119 MsnP2Pv2Header v2; | |
120 } header; | |
121 MsnP2PFooter footer; | |
122 } MsnP2PInfo; | |
123 | 123 |
124 typedef enum | 124 typedef enum |
125 { | 125 { |
126 P2P_NO_FLAG = 0x0, /**< No flags specified */ | 126 P2P_NO_FLAG = 0x0, /**< No flags specified */ |
127 P2P_OUT_OF_ORDER = 0x1, /**< Chunk out-of-order */ | 127 P2P_OUT_OF_ORDER = 0x1, /**< Chunk out-of-order */ |
149 P2P_APPID_FILE = 0x2, /**< File transfer */ | 149 P2P_APPID_FILE = 0x2, /**< File transfer */ |
150 P2P_APPID_EMOTE = 0xB, /**< CustomEmoticon */ | 150 P2P_APPID_EMOTE = 0xB, /**< CustomEmoticon */ |
151 P2P_APPID_DISPLAY = 0xC /**< Display Image */ | 151 P2P_APPID_DISPLAY = 0xC /**< Display Image */ |
152 } MsnP2PAppId; | 152 } MsnP2PAppId; |
153 | 153 |
154 MsnP2PHeader * | 154 typedef enum |
155 msn_p2p_header_from_wire(const char *wire); | 155 { |
156 P2P_OPCODE_NONE = 0x00, | |
157 P2P_OPCODE_SYN = 0x01, | |
158 P2P_OPCODE_RAK = 0x02 | |
159 } MsnP2Pv2OpCode; | |
160 | |
161 MsnP2PInfo * | |
162 msn_p2p_info_new(MsnP2PVersion version); | |
163 | |
164 MsnP2PInfo * | |
165 msn_p2p_info_dup(MsnP2PInfo *info); | |
166 | |
167 void | |
168 msn_p2p_info_free(MsnP2PInfo *info); | |
169 | |
170 size_t | |
171 msn_p2p_header_from_wire(MsnP2PInfo *info, const char *wire, size_t max_len); | |
156 | 172 |
157 char * | 173 char * |
158 msn_p2p_header_to_wire(MsnP2PHeader *header); | 174 msn_p2p_header_to_wire(MsnP2PInfo *info, size_t *len); |
159 | 175 |
160 MsnP2PFooter * | 176 size_t |
161 msn_p2p_footer_from_wire(const char *wire); | 177 msn_p2p_footer_from_wire(MsnP2PInfo *info, const char *wire); |
162 | 178 |
163 char * | 179 char * |
164 msn_p2p_footer_to_wire(MsnP2PFooter *footer); | 180 msn_p2p_footer_to_wire(MsnP2PInfo *info, size_t *len); |
181 | |
182 void | |
183 msn_p2p_info_to_string(MsnP2PInfo *info, GString *str); | |
165 | 184 |
166 gboolean | 185 gboolean |
167 msn_p2p_msg_is_data(const MsnP2PHeaderFlag flags); | 186 msn_p2p_msg_is_data(const MsnP2PHeaderFlag flags); |
168 | 187 |
188 gboolean | |
189 msn_p2p_info_is_valid(MsnP2PInfo *info); | |
190 | |
191 gboolean | |
192 msn_p2p_info_is_final(MsnP2PInfo *info); | |
193 | |
194 guint32 | |
195 msn_p2p_info_get_session_id(MsnP2PInfo *info); | |
196 | |
197 guint32 | |
198 msn_p2p_info_get_id(MsnP2PInfo *info); | |
199 | |
200 guint64 | |
201 msn_p2p_info_get_offset(MsnP2PInfo *info); | |
202 | |
203 guint64 | |
204 msn_p2p_info_get_total_size(MsnP2PInfo *info); | |
205 | |
206 guint32 | |
207 msn_p2p_info_get_length(MsnP2PInfo *info); | |
208 | |
209 guint32 | |
210 msn_p2p_info_get_flags(MsnP2PInfo *info); | |
211 | |
212 guint32 | |
213 msn_p2p_info_get_ack_id(MsnP2PInfo *info); | |
214 | |
215 guint32 | |
216 msn_p2p_info_get_ack_sub_id(MsnP2PInfo *info); | |
217 | |
218 guint64 | |
219 msn_p2p_info_get_ack_size(MsnP2PInfo *info); | |
220 | |
221 guint32 | |
222 msn_p2p_info_get_app_id(MsnP2PInfo *info); | |
223 | |
224 void | |
225 msn_p2p_info_set_session_id(MsnP2PInfo *info, guint32 session_id); | |
226 | |
227 void | |
228 msn_p2p_info_set_id(MsnP2PInfo *info, guint32 id); | |
229 | |
230 void | |
231 msn_p2p_info_set_offset(MsnP2PInfo *info, guint64 offset); | |
232 | |
233 void | |
234 msn_p2p_info_set_total_size(MsnP2PInfo *info, guint64 total_size); | |
235 | |
236 void | |
237 msn_p2p_info_set_length(MsnP2PInfo *info, guint32 length); | |
238 | |
239 void | |
240 msn_p2p_info_set_flags(MsnP2PInfo *info, guint32 flags); | |
241 | |
242 void | |
243 msn_p2p_info_set_ack_id(MsnP2PInfo *info, guint32 ack_id); | |
244 | |
245 void | |
246 msn_p2p_info_set_ack_sub_id(MsnP2PInfo *info, guint32 ack_sub_id); | |
247 | |
248 void | |
249 msn_p2p_info_set_ack_size(MsnP2PInfo *info, guint64 ack_size); | |
250 | |
251 void | |
252 msn_p2p_info_set_app_id(MsnP2PInfo *info, guint32 app_id); | |
253 | |
169 #endif /* MSN_P2P_H */ | 254 #endif /* MSN_P2P_H */ |