Adds tcpdump info onto packet parsed from pdml i.e. adds the packet payload for various protocols
@param parsedPacket
@return
160848
private Packet addTcpdumpInfoToPacket(Packet parsedPacket){ 

        int packetSize = parsedPacket.getPacketSize();
        
        tcpdumpReader.readNewPacket(packetSize);

        // Get Tcp Payload
        if ( parsedPacket.isTcp() ) {       
            int payloadSize = parsedPacket.getTcpPayloadSize();
            int payloadStart = parsedPacket.getTcpPayloadStart();
            parsedPacket.setTcpPayload(tcpdumpReader.getPayload(payloadStart, payloadSize));
        }
        
        tcpdumpReader.packetReadComplete();
        
        return parsedPacket;
    }
315662
protected Packet createPacket() throws IOException {
		synchronized (packets) {
			if (packets.size() == 0)
				return new Packet();
			Packet p = (Packet) packets.elementAt(0);
			packets.removeElementAt(0);
			return p;
		}
	}
1025841
@Override
    public OfferRequestPacket parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
        int eventType = parser.getEventType();
        String sessionID = null;
        int timeout = -1;
        OfferContent content = null;
        boolean done = false;
        Map<String, List<String>> metaData = new HashMap<>();

        if (eventType != XmlPullParser.START_TAG) {
            // throw exception
        }

        Jid userJID = ParserUtils.getJidAttribute(parser);
        // Default userID to the JID.
        Jid userID = userJID;

        while (!done) {
            eventType = parser.next();

            if (eventType == XmlPullParser.START_TAG) {
                String elemName = parser.getName();

                if ("timeout".equals(elemName)) {
                    timeout = Integer.parseInt(parser.nextText());
                }
                else if (MetaData.ELEMENT_NAME.equals(elemName)) {
                    metaData = MetaDataUtils.parseMetaData(parser);
                }
                else if (SessionID.ELEMENT_NAME.equals(elemName)) {
                   sessionID = parser.getAttributeValue("", "id");
                }
                else if (UserID.ELEMENT_NAME.equals(elemName)) {
                    userID = ParserUtils.getJidAttribute(parser, "id");
                }
                else if ("user-request".equals(elemName)) {
                    content = UserRequest.getInstance();
                }
                else if (RoomInvitation.ELEMENT_NAME.equals(elemName)) {
                    RoomInvitation invitation = (RoomInvitation) PacketParserUtils
                            .parseExtensionElement(RoomInvitation.ELEMENT_NAME, RoomInvitation.NAMESPACE, parser, xmlEnvironment);
                    content = new InvitationRequest(invitation.getInviter(), invitation.getRoom(),
                            invitation.getReason());
                }
                else if (RoomTransfer.ELEMENT_NAME.equals(elemName)) {
                    RoomTransfer transfer = (RoomTransfer) PacketParserUtils
                            .parseExtensionElement(RoomTransfer.ELEMENT_NAME, RoomTransfer.NAMESPACE, parser, xmlEnvironment);
                    content = new TransferRequest(transfer.getInviter(), transfer.getRoom(), transfer.getReason());
                }
            }
            else if (eventType == XmlPullParser.END_TAG) {
                if ("offer".equals(parser.getName())) {
                    done = true;
                }
            }
        }

        OfferRequestPacket offerRequest =
                new OfferRequestPacket(userJID, userID, timeout, metaData, sessionID, content);
        offerRequest.setType(IQ.Type.set);

        return offerRequest;
    }
833257
public static String formatAddress(InetSocketAddress inet){
        if(inet == null){
            throw new NullPointerException();
        }
        StringBuilder result = new StringBuilder();
        if(inet.isUnresolved()){
            result.append(inet.getHostName());
        }else{
            result.append(formatPossibleIpv6Address(formatAddress(inet.getAddress())));
        }
        result.append(":").append(inet.getPort());
        return result.toString();
    }
207177
@Override
    public T addPackage(String pack) throws IllegalArgumentException {
        Validate.notNull(pack, "Package must be specified");

        return addPackages(false, pack);
    }
