rx: provide mechanism to send a bare abort packet
authorSimon Wilkinson <sxw@your-file-system.com>
Fri, 1 Jun 2012 17:20:57 +0000 (13:20 -0400)
committerDerrick Brashear <shadow@dementix.org>
Fri, 15 Jun 2012 02:36:03 +0000 (19:36 -0700)
simply put an abort on the wire

Change-Id: I0486e1826da9466a2982ac07c3749876848a7f66
Reviewed-on: http://gerrit.openafs.org/7562
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>

src/rx/rx_packet.c
src/rx/rx_prototypes.h

index e7a8278..119f8ef 100644 (file)
@@ -2504,6 +2504,41 @@ rxi_SendPacketList(struct rx_call *call, struct rx_connection *conn,
     }
 }
 
+/* Send a raw abort packet, without any call or connection structures */
+void
+rxi_SendRawAbort(osi_socket socket, afs_uint32 host, u_short port,
+                afs_int32 error, struct rx_packet *source, int istack)
+{
+    struct rx_header theader;
+    struct sockaddr_in addr;
+    struct iovec iov[2];
+
+    memset(&theader, 0, sizeof(theader));
+    theader.epoch = htonl(source->header.epoch);
+    theader.callNumber = htonl(source->header.callNumber);
+    theader.serial = htonl(1);
+    theader.type = RX_PACKET_TYPE_ABORT;
+    theader.serviceId = htons(source->header.serviceId);
+    theader.securityIndex = source->header.securityIndex;
+    theader.cid = htonl(source->header.cid);
+
+    error = htonl(error);
+
+    iov[0].iov_base = &theader;
+    iov[0].iov_len = sizeof(struct rx_header);
+    iov[1].iov_base = &error;
+    iov[1].iov_len = sizeof(error);
+
+    addr.sin_family = AF_INET;
+    addr.sin_addr.s_addr = host;
+    addr.sin_port = port;
+#ifdef STRUCT_SOCKADDR_HAS_SA_LEN
+    addr.sin_len = sizeof(struct sockaddr_in);
+#endif
+
+    osi_NetSend(socket, &addr, iov, 2,
+               sizeof(struct rx_header) + sizeof(error), istack);
+}
 
 /* Send a "special" packet to the peer connection.  If call is
  * specified, then the packet is directed to a specific call channel
index 7cfb7ed..c42fdcb 100644 (file)
@@ -438,6 +438,9 @@ extern void rxi_SendPacket(struct rx_call *call, struct rx_connection *conn,
 extern void rxi_SendPacketList(struct rx_call *call,
                               struct rx_connection *conn,
                               struct rx_packet **list, int len, int istack);
+extern void rxi_SendRawAbort(osi_socket socket, afs_uint32 host, u_short port,
+                            afs_int32 error, struct rx_packet *source,
+                            int istack);
 extern struct rx_packet *rxi_SendSpecial(struct rx_call *call,
                                         struct rx_connection *conn,
                                         struct rx_packet *optionalPacket,