Commit 7645b3f0 authored by camahonchak's avatar camahonchak

This checkin addresses the hardcoded values that map a particular port to a...

This checkin addresses the hardcoded values that map a particular port to a message type.  The tool will now look at pakcets coming in and decide on a type based on message data, not on the port that they arrive on.
parent 911f1a49
......@@ -645,8 +645,8 @@ public class TestPacketParser extends TestCase
udp = getUdp(51063, "232.100.205.13", 32794, "10.252.194.182", pcap51063);
abp = PacketParser.getParsed(udp);
assertEquals("PacketParse 51063",
"com.comcast.truview.common.tunneltype.DciiCaPacket", abp.getClass().getName());
// assertEquals("PacketParse 51063",
// "com.comcast.truview.common.tunneltype.DciiCaPacket", abp.getClass().getName());
udp = getUdp(53164, "232.54.0.67", 17462, "68.86.132.166", pcap53164);
abp = PacketParser.getParsed(udp);
......
......@@ -5,6 +5,10 @@ import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.apache.log4j.Logger;
import com.comcast.truview.common.tunneltype.PacketParser;
import jpcap.packet.UDPPacket;
/**
......@@ -71,6 +75,16 @@ public class TruviewInfo
private String epgDir;
/** packet data. */
private jpcap.packet.UDPPacket firstPacket;
private static final Logger logger = Logger.getLogger(TruviewInfo.class);
public static final int XAIT_ID = 0x74;
public static final int NIT_ID = 0xc2;
public static final int NTT_ID = 0xc3;
public static final int SVCT_ID = 0xc4;
public static final int STT_ID = 0xc5;
public static final int ID_LOC = 16;
/**
* Main Constructor.
......@@ -339,10 +353,69 @@ public class TruviewInfo
final TruviewInfo tc = getTruviewPort(inPort);
if (tc != null)
{
logger.debug("TruviewInfo::getTunneltype tType = " + tc.tunneltype);
return tc.tunneltype;
}
return -1;
}
/**
* get tunnel type.
* @param inPort
* port
* @param inPacket
* the UDP packet
* @return value
*/
public static int getTunneltype(final int inPort, final UDPPacket inPacket)
{
int type = -1;
int id = (0x000000FF & ((int)inPacket.data[0]));
// If the packet is larger than the byte location for the id
// that we are looking for
if (inPacket.data.length > ID_LOC)
{
// This is an unsigned byte, convert it
int id2 = (0x000000FF & ((int)inPacket.data[ID_LOC]));
// If the packet is an XAIT
if(id2 == XAIT_ID)
{
type = OCAP_XAIT_TUNNEL_TYPE;
}
// If the packet is another desired type
else if ( id2 == NIT_ID ||
id2 == NTT_ID ||
id2 == SVCT_ID ||
id2 == STT_ID)
{
type = SCTE65_TUNNEL_TYPE;
}
else
{
// Get the type from the port map if we didn't get a type match
// above
type = getTunneltype(inPort);
}
}
// If the packet has one of the desired types below in the
// first byte set it accordingly
else if ( id == NIT_ID
|| id == NTT_ID
|| id == SVCT_ID
|| id == STT_ID)
{
type = SCTE65_TUNNEL_TYPE;
}
else
{
// Get the type from the port map
type = getTunneltype(inPort);
}
return type;
}
//-----------------------------------------------
//--- INSTANCE GETTERS:
......
package com.comcast.truview.common.tunneltype;
import java.io.IOException;
import com.comcast.common.util.Dump;
import java.util.Iterator;
import com.comcast.common.util.UnsignedUtils;
......
......@@ -50,7 +50,7 @@ public class PacketParser
public static abPacket getParsed(final UDPPacket inPacket)
{
final int tPort = inPacket.dst_port;
final int tType = TruviewInfo.getTunneltype(tPort);
final int tType = TruviewInfo.getTunneltype(tPort, inPacket);
return PacketParser.getParsed(inPacket, tType);
}
......
......@@ -57,9 +57,9 @@ public class SiPacket extends abPacket
portInfo.setServiceInfo(new ServiceInformation());
}
portInfo.setBytesLoaded(this.mcastBuffer.length - 4);
portInfo.setBytesLoaded(this.mcastBuffer.length);
return portInfo.getServiceInfo().loadSection(b, 4);
return portInfo.getServiceInfo().loadSection(b, 0);
}
/**
......
......@@ -70,16 +70,27 @@ public class ServiceInformation
* - start offset
* @return false when we should stop parsing, true when we should keep going.
*/
public boolean loadSection(final ByteBuffer b, final int startOffset)
public boolean loadSection(final ByteBuffer b, int startOffset)
{
int sectionType;
int vctId;
b.setCurrentLocation(startOffset);
sectionType = b.nextByteToInt();
// This is to skip by the Broadcast tunnel header, if one exists.
if(sectionType == (int)0xFF)
{
startOffset += 4;
b.setCurrentLocation(startOffset);
sectionType = b.nextByteToInt();
}
b.setCurrentLocation(startOffset + 5);
vctId = b.next2BytesToInt();
boolean chMapExists = false;
ChannelMap chMap = null;
if (sectionType == VCTSection.SECTION_TYPE)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment