Class Serverstate

java.lang.Object
  extended by Serverstate
All Implemented Interfaces:
java.lang.Cloneable

public final class Serverstate
extends java.lang.Object
implements java.lang.Cloneable

Class Serverstate defines and stores all objects sent from fcdebug to a feralcore instance. Serverstate also defines and stores all objects sent from the feralcore to fcdebug. It also encodes necessary command information.

Serverstate is mutable. It has an immutable version called IServerstate.

The main idea behind Serverstate is this: this class allows a complex object (i.e., instance of this class) to be sent from fcdebug to the feralcore and back using custom serialization.

This class stores these objects as public data members to enable getting and setting them. It has custom serialize and deserialize functions to enable all objects to be serialized. Custom serialization provides full control and knowledge of the size of the serialized class independent of Java serialization issues. A significant amount of the parsing for the communication between fcdebug and feralcore is in this class. So, this is an important place to conduct a code review for security.

See the description of the serialize() member function for the design decisions regarding serialization of this class.


Field Summary
static int MAXCOMMANDNAMELEN
           
 
Constructor Summary
Serverstate()
          This constructor is appropriate for when Fcdebug sends a Serverstate object to a Feracore node.
Serverstate(long uptimeinsec)
           
 
Method Summary
 Serverstate clone()
          Factory method that returns a copy of this.
static Serverstatedres deserialize(ByteArray inarray)
           
 boolean equals(java.lang.Object o)
           
 Reg32 getbreakpointaddress()
           
 boolean getbreakpointenabled()
           
 Fccommandenum getcommand()
           
 ByteArray getdebugprocID()
           
 boolean getfreerun()
           
 int getlog2ofmemsize()
           
 long getnumdroppedpackets()
           
 int getnumprocesses()
           
 ByteArray getsessionID()
           
 int getsizetuplecontainer()
           
 long getuptimeseconds()
           
 boolean getvariablebool()
           
 ByteArray getvariablechunk24()
           
 ByteArray getvariabledata()
           
 int getvariableint()
           
 ByteArray getvariableprocessID()
           
 IRegisters getvariableregs()
           
 java.lang.String getvariablestrerr64()
           
 Reg32 getvariableu32()
           
 int hashCode()
           
 void incrementprocessesaddedfcdebug()
           
 void incrementprocessesaddedinjector()
           
 void incrementprocessesaddednetwork()
           
 void incrementprocessesaddedspawn()
           
 void incrementprocessesaddedtotal()
           
 void incrementprocesseskilledbyfcdebug()
           
 void incrementprocesseskilledillegalinstr()
           
 void incrementprocesseskilledoverpop()
           
 void incrementprocesseskilledtotal()
           
 void incrementqueuedebugdropped()
           
 void incrementqueuefcdapingresponsedropped()
           
 void incrementqueuefcpingrequestmsgdropped()
           
 void incrementqueuefcprogsndrequestdropped()
           
static void main()
           
static int minimumserializedlength()
           
 ByteArray serialize()
          Serializes the internal objects of this Serverstate object and returns them in a byte array.
 int serializedlength()
           
 void setbreakpointaddress(Reg32 in)
           
 void setbreakpointenabled(boolean in)
           
 void setcommand(Fccommandenum in)
           
 void setdebugprocID(ByteArray id)
           
 void setfreerun(boolean in)
           
 void setlog2ofmemsize(int in)
           
 void setnumdroppedpackets(long in)
           
 void setnumprocesses(int in)
           
 void setqueuedebugsize(int in)
           
 void setqueuefcdapingresponsesize(int in)
           
 void setqueuefcpingrequestmsgsize(int in)
           
 void setqueuefcprogsndrequestsize(int in)
           
 void setsessionID(ByteArray id)
           
 void setsizetuplecontainer(int in)
           
 void setuptimeseconds(long uptimein)
           
 void setvariablebool(boolean in)
           
 void setvariablechunk24(ByteArray in)
           
 void setvariabledata(ByteArray in)
           
 void setvariableint(int in)
           
 void setvariableprocessID(ByteArray id)
           
 void setvariableregs(IRegisters in)
           
 void setvariablestrerr64(java.lang.String s)
           
 void setvariableu32(Reg32 in)
           
 java.lang.String toString()
          Returns a printable string that displays the data members in this.
 java.lang.String toStringStats()
          Returns a printable string that displays some statics values in this.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MAXCOMMANDNAMELEN

public static final int MAXCOMMANDNAMELEN
See Also:
Constant Field Values
Constructor Detail

Serverstate

public Serverstate()
            throws java.io.UnsupportedEncodingException
This constructor is appropriate for when Fcdebug sends a Serverstate object to a Feracore node. In this case the uptime is meanless since it is set by Fcdebug.

Throws:
java.io.UnsupportedEncodingException

Serverstate

public Serverstate(long uptimeinsec)
            throws java.io.UnsupportedEncodingException
Throws:
java.io.UnsupportedEncodingException
Method Detail

clone

public Serverstate clone()
                  throws java.lang.CloneNotSupportedException
Factory method that returns a copy of this.

Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException

setvariablestrerr64

public void setvariablestrerr64(java.lang.String s)
                         throws FeralcoreException,
                                java.io.UnsupportedEncodingException
Throws:
FeralcoreException
java.io.UnsupportedEncodingException

getvariablestrerr64

public java.lang.String getvariablestrerr64()

