This file is indexed.

/usr/include/msn/p2p.h is in libmsn-dev 4.2-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
#ifndef __msn_p2p_h__
#define __msn_p2p_h__
/*
 * p2p.h
 * libmsn
 *
 * Crated by Tiago Salem Herrmann on 08/2007.
 * Copyright (c) 2007 Tiago Salem Herrmann. All rights reserved
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */


#include <msn/connection.h>
#include <msn/authdata.h>
#include <msn/errorcodes.h>
#include <msn/buddy.h>
#include <msn/passport.h>
#include <msn/util.h>
#include <stdexcept>

#include <vector>
#include <fstream>
#include <iostream>

#include "libmsn_export.h"

namespace MSN
{
    class SwitchboardServerConnection;
    class FileTransferConnectionP2P;

    /** Manages all p2p communication. 
     */
    class LIBMSN_EXPORT P2P
    {
        public:
            P2P();
            virtual ~P2P();
            unsigned int rand_helper;
            enum {
                DIRECTION_SENDING = 0,
                DIRECTION_RECEIVING = 1
            };
            enum {
                STEP_INVITATION_SENT,
                STEP_ACK_INVITATION_SENT,
                STEP_200OK_SENT,
                STEP_200OK_ACK_SENT,
                STEP_603DECLINE_SENT,
                STEP_603DECLINE_ACK_SENT,
                STEP_DC_INVITE_SENT, // direct connection
                STEP_DC_INVITE_ACK_SENT, // direct connection
                STEP_DC_200OK_SENT,
                STEP_DC_200OKACK_SENT,
                STEP_DATA_PREPARATION_SENT,
                STEP_DATA_PREPARATION_ACK,
                STEP_SENDING,
                STEP_RECEIVING,
                STEP_RECEIVING_FINISHED,
                STEP_DATA_TRANSFER_ACK,
                STEP_BYE_SENT,
                STEP_BYE_ACK
            };
            typedef enum {
                APP_NONE = 0,
                APP_WEBCAM = 4,
                APP_FILE_TRANSFER = 2,
                APP_DISPLAY_PICTURE = 1,
                APP_EMOTICON = 11,
                APP_DISPLAY_PICTURE2 = 12, // MSNP15 uses 12 instead 1
                APP_VOICE_CLIP = 20, // MSNP15 uses 12 instead 1
                APP_WINK = 98, // non standard
                APP_INK = 99 // non standard
            } p2pTransferObj;
            enum {
                FLAG_NOP = 0x0,
                FLAG_ACK = 0x2,
                FLAG_ERROR = 0x8,
                FLAG_DATA_EMOTICONS = 0x20,
                FLAG_DATA_PICTURE = 0x20,
                FLAG_FILE_DATA = 0x01000030,
                FLAG_FILE_DATA2 = 0x01000020
            };
            
            struct p2pPacket {
                struct {
                    unsigned int sessionID;
                    unsigned int identifier;
                    unsigned long long dataOffset;
                    unsigned long long totalDataSize;
                    unsigned int messageLength;
                    unsigned int flag;
                    unsigned int ackID;
                    unsigned int ackUID;
                    unsigned long long ackDataSize;
                }p2pHeader;
                std::string body;
                struct {
                    unsigned int appID;
                }p2pFooter;

                p2pPacket() {
                    p2pHeader.sessionID = 0;
                    p2pHeader.identifier = 0;
                    p2pHeader.dataOffset = 0;
                    p2pHeader.totalDataSize = 0;
                    p2pHeader.messageLength = 0;
                    p2pHeader.flag = 0;
                    p2pHeader.ackID = 0;
                    p2pHeader.ackUID = 0;
                    p2pHeader.ackDataSize = 0;
                    p2pFooter.appID = 0;
                }
            };

            struct p2pSession {
                bool sending; // sending or receiving, if sending, so true
                unsigned long long totalDataSize;
                unsigned int step; // step at the moment
                unsigned int currentIdentifier;
                unsigned int baseIdentifier; // baseIdentifier
                unsigned int CSeq;
                unsigned int sessionID;
                unsigned int appID;
                MSN::FileTransferConnectionP2P *fileTransfer;
                std::string from;
                std::string to;
                std::string CallID;
                std::string Via;
                std::string ContentType;
                std::string Context; // can be the file preview or msnobject
                std::string filename; // filename to transfer
                std::ifstream *out_stream; // file to send
                std::ofstream *in_stream; // file to receive
                std::string ConnType;
                std::string Bridges;
                std::string NetID;
                std::string UPnPNat;
                std::string Listening;
                std::string ICF;
                std::string IPv4InternalAddrs;
                std::string IPv4InternalPort;
                std::string IPv4ExternalAddrs;
                std::string IPv4ExternalPort;
                p2pTransferObj typeTransfer;
                std::string emoticonAlias;

                p2pPacket tempPacket; // this is used for general purposes
                std::string ink;

                p2pSession() {
                    sending = false;
                    totalDataSize = 0;
                    step = 0;
                    currentIdentifier = 0;
                    baseIdentifier = 0;
                    CSeq = 0;
                    sessionID = 0;
                    appID = 0;
                    fileTransfer = 0;
                    out_stream = 0;
                    in_stream = 0;
                    typeTransfer = APP_NONE;
                }
            };