78484
@Override
    public Packet getNextPacket() throws IOException {
        final Buffer payload = getPayload();
        if (payload == null || payload.isEmpty()) {
            return null;
        }

        if (sipFramer.accept(payload)) {
            return sipFramer.frame(this, payload);
        } else if (rtpFramer.accept(payload)) {
            // RTP is tricky to parse so if we return
            // null then it wasn't an RTP packet afterall
            // so fall through...
            final RtpPacket rtp = frameRtp(payload);
            if (rtp != null) {
                return rtp;
            }
        }

        return new UnknownApplicationPacketImpl(this, payload);
    }
81639
protected void processReceivedMessage(DatagramPacket packet, byte[] buffer) {

		String received = new String(buffer).trim();
		String tokens[] = received.split("\\|");
		if (tokens.length != 3) {
			logger.warn("Malformed UDP message received (" + received + ")!");
			return;
		}

		// Check prefix and nodeID
		if (!namespace.equals(tokens[0]) || nodeID.equals(tokens[1])) {
			return;
		}
		if (tokens[1].isEmpty()) {
			logger.warn("Empty nodeID received!");
			return;
		}

		// Get source hostname or IP
		String host;
		try {
			InetAddress address = packet.getAddress();
			if (useHostname) {
				host = address.getHostName();
				if (host == null || host.isEmpty() || host.contains("localhost")) {
					host = address.getHostAddress();
				}
			} else {
				host = address.getHostAddress();
				if (host == null || host.isEmpty() || host.startsWith("127.")) {
					host = address.getHostName();
				}
			}
			if (host == null || host.isEmpty()) {
				logger.warn("Unable to detect sender's hostname!");
				return;
			}
		} catch (Exception cause) {
			logger.warn("Unable to detect sender's IP address or hostname!", cause);
			return;
		}
		int port = 0;
		try {
			port = Integer.parseInt(tokens[2]);
			if (port < 1) {
				logger.warn("Invalid port number (" + port + ")!");
				return;
			}
		} catch (Exception cause) {
			logger.warn("Invalid port number format (" + tokens[2] + ")!");
			return;
		}

		// Notify TCP Transporter
		transporter.udpPacketReceived(tokens[1], host.toLowerCase(), port);
	}
254170
def add(self, packet):
        """"""
        for name in self._names:
            value = getattr(packet, name)
            if value is not None:
                self._dict[name] = value
1213199
def on_packet_received(self, pkt):
        
        if not pkt:
            return
        if self.store:
            self.lst.append(pkt)
        if self.prn:
            result = self.prn(pkt)
            if result is not None:
                print(result)
23263
function EncackPacket(publicKey) {
  if (!(this instanceof EncackPacket))
    return new EncackPacket(publicKey);

  Packet.call(this);

  this.publicKey = publicKey || encoding.ZERO_KEY;
}
1251348
private Packet parseNextPacketFromPdml() {
        Packet currentPacket = null;
        int eventType;
        fieldStack.empty(); 
        try {
            eventType = parser.getEventType();
            while (eventType != XmlPullParser.END_DOCUMENT) {
                switch (eventType) {
                case XmlPullParser.START_TAG:
                    if ( parser.getRawName().contains("packet") ) { // At packet tag
                        currentPacket = setPacketProperties(xppFactory.newStartTag());
                    }
                    else if ( parser.getRawName().contains("proto") ) {
                        currentPacket = setProtoProperties(xppFactory.newStartTag(), currentPacket);
                    }
                    else if ( parser.getRawName().contains("field") ) {
                        fieldStack.push("field");
                        // Added http after all others 
                        if (protoStack.peek().equals("http") && currentPacket.isTcp()){
                            currentPacket = setHttpFieldProperties(xppFactory.newStartTag(), currentPacket);
                        }
                        else{
                        	currentPacket = setFieldProperties(xppFactory.newStartTag(), currentPacket);
                        }
                    }
                    else {
                        ;
                    }
                    break;
                case XmlPullParser.END_TAG:
                    if ( parser.getRawName().contains("packet") ) {
                        eventType = parser.next();
                        return currentPacket;
                    }
                    else if ( parser.getRawName().contains("proto") ) {
                        protoStack.pop();
                    }
                    else if ( parser.getRawName().contains("field") ) {
                        fieldStack.pop();
                    }
                default:
                }
                eventType = parser.next();
            }
            return null; // Returned if at end of pdml
        }
        catch (XmlPullParserException e) {
            e.printStackTrace();
            throw new ParserFailureException("Failed parsing pmdl " + e);
        }
        catch (IOException e) {
            e.printStackTrace();
            throw new ParserFailureException("Failed reading parser.next " + e);
        }
    }
