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
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
/*
* socket.h - CC31xx/CC32xx Host Driver Implementation
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 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.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 THE COPYRIGHT
* OWNER 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.
*
*/
/*****************************************************************************/
/* Include files */
/*****************************************************************************/
extern "C" SL_INC_STD_BSD_API_NAMING
/*****************************************************************************/
/* Structure/Enum declarations */
/*****************************************************************************/
/* Internet address */
typedef struct SlInAddr_t
SlInAddr_t;
/* sockopt */
typedef struct
SlSockKeepalive_t;
typedef struct
SlSockReuseaddr_t;
typedef struct
SlSockWinsize_t;
typedef struct
SlSockNonblocking_t;
typedef struct
SlSocketAsyncEvent_t;
typedef struct
SlSockTxFailEventData_t;
typedef union
SlSockEventData_u;
typedef struct
SlSockEvent_t;
typedef struct
SlSockSecureMask;
typedef struct
SlSockSecureMethod;
typedef enum
slBsd_secureSocketFilesIndex_e;
typedef struct
SlSockIpMreq;
/* sockopt */
typedef _u32 SlTime_t;
typedef _u32 SlSuseconds_t;
typedef struct SlTimeval_t
SlTimeval_t;
typedef _u16 SlSocklen_t;
/* IpV4 socket address */
typedef struct SlSockAddr_t
SlSockAddr_t;
/* IpV6 or Ipv6 EUI64 */
typedef struct SlIn6Addr_t
SlIn6Addr_t;
typedef struct SlSockAddrIn6_t
SlSockAddrIn6_t;
/* Socket address, Internet style. */
typedef struct SlSockAddrIn_t
SlSockAddrIn_t;
typedef struct
SlIpV4AcquiredAsync_t;
typedef struct
SlIpV6AcquiredAsync_t;
typedef struct
SlIpLeasedAsync_t;
typedef struct
SlIpReleasedAsync_t;
typedef union
SlNetAppEventData_u;
typedef struct
SlNetAppEvent_t;
typedef struct sock_secureFiles
SlSockSecureFiles_t;
typedef struct SlFdSet_t /* The select socket array manager */
SlFdSet_t;
typedef struct
SlTransceiverRxOverHead_t;
/*****************************************************************************/
/* Function prototypes */
/*****************************************************************************/
/*!
\brief create an endpoint for communication
The socket function creates a new socket of a certain socket type, identified
by an integer number, and allocates system resources to it.
This function is called by the application layer to obtain a socket handle.
\param[in] domain specifies the protocol family of the created socket.
For example:
AF_INET for network protocol IPv4
AF_RF for starting transceiver mode. Notes:
- sending and receiving any packet overriding 802.11 header
- for optimized power consumption the socket will be started in TX
only mode until receive command is activated
AF_INET6 for IPv6
\param[in] type specifies the communication semantic, one of:
SOCK_STREAM (reliable stream-oriented service or Stream Sockets)
SOCK_DGRAM (datagram service or Datagram Sockets)
SOCK_RAW (raw protocols atop the network layer)
when used with AF_RF:
SOCK_DGRAM - L2 socket
SOCK_RAW - L1 socket - bypass WLAN CCA (Clear Channel Assessment)
\param[in] protocol specifies a particular transport to be used with
the socket.
The most common are IPPROTO_TCP, IPPROTO_SCTP, IPPROTO_UDP,
IPPROTO_DCCP.
The value 0 may be used to select a default
protocol from the selected domain and type
\return On success, socket handle that is used for consequent socket operations.
A successful return code should be a positive number (int16)
On error, a negative (int16) value will be returned specifying the error code.
SL_EAFNOSUPPORT - illegal domain parameter
SL_EPROTOTYPE - illegal type parameter
SL_EACCES - permission denied
SL_ENSOCK - exceeded maximal number of socket
SL_ENOMEM - memory allocation error
SL_EINVAL - error in socket configuration
SL_EPROTONOSUPPORT - illegal protocol parameter
SL_EOPNOTSUPP - illegal combination of protocol and type parameters
\sa sl_Close
\note belongs to \ref basic_api
\warning
*/
_i16 ;
/*!
\brief gracefully close socket
This function causes the system to release resources allocated to a socket. \n
In case of TCP, the connection is terminated.
\param[in] sd socket handle (received in sl_Socket)
\return On success, zero is returned.
On error, a negative number is returned.
\sa sl_Socket
\note belongs to \ref ext_api
\warning
*/
_i16 ;
/*!
\brief Accept a connection on a socket
This function is used with connection-based socket types (SOCK_STREAM).
It extracts the first connection request on the queue of pending
connections, creates a new connected socket, and returns a new file
descriptor referring to that socket.
The newly created socket is not in the listening state. The
original socket sd is unaffected by this call.
The argument sd is a socket that has been created with
sl_Socket(), bound to a local address with sl_Bind(), and is
listening for connections after a sl_Listen(). The argument \b
\e addr is a pointer to a sockaddr structure. This structure
is filled in with the address of the peer socket, as known to
the communications layer. The exact format of the address
returned addr is determined by the socket's address family.
The \b \e addrlen argument is a value-result argument: it
should initially contain the size of the structure pointed to
by addr, on return it will contain the actual length (in
bytes) of the address returned.
\param[in] sd socket descriptor (handle)
\param[out] addr the argument addr is a pointer
to a sockaddr structure. This
structure is filled in with the
address of the peer socket, as
known to the communications
layer. The exact format of the
address returned addr is
determined by the socket's
address\n
sockaddr:\n - code for the
address format. On this version
only AF_INET is supported.\n -
socket address, the length
depends on the code format
\param[out] addrlen the addrlen argument is a value-result
argument: it should initially contain the
size of the structure pointed to by addr
\return On success, a socket handle.
On a non-blocking accept a possible negative value is SL_EAGAIN.
On failure, negative value.
SL_POOL_IS_EMPTY may be return in case there are no resources in the system
In this case try again later or increase MAX_CONCURRENT_ACTIONS
\sa sl_Socket sl_Bind sl_Listen
\note belongs to \ref server_side
\warning
*/
_i16 ;
/*!
\brief assign a name to a socket
This function gives the socket the local address addr.
addr is addrlen bytes long. Traditionally, this is called
When a socket is created with socket, it exists in a name
space (address family) but has no name assigned.
It is necessary to assign a local address before a SOCK_STREAM
socket may receive connections.
\param[in] sd socket descriptor (handle)
\param[in] addr specifies the destination
addrs\n sockaddr:\n - code for
the address format. On this
version only AF_INET is
supported.\n - socket address,
the length depends on the code
format
\param[in] addrlen contains the size of the structure pointed to by addr
\return On success, zero is returned. On error, a negative error code is returned.
\sa sl_Socket sl_Accept sl_Listen
\note belongs to \ref basic_api
\warning
*/
_i16 ;
/*!
\brief listen for connections on a socket
The willingness to accept incoming connections and a queue
limit for incoming connections are specified with listen(),
and then the connections are accepted with accept.
The listen() call applies only to sockets of type SOCK_STREAM
The backlog parameter defines the maximum length the queue of
pending connections may grow to.
\param[in] sd socket descriptor (handle)
\param[in] backlog specifies the listen queue depth.
\return On success, zero is returned. On error, a negative error code is returned.
\sa sl_Socket sl_Accept sl_Bind
\note belongs to \ref server_side
\warning
*/
_i16 ;
/*!
\brief Initiate a connection on a socket
Function connects the socket referred to by the socket
descriptor sd, to the address specified by addr. The addrlen
argument specifies the size of addr. The format of the
address in addr is determined by the address space of the
socket. If it is of type SOCK_DGRAM, this call specifies the
peer with which the socket is to be associated; this address
is that to which datagrams are to be sent, and the only
address from which datagrams are to be received. If the
socket is of type SOCK_STREAM, this call attempts to make a
connection to another socket. The other socket is specified
by address, which is an address in the communications space
of the socket.
\param[in] sd socket descriptor (handle)
\param[in] addr specifies the destination addr\n
sockaddr:\n - code for the
address format. On this version
only AF_INET is supported.\n -
socket address, the length
depends on the code format
\param[in] addrlen contains the size of the structure pointed
to by addr
\return On success, a socket handle.
On a non-blocking connect a possible negative value is SL_EALREADY.
On failure, negative value.
SL_POOL_IS_EMPTY may be return in case there are no resources in the system
In this case try again later or increase MAX_CONCURRENT_ACTIONS
\sa sl_Socket
\note belongs to \ref client_side
\warning
*/
_i16 ;
/*!
\brief Monitor socket activity
Select allow a program to monitor multiple file descriptors,
waiting until one or more of the file descriptors become
"ready" for some class of I/O operation
\param[in] nfds the highest-numbered file descriptor in any of the
three sets, plus 1.
\param[out] readsds socket descriptors list for read monitoring and accept monitoring
\param[out] writesds socket descriptors list for connect monitoring only, write monitoring is not supported, non blocking connect is supported
\param[out] exceptsds socket descriptors list for exception monitoring, not supported.
\param[in] timeout is an upper bound on the amount of time elapsed
before select() returns. Null or above 0xffff seconds means
infinity timeout. The minimum timeout is 10 milliseconds,
less than 10 milliseconds will be set automatically to 10 milliseconds.
Max microseconds supported is 0xfffc00.
\return On success, select() returns the number of
file descriptors contained in the three returned
descriptor sets (that is, the total number of bits that
are set in readfds, writefds, exceptfds) which may be
zero if the timeout expires before anything interesting
happens. On error, a negative value is returned.
readsds - return the sockets on which Read request will
return without delay with valid data.
writesds - return the sockets on which Write request
will return without delay.
exceptsds - return the sockets closed recently.
SL_POOL_IS_EMPTY may be return in case there are no resources in the system
In this case try again later or increase MAX_CONCURRENT_ACTIONS
\sa sl_Socket
\note If the timeout value set to less than 5ms it will automatically set
to 5ms to prevent overload of the system
belongs to \ref basic_api
Only one sl_Select can be handled at a time.
Calling this API while the same command is called from another thread, may result
in one of the two scenarios:
1. The command will wait (internal) until the previous command finish, and then be executed.
2. There are not enough resources and SL_POOL_IS_EMPTY error will return.
In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try
again later to issue the command.
\warning
*/
_i16 ;
/*!
\brief Select's SlFdSet_t SET function
Sets current socket descriptor on SlFdSet_t container
*/
void ;
/*!
\brief Select's SlFdSet_t CLR function
Clears current socket descriptor on SlFdSet_t container
*/
void ;
/*!
\brief Select's SlFdSet_t ISSET function
Checks if current socket descriptor is set (TRUE/FALSE)
\return Returns TRUE if set, FALSE if unset
*/
_i16 ;
/*!
\brief Select's SlFdSet_t ZERO function
Clears all socket descriptors from SlFdSet_t
*/
void ;
/*!
\brief set socket options
This function manipulate the options associated with a socket.
Options may exist at multiple protocol levels; they are always
present at the uppermost socket level.
When manipulating socket options the level at which the option resides
and the name of the option must be specified. To manipulate options at
the socket level, level is specified as SOL_SOCKET. To manipulate
options at any other level the protocol number of the appropriate proto-
col controlling the option is supplied. For example, to indicate that an
option is to be interpreted by the TCP protocol, level should be set to
the protocol number of TCP;
The parameters optval and optlen are used to access optval -
ues for setsockopt(). For getsockopt() they identify a
buffer in which the value for the requested option(s) are to
be returned. For getsockopt(), optlen is a value-result
parameter, initially containing the size of the buffer
pointed to by option_value, and modified on return to
indicate the actual size of the value returned. If no option
value is to be supplied or returned, option_value may be
NULL.
\param[in] sd socket handle
\param[in] level defines the protocol level for this option
- <b>SL_SOL_SOCKET</b> Socket level configurations (L4, transport layer)
- <b>SL_IPPROTO_IP</b> IP level configurations (L3, network layer)
- <b>SL_SOL_PHY_OPT</b> Link level configurations (L2, link layer)
\param[in] optname defines the option name to interrogate
- <b>SL_SOL_SOCKET</b>
- <b>SL_SO_KEEPALIVE</b> \n
Enable/Disable periodic keep alive.
Keeps TCP connections active by enabling the periodic transmission of messages \n
Timeout is 5 minutes.\n
Default: Enabled \n
This options takes SlSockKeepalive_t struct as parameter
- <b>SL_SO_RCVTIMEO</b> \n
Sets the timeout value that specifies the maximum amount of time an input function waits until it completes. \n
Default: No timeout \n
This options takes SlTimeval_t struct as parameter
- <b>SL_SO_RCVBUF</b> \n
Sets tcp max recv window size. \n
This options takes SlSockWinsize_t struct as parameter
- <b>SL_SO_NONBLOCKING</b> \n
Sets socket to non-blocking operation Impacts: connect, accept, send, sendto, recv and recvfrom. \n
Default: Blocking.
This options takes SlSockNonblocking_t struct as parameter
- <b>SL_SO_SECMETHOD</b> \n
Sets method to tcp secured socket (SL_SEC_SOCKET) \n
Default: SL_SO_SEC_METHOD_SSLv3_TLSV1_2 \n
This options takes SlSockSecureMethod struct as parameter
- <b>SL_SO_SEC_MASK</b> \n
Sets specific cipher to tcp secured socket (SL_SEC_SOCKET) \n
Default: "Best" cipher suitable to method \n
This options takes SlSockSecureMask struct as parameter
- <b>SL_SO_SECURE_FILES_CA_FILE_NAME</b> \n
Map secured socket to CA file by name \n
This options takes <b>_u8</b> buffer as parameter
- <b>SL_SO_SECURE_FILES_PRIVATE_KEY_FILE_NAME</b> \n
Map secured socket to private key by name \n
This options takes <b>_u8</b> buffer as parameter
- <b>SL_SO_SECURE_FILES_CERTIFICATE_FILE_NAME</b> \n
Map secured socket to certificate file by name \n
This options takes <b>_u8</b> buffer as parameter
- <b>SL_SO_SECURE_FILES_DH_KEY_FILE_NAME</b> \n
Map secured socket to Diffie Hellman file by name \n
This options takes <b>_u8</b> buffer as parameter
- <b>SL_SO_CHANGE_CHANNEL</b> \n
Sets channel in transceiver mode.
This options takes <b>_u32</b> as channel number parameter
- <b>SL_IPPROTO_IP</b>
- <b>SL_IP_MULTICAST_TTL</b> \n
Set the time-to-live value of outgoing multicast packets for this socket. \n
This options takes <b>_u8</b> as parameter
- <b>SL_IP_ADD_MEMBERSHIP</b> \n
UDP socket, Join a multicast group. \n
This options takes SlSockIpMreq struct as parameter
- <b>SL_IP_DROP_MEMBERSHIP</b> \n
UDP socket, Leave a multicast group \n
This options takes SlSockIpMreq struct as parameter
- <b>SL_IP_RAW_RX_NO_HEADER</b> \n
Raw socket remove IP header from received data. \n
Default: data includes ip header \n
This options takes <b>_u32</b> as parameter
- <b>SL_IP_HDRINCL</b> \n
RAW socket only, the IPv4 layer generates an IP header when sending a packet unless \n
the IP_HDRINCL socket option is enabled on the socket. \n
When it is enabled, the packet must contain an IP header. \n
Default: disabled, IPv4 header generated by Network Stack \n
This options takes <b>_u32</b> as parameter
- <b>SL_IP_RAW_IPV6_HDRINCL</b> (inactive) \n
RAW socket only, the IPv6 layer generates an IP header when sending a packet unless \n
the IP_HDRINCL socket option is enabled on the socket. When it is enabled, the packet must contain an IP header \n
Default: disabled, IPv4 header generated by Network Stack \n
This options takes <b>_u32</b> as parameter
- <b>SL_SOL_PHY_OPT</b>
- <b>SL_SO_PHY_RATE</b> \n
RAW socket, set WLAN PHY transmit rate \n
The values are based on RateIndex_e \n
This options takes <b>_u32</b> as parameter
- <b>SL_SO_PHY_TX_POWER</b> \n
RAW socket, set WLAN PHY TX power \n
Valid rage is 1-15 \n
This options takes <b>_u32</b> as parameter
- <b>SL_SO_PHY_NUM_FRAMES_TO_TX</b> \n
RAW socket, set number of frames to transmit in transceiver mode.
Default: 1 packet
This options takes <b>_u32</b> as parameter
- <b>SL_SO_PHY_PREAMBLE</b> \n
RAW socket, set WLAN PHY preamble for Long/Short\n
This options takes <b>_u32</b> as parameter
\param[in] optval specifies a value for the option
\param[in] optlen specifies the length of the
option value
\return On success, zero is returned.
On error, a negative value is returned.
\sa sl_getsockopt
\note belongs to \ref basic_api
\warning
\par Examples:
\par
<b> SL_SO_KEEPALIVE: </b>(disable Keepalive)
\code
SlSockKeepalive_t enableOption;
enableOption.KeepaliveEnabled = 0;
sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_KEEPALIVE, (_u8 *)&enableOption,sizeof(enableOption));
\endcode
\par
<b> SL_SO_RCVTIMEO: </b>
\code
struct SlTimeval_t timeVal;
timeVal.tv_sec = 1; // Seconds
timeVal.tv_usec = 0; // Microseconds. 10000 microseconds resolution
sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_RCVTIMEO, (_u8 *)&timeVal, sizeof(timeVal)); // Enable receive timeout
\endcode
\par
<b> SL_SO_RCVBUF: </b>
\code
SlSockWinsize_t size;
size.Winsize = 3000; // bytes
sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_RCVBUF, (_u8 *)&size, sizeof(size));
\endcode
\par
<b> SL_SO_NONBLOCKING: </b>
\code
SlSockNonblocking_t enableOption;
enableOption.NonblockingEnabled = 1;
sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_NONBLOCKING, (_u8 *)&enableOption,sizeof(enableOption)); // Enable/disable nonblocking mode
\endcode
\par
<b> SL_SO_SECMETHOD:</b>
\code
SlSockSecureMethod method;
method.secureMethod = SL_SO_SEC_METHOD_SSLV3; // security method we want to use
SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, SL_SEC_SOCKET);
sl_SetSockOpt(SockID, SL_SOL_SOCKET, SL_SO_SECMETHOD, (_u8 *)&method, sizeof(method));
\endcode
\par
<b> SL_SO_SECURE_MASK:</b>
\code
SlSockSecureMask cipher;
cipher.secureMask = SL_SEC_MASK_SSL_RSA_WITH_RC4_128_SHA; // cipher type
SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, SL_SEC_SOCKET);
sl_SetSockOpt(SockID, SL_SOL_SOCKET, SL_SO_SEC_MASK,(_u8 *)&cipher, sizeof(cipher));
\endcode
\par
<b> SL_SO_SECURE_FILES_CA_FILE_NAME:</b>
\code
sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_SECURE_FILES_CA_FILE_NAME,"exuifaxCaCert.der",strlen("exuifaxCaCert.der"));
\endcode
\par
<b> SL_SO_SECURE_FILES_PRIVATE_KEY_FILE_NAME:</b>
\code
sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_SECURE_FILES_PRIVATE_KEY_FILE_NAME,"myPrivateKey.der",strlen("myPrivateKey.der"));
\endcode
\par
<b> SL_SO_SECURE_FILES_CERTIFICATE_FILE_NAME:</b>
\code
sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_SECURE_FILES_CERTIFICATE_FILE_NAME,"myCertificate.der",strlen("myCertificate.der"));
\endcode
\par
<b> SL_SO_SECURE_FILES_DH_KEY_FILE_NAME:</b>
\code
sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_SECURE_FILES_DH_KEY_FILE_NAME,"myDHinServerMode.der",strlen("myDHinServerMode.der"));
\endcode
\par
<b> SL_IP_MULTICAST_TTL:</b>
\code
_u8 ttl = 20;
sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_MULTICAST_TTL, &ttl, sizeof(ttl));
\endcode
\par
<b> SL_IP_ADD_MEMBERSHIP:</b>
\code
SlSockIpMreq mreq;
sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq));
\endcode
\par
<b> SL_IP_DROP_MEMBERSHIP:</b>
\code
SlSockIpMreq mreq;
sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq));
\endcode
\par
<b> SL_SO_CHANGE_CHANNEL:</b>
\code
_u32 newChannel = 6; // range is 1-13
sl_SetSockOpt(SockID, SL_SOL_SOCKET, SL_SO_CHANGE_CHANNEL, &newChannel, sizeof(newChannel));
\endcode
\par
<b> SL_IP_RAW_RX_NO_HEADER:</b>
\code
_u32 header = 1; // remove ip header
sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_RAW_RX_NO_HEADER, &header, sizeof(header));
\endcode
\par
<b> SL_IP_HDRINCL:</b>
\code
_u32 header = 1;
sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_HDRINCL, &header, sizeof(header));
\endcode
\par
<b> SL_IP_RAW_IPV6_HDRINCL:</b>
\code
_u32 header = 1;
sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_RAW_IPV6_HDRINCL, &header, sizeof(header));
\endcode
\par
<b> SL_SO_PHY_RATE:</b>
\code
_u32 rate = 6; // see wlan.h RateIndex_e for values
sl_SetSockOpt(SockID, SL_SOL_PHY_OPT, SL_SO_PHY_RATE, &rate, sizeof(rate));
\endcode
\par
<b> SL_SO_PHY_TX_POWER:</b>
\code
_u32 txpower = 1; // valid range is 1-15
sl_SetSockOpt(SockID, SL_SOL_PHY_OPT, SL_SO_PHY_TX_POWER, &txpower, sizeof(txpower));
\endcode
\par
<b> SL_SO_PHY_NUM_FRAMES_TO_TX:</b>
\code
_u32 numframes = 1;
sl_SetSockOpt(SockID, SL_SOL_PHY_OPT, SL_SO_PHY_NUM_FRAMES_TO_TX, &numframes, sizeof(numframes));
\endcode
\par
<b> SL_SO_PHY_PREAMBLE:</b>
\code
_u32 preamble = 1;
sl_SetSockOpt(SockID, SL_SOL_PHY_OPT, SL_SO_PHY_PREAMBLE, &preamble, sizeof(preamble));
\endcode
*/
_i16 ;
/*!
\brief Get socket options
This function manipulate the options associated with a socket.
Options may exist at multiple protocol levels; they are always
present at the uppermost socket level.
When manipulating socket options the level at which the option resides
and the name of the option must be specified. To manipulate options at
the socket level, level is specified as SOL_SOCKET. To manipulate
options at any other level the protocol number of the appropriate proto-
col controlling the option is supplied. For example, to indicate that an
option is to be interpreted by the TCP protocol, level should be set to
the protocol number of TCP;
The parameters optval and optlen are used to access optval -
ues for setsockopt(). For getsockopt() they identify a
buffer in which the value for the requested option(s) are to
be returned. For getsockopt(), optlen is a value-result
parameter, initially containing the size of the buffer
pointed to by option_value, and modified on return to
indicate the actual size of the value returned. If no option
value is to be supplied or returned, option_value may be
NULL.
\param[in] sd socket handle
\param[in] level defines the protocol level for this option
\param[in] optname defines the option name to interrogate
\param[out] optval specifies a value for the option
\param[out] optlen specifies the length of the
option value
\return On success, zero is returned.
On error, a negative value is returned.
\sa sl_SetSockOpt
\note See sl_SetSockOpt
belongs to \ref ext_api
\warning
*/
_i16 ;
/*!
\brief read data from TCP socket
function receives a message from a connection-mode socket
\param[in] sd socket handle
\param[out] buf Points to the buffer where the
message should be stored.
\param[in] Len Specifies the length in bytes of
the buffer pointed to by the buffer argument.
Range: 1-16000 bytes
\param[in] flags Specifies the type of message
reception. On this version, this parameter is not
supported.
\return return the number of bytes received,
or a negative value if an error occurred.
using a non-blocking recv a possible negative value is SL_EAGAIN.
SL_POOL_IS_EMPTY may be return in case there are no resources in the system
In this case try again later or increase MAX_CONCURRENT_ACTIONS
\sa sl_RecvFrom
\note belongs to \ref recv_api
\warning
\par Examples:
\code An example of receiving data using TCP socket:
SlSockAddrIn_t Addr;
SlSockAddrIn_t LocalAddr;
_i16 AddrSize = sizeof(SlSockAddrIn_t);
_i16 SockID, newSockID;
_i16 Status;
_i8 Buf[RECV_BUF_LEN];
LocalAddr.sin_family = SL_AF_INET;
LocalAddr.sin_port = sl_Htons(5001);
LocalAddr.sin_addr.s_addr = 0;
Addr.sin_family = SL_AF_INET;
Addr.sin_port = sl_Htons(5001);
Addr.sin_addr.s_addr = sl_Htonl(SL_IPV4_VAL(10,1,1,200));
SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
Status = sl_Bind(SockID, (SlSockAddr_t *)&LocalAddr, AddrSize);
Status = sl_Listen(SockID, 0);
newSockID = sl_Accept(SockID, (SlSockAddr_t*)&Addr, (SlSocklen_t*) &AddrSize);
Status = sl_Recv(newSockID, Buf, 1460, 0);
\endcode
\code Example code for Rx transceiver mode using a raw socket
_i8 buffer[1536];
_i16 sd;
_u16 size;
SlTransceiverRxOverHead_t *transHeader;
sd = sl_Socket(SL_AF_RF,SL_SOCK_RAW,11); // channel 11
while(1)
{
size = sl_Recv(sd,buffer,1536,0);
transHeader = (SlTransceiverRxOverHead_t *)buffer;
printf("RSSI is %d frame type is 0x%x size %d\n",transHeader->rssi,buffer[sizeof(SlTransceiverRxOverHead_t)],size);
}
\endcode
*/
_i16 ;
/*!
\brief read data from socket
function receives a message from a connection-mode or
connectionless-mode socket
\param[in] sd socket handle
\param[out] buf Points to the buffer where the message should be stored.
\param[in] Len Specifies the length in bytes of the buffer pointed to by the buffer argument.
Range: 1-16000 bytes
\param[in] flags Specifies the type of message
reception. On this version, this parameter is not
supported.
\param[in] from pointer to an address structure
indicating the source
address.\n sockaddr:\n - code
for the address format. On this
version only AF_INET is
supported.\n - socket address,
the length depends on the code
format
\param[in] fromlen source address structure
size. This parameter MUST be set to the size of the structure pointed to by addr.
\return return the number of bytes received,
or a negative value if an error occurred.
using a non-blocking recv a possible negative value is SL_EAGAIN.
SL_RET_CODE_INVALID_INPUT (-2) will be returned if fromlen has incorrect length.
SL_POOL_IS_EMPTY may be return in case there are no resources in the system
In this case try again later or increase MAX_CONCURRENT_ACTIONS
\sa sl_Recv
\note belongs to \ref recv_api
\warning
\par Example:
\code An example of receiving data:
SlSockAddrIn_t Addr;
SlSockAddrIn_t LocalAddr;
_i16 AddrSize = sizeof(SlSockAddrIn_t);
_i16 SockID;
_i16 Status;
_i8 Buf[RECV_BUF_LEN];
LocalAddr.sin_family = SL_AF_INET;
LocalAddr.sin_port = sl_Htons(5001);
LocalAddr.sin_addr.s_addr = 0;
SockID = sl_Socket(SL_AF_INET,SL_SOCK_DGRAM, 0);
Status = sl_Bind(SockID, (SlSockAddr_t *)&LocalAddr, AddrSize);
Status = sl_RecvFrom(SockID, Buf, 1472, 0, (SlSockAddr_t *)&Addr, (SlSocklen_t*)&AddrSize);
\endcode
*/
_i16 ;
/*!
\brief write data to TCP socket
This function is used to transmit a message to another socket.
Returns immediately after sending data to device.
In case of TCP failure an async event SL_SOCKET_TX_FAILED_EVENT is going to
be received.
In case of a RAW socket (transceiver mode), extra 4 bytes should be reserved at the end of the
frame data buffer for WLAN FCS
\param[in] sd socket handle
\param[in] buf Points to a buffer containing
the message to be sent
\param[in] Len message size in bytes. Range: 1-1460 bytes
\param[in] flags Specifies the type of message
transmission. On this version, this parameter is not
supported for TCP.
For transceiver mode, the SL_RAW_RF_TX_PARAMS macro can be used to determine
transmission parameters (channel,rate,tx_power,preamble)
\return Return the number of bytes transmitted,
or -1 if an error occurred
\sa sl_SendTo
\note belongs to \ref send_api
\warning
\par Example:
\code An example of sending data:
SlSockAddrIn_t Addr;
_i16 AddrSize = sizeof(SlSockAddrIn_t);
_i16 SockID;
_i16 Status;
_i8 Buf[SEND_BUF_LEN];
Addr.sin_family = SL_AF_INET;
Addr.sin_port = sl_Htons(5001);
Addr.sin_addr.s_addr = sl_Htonl(SL_IPV4_VAL(10,1,1,200));
SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
Status = sl_Connect(SockID, (SlSockAddr_t *)&Addr, AddrSize);
Status = sl_Send(SockID, Buf, 1460, 0 );
\endcode
*/
_i16 ;
/*!
\brief write data to socket
This function is used to transmit a message to another socket
(connection less socket SOCK_DGRAM, SOCK_RAW).
Returns immediately after sending data to device.
In case of transmission failure an async event SL_SOCKET_TX_FAILED_EVENT is going to
be received.
\param[in] sd socket handle
\param[in] buf Points to a buffer containing
the message to be sent
\param[in] Len message size in bytes. Range: 1-1460 bytes
\param[in] flags Specifies the type of message
transmission. On this version, this parameter is not
supported
\param[in] to pointer to an address structure
indicating the destination
address.\n sockaddr:\n - code
for the address format. On this
version only AF_INET is
supported.\n - socket address,
the length depends on the code
format
\param[in] tolen destination address structure size
\return Return the number of transmitted bytes,
or -1 if an error occurred
\sa sl_Send
\note belongs to \ref send_api
\warning
\par Example:
\code An example of sending data:
SlSockAddrIn_t Addr;
_i16 AddrSize = sizeof(SlSockAddrIn_t);
_i16 SockID;
_i16 Status;
_i8 Buf[SEND_BUF_LEN];
Addr.sin_family = SL_AF_INET;
Addr.sin_port = sl_Htons(5001);
Addr.sin_addr.s_addr = sl_Htonl(SL_IPV4_VAL(10,1,1,200));
SockID = sl_Socket(SL_AF_INET,SL_SOCK_DGRAM, 0);
Status = sl_SendTo(SockID, Buf, 1472, 0, (SlSockAddr_t *)&Addr, AddrSize);
\endcode
*/
_i16 ;
/*!
\brief Reorder the bytes of a 32-bit unsigned value
This function is used to Reorder the bytes of a 32-bit unsigned value from processor order to network order.
\param[in] var variable to reorder
\return Return the reorder variable,
\sa sl_SendTo sl_Bind sl_Connect sl_RecvFrom sl_Accept
\note belongs to \ref send_api
\warning
*/
_u32 ;
/*!
\brief Reorder the bytes of a 16-bit unsigned value
This function is used to Reorder the bytes of a 16-bit unsigned value from processor order to network order.
\param[in] var variable to reorder
\return Return the reorder variable,
\sa sl_SendTo sl_Bind sl_Connect sl_RecvFrom sl_Accept
\note belongs to \ref send_api
\warning
*/
_u16 ;
/*!
Close the Doxygen group.
@}
*/
}
/* __cplusplus */
/* __SOCKET_H__ */