getvariablebool

public boolean getvariablebool()

setvariablebool

public void setvariablebool(boolean in)

getvariableregs

public IRegisters getvariableregs()

setvariableregs

public void setvariableregs(IRegisters in)

getvariablechunk24

public ByteArray getvariablechunk24()

setvariablechunk24

public void setvariablechunk24(ByteArray in)

getvariabledata

public ByteArray getvariabledata()

setvariabledata

public void setvariabledata(ByteArray in)

getdebugprocID

public ByteArray getdebugprocID()

setdebugprocID

public void setdebugprocID(ByteArray id)

getvariableprocessID

public ByteArray getvariableprocessID()

setvariableprocessID

public void setvariableprocessID(ByteArray id)

getbreakpointaddress

public Reg32 getbreakpointaddress()

setbreakpointaddress

public void setbreakpointaddress(Reg32 in)

getvariableu32

public Reg32 getvariableu32()

setvariableu32

public void setvariableu32(Reg32 in)

getnumprocesses

public int getnumprocesses()

getlog2ofmemsize

public int getlog2ofmemsize()

getsizetuplecontainer

public int getsizetuplecontainer()

setsizetuplecontainer

public void setsizetuplecontainer(int in)

setnumprocesses

public void setnumprocesses(int in)

setqueuefcprogsndrequestsize

public void setqueuefcprogsndrequestsize(int in)

setqueuefcpingrequestmsgsize

public void setqueuefcpingrequestmsgsize(int in)

setqueuefcdapingresponsesize

public void setqueuefcdapingresponsesize(int in)

setqueuedebugsize

public void setqueuedebugsize(int in)

incrementqueuefcprogsndrequestdropped

public void incrementqueuefcprogsndrequestdropped()

incrementqueuefcpingrequestmsgdropped

public void incrementqueuefcpingrequestmsgdropped()

incrementqueuefcdapingresponsedropped

public void incrementqueuefcdapingresponsedropped()

incrementqueuedebugdropped

public void incrementqueuedebugdropped()

incrementprocesseskilledillegalinstr

public void incrementprocesseskilledillegalinstr()

incrementprocesseskilledoverpop

public void incrementprocesseskilledoverpop()

incrementprocesseskilledbyfcdebug

public void incrementprocesseskilledbyfcdebug()

incrementprocesseskilledtotal

public void incrementprocesseskilledtotal()

incrementprocessesaddedspawn

public void incrementprocessesaddedspawn()

incrementprocessesaddedinjector

public void incrementprocessesaddedinjector()

incrementprocessesaddednetwork

public void incrementprocessesaddednetwork()

incrementprocessesaddedfcdebug

public void incrementprocessesaddedfcdebug()

incrementprocessesaddedtotal

public void incrementprocessesaddedtotal()

setlog2ofmemsize

public void setlog2ofmemsize(int in)

getvariableint

public int getvariableint()

setvariableint

public void setvariableint(int in)

setuptimeseconds

public void setuptimeseconds(long uptimein)

getuptimeseconds

public long getuptimeseconds()

getnumdroppedpackets

public long getnumdroppedpackets()

setnumdroppedpackets

public void setnumdroppedpackets(long in)

getfreerun

public boolean getfreerun()

setfreerun

public void setfreerun(boolean in)

getbreakpointenabled

public boolean getbreakpointenabled()

setbreakpointenabled

public void setbreakpointenabled(boolean in)

getsessionID

public ByteArray getsessionID()

setsessionID

public void setsessionID(ByteArray id)

getcommand

public Fccommandenum getcommand()

setcommand

public void setcommand(Fccommandenum in)
                throws java.io.UnsupportedEncodingException
Throws:
java.io.UnsupportedEncodingException

minimumserializedlength

public static int minimumserializedlength()

serializedlength

public int serializedlength()

serialize

public ByteArray serialize()
Serializes the internal objects of this Serverstate object and returns them in a byte array.

In [1] Item 74 indicates that an issue with implementing Serializable is that it increases the chances of bugs and security holes. So, we don't implement Serializable. We use custom serialization.

In [1], Item 75 indicates that no matter what form of serialization is used, be sure to employ an explicit version identifier for the serializable classes that are created. This helps avoid incompatability issues as the software evolves over time. This class adheres to this by employing a serialization version number which is checked upon deserialization.

[1] Joshua Block, "Effective Java", 2nd Edition, Addison Wesley, 2008.


deserialize

public static Serverstatedres deserialize(ByteArray inarray)
                                   throws FeralcoreException,
                                          java.io.UnsupportedEncodingException,
                                          java.lang.CloneNotSupportedException
Throws:
FeralcoreException
java.io.UnsupportedEncodingException
java.lang.CloneNotSupportedException

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Returns a printable string that displays the data members in this.

Overrides:
toString in class java.lang.Object

toStringStats

public java.lang.String toStringStats()
Returns a printable string that displays some statics values in this.


main

public static void main()
                 throws FeralcoreException,
                        java.security.NoSuchAlgorithmException,
                        java.io.FileNotFoundException,
                        java.io.IOException,
                        java.lang.InterruptedException,
                        java.lang.CloneNotSupportedException
Throws:
FeralcoreException
java.security.NoSuchAlgorithmException
java.io.FileNotFoundException
java.io.IOException
java.lang.InterruptedException
java.lang.CloneNotSupportedException