returns true if this packet is appropriately addressed
543174
def packet_is_for_me(self, m):
        ''''''
        if m.target_system != self.master.mav.srcSystem:
            return False
        if m.target_component != self.master.mav.srcComponent:
            return False
        # if have a sender we can also check the source address:
        if self.sender is not None:
            if (m.get_srcSystem(), m.get_srcComponent()) != self.sender:
                return False
        return True
507761
def send_by_packet(self, data):
        
        total_sent = 0
        while total_sent < PACKET_SIZE:
            sent = self.sock.send(data[total_sent:])
            if sent == 0:
                raise RuntimeError("socket connection broken")
            total_sent += sent
        return total_sent
46102
function(packet) {
        const result = packet.readInt(8);
        packet.result = result;
        debug('<<< LOGIN_RESULT', result);

        if (result !== 0) {
            packet.error = 'LOGIN_FAILED';
            packet.error_code = result;

            const statuses = {
                20: 'PIN_IS_NEEDED',
                22: 'PASSCODE_IS_NEEDED',
                24: 'PASSCODE_IS_UNMATCHED',
                30: 'LOGIN_MGR_BUSY',
            };
            if (statuses[result]) {
                packet.error = statuses[result];
            }

            // NB we do not emit an error if the login
            //  failed; we simply know that we need to
            //  get a pin code and try again
        }

        if (result === 0) {
            // logged in successfully!
            // provide the server with our status
            this.packets.newStatusPacket(0)
                .encrypted()
                .send(this);

            this.loggedIn = true;
        }

        this._loginResult = packet;
        this.emit('ready', this);
        this.emit('login_result', packet);
    }
735782
private function checkControlPacketValue(int $controlPacketValue): bool
    {
        // Check whether the first byte corresponds to the expected control packet value
        if (static::CONTROL_PACKET_VALUE !== $controlPacketValue) {
            throw new InvalidResponseType(sprintf(
                'Value of received value does not correspond to response (Expected: %d, Actual: %d)',
                static::CONTROL_PACKET_VALUE,
                $controlPacketValue
            ));
        }

        return true;
    }
413119
def statusEnquiry():
    """"""
    a = TpPd(pd=0x3)
    b = MessageType(mesType=0x34)  # 00110100
    packet = a / b
    return packet
1090702
def _process_response(self, received_data):
        
        resp = bytearray(received_data)
        self._resolved_gateway_ip_address = str.format(
            "{}.{}.{}.{}", resp[8], resp[9], resp[10], resp[11])
        self._resolved_gateway_ip_port = struct.unpack(
            '!h', bytes(resp[12:14]))[0]
386734
def handle_raw_packet(self, raw_packet):
        """"""
        log.debug('got packet: %s', raw_packet)
        packet = None
        try:
            packet = decode_packet(raw_packet)
        except:
            log.exception('failed to parse packet: %s', packet)

        log.debug('decoded packet: %s', packet)

        if packet:
            if 'ok' in packet:
                # handle response packets internally
                log.debug('command response: %s', packet)
                self._last_ack = packet
                self._command_ack.set()
            elif self.raw_callback:
                self.raw_callback(raw_packet)
        else:
            log.warning('no valid packet')
1180822
protected boolean hasOngoingTransaction() {
		if(!isSupervisedMode()) {
			return false;
		} else {
			if(ongoingTransactions != null) {
				for (Transaction transaction : ongoingTransactions) {
					if(TransactionState.CALLING.equals(transaction.getState()) ||
						TransactionState.TRYING.equals(transaction.getState()) ||
						TransactionState.PROCEEDING.equals(transaction.getState()) ||
						TransactionState.COMPLETED.equals(transaction.getState()) ||
						TransactionState.CONFIRMED.equals(transaction.getState())) {
							return true;
					}
				}
			}
			return false;
		}
	}
331850
async def _send_packet(self, pkt):
        """"""
        if self.state != 'connected':
            return
        await self.queue.put(pkt)
        self.logger.info(
            'Sending packet %s data %s',
            packet.packet_names[pkt.packet_type],
            pkt.data if not isinstance(pkt.data, bytes) else '<binary>')
536372
private boolean isTransportSecure(HttpServletRequest req) {
		String url = req.getRequestURL().toString();
		if (req.getScheme().equals("https")) {
			return true;
		}

		String value = req.getHeader("X-Forwarded-Proto");
		if (value != null && value.toLowerCase().equals("https")) {
			return true;
		}
		return false;
	}
280094
def _checksum(self, packet):
        ''''''
        xorsum = 0
        for s in packet:
            xorsum ^= ord(s)
        return xorsum
927299
@Override
	public final boolean packetReceived(AbstractPacket packet)
    {
        if (packet.getType() == PacketType.NOTIFICATION)
        {
            final NotificationPacket notifPacket = (NotificationPacket)packet;
            final AbstractMessage prefetchedMessage = notifPacket.getMessage();
            
            boolean acceptedByConsumer = false;
                
    		AbstractSession session = lookupRegisteredSession(notifPacket.getSessionId());
            if (session != null)
            {                   
                RemoteMessageConsumer consumer = (RemoteMessageConsumer)session.lookupRegisteredConsumer(notifPacket.getConsumerId());
                if (consumer != null)		
                    acceptedByConsumer = consumer.addToPrefetchQueue(prefetchedMessage,notifPacket.isDonePrefetching());
                else
                	log.debug("#"+id+" No such consumer : #"+notifPacket.getSessionId()+":"+notifPacket.getConsumerId()); // Consumer was concurrently closed or not yet registered
            }
            else
            	log.debug("#"+id+" No such session : #"+notifPacket.getSessionId()); // Session was concurrently closed
            
            // If the consumer was already gone, we need to rollback the prefetched message on the server side
            if (!acceptedByConsumer)
                scheduleRollback(notifPacket.getSessionId(),
                		         notifPacket.getConsumerId(),
                		         prefetchedMessage);
            
            return true;
        }
        
        if (packet.getType() == PacketType.R_PING)
        	return true;
        
        // Standard response, route to target endpoint
        transportHub.routeResponse((AbstractResponsePacket)packet);
        
        return true;
    }
185833
def _handle_packet(self, packet):
        
        events = packet_events(packet)

        for event in events:
            if self.ignore_event(event['id']):
                log.debug('ignoring event with id: %s', event)
                continue
            log.debug('got event: %s', event)
            if self.event_callback:
                self.event_callback(event)
            else:
                self.handle_event(event)
733190
def is_response_correct(self, response):
        """"""
        for answer in self.my_osid_object.get_answers():
            if self._is_match(response, answer):
                return True
        return False
1265380
private static boolean checkValidity(ClientSocket client, byte from, StateConnection expected)
    {
        return from >= 0 && client.getState() == expected;
    }
259424
public boolean isSupported() throws NoResponseException, NotConnectedException,
                    InterruptedException, XMPPErrorException {
        // This is just a primitive hack, since XEP-49 does not specify a way to determine if the
        // service supports it
        try {
            setPrivateData(DUMMY_PRIVATE_DATA);
            return true;
        }
        catch (XMPPErrorException e) {
            if (e.getStanzaError().getCondition() == Condition.service_unavailable) {
                return false;
            }
            else {
                throw e;
            }
        }
    }
173569
public boolean isTransferEncodingChunked() {
        String transferEncoding = getHeader(TRANSFER_ENCODING);
        if (transferEncoding != null && transferEncoding.equalsIgnoreCase(_CHUNKED)) {
            return true;
        }
        return false;
    }