BUG/MEDIUM: contrib/spoa_server: Set FIN flag on agent frames

When communicating over SPOP the AGENT-HELLO, AGENT-DISCONNECT,
and ACK frames must have the FIN flag set.
diff --git a/contrib/spoa_server/spoa.c b/contrib/spoa_server/spoa.c
index a958f22..f36c3db 100644
--- a/contrib/spoa_server/spoa.c
+++ b/contrib/spoa_server/spoa.c
@@ -679,13 +679,16 @@
  * the number of written bytes otherwise. */
 static void prepare_agentack(struct worker *w)
 {
+	unsigned int flags = 0;
+
 	w->ack_len = 0;
 
 	/* Frame type */
 	w->ack[w->ack_len++] = SPOE_FRM_T_AGENT_ACK;
 
-	/* No flags for now */
-	memset(w->ack + w->ack_len, 0, 4); /* No flags */
+	/* Set flags */
+	flags |= htonl(SPOE_FRM_FL_FIN);
+	memcpy(w->ack + w->ack_len, &flags, 4);
 	w->ack_len += 4;
 
 	/* Set stream-id and frame-id for ACK frames */
@@ -940,12 +943,14 @@
 prepare_agenthello(struct worker *w)
 {
 	int idx = 0;
+	unsigned int flags = 0;
 
 	/* Frame Type */
 	w->buf[idx++] = SPOE_FRM_T_AGENT_HELLO;
 
-	/* No flags for now */
-	memset(w->buf+idx, 0, 4); /* No flags */
+	/* Set flags */
+	flags |= htonl(SPOE_FRM_FL_FIN);
+	memcpy(w->buf+idx, &flags, 4);
 	idx += 4;
 
 	/* No stream-id and frame-id for HELLO frames */
@@ -978,6 +983,7 @@
 {
 	const char *reason;
 	int         rlen, idx = 0;
+	unsigned int flags = 0;
 
 	if (w->status_code >= SPOE_FRM_ERRS)
 		w->status_code = SPOE_FRM_ERR_UNKNOWN;
@@ -987,8 +993,9 @@
 	/* Frame type */
 	w->buf[idx++] = SPOE_FRM_T_AGENT_DISCON;
 
-	/* No flags for now */
-	memset(w->buf+idx, 0, 4);
+	/* Set flags */
+	flags |= htonl(SPOE_FRM_FL_FIN);
+	memcpy(w->buf+idx, &flags, 4);
 	idx += 4;
 
 	/* No stream-id and frame-id for DISCONNECT frames */
diff --git a/contrib/spoa_server/spoa.h b/contrib/spoa_server/spoa.h
index e9a7a46..8f912e4 100644
--- a/contrib/spoa_server/spoa.h
+++ b/contrib/spoa_server/spoa.h
@@ -21,6 +21,9 @@
 #define SPOP_VERSION      "2.0"
 #define SPOA_CAPABILITIES ""
 
+/* Flags set on the SPOE frame */
+#define SPOE_FRM_FL_FIN         0x00000001
+
 /* All supported data types */
 enum spoe_data_type {
 	SPOE_DATA_T_NULL = 0,