1 /*
2  *  $Id$
3  *
4  * SocketAPI implementation for the sctplib.
5  * Copyright (C) 1999-2020 by Thomas Dreibholz
6  *
7  * Realized in co-operation between
8  * - Siemens AG
9  * - University of Essen, Institute of Computer Networking Technology
10  * - University of Applied Sciences, Muenster
11  *
12  * Acknowledgement
13  * This work was partially funded by the Bundesministerium fuer Bildung und
14  * Forschung (BMBF) of the Federal Republic of Germany (Foerderkennzeichen 01AK045).
15  * The authors alone are responsible for the contents.
16  *
17  * This program is free software: you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation, either version 3 of the License, or
20  * (at your option) any later version.
21 
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
29  *
30  * Contact: discussion@sctp.de
31  *          dreibh@iem.uni-due.de
32  *          tuexen@fh-muenster.de
33  *
34  * Purpose: Extended Socket Descriptor
35  *
36  */
37 
38 
39 #ifndef EXTSOCKETDESCRIPTOR_H
40 #define EXTSOCKETDESCRIPTOR_H
41 
42 
43 #include "tdsystem.h"
44 #include "sctpsocket.h"
45 #include "sctpassociation.h"
46 
47 
48 
49 // ###### ExtSocketDescriptor structure #####################################
50 struct ExtSocketDescriptor
51 {
52    enum ExtSocketDescriptorTypes {
53       ESDT_Invalid = 0,
54       ESDT_System  = 1,
55       ESDT_SCTP    = 2
56    };
57 
58    unsigned int Type;
59 
60    union ExtSocketDescriptorUnion {
61       int SystemSocketID;
62       struct SCTP {
63          int              Domain;
64          int              Type;
65          SCTPSocket*      SCTPSocketPtr;
66          SCTPAssociation* SCTPAssociationPtr;
67          int              Flags;
68          sctp_initmsg     InitMsg;
69          linger           Linger;
70          bool             ConnectionOriented;
71       } SCTPSocketDesc;
72    } Socket;
73 };
74 
75 
76 // ###### Class for ExtSocketDescriptor management ##########################
77 class ExtSocketDescriptorMaster
78 {
79    protected:
80    ExtSocketDescriptorMaster();
81 
82    public:
83    ~ExtSocketDescriptorMaster();
84 
85    public:
86    inline static ExtSocketDescriptor* getSocket(const int id);
87    static int setSocket(const ExtSocketDescriptor& newSocket);
88    static const unsigned int MaxSockets = FD_SETSIZE;
89 
90    private:
91    static ExtSocketDescriptorMaster MasterInstance;
92    static ExtSocketDescriptor Sockets[MaxSockets];
93 };
94 
95 
96 #endif
97