Make sure LLCP header fields are reset.

In some conditions these would persist
over a link tear-down, causing them to
be sent out the next time the link comes up.

Also, don't overwrite them if a send is
still in progress.

Change-Id: I19dec5d79ae4b25f41fb5e8a0514e565ceca7a91
diff --git a/src/phFriNfc_Llcp.c b/src/phFriNfc_Llcp.c
index ca2836a..5b9736b 100644
--- a/src/phFriNfc_Llcp.c
+++ b/src/phFriNfc_Llcp.c
@@ -162,13 +162,13 @@
       /* Stop timer */
       phOsalNfc_Timer_Stop(Llcp->hSymmTimer);
 
+      Llcp->psSendHeader = NULL;
+      Llcp->psSendSequence = NULL;
       /* Return delayed send operation in error, in any */
       if (Llcp->psSendInfo != NULL)
       {
          phFriNfc_Llcp_Deallocate(Llcp->psSendInfo);
          Llcp->psSendInfo = NULL;
-         Llcp->psSendHeader = NULL;
-         Llcp->psSendSequence = NULL;
       }
       if (Llcp->pfSendCB != NULL)
       {
@@ -560,7 +560,6 @@
          phFriNfc_Llcp_ResetLTO(Llcp);
       }
    }
-
    /* Notify upper layer, if Activation failed CB called by Deactivate */
    if (status == NFCSTATUS_SUCCESS)
    {
@@ -869,7 +868,6 @@
    NFCSTATUS                        result;
    uint8_t                          bDeallocate = FALSE;
    uint8_t                          return_value = FALSE;
-
    /* Handle pending disconnection request */
    if (Llcp->bDiscPendingFlag == TRUE)
    {
@@ -1339,6 +1337,10 @@
    /* Update state */
    Llcp->state = PHFRINFC_LLCP_STATE_ACTIVATION;
 
+   /* Reset any headers to send */
+   Llcp->psSendHeader = NULL;
+   Llcp->psSendSequence = NULL;
+
    /* Forward check request to MAC layer */
    return phFriNfc_LlcpMac_Activate(&Llcp->MAC);
 }
@@ -1413,7 +1415,6 @@
                               void                             *pContext )
 {
    NFCSTATUS result;
-
    /* Check parameters */
    if ((Llcp == NULL) || (psHeader == NULL) || (pfSend_CB == NULL))
    {
diff --git a/src/phFriNfc_LlcpTransport_Connection.c b/src/phFriNfc_LlcpTransport_Connection.c
index 4f7badf..f4be919 100644
--- a/src/phFriNfc_LlcpTransport_Connection.c
+++ b/src/phFriNfc_LlcpTransport_Connection.c
@@ -52,7 +52,6 @@
    uint8_t                           index;
    uint8_t                           socketFound = FALSE;
    NFCSTATUS                         result;
-
    /* Get Send CB context */
    psTransport = (phFriNfc_LlcpTransport_t*)pContext;
 
@@ -227,7 +226,6 @@
          pSocket->pSocketErrCb(pSocket->pContext, PHFRINFC_LLCP_ERR_DISCONNECTED);
       }
    }
-
    return result;
 }
 
@@ -2053,11 +2051,6 @@
        }
    }
 
-   /* Set the socket Header */
-   pLlcpSocket->sLlcpHeader.dsap  = pLlcpSocket->socket_dSap;
-   pLlcpSocket->sLlcpHeader.ptype = PHFRINFC_LLCP_PTYPE_DISC;
-   pLlcpSocket->sLlcpHeader.ssap  = pLlcpSocket->socket_sSap;
-
    /* Test if a send is pending */
    if( testAndSetSendPending(pLlcpSocket->psTransport))
    {
@@ -2066,6 +2059,11 @@
    }
    else
    {
+      /* Set the socket Header */
+      pLlcpSocket->sLlcpHeader.dsap  = pLlcpSocket->socket_dSap;
+      pLlcpSocket->sLlcpHeader.ptype = PHFRINFC_LLCP_PTYPE_DISC;
+      pLlcpSocket->sLlcpHeader.ssap  = pLlcpSocket->socket_sSap;
+
       status =  phFriNfc_LlcpTransport_LinkSend(pLlcpSocket->psTransport,
                                    &pLlcpSocket->sLlcpHeader,
                                    NULL,