DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
include/ipx.h
00001 /*
00002  *  Copyright (C) 2002-2013  The DOSBox Team
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  */
00018 
00019 
00020 #ifndef DOSBOX_IPX_H
00021 #define DOSBOX_IPX_H
00022 
00023 // Uncomment this for a lot of debug messages:
00024 //#define IPX_DEBUGMSG 
00025 
00026 #ifdef IPX_DEBUGMSG
00027 #define LOG_IPX LOG_MSG
00028 #else
00029 #if defined (_MSC_VER)
00030 #define LOG_IPX
00031 #else
00032 #define LOG_IPX(...)
00033 #endif
00034 #endif
00035 
00036 #ifndef DOSBOX_DOSBOX_H
00037 #include "dosbox.h"
00038 #endif
00039 #ifndef DOSBOX_MEM_H
00040 #include "mem.h"
00041 #endif
00042 
00043 // In Use Flag codes
00044 #define USEFLAG_AVAILABLE  0x00
00045 #define USEFLAG_AESTEMP    0xe0
00046 #define USEFLAG_IPXCRIT    0xf8
00047 #define USEFLAG_SPXLISTEN  0xf9
00048 #define USEFLAG_PROCESSING 0xfa
00049 #define USEFLAG_HOLDING    0xfb
00050 #define USEFLAG_AESWAITING 0xfc
00051 #define USEFLAG_AESCOUNT   0xfd
00052 #define USEFLAG_LISTENING  0xfe
00053 #define USEFLAG_SENDING    0xff
00054 
00055 // Completion codes
00056 #define COMP_SUCCESS          0x00
00057 #define COMP_REMOTETERM       0xec
00058 #define COMP_DISCONNECT       0xed
00059 #define COMP_INVALIDID        0xee
00060 #define COMP_SPXTABLEFULL     0xef
00061 #define COMP_EVENTNOTCANCELED 0xf9
00062 #define COMP_NOCONNECTION     0xfa
00063 #define COMP_CANCELLED        0xfc
00064 #define COMP_MALFORMED        0xfd
00065 #define COMP_UNDELIVERABLE    0xfe
00066 #define COMP_HARDWAREERROR    0xff
00067 
00068 #ifdef _MSC_VER
00069 #pragma pack(1)
00070 #endif
00071 
00072 // For Uint8 type
00073 #include "SDL_net.h"
00074 
00075 struct PackedIP {
00076         Uint32 host;
00077         Uint16 port;
00078 } GCC_ATTRIBUTE(packed);
00079 
00080 struct nodeType {
00081         Uint8 node[6];
00082 } GCC_ATTRIBUTE(packed) ;
00083 
00084 struct IPXHeader {
00085         Uint8 checkSum[2];
00086         Uint8 length[2];
00087         Uint8 transControl; // Transport control
00088         Uint8 pType; // Packet type
00089 
00090         struct transport {
00091                 Uint8 network[4];
00092                 union addrtype {
00093                         nodeType byNode;
00094                         PackedIP byIP ;
00095                 } GCC_ATTRIBUTE(packed) addr;
00096                 Uint8 socket[2];
00097         } dest, src;
00098 } GCC_ATTRIBUTE(packed);
00099 
00100 struct fragmentDescriptor {
00101         Bit16u offset;
00102         Bit16u segment;
00103         Bit16u size;
00104 };
00105 
00106 #define IPXBUFFERSIZE 1424
00107 
00108 class ECBClass {
00109 public:
00110         RealPt ECBAddr;
00111         bool isInESRList;
00112         ECBClass *prevECB;      // Linked List
00113         ECBClass *nextECB;
00114         
00115         Bit8u iuflag;           // Need to save data since we are not always in
00116         Bit16u mysocket;        // real mode
00117 
00118         Bit8u* databuffer;      // received data is stored here until we get called
00119         Bitu buflen;            // by Interrupt
00120 
00121 #ifdef IPX_DEBUGMSG 
00122         Bitu SerialNumber;
00123 #endif
00124 
00125         ECBClass(Bit16u segment, Bit16u offset);
00126         Bit16u getSocket(void);
00127 
00128         Bit8u getInUseFlag(void);
00129 
00130         void setInUseFlag(Bit8u flagval);
00131 
00132         void setCompletionFlag(Bit8u flagval);
00133 
00134         Bit16u getFragCount(void);
00135 
00136         bool writeData();
00137         void writeDataBuffer(Bit8u* buffer, Bit16u length);
00138 
00139         void getFragDesc(Bit16u descNum, fragmentDescriptor *fragDesc);
00140         RealPt getESRAddr(void);
00141 
00142         void NotifyESR(void);
00143 
00144         void setImmAddress(Bit8u *immAddr);
00145         void getImmAddress(Bit8u* immAddr);
00146 
00147         ~ECBClass();
00148 };
00149 
00150 // The following routines may not be needed on all systems.  On my build of SDL the IPaddress structure is 8 octects 
00151 // and therefore screws up my IPXheader structure since it needs to be packed.
00152 
00153 void UnpackIP(PackedIP ipPack, IPaddress * ipAddr);
00154 void PackIP(IPaddress ipAddr, PackedIP *ipPack);
00155 
00156 #ifdef _MSC_VER
00157 #pragma pack()
00158 #endif
00159 
00160 #endif