846409
public static OpusPacket create(OggPacket packet) {
       // Special header types detection
       if(isOpusSpecial(packet)) {
           byte type = packet.getData()[4];
           switch(type) {
           case (byte)'H': // OpusHead
               return new OpusInfo(packet);
           case (byte)'T': // OpusTags
               return new OpusTags(packet);
           }
       }

       return new OpusAudioData(packet);
   }
525064
protected void parseTransactions(final int transactionsOffset) throws ProtocolException {
        cursor = transactionsOffset;
        optimalEncodingMessageSize = HEADER_SIZE;
        if (payload.length == cursor) {
            // This message is just a header, it has no transactions.
            transactionBytesValid = false;
            return;
        }

        int numTransactions = (int) readVarInt();
        optimalEncodingMessageSize += VarInt.sizeOf(numTransactions);
        transactions = new ArrayList<>(Math.min(numTransactions, Utils.MAX_INITIAL_ARRAY_LENGTH));
        for (int i = 0; i < numTransactions; i++) {
            Transaction tx = new Transaction(params, payload, cursor, this, serializer, UNKNOWN_LENGTH, null);
            // Label the transaction as coming from the P2P network, so code that cares where we first saw it knows.
            tx.getConfidence().setSource(TransactionConfidence.Source.NETWORK);
            transactions.add(tx);
            cursor += tx.getMessageSize();
            optimalEncodingMessageSize += tx.getOptimalEncodingMessageSize();
        }
        transactionBytesValid = serializer.isParseRetainMode();
    }
1134426
private byte[] readXBytesFromTcpdump(int x) {

        byte[] buffer = new byte[x];

        try {
            int read = tcpDumpReader.read(buffer);
            if ( x == -1 ) {
                throw new ParserFailureException("Attempted to read pass the size of the tcpdump file, tcpDumpPos:"
                        + tcpDumpPos + ", attempted to read " + x + " bytes");
            }
            tcpDumpPos += read;
            if ( read != x )
                throw new ParserFailureException("Tried to read over the size of the file");
            return buffer;
        }
        catch (IOException e) {
            e.printStackTrace();
            throw new ParserFailureException("Failed to read from tcpdump file: ");
        }

    }
417944
@Override
    public void write(RtpPacket packet, RTPFormat format) {
        // checking format
        if (format == null) {
            if (logger.isTraceEnabled()) {
                logger.trace("No format specified. Packet dropped!");
            }
            return;
        }

        boolean locked = false;
        try {
            locked = this.lock.tryLock() || this.lock.tryLock(5, TimeUnit.MILLISECONDS);
            if (locked) {
                safeWrite(packet, format);
            }
        } catch (InterruptedException e) {
            if (logger.isTraceEnabled()) {
                logger.trace("Could not aquire write lock for jitter buffer. Dropped packet.");
            }
        } finally {
            if (locked) {
                this.lock.unlock();
            }
        }
    }
1048369
function GetBlockTxnPacket(request) {
  if (!(this instanceof GetBlockTxnPacket))
    return new GetBlockTxnPacket(request);

  Packet.call(this);

  this.request = request || new bip152.TXRequest();
}
362612
public static TheoraPacket create(OggPacket packet) {
        byte type = packet.getData()[0];

        // Special header types detection
        if(isTheoraSpecial(packet)) {
            switch(type) {
            case (byte)TYPE_IDENTIFICATION:
                return new TheoraInfo(packet);
            case (byte)TYPE_COMMENTS:
                return new TheoraComments(packet);
            case (byte)TYPE_SETUP:
                return new TheoraSetup(packet);
            }
        }

        return new TheoraVideoData(packet);
    }