コード例 #1
0
void networkinterface_packetDropped(NetworkInterface* interface, Packet* packet) {
    MAGIC_ASSERT(interface);

    /* hand it off to the correct socket layer */
    gint key = packet_getSourceAssociationKey(packet);
    Socket* socket = g_hash_table_lookup(interface->boundSockets, GINT_TO_POINTER(key));

    /* if the socket closed, just drop the packet */
    gint socketHandle = -1;
    if(socket) {
        socketHandle = *descriptor_getHandleReference((Descriptor*)socket);
        socket_dropPacket(socket, packet);
    }
}
コード例 #2
0
void networkinterface_packetDropped(NetworkInterface* interface, Packet* packet) {
	MAGIC_ASSERT(interface);

	/*
	 * someone dropped a packet belonging to our interface
	 * hand it off to the correct socket layer
	 */
	gint key = packet_getSourceAssociationKey(packet);
	Socket* socket = g_hash_table_lookup(interface->boundSockets, GINT_TO_POINTER(key));

	/* just ignore if the socket closed in the meantime */
	if(socket) {
		socket_droppedPacket(socket, packet);
	} else {
		in_addr_t ip = packet_getSourceIP(packet);
		gchar* ipString = address_ipToNewString(ip);
		debug("interface dropping packet from %s:%u, no socket registered at %i",
				ipString, packet_getSourcePort(packet), key);
		g_free(ipString);
	}
}