            typedef void (P2P::*P2PCallbacks)(MSN::SwitchboardServerConnection &conn, 
                    unsigned int sessionID, 
                    p2pPacket &packet);

            std::map<unsigned int, std::pair<P2PCallbacks, unsigned int> > callbacks;

            virtual void addCallback(P2PCallbacks, unsigned int sessionID, 
                    unsigned int ackID);

            virtual void removeCallback(unsigned int ackID);

            std::map<unsigned int, p2pPacket> pendingP2PMsg;
            std::map<unsigned int, p2pSession> startedSessions;

            void sendFile(MSN::SwitchboardServerConnection &conn, 
                          MSN::fileTransferInvite ft);

            void handleP2Pmessage(MSN::SwitchboardServerConnection &conn, 
                          std::vector<std::string> & args, 
                          std::string mime, std::string body);

            void sendACK(MSN::SwitchboardServerConnection &conn, 
                      p2pPacket &packet,
                      p2pSession &session);

            void sendP2PPacket(MSN::SwitchboardServerConnection &conn, 
                    p2pPacket &packet, 
                    p2pSession &session);

            void sendP2PData(MSN::SwitchboardServerConnection &conn, 
                    p2pSession &session,
                    p2pPacket &packet);

            void receiveP2PData(MSN::SwitchboardServerConnection &conn, 
                    p2pPacket &packet);

            void handle_negotiation(MSN::SwitchboardServerConnection &conn, 
                    p2pPacket &packet);

            void handle_INVITE(MSN::SwitchboardServerConnection &conn, 
                    p2pPacket &packet);

            void handle_603Decline(MSN::SwitchboardServerConnection &conn, 
                    p2pPacket &packet);

            void handle_INVITE_ACK(MSN::SwitchboardServerConnection &conn, 
                    unsigned int sessionID, 
                    p2pPacket &packet);

            void handle_200OK(MSN::SwitchboardServerConnection &conn, 
                    p2pPacket &packet);

            void handle_BYE(MSN::SwitchboardServerConnection &conn, 
                    p2pPacket &packet);

            void send_200OK(MSN::SwitchboardServerConnection &conn, 
                    p2pSession &session,
                    std::string body);

            void send_BYE(MSN::SwitchboardServerConnection &conn, 
                    p2pPacket &packet,
                    p2pSession &session);

            void send_603Decline(MSN::SwitchboardServerConnection &conn, 
                    p2pSession &session);

            void handle_p2pACK(MSN::SwitchboardServerConnection &conn, 
                    p2pPacket &packet);

            void handle_200OKACK(MSN::SwitchboardServerConnection &conn, 
                    unsigned int sessionID, 
                    p2pPacket &packet);

            void handle_603DeclineACK(MSN::SwitchboardServerConnection &conn, 
                    unsigned int sessionID, 
                    p2pPacket &packet);

            void handle_DataPreparationACK(MSN::SwitchboardServerConnection &conn, 
                    unsigned int sessionID, 
                    p2pPacket &packet);

            void handle_DataACK(MSN::SwitchboardServerConnection &conn, 
                    unsigned int sessionID, 
                    p2pPacket &packet);

            void handle_BYEACK(MSN::SwitchboardServerConnection &conn, 
                    unsigned int sessionID, 
                    p2pPacket &packet);

            void handle_MSGACKReceived(MSN::SwitchboardServerConnection &conn,
                    unsigned int sessionID,
                    std::string fromPassport);

            void handle_fileTransferResponse(MSN::SwitchboardServerConnection &conn,
                    unsigned int sessionID,
                    std::string filename,
                    bool response);

            void handle_session_changes(MSN::SwitchboardServerConnection &conn, 
                    p2pPacket &packet, 
                    p2pSession &session);

            void requestFile(MSN::SwitchboardServerConnection &conn, 
                    unsigned int sessionID, 
                    std::string filename, 
                    std::string msnobject,
                    p2pTransferObj obj);

            void requestDisplayPicture(MSN::SwitchboardServerConnection &conn, 
                    unsigned int sessionID, 
                    std::string filename, 
                    std::string msnobject);

            void sendInk(MSN::SwitchboardServerConnection &conn, 
                    std::string image);

            void cancelTransfer(MSN::SwitchboardServerConnection &conn, 
                    unsigned int sessionID);

            void requestEmoticon(MSN::SwitchboardServerConnection &conn, 
                    unsigned int sessionID, 
                    std::string filename, 
                    std::string msnobject,
                    std::string alias);

            void requestVoiceClip(MSN::SwitchboardServerConnection &conn, 
                    unsigned int sessionID, 
                    std::string filename, 
                    std::string msnobject);

            void requestWink(MSN::SwitchboardServerConnection &conn, 
                    unsigned int sessionID, 
                    std::string filename, 
                    std::string msnobject);

            void requestInk(MSN::SwitchboardServerConnection &conn, 
                    unsigned int sessionID, 
                    std::string filename, 
                    std::string msnobject);
    };
}

#endif