blob: 7ec3a38691261ba96bf04ded47200ca7cbaea3fc [file] [log] [blame]
anjana_sreekumar@infosys.com991c2062020-01-08 11:42:57 +05301/*
2 * Copyright (c) 2003-2018, Great Software Laboratory Pvt. Ltd.
3 * Copyright (c) 2017 Intel Corporation
4 * Copyright (c) 2019, Infosys Ltd.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19#include <arpa/inet.h>
20#include "gtpv2c.h"
21
22void
23set_gtpv2c_header(struct gtpv2c_header *gtpv2c_tx, uint8_t type, uint32_t teid,
24 uint32_t seq)
25{
26
27 gtpv2c_tx->gtp.message_type = type;
28
29 gtpv2c_tx->gtp.version = GTP_VERSION_GTPV2C;
30 gtpv2c_tx->gtp.piggyback = 0;
31 gtpv2c_tx->gtp.teidFlg = 1;
32 gtpv2c_tx->gtp.spare = 0;
33
34 gtpv2c_tx->teid.has_teid.teid = htonl(teid);
35 gtpv2c_tx->teid.has_teid.seq = htonl(seq) >> 8;
36 gtpv2c_tx->teid.has_teid.spare = 0;
37
38 gtpv2c_tx->gtp.len = htons(8);
39
40 return;
41}