net.jolsrv2
Class Interface

java.lang.Object
  extended by net.jolsrv2.Interface

public class Interface
extends java.lang.Object

The class is responsible for dealing with all things related to the interfaces

Author:
Andreas Schjønhaug

Constructor Summary
Interface(boolean multiple, CidrAddress localCAddress, java.net.InetAddress broadcastAddress, int port)
           
 
Method Summary
 void generateHello()
          Creates a new HELLO message and adds it to the queue of outgoing messages
 void generateTc()
          Creates a new TC message and adds it to the queue of outgoing messages
 int getAPacketSequenceNumber()
          Returns the next packet sequence number.
 java.net.InetAddress getBroadcastAddress()
           
 CidrAddress getLocalCAddress()
          Returns the local CIDR address
 java.util.ArrayList<java.net.InetAddress> getMprs()
          Return the MPRs on the Interface
 java.net.DatagramSocket getSocket()
          Returns the datagram socket
 void offerToOutgoingMessages(Message message)
          Puts a new message in the outgoing messages queue.
 void offerToParsedPackets(ParsedPacket parsedPacket)
          Puts a new parsed packet in the parsed packets queue
 void populateMprSet()
          Populates the MPR set on the Interface
 void processParsedPackets()
          The methods takes an incoming message, populates the repositories with it and checks if it is to be forwarded
 void purgeReceivedSet()
          Purges the received set
 java.util.ArrayList<Message> takeFromOutgoingMessages()
          Takes one or more messages from the outgoing queue in a FIFO manner
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Interface

public Interface(boolean multiple,
                 CidrAddress localCAddress,
                 java.net.InetAddress broadcastAddress,
                 int port)
Parameters:
multiple - whether or not multiple interfaces are used
localCAddress - the local CIDR address the local CIDR address
broadcastAddress - the broadcast Address the broadcast address
port - the port to be used for broadcasts
Method Detail

generateHello

public void generateHello()
Creates a new HELLO message and adds it to the queue of outgoing messages


generateTc

public void generateTc()
Creates a new TC message and adds it to the queue of outgoing messages


getLocalCAddress

public CidrAddress getLocalCAddress()
Returns the local CIDR address

Returns:
the CIDR block attached to the interface

takeFromOutgoingMessages

public java.util.ArrayList<Message> takeFromOutgoingMessages()
Takes one or more messages from the outgoing queue in a FIFO manner

Returns:
the messages

populateMprSet

public void populateMprSet()
Populates the MPR set on the Interface


getMprs

public java.util.ArrayList<java.net.InetAddress> getMprs()
Return the MPRs on the Interface

Returns:
the IP addresses of the MPRs

offerToOutgoingMessages

public void offerToOutgoingMessages(Message message)
Puts a new message in the outgoing messages queue.

Parameters:
message - to be put in the queue

offerToParsedPackets

public void offerToParsedPackets(ParsedPacket parsedPacket)
Puts a new parsed packet in the parsed packets queue

Parameters:
parsedPacket - to be put in the queue

getAPacketSequenceNumber

public int getAPacketSequenceNumber()
Returns the next packet sequence number. Wrap around is handled

Returns:
the next packet sequence number

purgeReceivedSet

public void purgeReceivedSet()
Purges the received set


getSocket

public java.net.DatagramSocket getSocket()
Returns the datagram socket

Returns:
the datagram socket

getBroadcastAddress

public java.net.InetAddress getBroadcastAddress()

processParsedPackets

public void processParsedPackets()
The methods takes an incoming message, populates the repositories with it and checks if it is to be forwarded