Commit 840dd7bc authored by Lionel Gauthier's avatar Lionel Gauthier

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5957 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 1ad05afd
......@@ -210,7 +210,7 @@ nwGtpv1uCreateAndSendMsg( NwGtpv1uStackT *thiz, NwU32T peerIp, NwU16T peerPort,
*((NwU32T *) msgHdr) = htonl(pMsg->teid);
msgHdr += 4;
GTPU_DEBUG("nwGtpv1uCreateAndSendMsg to teid %u\n", pMsg->teid);
GTPU_DEBUG("nwGtpv1uCreateAndSendMsg to teid %u length %d\n", pMsg->teid, pMsg->msgLen);
if(pMsg->seqNumFlag || pMsg->extHdrFlag || pMsg->npduNumFlag) {
*((NwU16T *) msgHdr) = (pMsg->seqNumFlag ? htons(pMsg->seqNum) : 0x0000);
......
......@@ -121,6 +121,7 @@ nwGtpv1uGpduMsgNew( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
{
NwGtpv1uStackT *pStack = (NwGtpv1uStackT *) hGtpuStackHandle;
NwGtpv1uMsgT *pMsg;
NwU32T header_len = 0;
if(gpGtpv1uMsgPool) {
pMsg = gpGtpv1uMsgPool;
......@@ -130,26 +131,57 @@ nwGtpv1uGpduMsgNew( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
}
if(pMsg) {
// Version field: This field is used to determine the version of the GTP-U protocol.
// The version number shall be set to '1'.
pMsg->version = NW_GTPU_VERSION;
// Protocol Type (PT): This bit is used as a protocol discriminator between GTP (when PT is '1')
// and GTP' (when PT is '0'). GTP is described in this document and the GTP' protocol in 3GPP TS 32.295 [8].
// Note that the interpretation of the header fields may be different in GTP' than in GTP.
pMsg->protocolType = NW_GTP_PROTOCOL_TYPE_GTP;
// Extension Header flag (E): This flag indicates the presence of a meaningful value of the Next Extension
// Header field. When it is set to '0', the Next Extension Header field either is not present or, if present,
// shall not be interpreted.
pMsg->extHdrFlag = NW_FALSE;
// Sequence number flag (S): This flag indicates the presence of a meaningful value of the Sequence Number field.
// When it is set to '0', the Sequence Number field either is not present or, if present, shall not be interpreted.
// When it is set to '1', the Sequence Number field is present, and shall be interpreted, as described below in
// this section.
// For the Echo Request, Echo Response, Error Indication and Supported Extension Headers Notification
// messages, the S flag shall be set to '1'. Since the use of Sequence Numbers is optional for G-PDUs, the PGW,
// SGW, ePDG and eNodeB should set the flag to '0'. However, when a G-PDU (T-PDU+header) is being relayed
// by the Indirect Data Forwarding for Inter RAT HO procedure, then if the received G-PDU has the S flag set to
// '1', then the relaying entity shall set S flag to '1' and forward the G-PDU (T-PDU+header). In an End marker
// message the S flag shall be set to '0'.
pMsg->seqNumFlag = (seqNumFlag? NW_TRUE : NW_FALSE);
pMsg->npduNumFlag = NW_FALSE;
pMsg->msgType = NW_GTP_GPDU;
pMsg->teid = teid;
pMsg->seqNum = seqNum;
// N-PDU Number flag (PN): This flag indicates the presence of a meaningful value of the N-PDU Number field.
// When it is set to '0', the N-PDU Number field either is not present, or, if present, shall not be interpreted.
// When it is set to '1', the N-PDU Number field is present, and shall be interpreted.
pMsg->npduNumFlag = NW_FALSE;
pMsg->npduNum = 0x00;
pMsg->nextExtHdrType= 0x00;
// Message Type: This field indicates the type of GTP-U message.
pMsg->msgType = NW_GTP_GPDU;
// Length: This field indicates the length in octets of the payload, i.e. the rest of the packet following the
// mandatory part of the GTP header (that is the first 8 octets).
// The Sequence Number, the N-PDU Number or any Extension headers shall be considered to be part of the payload,
// i.e. included in the length count.
header_len = ((pMsg->seqNumFlag || pMsg->npduNumFlag || pMsg->extHdrFlag ) ?
NW_GTPV1U_EPC_SPECIFIC_HEADER_SIZE : NW_GTPV1U_EPC_MIN_HEADER_SIZE);
pMsg->msgLen = ((pMsg->seqNumFlag || pMsg->npduNumFlag
|| pMsg->extHdrFlag ) ?
NW_GTPV1U_EPC_SPECIFIC_HEADER_SIZE : (NW_GTPV1U_EPC_SPECIFIC_HEADER_SIZE - 4));
memcpy(pMsg->msgBuf + pMsg->msgLen, tpdu, tpduLength);
pMsg->msgLen += tpduLength;
pMsg->msgLen = pMsg->msgLen - ((pMsg->seqNumFlag || pMsg->npduNumFlag
|| pMsg->extHdrFlag ) ?
NW_GTPV1U_EPC_SPECIFIC_HEADER_SIZE : (NW_GTPV1U_EPC_SPECIFIC_HEADER_SIZE - 4));
(NW_GTPV1U_EPC_SPECIFIC_HEADER_SIZE - NW_GTPV1U_EPC_MIN_HEADER_SIZE) + tpduLength : tpduLength);
// Tunnel Endpoint Identifier (TEID): This field unambiguously identifies a tunnel endpoint in the receiving
// GTP-U protocol entity. The receiving end side of a GTP tunnel locally assigns the TEID value the transmitting
// side has to use. The TEID shall be used by the receiving entity to find the PDP context, except for the
// following cases:
// - The Echo Request/Response and Supported Extension Headers notification messages, where the Tunnel
// Endpoint Identifier shall be set to all zeroes.
// - The Error Indication message where the Tunnel Endpoint Identifier shall be set to all zeros.
pMsg->teid = teid;
pMsg->nextExtHdrType= 0x00;
memcpy(pMsg->msgBuf + header_len, tpdu, tpduLength);
*phMsg = (NwGtpv1uMsgHandleT) pMsg;
return NW_GTPV1U_OK;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment