Lines Matching refs:packet

72     /** A generic packet of bytes. */
77 /** Reading a packet header. */
87 /** A packet header. */
100 /** A packet which will be sent to a peer. */
114 /** Frees all resources associated with this packet. */
115 void (*free)(OutgoingPacket* packet);
120 /** Next packet in the queue. */
264 /** Frees a simple, i.e. header-only, outgoing packet. */
265 static void outgoingPacketFree(OutgoingPacket* packet) {
266 ALOGD("Freeing outgoing packet.");
267 free(packet);
271 * Prepare to read a new packet from the peer.
286 /** Adds a packet to the end of the queue. Callers must have the mutex. */
301 /** Takes the peer lock and enqueues the given packet. */
311 * Frees current packet and moves to the next one. Returns true if there is
312 * a next packet or false if the queue is empty.
339 // TODO: Start writing next packet? It would reduce the number of
413 // Clear outgoing packet queue.
460 /** Writes packet bytes to peer. */
506 // Success. Queue up the next packet.
553 LOG_ALWAYS_FATAL("Unknown packet type: %d", type);
589 // TODO: Ignore the packet and log a warning?
634 // Make sure we can allocate the connection request packet.
635 OutgoingPacket* packet = NULL;
637 packet = calloc(1, sizeof(OutgoingPacket));
638 if (packet == NULL) {
643 packet->header.type = CONNECTION_REQUEST;
644 packet->header.credentials = credentials;
645 packet->free = &outgoingPacketFree;
650 free(packet);
657 peerProxyEnqueueOutgoingPacket(masterProxy, packet);
800 * Frees an outgoing packet containing a connection.
802 static void outgoingPacketFreeSocket(OutgoingPacket* packet) {
803 closeWithWarning(packet->socket);
804 outgoingPacketFree(packet);
853 OutgoingPacket* packet = calloc(1, sizeof(OutgoingPacket));
854 if (packet == NULL) {
860 packet->header.type = CONNECTION_ERROR;
861 packet->header.credentials = credentials;
862 packet->free = &outgoingPacketFree;
864 peerProxyLockAndEnqueueOutgoingPacket(peerProxy, packet);
886 // This packet is complete. Get ready for the next one.
915 * Handles a packet header.
932 ALOGW("Invalid packet type from %d: %d", peerProxy->credentials.pid,
983 // We have the complete packet. Notify bytes listener.
987 // Get ready for the next packet.
1119 /** Frees a packet of bytes. */
1120 static void outgoingPacketFreeBytes(OutgoingPacket* packet) {
1121 ALOGD("Freeing outgoing packet.");
1122 bufferFree(packet->bytes);
1123 free(packet);
1127 * Sends a packet of bytes to a remote peer. Returns 0 on success.
1137 OutgoingPacket* packet = calloc(1, sizeof(OutgoingPacket));
1138 if (packet == NULL) {
1145 free(packet);
1154 packet->bytes = copy;
1155 packet->header.type = BYTES;
1156 packet->header.size = size;
1157 packet->free = outgoingPacketFreeBytes;
1158 bufferPrepareForWrite(packet->bytes);
1167 packet->free(packet);
1170 peerProxyEnqueueOutgoingPacket(peerProxy, packet);
1184 static void outgoingPacketFreeSharedBytes(OutgoingPacket* packet) {
1186 = (SharedBytesFreer*) packet->context;
1189 free(packet);
1193 * Sends a packet of bytes to a remote peer without copying the bytes. Calls
1205 OutgoingPacket* packet = calloc(1, sizeof(OutgoingPacket));
1206 if (packet == NULL) {
1213 free(packet);
1220 free(packet);
1228 packet->bytes = wrapper;
1229 packet->context = sharedBytesFreer;
1230 packet->header.type = BYTES;
1231 packet->header.size = size;
1232 packet->free = &outgoingPacketFreeSharedBytes;
1233 bufferPrepareForWrite(packet->bytes);
1242 packet->free(packet);
1245 peerProxyEnqueueOutgoingPacket(peerProxy, packet);