blob: b955a0376ed9dd322ea9679aba2a81986edd0762 [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 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef __S1AP_H_
19#define __S1AP_H_
20
21#include <stdbool.h>
22
23#include "s1ap_structs.h"
24#include "log.h"
25#include "s1ap_ie.h"
26#include "InitiatingMessage.h"
27#include "SuccessfulOutcome.h"
28#include "UnsuccessfulOutcome.h"
29#include "common_proc_info.h"
30
31int
32s1_init_ctx_resp_handler(SuccessfulOutcome_t *msg);
33
34int
35parse_IEs(char *msg, struct proto_IE *proto_ies, unsigned short proc_code);
36
37int convertToInitUeProtoIe(InitiatingMessage_t *msg, struct proto_IE* proto_ies);
38int convertUplinkNasToProtoIe(InitiatingMessage_t *msg, struct proto_IE* proto_ies);
39int convertUeCtxRelReqToProtoIe(InitiatingMessage_t *msg, struct proto_IE* proto_ies);
40int convertInitCtxRspToProtoIe(SuccessfulOutcome_t *msg, struct proto_IE* proto_ies);
41int convertUeCtxRelComplToProtoIe(SuccessfulOutcome_t *msg, struct proto_IE* proto_ies);
42
43int
44s1_setup_handler(InitiatingMessage_t *msg, int enb_fd);
45
46int
47s1_init_ue_handler(struct proto_IE *s1_init_ies, int enb_fd);
48
49void
50handle_s1ap_message(void *message);
51
52int
53init_s1ap();
54
55void
56read_config();
57
58void*
59IAM_handler(void *data);
60
61int s1_esm_resp_handler(struct proto_IE *s1_esm_resp_ies);
62
63int s1_secmode_resp_handler(struct proto_IE *s1_sec_resp_ies);
64
65int s1_auth_resp_handler(struct proto_IE *s1_auth_resp_ies);
66
67int s1_auth_fail_handler(struct proto_IE *s1_auth_resp_ies);
68
69int s1_identity_resp_handler(struct proto_IE *s1_id_resp_ies);
70
71int s1_attach_complete_handler(struct proto_IE *s1_esm_resp_ies);
72
73int
74detach_stage1_handler(struct proto_IE *detach_ies, bool retransmit);
75
76int
77s1_init_ue_service_req_handler(struct proto_IE *service_req_ies, int enb_fd);
78
79int
80tau_request_handler(struct proto_IE *s1_tau_req_ies, int enb_fd);
81
82int
83s1_ctx_release_resp_handler(SuccessfulOutcome_t *msg);
84
85int
86s1_ctx_release_request_handler(InitiatingMessage_t *msg);
87
88int
89s1_ctx_release_complete_handler(SuccessfulOutcome_t *msg);
90
91int
92detach_accept_from_ue_handler(struct proto_IE *detach_ies, bool retransmit);
93
94int s1ap_mme_encode_ue_context_release_command(
95 struct s1ap_common_req_Q_msg *s1apPDU,
96 uint8_t **buffer, uint32_t *length);
97
98int s1ap_mme_encode_paging_request(
99 struct s1ap_common_req_Q_msg *s1apPDU,
100 uint8_t **buffer, uint32_t *length);
101
102int s1ap_mme_encode_initiating(
103 struct s1ap_common_req_Q_msg *s1apPDU,
104 uint8_t **buffer, uint32_t *length);
105
106int s1ap_mme_encode_initial_context_setup_request(
107 struct s1ap_common_req_Q_msg *s1apPDU,
108 uint8_t **buffer, uint32_t *length);
109
110int
111s1ap_mme_decode_initiating (InitiatingMessage_t *initiating_p, int enb_fd);
112
113int
114s1ap_mme_decode_successfull_outcome (SuccessfulOutcome_t *initiating_p);
115
116int
117s1ap_mme_decode_unsuccessfull_outcome (UnsuccessfulOutcome_t *initiating_p);
118
119int
120copyU16(unsigned char *buffer, uint32_t val);
121
122int
123send_sctp_msg(int connSock, unsigned char *buffer, size_t len, uint16_t stream_no);
124
125void
126buffer_copy(struct Buffer *buffer, void *value, size_t size);
127
128/**
129 * @brief Decode int value from the byte array received in the s1ap incoming
130 * packet.
131 * @param[in] bytes - Array of bytes in packet
132 * @param[in] len - Length of the bytes array from which to extract the int
133 * @return Integer value extracted out of bytes array. 0 if failed.
134 */
135int
136decode_int_val(unsigned char *bytes, short len);
137
138char*
139msg_to_hex_str(const char *msg, int len, char **buffer);
140
141unsigned short
142get_length(char **msg);
143#endif /*__S1AP_H_*/