Код pdcp протокола
21.03.2018, 10:05. Показов 1424. Ответов 3
Добрый день. Мне нужно сгенерировать pdcp lte трафик. Нашел код соответствующей программы на сайте wireshark (в самом низу). Что получилось, значит:
packet-rohc.h
Кликните здесь для просмотра всего текста
| C++ | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
| /* packet-rohc.h
* Routines for RObust Header Compression (ROHC) dissection.
*
* Copyright 2011, Anders Broman <anders.broman[at]ericsson.com>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Ref:
* http://www.ietf.org/rfc/rfc3095.txt RObust Header Compression (ROHC): Framework and four profiles: RTP, UDP, ESP, and uncompressed
* http://datatracker.ietf.org/doc/rfc4815/ RObust Header Compression (ROHC): Corrections and Clarifications to RFC 3095
* http://datatracker.ietf.org/doc/rfc5225/ RObust Header Compression Version 2 (ROHCv2): Profiles for RTP, UDP, IP, ESP and UDP-Lite
*/
#ifndef PACKET_ROHC_H
#define PACKET_ROHC_H
#define MAX_CID 15
enum rohc_mode
{
MODE_NOT_SET = 0,
UNIDIRECTIONAL = 1,
OPTIMISTIC_BIDIRECTIONAL = 2,
RELIABLE_BIDIRECTIONAL = 3
};
enum rohc_d_mode
{
NO_CONTEXT = 1,
STATIC_CONTEXT = 2,
FULL_CONTEXT = 3
};
typedef struct rohc_info
{
gboolean rohc_compression;
guint16 rohc_ip_version;
gboolean cid_inclusion_info;
gboolean large_cid_present;
enum rohc_mode mode;
gboolean rnd;
gboolean udp_checksum_present;
guint16 profile;
// proto_item *last_created_item;
} rohc_info;
typedef struct rohc_context
{
guint16 rohc_ip_version[MAX_CID + 1];
gboolean large_cid_present[MAX_CID + 1];
enum rohc_mode mode[MAX_CID + 1];
enum rohc_d_mode d_mode[MAX_CID + 1];
gboolean rnd[MAX_CID + 1];
gboolean udp_checkum_present[MAX_CID + 1];
guint16 profile[MAX_CID + 1];
gboolean rohc_context_init[MAX_CID + 1];
// gint ir_frame_number[MAX_CID + 1]; /* The frame number of the last IR packet seen */
} rohc_context;
#endif /* PACKET_ROHC_H */ |
|
packet-pdcp-lte.h
Кликните здесь для просмотра всего текста
| C++ | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
| #pragma once
/* packet-pdcp-lte.h
*
* Martin Mathieson
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "packet-rohc.h"
/* Direction */
#define DIRECTION_UPLINK 0
#define DIRECTION_DOWNLINK 1
enum pdcp_plane
{
SIGNALING_PLANE = 1,
USER_PLANE = 2
};
typedef enum LogicalChannelType
{
Channel_DCCH = 1,
Channel_BCCH = 2,
Channel_CCCH = 3,
Channel_PCCH = 4,
Channel_DCCH_NB = 5,
Channel_BCCH_NB = 6,
Channel_CCCH_NB = 7,
Channel_PCCH_NB = 8
} LogicalChannelType;
typedef enum
{
BCH_TRANSPORT = 1,
DLSCH_TRANSPORT = 2
} BCCHTransportType;
#define PDCP_SN_LENGTH_5_BITS 5
#define PDCP_SN_LENGTH_7_BITS 7
#define PDCP_SN_LENGTH_12_BITS 12
#define PDCP_SN_LENGTH_15_BITS 15
#define PDCP_SN_LENGTH_18_BITS 18
enum security_integrity_algorithm_e { eia0, eia1, eia2, eia3 };
enum security_ciphering_algorithm_e { eea0, eea1, eea2, eea3 };
typedef struct pdcp_security_info_t
{
guint32 configuration_frame;
gboolean seen_next_ul_pdu; /* i.e. have we seen SecurityModeResponse */
enum security_integrity_algorithm_e integrity;
enum security_ciphering_algorithm_e ciphering;
/* Store previous settings so can revert if get SecurityModeFailure */
guint32 previous_configuration_frame;
enum security_integrity_algorithm_e previous_integrity;
enum security_ciphering_algorithm_e previous_ciphering;
} pdcp_security_info_t;
/* Info attached to each LTE PDCP/RoHC packet */
typedef struct pdcp_lte_info
{
/* Channel info is needed for RRC parsing */
guint8 direction;
guint16 ueid;
LogicalChannelType channelType;
guint16 channelId;
BCCHTransportType BCCHTransport;
/* Details of PDCP header */
gboolean no_header_pdu;
enum pdcp_plane plane;
guint8 seqnum_length;
/* RoHC settings */
rohc_info rohc;
guint8 is_retx;
} pdcp_lte_info;
/*****************************************************************/
/* UDP framing format */
/* ----------------------- */
/* Several people have asked about dissecting PDCP by framing */
/* PDUs over IP. A suggested format over UDP has been defined */
/* and implemented by this dissector, using the definitions */
/* below. A link to an example program showing you how to encode */
/* these headers and send LTE PDCP PDUs on a UDP socket is */
/* provided at https://wiki.wireshark.org/PDCP-LTE */
/* */
/* A heuristic dissecter (enabled by a preference) will */
/* recognise a signature at the beginning of these frames. */
/* Until someone is using this format, suggestions for changes */
/* are welcome. */
/*****************************************************************/
/* Signature. Rather than try to define a port for this, or make the
port number a preference, frames will start with this string (with no
terminating NULL */
#define PDCP_LTE_START_STRING "pdcp-lte"
/* Fixed fields. This is followed by the following 3 mandatory fields:
- no_header_pdu (1 byte)
- plane (1 byte)
- rohc_compression ( byte)
(where the allowed values are defined above) */
/* Conditional field. This field is mandatory in case of User Plane PDCP PDU.
The format is to have the tag, followed by the value (there is no length field,
it's implicit from the tag). The allowed values are defined above. */
#define PDCP_LTE_SEQNUM_LENGTH_TAG 0x02
/* 1 byte */
/* Optional fields. Attaching this info to frames will allow you
to show you display/filter/plot/add-custom-columns on these fields, so should
be added if available.
The format is to have the tag, followed by the value (there is no length field,
it's implicit from the tag) */
#define PDCP_LTE_DIRECTION_TAG 0x03
/* 1 byte */
#define PDCP_LTE_LOG_CHAN_TYPE_TAG 0x04
/* 1 byte */
#define PDCP_LTE_BCCH_TRANSPORT_TYPE_TAG 0x05
/* 1 byte */
#define PDCP_LTE_ROHC_IP_VERSION_TAG 0x06
/* 2 bytes, network order */
#define PDCP_LTE_ROHC_CID_INC_INFO_TAG 0x07
/* 1 byte */
#define PDCP_LTE_ROHC_LARGE_CID_PRES_TAG 0x08
/* 1 byte */
#define PDCP_LTE_ROHC_MODE_TAG 0x09
/* 1 byte */
#define PDCP_LTE_ROHC_RND_TAG 0x0A
/* 1 byte */
#define PDCP_LTE_ROHC_UDP_CHECKSUM_PRES_TAG 0x0B
/* 1 byte */
#define PDCP_LTE_ROHC_PROFILE_TAG 0x0C
/* 2 bytes, network order */
#define PDCP_LTE_CHANNEL_ID_TAG 0x0D
/* 2 bytes, network order */
#define PDCP_LTE_UEID_TAG 0x0E
/* 2 bytes, network order */
/* PDCP PDU. Following this tag comes the actual PDCP PDU (there is no length, the PDU
continues until the end of the frame) */
#define PDCP_LTE_PAYLOAD_TAG 0x01
/* Called by RRC, or other configuration protocols */
/* Function to configure ciphering & integrity algorithms */
void set_pdcp_lte_security_algorithms(guint16 ueid, pdcp_security_info_t *security_info);
/* Function to indicate securityModeCommand did not complete */
void set_pdcp_lte_security_algorithms_failed(guint16 ueid);
/* Called by external dissectors */
void set_pdcp_lte_rrc_ciphering_key(guint16 ueid, const char *key);
void set_pdcp_lte_rrc_integrity_key(guint16 ueid, const char *key);
void set_pdcp_lte_up_ciphering_key(guint16 ueid, const char *key);
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* vi: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/ |
|
main.cpp
Кликните здесь для просмотра всего текста
| C++ | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
| /* pdcp_lte_logger.c
*
* Example code for sending PDCP LTE frames over UDP
* Written by Pascal Quantin and Martin Mathieson
* This header file may also be distributed under
* the terms of the BSD Licence as follows:
*
* Copyright (C) 2009 Pascal Quantin & Martin Mathieson. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE
*/
#pragma comment(lib, "ws2_32.lib")
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#include <WinSock2.h>
//#include <netinet/in.h>
//#include <arpa/inet.h>
//#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
//#include <unistd.h>
typedef unsigned char guint8;
typedef unsigned short guint16;
typedef unsigned int guint32;
typedef int gboolean;
#ifndef FALSE
#define FALSE (0)
#endif
#ifndef TRUE
#define TRUE (!FALSE)
#endif
#include "packet-pdcp-lte.h"
/* Globals where each frame is composed before sending */
static unsigned char g_PDUBuffer[16000];
static unsigned int g_PDUOffset;
static /*unsigned*/ char g_frameBuffer[16000];
static unsigned int g_frameOffset;
/* UDP socket used for sending frames */
static int g_sockfd;
/* Remote serveraddress (where Wireshark is running) */
static struct sockaddr_in g_serv_addr;
/* Write a Signaling Plane PDCP PDU */
static void EncodeDummyPDCPPDU1(void)
{
g_PDUOffset = 0;
g_PDUBuffer[g_PDUOffset++] = 0x00;
g_PDUBuffer[g_PDUOffset++] = 0x48;
g_PDUBuffer[g_PDUOffset++] = 0x00;
g_PDUBuffer[g_PDUOffset++] = 0xE0;
g_PDUBuffer[g_PDUOffset++] = 0xE8;
g_PDUBuffer[g_PDUOffset++] = 0x60;
g_PDUBuffer[g_PDUOffset++] = 0x00;
g_PDUBuffer[g_PDUOffset++] = 0x6A;
g_PDUBuffer[g_PDUOffset++] = 0x40;
g_PDUBuffer[g_PDUOffset++] = 0x18;
g_PDUBuffer[g_PDUOffset++] = 0x40;
g_PDUBuffer[g_PDUOffset++] = 0x00;
g_PDUBuffer[g_PDUOffset++] = 0x00;
g_PDUBuffer[g_PDUOffset++] = 0x00;
g_PDUBuffer[g_PDUOffset++] = 0x00;
}
/* Write a User Plane Control PDCP PDU */
static void EncodeDummyPDCPPDU2(void)
{
g_PDUOffset = 0;
g_PDUBuffer[g_PDUOffset++] = 0x03;
g_PDUBuffer[g_PDUOffset++] = 0x10;
g_PDUBuffer[g_PDUOffset++] = 0x00;
g_PDUBuffer[g_PDUOffset++] = 0x00;
g_PDUBuffer[g_PDUOffset++] = 0x00;
g_PDUBuffer[g_PDUOffset++] = 0xDD;
g_PDUBuffer[g_PDUOffset++] = 0xBA;
}
/* Write a Data Plane Data PDCP PDU */
static void EncodeDummyPDCPPDU3(void)
{
g_PDUOffset = 0;
g_PDUBuffer[g_PDUOffset++] = 0x81;
g_PDUBuffer[g_PDUOffset++] = 0x09;
g_PDUBuffer[g_PDUOffset++] = 0x45;
g_PDUBuffer[g_PDUOffset++] = 0x00;
g_PDUBuffer[g_PDUOffset++] = 0x05;
g_PDUBuffer[g_PDUOffset++] = 0x40;
g_PDUBuffer[g_PDUOffset++] = 0xF6;
g_PDUBuffer[g_PDUOffset++] = 0xAD;
g_PDUBuffer[g_PDUOffset++] = 0x00;
g_PDUBuffer[g_PDUOffset++] = 0x00;
g_PDUBuffer[g_PDUOffset++] = 0x80;
g_PDUBuffer[g_PDUOffset++] = 0x11;
g_PDUBuffer[g_PDUOffset++] = 0xBD;
g_PDUBuffer[g_PDUOffset++] = 0xAB;
g_PDUBuffer[g_PDUOffset++] = 0xC0;
g_PDUBuffer[g_PDUOffset++] = 0xA8;
g_PDUBuffer[g_PDUOffset++] = 0x00;
g_PDUBuffer[g_PDUOffset++] = 0x01;
g_PDUBuffer[g_PDUOffset++] = 0xC0;
g_PDUBuffer[g_PDUOffset++] = 0xA8;
g_PDUBuffer[g_PDUOffset++] = 0x00;
g_PDUBuffer[g_PDUOffset++] = 0x02;
g_PDUBuffer[g_PDUOffset++] = 0x05;
g_PDUBuffer[g_PDUOffset++] = 0x74;
g_PDUBuffer[g_PDUOffset++] = 0x04;
g_PDUBuffer[g_PDUOffset++] = 0xD2;
g_PDUBuffer[g_PDUOffset++] = 0x05;
g_PDUBuffer[g_PDUOffset++] = 0x2C;
g_PDUBuffer[g_PDUOffset++] = 0x2F;
g_PDUBuffer[g_PDUOffset++] = 0x42;
g_PDUBuffer[g_PDUOffset++] = 0x47;
g_PDUBuffer[g_PDUOffset++] = 0x00;
g_PDUBuffer[g_PDUOffset++] = 0x45;
g_PDUBuffer[g_PDUOffset++] = 0x1D;
g_PDUBuffer[g_PDUOffset++] = 0x12;
}
/*******************************************/
/* Add framing header to PDCP PDU and send. */
void SendFrame(guint8 direction, LogicalChannelType channelType,
BCCHTransportType BCCHTransport, gboolean no_header_pdu,
enum pdcp_plane plane, guint8 seqnum_length, gboolean rohc_compression,
unsigned short rohc_ip_version, gboolean cid_inclusion_info,
gboolean large_cid_present, enum rohc_mode mode,
gboolean rnd, gboolean udp_checkum_present, unsigned short profile)
{
size_t bytesSent;
g_frameOffset = 0;
unsigned short tmp16;
/********************************************************************/
/* Fixed start to each frame (allowing heuristic dissector to work) */
/* Not NULL terminated */
memcpy(g_frameBuffer + g_frameOffset, PDCP_LTE_START_STRING,
strlen(PDCP_LTE_START_STRING));
g_frameOffset += strlen(PDCP_LTE_START_STRING);
/*******************************************************************************/
/* Now write out fixed fields (the mandatory elements of struct pdcp_lte_info) */
g_frameBuffer[g_frameOffset++] = no_header_pdu;
g_frameBuffer[g_frameOffset++] = plane;
g_frameBuffer[g_frameOffset++] = rohc_compression;
/*************************************/
/* Now conditional fields */
/* Seq Num Length */
if (plane == USER_PLANE) {
g_frameBuffer[g_frameOffset++] = PDCP_LTE_SEQNUM_LENGTH_TAG;
g_frameBuffer[g_frameOffset++] = seqnum_length;
}
/*************************************/
/* Now optional fields */
/* Direction */
g_frameBuffer[g_frameOffset++] = PDCP_LTE_DIRECTION_TAG;
g_frameBuffer[g_frameOffset++] = direction;
/* Logical Channel Type */
g_frameBuffer[g_frameOffset++] = PDCP_LTE_LOG_CHAN_TYPE_TAG;
g_frameBuffer[g_frameOffset++] = channelType;
/* BCCH Transport Type */
g_frameBuffer[g_frameOffset++] = PDCP_LTE_BCCH_TRANSPORT_TYPE_TAG;
g_frameBuffer[g_frameOffset++] = BCCHTransport;
/* RoHC IP Version */
g_frameBuffer[g_frameOffset++] = PDCP_LTE_ROHC_IP_VERSION_TAG;
tmp16 = htons(rohc_ip_version);
memcpy(g_frameBuffer + g_frameOffset, &tmp16, 2);
g_frameOffset += 2;
/* RoHC Cid Inclusion Info */
g_frameBuffer[g_frameOffset++] = PDCP_LTE_ROHC_CID_INC_INFO_TAG;
g_frameBuffer[g_frameOffset++] = cid_inclusion_info;
/* RoHC Large Cid Present */
g_frameBuffer[g_frameOffset++] = PDCP_LTE_ROHC_LARGE_CID_PRES_TAG;
g_frameBuffer[g_frameOffset++] = large_cid_present;
/* RoHC Mode */
g_frameBuffer[g_frameOffset++] = PDCP_LTE_ROHC_MODE_TAG;
g_frameBuffer[g_frameOffset++] = mode;
/* RoHC Rand */
g_frameBuffer[g_frameOffset++] = PDCP_LTE_ROHC_RND_TAG;
g_frameBuffer[g_frameOffset++] = rnd;
/* RoHC UDP Checksum Present */
g_frameBuffer[g_frameOffset++] = PDCP_LTE_ROHC_UDP_CHECKSUM_PRES_TAG;
g_frameBuffer[g_frameOffset++] = udp_checkum_present;
/* RoHC Profile */
g_frameBuffer[g_frameOffset++] = PDCP_LTE_ROHC_PROFILE_TAG;
tmp16 = htons(profile);
memcpy(g_frameBuffer + g_frameOffset, &tmp16, 2);
g_frameOffset += 2;
/***************************************/
/* Now write the PDCP PDU */
g_frameBuffer[g_frameOffset++] = PDCP_LTE_PAYLOAD_TAG;
/* Append actual PDU */
memcpy(g_frameBuffer + g_frameOffset, g_PDUBuffer, g_PDUOffset);
g_frameOffset += g_PDUOffset;
/* Send out the data over the UDP socket */
bytesSent = sendto(
g_sockfd,
&g_frameBuffer[0],
g_frameOffset, 0,
(const struct sockaddr*)&g_serv_addr, sizeof(g_serv_addr));
if (bytesSent != g_frameOffset) {
fprintf(stderr, "sendto() failed - expected %d bytes, got %d (errno=%d)\n",
g_frameOffset, bytesSent, errno);
exit(1);
}
}
/**************************************************************************/
/* Main function */
/* - set up socket + aserver address */
/* - encode and send some example LTE PDCP frames using framing protocol */
int main(int argc, char *argv[])
{
struct hostent *hp;
if (argc < 3) {
fprintf(stderr, "Usage: coclient <server-host> <server-port>\n");
exit(1);
}
/***********************************/
/* Create local socket */
g_sockfd = socket(AF_INET, SOCK_DGRAM, 0);
if (g_sockfd == -1) {
fprintf(stderr, "Error trying to create socket (errno=%d)\n", errno);
exit(1);
}
/***************************************************/
/* Get remote IP address from 1st command-line arg */
g_serv_addr.sin_family = AF_INET;
hp = gethostbyname(argv[1]);
if (hp == (struct hostent *)0) {
fprintf(stderr, "Unknown host %s (h_errno=%d)\n", argv[1], h_errno);
exit(1);
}
memcpy((void*)&g_serv_addr.sin_addr, (void*)hp->h_addr, hp->h_length);
/****************************************************/
/* Get remote port number from 2nd command-line arg */
g_serv_addr.sin_port = htons(atoi(argv[2]));
/****************************************************/
/* Encode and send some frames */
EncodeDummyPDCPPDU1();
SendFrame(DIRECTION_UPLINK,
Channel_DCCH,
BCCHTransportType(0) /* BCCHTransport */,
FALSE /* no_header_pdu */,
SIGNALING_PLANE,
0 /* seqnum_length */,
FALSE /* rohc_compression */,
0 /* rohc_ip_version */,
FALSE /* cid_inclusion_info */,
FALSE /* large_cid_present */,
UNIDIRECTIONAL,
FALSE /* rnd */,
FALSE /* udp_checkum_present */,
0 /* profile */);
EncodeDummyPDCPPDU2();
SendFrame(DIRECTION_UPLINK,
Channel_DCCH,
BCCHTransportType(0) /* BCCHTransport */,
FALSE /* no_header_pdu */,
USER_PLANE,
PDCP_SN_LENGTH_12_BITS,
FALSE /* rohc_compression */,
0 /* rohc_ip_version */,
FALSE /* cid_inclusion_info */,
FALSE /* large_cid_present */,
UNIDIRECTIONAL,
FALSE /* rnd */,
FALSE /* udp_checkum_present */,
0 /* profile */);
EncodeDummyPDCPPDU3();
SendFrame(DIRECTION_DOWNLINK,
Channel_DCCH,
BCCHTransportType(0) /* BCCHTransport */,
FALSE /* no_header_pdu */,
USER_PLANE,
PDCP_SN_LENGTH_12_BITS,
FALSE /* rohc_compression */,
0 /* rohc_ip_version */,
FALSE /* cid_inclusion_info */,
FALSE /* large_cid_present */,
UNIDIRECTIONAL,
FALSE /* rnd */,
FALSE /* udp_checkum_present */,
0 /* profile */);
/* Close local socket */
closesocket(g_sockfd);
return EXIT_SUCCESS;
} |
|
В качестве входных параметров, я писал "127.0.0.1 8080" - при чем не знаю, нормально ли это или нет, т.к. в сетях не силен. Но проблема сейчас в том, что не получается создать сокет | C++ | 1
2
| /* Create local socket */
g_sockfd = socket(AF_INET, SOCK_DGRAM, 0); |
|
. Может кто подсказать, что не так?
P.S. Я использую брендмауэр винды на запрет исходящих подключений, думал из-за этого, отключал его - не помогло.
P.S.P.S. ОС - Windows 10 LTBS, VS2015
0
|