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
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _CHAP_H
#define _CHAP_H
#ifdef __cplusplus
extern "C" {
#endif
#include <netinet/in.h>
#include <sys/int_types.h>
#include <sys/iscsit/iscsi_if.h>
#include <sys/iscsit/radius_protocol.h>
typedef enum chap_validation_status_type {
CHAP_VALIDATION_PASSED, /* CHAP validation passed */
CHAP_VALIDATION_INVALID_RESPONSE, /* Invalid CHAP response */
CHAP_VALIDATION_DUP_SECRET, /* Same CHAP secret used */
/* for authentication in the */
/* other direction */
CHAP_VALIDATION_UNKNOWN_AUTH_METHOD, /* Unknown authentication */
/* method */
CHAP_VALIDATION_INTERNAL_ERROR, /* MISC internal error */
CHAP_VALIDATION_RADIUS_ACCESS_ERROR, /* Problem accessing RADIUS */
CHAP_VALIDATION_BAD_RADIUS_SECRET, /* Invalid RADIUS shared */
/* secret */
CHAP_VALIDATION_UNKNOWN_RADIUS_CODE /* Irrelevant or unknown */
/* RADIUS packet code */
/* returned */
} chap_validation_status_type;
typedef enum authentication_method_type {
RADIUS_AUTHENTICATION,
DIRECT_AUTHENTICATION
} authentication_method_type;
typedef struct radius_config {
iscsi_ipaddr_t rad_svr_addr; /* IPv6 enabled */
uint32_t rad_svr_port;
uint8_t rad_svr_shared_secret[MAX_RAD_SHARED_SECRET_LEN];
uint32_t rad_svr_shared_secret_len;
} RADIUS_CONFIG;
/*
* To validate a target CHAP response given the associated challenge.
*
* target_chap_name - The CHAP name of the target being authenticated.
* initiator_chap_name - The CHAP name of the authenticating initiator.
* challenge - The CHAP challenge to which the target responded.
* target_response - The target's CHAP response to be validated.
* identifier - The identifier associated with the CHAP challenge.
* auth_method - The authentication method to be used.
* auth_config_data - Any required configuration data to support the
* specified authentication method.
*/
chap_validation_status_type
chap_validate(
char *target_chap_name,
char *initiator_chap_name,
uint8_t *challenge,
uint8_t *target_response,
uint8_t identifier,
authentication_method_type auth_method,
void *auth_config_data);
#ifdef __cplusplus
}
#endif
#endif /* _CHAP_H */
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _ISCSI_IF_H
#define _ISCSI_IF_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _KERNEL
#include <sys/types.h>
#include <sys/strsubr.h> /* for prototype of kstrgetmsg */
#include <sys/socket.h>
#include <sys/socketvar.h> /* for struct sonode */
#endif
#include <netinet/in.h>
#include <sys/scsi/impl/uscsi.h>
#include <sys/iscsi_protocol.h>
/*
* Each of the top level structures have a version field as
* the first member. That version value will be set by the
* caller. The consumer of the structure will check to see
* if the version is correct.
*/
#define ISCSI_INTERFACE_VERSION 3
/*
* The maximum length of an iSCSI name is 223. 224 is used
* to provide space for a null character.
*/
#define ISCSI_MAX_NAME_LEN 224
/*
* Login parameter values are used instead of ascii text
* between the IMA plug-in and kernel.
*/
#define ISCSI_LOGIN_PARAM_DATA_SEQUENCE_IN_ORDER 0x0000 /* bool */
#define ISCSI_LOGIN_PARAM_IMMEDIATE_DATA 0x0001 /* bool */
#define ISCSI_LOGIN_PARAM_INITIAL_R2T 0x0002 /* bool */
#define ISCSI_LOGIN_PARAM_DATA_PDU_IN_ORDER 0x0003 /* bool */
#define ISCSI_LOGIN_PARAM_HEADER_DIGEST 0x0004 /* int */
#define ISCSI_LOGIN_PARAM_DATA_DIGEST 0x0005 /* int */
#define ISCSI_LOGIN_PARAM_DEFAULT_TIME_2_RETAIN 0x0006 /* int */
#define ISCSI_LOGIN_PARAM_DEFAULT_TIME_2_WAIT 0x0007 /* int */
#define ISCSI_LOGIN_PARAM_MAX_RECV_DATA_SEGMENT_LENGTH 0x0008 /* int */
#define ISCSI_LOGIN_PARAM_FIRST_BURST_LENGTH 0x0009 /* int */
#define ISCSI_LOGIN_PARAM_MAX_BURST_LENGTH 0x000A /* int */
#define ISCSI_LOGIN_PARAM_MAX_CONNECTIONS 0x000B /* int */
#define ISCSI_LOGIN_PARAM_OUTSTANDING_R2T 0x000C /* int */
#define ISCSI_LOGIN_PARAM_ERROR_RECOVERY_LEVEL 0x000D /* int */
/*
* number of login parameters - needs to be updated when new parameter added
*/
#define ISCSI_NUM_LOGIN_PARAM 0x000E
/*
* Used internally by the persistent store code. Currently a bitmap is kept of
* which params are currently set. This allows for quick a look up instead of
* cycling through the possible entries. Using an unsigned int as the bitmap we
* can have parameter numbers up through 31. Since the current only has 22
* we're okay.
*/
#define ISCSI_LOGIN_PARAM_DB_ENTRY 0x0020
/*
* Special case. When this parameter value is set in iscsi_param_set_t
* the member s_value (type iscsi_param_set_t) is not used.
* The name field contains the InitiatorName for the system which
* should be used for all future sessions.
*/
#define ISCSI_LOGIN_PARAM_INITIATOR_NAME 0x0021
#define ISCSI_LOGIN_PARAM_INITIATOR_ALIAS 0x0022
#define ISCSI_DEVCTL "devctl"
#define ISCSI_DRIVER_DEVCTL "/devices/iscsi:" ISCSI_DEVCTL
/*
* ioctls supported by the driver.
*/
#define ISCSI_IOCTL (('i' << 24) | ('S' << 16) | ('C' << 8))
#define ISCSI_CREATE_OID (ISCSI_IOCTL | 2)
#define ISCSI_LOGIN (ISCSI_IOCTL | 3)
#define ISCSI_LOGOUT (ISCSI_IOCTL | 4)
#define ISCSI_PARAM_GET (ISCSI_IOCTL | 5)
#define ISCSI_PARAM_SET (ISCSI_IOCTL | 6)
#define ISCSI_TARGET_PARAM_CLEAR (ISCSI_IOCTL | 8)
#define ISCSI_TARGET_OID_LIST_GET (ISCSI_IOCTL | 9)
#define ISCSI_TARGET_PROPS_GET (ISCSI_IOCTL | 10)
#define ISCSI_TARGET_PROPS_SET (ISCSI_IOCTL | 11)
#define ISCSI_TARGET_ADDRESS_GET (ISCSI_IOCTL | 12)
#define ISCSI_CHAP_SET (ISCSI_IOCTL | 13)
#define ISCSI_CHAP_GET (ISCSI_IOCTL | 14)
#define ISCSI_CHAP_CLEAR (ISCSI_IOCTL | 15)
#define ISCSI_STATIC_GET (ISCSI_IOCTL | 16)
#define ISCSI_STATIC_SET (ISCSI_IOCTL | 17)
#define ISCSI_STATIC_CLEAR (ISCSI_IOCTL | 18)
#define ISCSI_DISCOVERY_SET (ISCSI_IOCTL | 19)
#define ISCSI_DISCOVERY_GET (ISCSI_IOCTL | 20)
#define ISCSI_DISCOVERY_CLEAR (ISCSI_IOCTL | 21)
#define ISCSI_DISCOVERY_PROPS (ISCSI_IOCTL | 22)
#define ISCSI_DISCOVERY_ADDR_SET (ISCSI_IOCTL | 23)
#define ISCSI_DISCOVERY_ADDR_LIST_GET (ISCSI_IOCTL | 24)
#define ISCSI_DISCOVERY_ADDR_CLEAR (ISCSI_IOCTL | 25)
#define ISCSI_RADIUS_SET (ISCSI_IOCTL | 26)
#define ISCSI_RADIUS_GET (ISCSI_IOCTL | 27)
#define ISCSI_DB_RELOAD (ISCSI_IOCTL | 28)
#define ISCSI_LUN_OID_LIST_GET (ISCSI_IOCTL | 29)
#define ISCSI_LUN_PROPS_GET (ISCSI_IOCTL | 30)
#define ISCSI_CONN_OID_LIST_GET (ISCSI_IOCTL | 31)
#define ISCSI_CONN_PROPS_GET (ISCSI_IOCTL | 32)
#define ISCSI_USCSI (ISCSI_IOCTL | 33)
#define ISCSI_DOOR_HANDLE_SET (ISCSI_IOCTL | 34)
#define ISCSI_DISCOVERY_EVENTS (ISCSI_IOCTL | 35)
#define ISCSI_AUTH_SET (ISCSI_IOCTL | 36)
#define ISCSI_AUTH_GET (ISCSI_IOCTL | 37)
#define ISCSI_AUTH_CLEAR (ISCSI_IOCTL | 38)
#define ISCSI_SENDTGTS_GET (ISCSI_IOCTL | 39)
#define ISCSI_ISNS_SERVER_ADDR_SET (ISCSI_IOCTL | 40)
#define ISCSI_ISNS_SERVER_ADDR_LIST_GET (ISCSI_IOCTL | 41)
#define ISCSI_ISNS_SERVER_ADDR_CLEAR (ISCSI_IOCTL | 42)
#define ISCSI_ISNS_SERVER_GET (ISCSI_IOCTL | 43)
#define ISCSI_GET_CONFIG_SESSIONS (ISCSI_IOCTL | 44)
#define ISCSI_SET_CONFIG_SESSIONS (ISCSI_IOCTL | 45)
#define ISCSI_INIT_NODE_NAME_SET (ISCSI_IOCTL | 46)
#define ISCSI_DB_DUMP (ISCSI_IOCTL | 100) /* DBG */
/*
* Misc. defines
*/
#define ISCSI_CHAP_NAME_LEN 512
#define ISCSI_CHAP_SECRET_LEN 16
#define ISCSI_TGT_OID_LIST 0x0001
#define ISCSI_STATIC_TGT_OID_LIST 0x0002
#define ISCSI_TGT_PARAM_OID_LIST 0x0004
#define ISCSI_SESS_PARAM 0x0001
#define ISCSI_CONN_PARAM 0x0002
/* digest level defines */
#define ISCSI_DIGEST_NONE 0
#define ISCSI_DIGEST_CRC32C 1
#define ISCSI_DIGEST_CRC32C_NONE 2 /* offer both, prefer CRC32C */
#define ISCSI_DIGEST_NONE_CRC32C 3 /* offer both, prefer None */
/*
* A last error associated with each target session is returned in the
* iscsi_target_t structure.
*/
typedef enum iscsi_error {
NoError, AuthenticationError, LoginParamError, ConnectionReset
} iscsi_error_t;
/*
* The values associated with each enum is based on the IMA specification.
*/
typedef enum iSCSIDiscoveryMethod {
iSCSIDiscoveryMethodUnknown = 0,
iSCSIDiscoveryMethodStatic = 1,
iSCSIDiscoveryMethodSLP = 2,
iSCSIDiscoveryMethodISNS = 4,
iSCSIDiscoveryMethodSendTargets = 8
} iSCSIDiscoveryMethod_t;
#define ISCSI_ALL_DISCOVERY_METHODS (iSCSIDiscoveryMethodStatic | \
iSCSIDiscoveryMethodSLP | \
iSCSIDiscoveryMethodISNS | \
iSCSIDiscoveryMethodSendTargets)
/*
* Before anything can be done to a target it must have an OID.
*/
typedef struct iscsi_oid {
uint32_t o_vers; /* In */
uchar_t o_name[ISCSI_MAX_NAME_LEN]; /* In */
/*
* tpgt is only 16 bits per spec. use 32 in ioctl to reduce
* packing issue. Also -1 tpgt denotes default value. iSCSI
* stack will detemermine tpgt during login.
*/
int o_tpgt; /* In */
uint32_t o_oid; /* Out */
} iscsi_oid_t;
#define ISCSI_OID_NOTSET 0
#define ISCSI_INITIATOR_OID 1 /* Other OIDs follow > 1 */
#define ISCSI_DEFAULT_TPGT -1
/*
* iSCSI Login Parameters - Reference iscsi draft for
* definitions of the below login params.
*/
typedef struct iscsi_login_params {
boolean_t immediate_data;
boolean_t initial_r2t;
int first_burst_length; /* range: 512 - 2**24-1 */
int max_burst_length; /* range: 512 - 2**24-1 */
boolean_t data_pdu_in_order;
boolean_t data_sequence_in_order;
int default_time_to_wait;
int default_time_to_retain;
int header_digest;
int data_digest;
int max_recv_data_seg_len; /* range: 512 - 2**24-1 */
int max_xmit_data_seg_len; /* range: 512 - 2**24-1 */
int max_connections;
int max_outstanding_r2t;
int error_recovery_level;
boolean_t ifmarker;
boolean_t ofmarker;
} iscsi_login_params_t;
/*
* Once parameters have been set via ISCSI_SET_PARAM the login is initiated
* by sending an ISCSI_LOGIN ioctl with the following structure filled in.
*/
typedef struct entry {
int e_vers;
uint32_t e_oid;
union {
struct in_addr u_in4;
struct in6_addr u_in6;
} e_u;
/*
* e_insize indicates which of the previous structs is valid.
*/
int e_insize;
int e_port;
int e_tpgt;
} entry_t;
/*
* Used when setting or gettnig the Initiator Name or Alias.
*/
typedef struct node_name {
unsigned char n_name[ISCSI_MAX_NAME_LEN];
int n_len;
} node_name_t;
typedef struct _iSCSIMinMaxValue {
uint32_t i_current,
i_default,
i_min,
i_max,
i_incr;
} iscsi_int_info_t;
typedef struct _iSCSIBoolValue {
boolean_t b_current,
b_default;
} iscsi_bool_info_t;
typedef struct _iSCSIParamValueGet {
boolean_t v_valid,
v_settable;
iscsi_int_info_t v_integer;
iscsi_bool_info_t v_bool;
uchar_t v_name[ISCSI_MAX_NAME_LEN];
} iscsi_get_value_t;
typedef struct _iSCSILoginParamGet {
uint32_t g_vers; /* In */
uint32_t g_oid; /* In */
uint32_t g_param; /* Out */
iscsi_get_value_t g_value; /* Out */
uint32_t g_conn_cid; /* In */
/*
* To indicate whether session or connection related param is
* being requested.
*/
uint32_t g_param_type; /* In */
} iscsi_param_get_t;
typedef struct iscsi_set_value {
uint32_t v_integer;
boolean_t v_bool;
uchar_t v_name[ISCSI_MAX_NAME_LEN];
} iscsi_set_value_t;
/*
* All of the members of this structure are set by the user agent and
* consumed by the driver.
*/
typedef struct iSCSILoginParamSet {
uint32_t s_vers,
s_oid;
uint32_t s_param;
iscsi_set_value_t s_value;
} iscsi_param_set_t;
/*
* Data in this structure is set by the user agent and consumed by
* the driver.
*/
typedef struct chap_props {
uint32_t c_vers,
c_retries,
c_oid;
unsigned char c_user[128];
uint32_t c_user_len;
unsigned char c_secret[16];
uint32_t c_secret_len;
} iscsi_chap_props_t;
typedef enum authMethod {
authMethodNone = 0x00,
authMethodCHAP = 0x01,
authMethodSRP = 0x02,
authMethodKRB5 = 0x04,
authMethodSPKM1 = 0x08,
authMethodSPKM2 = 0x10
} authMethod_t;
/*
* Data in this structure is set by the user agent and consumed by
* the driver.
*/
typedef struct auth_props {
uint32_t a_vers;
uint32_t a_oid;
boolean_t a_bi_auth;
authMethod_t a_auth_method;
} iscsi_auth_props_t;
/*
* Data in this structure is set by the user agent and consumed by
* the driver.
*/
#define MAX_RAD_SHARED_SECRET_LEN 128
typedef struct radius_props {
uint32_t r_vers;
uint32_t r_oid;
union {
struct in_addr u_in4;
struct in6_addr u_in6;
} r_addr;
/*
* r_insize indicates which of the previous structs is valid.
*/
int r_insize;
uint32_t r_port;
uint8_t r_shared_secret[MAX_RAD_SHARED_SECRET_LEN];
boolean_t r_radius_access;
boolean_t r_radius_config_valid;
uint32_t r_shared_secret_len;
} iscsi_radius_props_t;
typedef struct _IPAddress {
union {
struct in_addr in4;
struct in6_addr in6;
} i_addr;
/* i_insize determines which is valid in the union above */
int i_insize;
} iscsi_ipaddr_t;
typedef struct _iSCSITargetAddressKey {
iscsi_ipaddr_t a_addr;
uint32_t a_port,
a_oid;
} iscsi_addr_t;
typedef struct _iSCSITargetAddressKeyProperties {
uint32_t al_vers, /* In */
al_oid; /* In */
uint32_t al_in_cnt; /* In */
uint32_t al_out_cnt; /* Out */
uint32_t al_tpgt; /* Out */
iscsi_addr_t al_addrs[1]; /* Out */
} iscsi_addr_list_t;
typedef struct _iSCSITargetProperties {
uint32_t p_vers, /* In */
p_oid; /* In */
uchar_t p_name[ISCSI_MAX_NAME_LEN]; /* Out */
uint_t p_name_len; /* Out */
uchar_t p_alias[ISCSI_MAX_NAME_LEN]; /* Out */
uint_t p_alias_len; /* Out */
iSCSIDiscoveryMethod_t p_discovery; /* Out */
boolean_t p_connected; /* Out */
uint32_t p_num_of_connections; /* Out */
/* ---- If connected == B_TRUE then lastErr has no meaning. ---- */
iscsi_error_t p_last_err; /* Out */
/*
* Target portal group tag = -1 value means default.
*/
int p_tpgt_conf; /* Out */
int p_tpgt_nego; /* Out */
uchar_t p_isid[ISCSI_ISID_LEN]; /* Out */
uchar_t p_reserved[128];
} iscsi_property_t;
typedef struct _iSCSITargetDeviceList {
uint32_t tl_vers, /* In */
tl_in_cnt, /* In */
tl_tgt_list_type, /* In */
tl_out_cnt, /* Out */
tl_oid_list[1]; /* Out */
} iscsi_target_list_t;
typedef struct _iSCSIStaticTargetProperties {
uint32_t p_vers, /* In */
p_oid; /* In */
uchar_t p_name[ISCSI_MAX_NAME_LEN]; /* Out */
uint_t p_name_len; /* Out */
iscsi_addr_list_t p_addr_list; /* Out */
} iscsi_static_property_t;
typedef enum iscsi_lun_status {
LunValid, LunDoesNotExist
} iscsi_lun_status_t;
/*
* SCSI inquiry vendor and product identifier buffer length - these values are
* defined by the identifier length plus 1 byte for the
* null termination.
*/
#define ISCSI_INQ_VID_BUF_LEN 9 /* 8 byte ID */
#define ISCSI_INQ_PID_BUF_LEN 17 /* 16 byte ID */
typedef struct iscsi_lun_props {
uint32_t lp_vers, /* In */
lp_tgt_oid, /* In */
lp_oid, /* In */
lp_num, /* Out */
lp_status; /* Out */
char lp_pathname[MAXPATHLEN], /* Out */
lp_vid[ISCSI_INQ_VID_BUF_LEN], /* Out */
lp_pid[ISCSI_INQ_PID_BUF_LEN]; /* Out */
time_t lp_time_online; /* Out */
} iscsi_lun_props_t;
typedef struct iscsi_if_lun {
uint32_t l_tgt_oid,
l_oid,
l_num;
} iscsi_if_lun_t;
typedef struct iscsi_lun_list {
uint32_t ll_vers; /* In */
boolean_t ll_all_tgts; /* In */
uint32_t ll_tgt_oid, /* In */
ll_in_cnt, /* In */
ll_out_cnt; /* Out */
iscsi_if_lun_t ll_luns[1]; /* Out */
} iscsi_lun_list_t;
typedef struct iscsi_conn_props {
uint32_t cp_vers, /* In */
cp_oid, /* In */
cp_cid, /* In */
cp_sess_oid; /* In */
union {
struct sockaddr_in soa4;
struct sockaddr_in6 soa6;
} cp_local; /* Out */
union {
struct sockaddr_in soa4;
struct sockaddr_in6 soa6;
} cp_peer; /* Out */
iscsi_login_params_t cp_params;
boolean_t cp_params_valid;
} iscsi_conn_props_t;
typedef struct iscsi_if_conn {
uint32_t c_sess_oid,
c_oid,
c_cid;
} iscsi_if_conn_t;
typedef struct iscsi_conn_list {
uint32_t cl_vers; /* In */
boolean_t cl_all_sess; /* In */
uint32_t cl_sess_oid, /* In */
cl_in_cnt, /* In */
cl_out_cnt; /* Out */
iscsi_if_conn_t cl_list[1]; /* Out */
} iscsi_conn_list_t;
typedef enum iSNSDiscoveryMethod {
iSNSDiscoveryMethodStatic = 0,
iSNSDiscoveryMethodDHCP = 1,
iSNSDiscoveryMethodSLP = 2
} isns_method_t;
typedef struct iSCSIDiscoveryProperties {
uint32_t vers;
boolean_t iSNSDiscoverySettable;
boolean_t iSNSDiscoveryEnabled;
isns_method_t iSNSDiscoveryMethod;
unsigned char iSNSDomainName[256];
boolean_t SLPDiscoverySettable;
boolean_t SLPDiscoveryEnabled;
boolean_t StaticDiscoverySettable;
boolean_t StaticDiscoveryEnabled;
boolean_t SendTargetsDiscoverySettable;
boolean_t SendTargetsDiscoveryEnabled;
} iSCSIDiscoveryProperties_t;
typedef struct iscsi_uscsi {
uint32_t iu_vers;
uint32_t iu_oid;
int iu_tpgt;
uint32_t iu_len;
uint32_t iu_lun;
struct uscsi_cmd iu_ucmd;
} iscsi_uscsi_t;
#if defined(_SYSCALL32)
typedef struct iscsi_uscsi32 {
uint32_t iu_vers;
uint32_t iu_oid;
int iu_tpgt;
uint32_t iu_len;
uint32_t iu_lun;
struct uscsi_cmd32 iu_ucmd;
} iscsi_uscsi32_t;
#endif /* _SYSCALL32 */
typedef struct iscsi_sendtgts_entry {
/* ---- Node name, NULL terminated UTF-8 string ---- */
uchar_t ste_name[ISCSI_MAX_NAME_LEN];
iscsi_addr_t ste_ipaddr;
int ste_tpgt;
} iscsi_sendtgts_entry_t;
typedef struct iscsi_sendtgts_list {
entry_t stl_entry; /* In */
uint32_t stl_in_cnt, /* In */
stl_out_cnt; /* Out */
iscsi_sendtgts_entry_t stl_list[1]; /* Out */
} iscsi_sendtgts_list_t;
typedef struct iscsi_statictgt_entry {
entry_t te_entry; /* In */
uchar_t te_name[ISCSI_MAX_NAME_LEN]; /* In */
} iscsi_target_entry_t;
/* iSNS Draft - section 4.1.1. */
typedef struct isns_portal_group {
uint8_t pg_iscsi_name[ISCSI_MAX_NAME_LEN];
union {
in_addr_t u_ip4;
in6_addr_t u_ip6;
} pg_ip_addr;
int insize;
in_port_t pg_port;
uint16_t pg_tag;
iscsi_ipaddr_t isns_server_ip;
uint32_t isns_server_port;
} isns_portal_group_t;
typedef struct isns_portal_group_list {
uint32_t pg_in_cnt,
pg_out_cnt;
isns_portal_group_t pg_list[1];
} isns_portal_group_list_t;
typedef struct isns_server_portal_group_list {
iscsi_addr_t addr;
isns_portal_group_list_t addr_port_list;
} isns_server_portal_group_list_t;
#define ISCSI_MIN_CONFIG_SESSIONS 1
/* lowered max config sessions due to ct_power_cnt >= 0 assert */
#define ISCSI_MAX_CONFIG_SESSIONS 4
typedef struct iscsi_config_sess {
uint32_t ics_ver;
uint32_t ics_oid;
boolean_t ics_bound;
uint_t ics_in;
uint_t ics_out;
iscsi_ipaddr_t ics_bindings[1];
} iscsi_config_sess_t;
#define ISCSI_SESSION_CONFIG_SIZE(SIZE) \
(sizeof (iscsi_config_sess_t) + \
((SIZE - 1) * sizeof (iscsi_ipaddr_t)))
/*
* Event class and subclass information
*/
#define EC_ISCSI "EC_iSCSI"
#define ESC_ISCSI_STATIC_START "ESC_static_start"
#define ESC_ISCSI_STATIC_END "ESC_static_end"
#define ESC_ISCSI_SEND_TARGETS_START "ESC_send_targets_start"
#define ESC_ISCSI_SEND_TARGETS_END "ESC_send_targets_end"
#define ESC_ISCSI_SLP_START "ESC_slp_start"
#define ESC_ISCSI_SLP_END "ESC_slp_end"
#define ESC_ISCSI_ISNS_START "ESC_isns_start"
#define ESC_ISCSI_ISNS_END "ESC_isns_end"
#define ESC_ISCSI_PROP_CHANGE "ESC_prop_change"
#ifdef _KERNEL
/* ---- iscsi_utils.c ---- */
extern int iscsid_open(char *, int, int);
extern int iscsid_close(int);
extern int iscsid_remove(char *filename);
extern int iscsid_rename(char *oldname, char *newname);
extern ssize_t iscsid_write(int, void *, ssize_t);
extern ssize_t iscsid_read(int, void *, ssize_t);
extern ssize_t iscsid_sendto(struct sonode *, void *, size_t,
struct sockaddr *, socklen_t);
extern ssize_t iscsid_recvfrom(struct sonode *, void *buffer,
size_t len);
extern int iscsid_errno;
#endif
/*
* Function prototypes for those routines found in the common code
*/
/* ---- utils.c ---- */
extern boolean_t utils_iqn_create(char *, int);
extern char *prt_bitmap(int, char *, char *, int);
extern char *utils_map_param(int);
extern boolean_t parse_addr_port_tpgt(char *in, char **addr,
int *type, char **port, char **tpgt);
#ifdef __cplusplus
}
#endif
#endif /* _ISCSI_IF_H */
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _ISCSIT_COMMON_H_
#define _ISCSIT_COMMON_H_
#ifdef _KERNEL
#include <sys/nvpair.h>
#else
#include <libnvpair.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define ISCSIT_API_VERS0 0
#define ISCSIT_MODNAME "iscsit"
#define ISCSIT_NODE "/devices/pseudo/iscsit@0:iscsit"
typedef enum {
ITCFG_SUCCESS = 0,
ITCFG_INVALID,
ITCFG_TGT_CREATE_ERR,
ITCFG_MISC_ERR
} it_cfg_status_t;
/*
* This structure is passed back to the driver during ISCSIT_IOC_ENABLE_SVC
* in order to provide the fully qualified hostname for use as the EID
* by iSNS.
*/
#define ISCSIT_MAX_HOSTNAME_LEN 256
typedef struct iscsit_hostinfo_s {
uint32_t length;
char fqhn[ISCSIT_MAX_HOSTNAME_LEN];
} iscsit_hostinfo_t;
#define ISCSIT_IOC_SET_CONFIG 1
#define ISCSIT_IOC_GET_STATE 2
#define ISCSIT_IOC_ENABLE_SVC 101
#define ISCSIT_IOC_DISABLE_SVC 102
/* XXX Rationalize these with other error values (used in it_smf.c */
#define ITADM_SUCCESS 0
#define ITADM_FATAL_ERROR 0x1
#define ITADM_NO_MEM 0x2
#define ITADM_INVALID 0x4
#define ITADM_NODATA 0x8
#define ITADM_PERM 0x10
#define PROP_AUTH "auth"
#define PROP_ALIAS "alias"
#define PROP_CHAP_USER "chapuser"
#define PROP_CHAP_SECRET "chapsecret"
#define PROP_TARGET_CHAP_USER "targetchapuser"
#define PROP_TARGET_CHAP_SECRET "targetchapsecret"
#define PROP_RADIUS_SERVER "radiusserver"
#define PROP_RADIUS_SECRET "radiussecret"
#define PROP_ISNS_ENABLED "isns"
#define PROP_ISNS_SERVER "isnsserver"
#define PROP_OLD_TARGET_NAME "oldtargetname"
#define PA_AUTH_RADIUS "radius"
#define PA_AUTH_CHAP "chap"
#define PA_AUTH_NONE "none"
typedef struct {
int set_cfg_vers;
int set_cfg_pnvlist_len;
caddr_t set_cfg_pnvlist;
} iscsit_ioc_set_config_t;
typedef struct {
int getst_vers;
int getst_pnvlist_len;
char *getst_pnvlist;
} iscsit_ioc_getstate_t;
#ifdef _SYSCALL32
typedef struct {
int set_cfg_vers;
int set_cfg_pnvlist_len;
caddr32_t set_cfg_pnvlist;
} iscsit_ioc_set_config32_t;
typedef struct {
int getst_vers;
int getst_pnvlist_len;
caddr32_t getst_pnvlist;
} iscsit_ioc_getstate32_t;
#endif /* _SYSCALL32 */
/* Shared user/kernel structures */
/* Maximum size of a Target Portal Group name */
#define MAX_TPG_NAMELEN 256 /* XXX */
/* Maximum size of an iSCSI Target Node name */
#define MAX_ISCSI_NODENAMELEN 256 /* XXX */
/*
* A target portal group tag is a binding between a target and a target
* portal group along with a numerical value associated with that binding.
* The numerical identifier is used as the 'target portal group tag' defined
* in RFC3720.
*
* tpgt_tpg_name The name of the target portal group associated with
* this target portal group tag.
* tpgt_generation Generation number which is incremented each time the
* structure changes.
* tpgt_next Next target portal group tag in th list of target portal
* group tags. If tpgt_next is NUL, then this is the last
* target portal group in the list.
* tpgt_tag A numerical identifier that uniquely identifies a
* target portal group within the associated target node.
*/
typedef struct it_tpgt_s {
char tpgt_tpg_name[MAX_TPG_NAMELEN];
uint64_t tpgt_generation;
struct it_tpgt_s *tpgt_next;
uint16_t tpgt_tag;
} it_tpgt_t;
/*
* An iSCSI target node is represented by an it_tgt_structure. Each
* target node includes a list of associated target portal group tags
* and a list of properties.
*
* tgt_name The iSCSI target node name in either IQN or EUI
* format (see RFC3720).
* tgt_generation Generation number which is incremented each time
* the structure changes.
* tgt_next Next target in the list of targets. If tgt_next
* is NULL, then this is the last target in the list.
* tgt_tpgt_list A linked list representing the current target
* portal group tags associated with this target.
* tgt_tpgt_count The number of currently defined target portal
* group tags.
* tgt_properties An nvlist representation of the properties
* associated with this target. This list can be
* manipulated using libnvpair(3lib), and should be
* validated and stored using it_tgt_setprop().
*
* Target nvlist Properties:
*
* nvlist Key Type Valid Values
* --------------------------------------------------------------------
* targetchapuser string any string or "none" to remove
* targetchapsecret string string of at least 12 characters
* but not more than 255 characters.
* secret will be base64 encoded when
* stored.
* alias string any string or "none" to remove
* auth string "radius", "chap", or "none"
*
*/
typedef struct it_tgt_s {
char tgt_name[MAX_ISCSI_NODENAMELEN];
uint64_t tgt_generation;
struct it_tgt_s *tgt_next;
it_tpgt_t *tgt_tpgt_list;
uint32_t tgt_tpgt_count;
nvlist_t *tgt_properties;
} it_tgt_t;
/*
* A target portal is represented by an IP address and a listening
* TCP port.
*
* portal_addr sockaddr_storage structure representing the
* IPv4 or IPv6 address and TCP port associated
* with the portal.
* portal_next Next portal in the list of portals. If
* portal_next is NULL, this is the last portal
* in the list.
*/
typedef struct it_portal_s {
struct sockaddr_storage portal_addr;
struct it_portal_s *portal_next;
} it_portal_t;
/*
* A portal is an IP address and TCP port and a portal group is a set
* of portals. Each defined portal belongs to exactly one portal group.
* Applications can associate a target portal group with a particular
* target using a target portal group name. Initiators can only connect
* to targets through the portals associated with the target's target
* portal group tags.
*
* tpg_name Identifier for the target portal group.
* tpg_generation Generation number which is incremented each
* time this structure changes.
* tpg_next Next target portal group in the list of target
* portal groups. If tpg_next is NULL, this is the
* last target portal group in the list.
* tpg_portal_count Number of it_portal_t structures in the list.
* tpg_portal_list Linked list of it_portal_t structures.
*/
typedef struct it_tpg_s {
char tpg_name[MAX_TPG_NAMELEN];
uint64_t tpg_generation;
struct it_tpg_s *tpg_next;
uint32_t tpg_portal_count;
it_portal_t *tpg_portal_list;
} it_tpg_t;
/*
* A context representing a remote iSCSI initiator node. The purpose
* of this structure is to maintain information specific to a remote
* initiator such as the CHAP username and CHAP secret.
*
* ini_name the iSCSI node name of the remote initiator.
* ini_generation Generation number which is incremented each
* time this structure changes.
* ini_next Next initiator in the list of initiators.
* If ini_next is NULL, this is the last initiator
* in the list.
* ini_properties Name/Value list containing the properties
* associated with the initiator context. This list
* can be manipulated using libnvpair(3lib), and should
* be validated and stored using it_ini_setprop().
*
* Initiator nvlist Properties:
*
* nvlist Key Type Valid Values
* --------------------------------------------------------------------
* chapuser string any string
* chapsecret string string of at least 12 characters
* but not more than 255 characters.
* secret will be base64 encoded when
* stored.
*/
typedef struct it_ini_s {
char ini_name[MAX_ISCSI_NODENAMELEN];
uint64_t ini_generation;
struct it_ini_s *ini_next;
nvlist_t *ini_properties;
} it_ini_t;
/*
* This structure represents a complete configuration for the iscsit
* port provider. In addition to the global configuration, it_config_t
* includes lists of child objects including targets, target portal
* groups and initiator contexts. Each object includes a "generation"
* value which is used by the iscsit kernel driver to identify changes
* from one configuration update to the next.
*
* stmf_token A uint64_t that contains the value returned from a
* successful call to stmfGetProviderDataProt(3STMF).
* This token is used to verify that the configuration
* data persistently stored in COMSTAR has not been
* modified since this version was loaded.
* config_version Version number for this configuration structure
* config_tgt_list Linked list of target contexts representing the
* currently defined targets. Applications can add
* targets to or remove targets from this list using
* the it_tgt_create and it_tgt_delete functions.
* config_tgt_count The number of currently defined targets.
* config_tpg_list Linked list of target portal group contexts.
* Applications can add or remove target portal groups
* to/from this list using the it_tpg_create and
* it_tpg_delete functions.
* config_tpg_count The number of currently defined target portal groups
* config_ini_list Linked list of initiator contexts. Applications
* can add initiator contexts or remove initiator
* contexts from this list using the it_ini_create
* and it_ini_delete functions.
* config_ini_count The number of currently defined initiator contexts.
* config_global_properties
* Name/Value list representing the current global
* property settings. This list can be manipulated
* using libnvpair(3lib), and should be validated
* and stored using it_config_setprop().
* config_isns_svr_list
* Linked list of currently defined iSNS servers.
* Applications can add or remove iSNS servers by
* using the it_config_setprop() function and changing
* the array of iSNS servers stored in the "isnsserver"
* property.
* config_isns_svr_count
* The number of currently defined iSNS servers.
*
* Global nvlist Properties:
*
* nvlist Key Type Valid Values
* --------------------------------------------------------------------
* alias string any string
* auth string "radius", "chap", or "none"
* isns boolean B_TRUE, B_FALSE
* isnsserver string array Array of portal specifications of
* the form IPaddress:port. Port
* is optional; if not specified, the
* default iSNS port number of 3205 will
* be used. IPv6 addresses should
* be enclosed in square brackets '[' ']'.
* If "none" is specified, all defined
* iSNS servers will be removed from the
* configuration.
* radiusserver string IPaddress:port specification as
* described for 'isnsserver'.
* radiussecret string string of at least 12 characters
* but not more than 255 characters.
* secret will be base64 encoded when
* stored.
*/
typedef struct it_config_s {
uint64_t stmf_token;
uint32_t config_version;
it_tgt_t *config_tgt_list;
uint32_t config_tgt_count;
it_tpg_t *config_tpg_list;
uint32_t config_tpg_count;
it_ini_t *config_ini_list;
uint32_t config_ini_count;
it_portal_t *config_isns_svr_list;
uint32_t config_isns_svr_count;
nvlist_t *config_global_properties;
} it_config_t;
/* Functions to convert iSCSI target structures to/from nvlists. */
int
it_config_to_nv(it_config_t *cfg, nvlist_t **nvl);
/*
* nvlist version of config is 3 list-of-list, + 1 proplist. arrays
* are interesting, but lists-of-lists are more useful when doing
* individual lookups when we later add support for it. Also, no
* need to store name in individual struct representation.
*/
int
it_nv_to_config(nvlist_t *nvl, it_config_t **cfg);
int
it_nv_to_tgtlist(nvlist_t *nvl, uint32_t *count, it_tgt_t **tgtlist);
int
it_tgtlist_to_nv(it_tgt_t *tgtlist, nvlist_t **nvl);
int
it_tgt_to_nv(it_tgt_t *tgt, nvlist_t **nvl);
int
it_nv_to_tgt(nvlist_t *nvl, char *name, it_tgt_t **tgt);
int
it_tpgt_to_nv(it_tpgt_t *tpgt, nvlist_t **nvl);
int
it_nv_to_tpgt(nvlist_t *nvl, char *name, it_tpgt_t **tpgt);
int
it_tpgtlist_to_nv(it_tpgt_t *tpgtlist, nvlist_t **nvl);
int
it_nv_to_tpgtlist(nvlist_t *nvl, uint32_t *count, it_tpgt_t **tpgtlist);
int
it_tpg_to_nv(it_tpg_t *tpg, nvlist_t **nvl);
int
it_nv_to_tpg(nvlist_t *nvl, char *name, it_tpg_t **tpg);
int
it_tpglist_to_nv(it_tpg_t *tpglist, nvlist_t **nvl);
int
it_nv_to_tpglist(nvlist_t *nvl, uint32_t *count, it_tpg_t **tpglist);
int
it_ini_to_nv(it_ini_t *ini, nvlist_t **nvl);
int
it_nv_to_ini(nvlist_t *nvl, char *name, it_ini_t **ini);
int
it_inilist_to_nv(it_ini_t *inilist, nvlist_t **nvl);
int
it_nv_to_inilist(nvlist_t *nvl, uint32_t *count, it_ini_t **inilist);
it_tgt_t *
it_tgt_lookup(it_config_t *cfg, char *tgt_name);
it_tpg_t *
it_tpg_lookup(it_config_t *cfg, char *tpg_name);
it_portal_t *
it_sns_svr_lookup(it_config_t *cfg, struct sockaddr_storage *sa);
it_portal_t *
it_portal_lookup(it_tpg_t *cfg_tpg, struct sockaddr_storage *sa);
int
it_sa_compare(struct sockaddr_storage *sa1, struct sockaddr_storage *sa2);
/*
* Convert a sockaddr to the string representation, suitable for
* storing in an nvlist or printing out in a list.
*/
int
sockaddr_to_str(struct sockaddr_storage *sa, char **addr);
/*
* Convert a char string to a sockaddr structure
*
* default_port should be the port to be used, if not specified
* as part of the supplied string 'arg'.
*/
struct sockaddr_storage *
it_common_convert_sa(char *arg, struct sockaddr_storage *buf,
uint32_t default_port);
/*
* Convert an string array of IP-addr:port to a portal list
*/
int
it_array_to_portallist(char **arr, uint32_t count, uint32_t default_port,
it_portal_t **portallist, uint32_t *list_count);
/*
* Function: it_config_free_cmn()
*
* Free any resources associated with the it_config_t structure.
*
* Parameters:
* cfg A C representation of the current iSCSI configuration
*/
void
it_config_free_cmn(it_config_t *cfg);
/*
* Function: it_tgt_free_cmn()
*
* Frees an it_tgt_t structure. If tgt_next is not NULL, frees
* all structures in the list.
*/
void
it_tgt_free_cmn(it_tgt_t *tgt);
/*
* Function: it_tpgt_free_cmn()
*
* Deallocates resources of an it_tpgt_t structure. If tpgt->next
* is not NULL, frees all members of the list.
*/
void
it_tpgt_free_cmn(it_tpgt_t *tpgt);
/*
* Function: it_tpg_free_cmn()
*
* Deallocates resources associated with an it_tpg_t structure.
* If tpg->next is not NULL, frees all members of the list.
*/
void
it_tpg_free_cmn(it_tpg_t *tpg);
/*
* Function: it_ini_free_cmn()
*
* Deallocates resources of an it_ini_t structure. If ini->next is
* not NULL, frees all members of the list.
*/
void
it_ini_free_cmn(it_ini_t *ini);
/*
* Function: iscsi_binary_to_base64_str()
*
* Encodes a byte array into a base64 string.
*/
int
iscsi_binary_to_base64_str(uint8_t *in_buf, int in_buf_len,
char *base64_str_buf, int base64_buf_len);
/*
* Function: iscsi_base64_str_to_binary()
*
* Decodes a base64 string into a byte array
*/
int
iscsi_base64_str_to_binary(char *hstr, int hstr_len,
uint8_t *binary, int binary_buf_len, int *out_len);
#ifdef __cplusplus
}
#endif
#endif /* _ISCSIT_COMMON_H_ */
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _ISNS_PROTOCOL_H
#define _ISNS_PROTOCOL_H
#ifdef __cplusplus
extern "C" {
#endif
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/types.h>
#define ISNSP_VERSION (0x01)
#define ISNS_DEFAULT_SERVER_PORT (3205)
#define ISNSP_HEADER_SIZE (12)
#define ISNSP_RSP_CODE_SIZE (4)
#define ISNSP_MAX_PAYLOAD_SIZE (65532)
#define ISNSP_MAX_PDU_SIZE (ISNSP_HEADER_SIZE + \
ISNSP_MAX_PAYLOAD_SIZE)
#define ISNS_TLV_ATTR_ID_LEN (4)
#define ISNS_TLV_ATTR_LEN_LEN (4)
#define MAX_ISNS_MESG_ATTR_ENTRIES (8)
#define MAX_ISNS_OPER_ATTR_ENTRIES (32)
/* iSNS Entity Protocol, iSNS Draft - section 6.2.2. */
#define ISNS_ENTITY_PROTOCOL_NO (1)
#define ISNS_ENTITY_PROTOCOL_ISCSI (2)
#define ISNS_ENTITY_PROTOCOL_FCP (3)
/* iSNS Function IDs, iSNS Draft - section 4.1.3. */
#define ISNS_DEV_ATTR_REG (0x0001)
#define ISNS_DEV_ATTR_QRY (0x0002)
#define ISNS_DEV_GET_NEXT (0x0003)
#define ISNS_DEV_DEREG (0x0004)
#define ISNS_SCN_REG (0x0005)
#define ISNS_SCN_DEREG (0x0006)
#define ISNS_SCN_EVENT (0x0007)
#define ISNS_SCN (0x0008)
#define ISNS_DD_REG (0x0009)
#define ISNS_DD_DEREG (0x000A)
#define ISNS_DDS_REG (0x000B)
#define ISNS_DDS_DEREG (0x000C)
#define ISNS_ESI (0x000D)
#define ISNS_HEARTBEAT (0x000E)
#define ISNS_DEV_ATTR_REG_RSP (0x8001)
#define ISNS_DEV_ATTR_QRY_RSP (0x8002)
#define ISNS_DEV_GET_NEXT_RSP (0x8003)
#define ISNS_DEV_DEREG_RSP (0x8004)
#define ISNS_SCN_REG_RSP (0x8005)
#define ISNS_SCN_DEREG_RSP (0x8006)
#define ISNS_SCN_EVENT_RSP (0x8007)
#define ISNS_SCN_RSP (0x8008)
#define ISNS_DD_REG_RSP (0x8009)
#define ISNS_DD_DEREG_RSP (0x800A)
#define ISNS_DDS_REG_RSP (0x800B)
#define ISNS_DDS_DEREG_RSP (0x800C)
#define ISNS_ESI_RSP (0x800D)
/* iSNS Flags, iSNS Draft - section 5.1.4. */
#define ISNS_FLAG_FIRST_PDU (0x0400)
#define ISNS_FLAG_LAST_PDU (0x0800)
#define ISNS_FLAG_REPLACE_REG (0x1000)
#define ISNS_FLAG_AUTH_BLK_PRESENTED (0x2000)
#define ISNS_FLAG_SERVER (0x4000)
#define ISNS_FLAG_CLIENT (0x8000)
/* iSNS Response Status, iSNS Draft - section 5.4 */
#define ISNS_RSP_SUCCESSFUL (0)
#define ISNS_RSP_UNKNOWN_ERROR (1)
#define ISNS_RSP_MSG_FORMAT_ERROR (2)
#define ISNS_RSP_INVALID_REGIS (3)
#define ISNS_RSP_INVALID_QRY (5)
#define ISNS_RSP_SRC_UNKNOWN (6)
#define ISNS_RSP_SRC_ABSENT (7)
#define ISNS_RSP_SRC_UNAUTHORIZED (8)
#define ISNS_RSP_NO_SUCH_ENTRY (9)
#define ISNS_RSP_VER_NOT_SUPPORTED (10)
#define ISNS_RSP_INTERNAL_ERROR (11)
#define ISNS_RSP_BUSY (12)
#define ISNS_RSP_OPTION_NOT_UNDERSTOOD (13)
#define ISNS_RSP_INVALID_UPDATE (14)
#define ISNS_RSP_MSG_NOT_SUPPORTED (15)
#define ISNS_RSP_SCN_EVENT_REJECTED (16)
#define ISNS_RSP_SCN_REGIS_REJECTED (17)
#define ISNS_RSP_ATTR_NOT_IMPL (18)
#define ISNS_RSP_ESI_NOT_AVAILABLE (21)
#define ISNS_RSP_INVALID_DEREGIS (22)
#define ISNS_RSP_REGIS_NOT_SUPPORTED (23)
/* iSNS Attribute IDs, iSNS Draft - section 6.1. */
#define ISNS_DELIMITER_ATTR_ID (0)
#define ISNS_EID_ATTR_ID (1)
#define ISNS_ENTITY_PROTOCOL_ATTR_ID (2)
#define ISNS_MGMT_IP_ADDR_ATTR_ID (3)
#define ISNS_TIMESTAMP_ATTR_ID (4)
#define ISNS_VERSION_RANGE_ATTR_ID (5)
#define ISNS_ENTITY_REG_PERIOD_ATTR_ID (6)
#define ISNS_ENTITY_INDEX_ATTR_ID (7)
#define ISNS_ENTITY_NEXT_INDEX_ATTR_ID (8)
#define ISNS_ENTITY_ISAKMP_P1_ATTR_ID (11)
#define ISNS_ENTITY_CERT_ATTR_ID (12)
#define ISNS_PORTAL_IP_ADDR_ATTR_ID (16)
#define ISNS_PORTAL_PORT_ATTR_ID (17)
#define ISNS_PORTAL_NAME_ATTR_ID (18)
#define ISNS_ESI_INTERVAL_ATTR_ID (19)
#define ISNS_ESI_PORT_ATTR_ID (20)
#define ISNS_PORTAL_INDEX_ATTR_ID (22)
#define ISNS_SCN_PORT_ATTR_ID (23)
#define ISNS_PORTAL_NEXT_INDEX_ATTR_ID (24)
#define ISNS_PORTAL_SEC_BMP_ATTR_ID (27)
#define ISNS_PORTAL_ISAKMP_P1_ATTR_ID (28)
#define ISNS_PORTAL_ISAKMP_P2_ATTR_ID (29)
#define ISNS_PORTAL_CERT_ATTR_ID (31)
#define ISNS_ISCSI_NAME_ATTR_ID (32)
#define ISNS_ISCSI_NODE_TYPE_ATTR_ID (33)
#define ISNS_ISCSI_ALIAS_ATTR_ID (34)
#define ISNS_ISCSI_SCN_BITMAP_ATTR_ID (35)
#define ISNS_ISCSI_NODE_INDEX_ATTR_ID (36)
#define ISNS_WWNN_TOKEN_ATTR_ID (37)
#define ISNS_NODE_NEXT_INDEX_ATTR_ID (38)
#define ISNS_ISCSI_AUTH_METHOD_ATTR_ID (42)
#define ISNS_PG_ISCSI_NAME_ATTR_ID (48)
#define ISNS_PG_PORTAL_IP_ADDR_ATTR_ID (49)
#define ISNS_PG_PORTAL_PORT_ATTR_ID (50)
#define ISNS_PG_TAG_ATTR_ID (51)
#define ISNS_PG_INDEX_ATTR_ID (52)
#define ISNS_PG_NEXT_ID_ATTR_ID (53)
#define ISNS_DD_SET_ID_ATTR_ID (2049)
#define ISNS_DD_SET_NAME_ATTR_ID (2050)
#define ISNS_DD_SET_STATUS_ATTR_ID (2051)
#define ISNS_DD_ID_ATTR_ID (2065)
#define ISNS_DD_NAME_ATTR_ID (2066)
#define ISNS_DD_ISCSI_INDEX_ATTR_ID (2067)
#define ISNS_DD_ISCSI_NAME_ATTR_ID (2068)
#define ISNS_DD_FC_PORT_NAME_ATTR_ID (2069)
#define ISNS_DD_PORTAL_INDEX_ATTR_ID (2070)
#define ISNS_DD_PORTAL_IP_ADDR_ATTR_ID (2071)
#define ISNS_DD_PORTAL_PORT_ATTR_ID (2072)
#define ISNS_DD_FEATURES_ATTR_ID (2078)
/* Entity Protocol, RFC 4171 - section 6.2.2. */
#define ISNS_ENTITY_NO_PROTOCOL (1)
#define ISNS_ENTITY_ISCSI (2)
#define ISNS_ENTITY_IFCP (3)
/* Protocol Version Range, RFC 4171 - section 6.2.5. */
#define ISNS_VER_SHIFT (16)
#define ISNS_VERSION (0x0000FFFF)
/* Portal Port, RFC 4171 - section 6.3.2. */
#define ISNS_PORT_BITS (0x0000FFFF) /* Bits 16 - 31 */
#define ISNS_PORT_TYPE (0x00010000) /* Bit 15 */
/* Portal Security Bitmap, RFC 4171 - section 6.3.9. */
#define ISNS_TUNNEL_MODE_PREFERRED (0x0040) /* Bit 25 */
#define ISNS_TRANS_MODE_PREFERRED (0x0020) /* Bit 26 */
#define ISNS_PFS_ENABLED (0x0010) /* Bit 27 */
#define ISNS_AGGR_MODE_ENABLED (0x0008) /* Bit 28 */
#define ISNS_MAIN_MODE_ENABLED (0x0004) /* Bit 29 */
#define ISNS_IKE_IPSEC_ENABLED (0x0002) /* Bit 30 */
#define ISNS_BITMAP_VALID (0x0001) /* Bit 31 */
/* iSCSI Node Type, RFC 4171 - section 6.4.2. */
#define ISNS_TARGET_NODE_TYPE (0x0001)
#define ISNS_INITIATOR_NODE_TYPE (0x0002)
#define ISNS_CONTROL_NODE_TYPE (0x0004)
/* iSCSI Node SCN Bitmap, RFC 4171 - section 6.4.4. */
#define ISNS_INIT_SELF_INFO_ONLY (0x0080) /* Bit 24 */
#define ISNS_TARGET_SELF_INFO_ONLY (0x0040) /* Bit 25 */
#define ISNS_MGMT_REG (0x0020) /* Bit 26 */
#define ISNS_OBJECT_REMOVED (0x0010) /* Bit 27 */
#define ISNS_OBJECT_ADDED (0x0008) /* Bit 28 */
#define ISNS_OBJECT_UPDATED (0x0004) /* Bit 29 */
#define ISNS_MEMBER_REMOVED (0x0002) /* Bit 30 */
#define ISNS_MEMBER_ADDED (0x0001) /* Bit 31 */
/* Portal Group Tag, RFC 4171 - section 6.5.4. */
#define ISNS_PG_TAG (0x0000FFFF) /* Bits 16 - 31 */
/* DDS Status, RFC 4171 - section 6.11.1.3. */
#define ISNS_DDS_STATUS (0x0001) /* Bit 31 */
/* DD Feature, RFC 4171 - section 6.11.2.9. */
#define ISNS_DD_BOOTLIST (0x0001) /* Bit 31 */
/* iSNS Defaults */
#define ISNS_DEFAULT_PGT (0x00000001)
#define ISNS_DEFAULT_DD_SET_ID (1)
#define ISNS_DEFAULT_DD_ID (1)
/* Min/Max length of names */
#define ISNS_DDS_MAX_NAME_LEN (256)
#define ISNS_DD_MAX_NAME_LEN (256)
#define ISNS_ISCSI_MAX_NAME_LEN (224)
#define ISNS_ISCSI_MAX_ALIAS_LEN (256)
#define ISNS_ENTITY_MIN_EID_LEN (3)
#define ISNS_ENTITY_MAX_EID_LEN (255)
typedef struct isns_tlv {
uint32_t attr_id;
uint32_t attr_len;
uint8_t attr_value[1];
} isns_tlv_t;
typedef struct isns_packet_data {
uint16_t version;
uint16_t func_id;
uint16_t payload_len;
uint16_t flags;
uint16_t xid;
uint16_t seq;
int num_of_tlvs;
isns_tlv_t tlvs[MAX_ISNS_OPER_ATTR_ENTRIES];
} isns_packet_data_t;
typedef struct isns_reg_mesg {
isns_tlv_t src_attr;
int num_of_mesg_attrs;
isns_tlv_t *mesg_attrs[MAX_ISNS_MESG_ATTR_ENTRIES];
isns_tlv_t delimiter_attr;
isns_tlv_t *operating_attrs[MAX_ISNS_OPER_ATTR_ENTRIES];
} isns_reg_mesg_t;
typedef struct isns_resp_mesg {
uint8_t status[4];
isns_tlv_t messages_attrs[MAX_ISNS_MESG_ATTR_ENTRIES];
isns_tlv_t delimiter_attr;
isns_tlv_t operating_attrs[MAX_ISNS_OPER_ATTR_ENTRIES];
} isns_resp_mesg_t;
typedef struct isns_pdu {
uint16_t version;
uint16_t func_id;
uint16_t payload_len;
uint16_t flags;
uint16_t xid;
uint16_t seq;
uint8_t payload[1];
} isns_pdu_t;
typedef struct isns_resp {
uint32_t status;
uint8_t data[1];
} isns_resp_t;
#ifdef __cplusplus
}
#endif
#endif /* _ISNS_PROTOCOL_H */
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _RADIUS_PACKET_H
#define _RADIUS_PACKET_H
#ifdef __cplusplus
extern "C" {
#endif
#include <netinet/in.h>
#include <sys/types.h>
#include <sys/ksocket.h>
#include <sys/iscsit/radius_protocol.h>
/* A total of RAD_RCV_TIMEOUT * RAD_RETRY_MAX seconds timeout. */
#define RAD_RCV_TIMEOUT 5 /* Timeout for receiving RADIUS packet in */
/* sec. */
#define RAD_RETRY_MAX 2 /* Max. # of times to retry receiving */
/* packet. */
/* Describes a RADIUS attribute */
typedef struct radius_attr {
int attr_type_code; /* RADIUS attribute type code, */
/* e.g. RAD_USER_PASSWORD, etc. */
int attr_value_len;
uint8_t attr_value[MAX_RAD_ATTR_VALUE_LEN];
} radius_attr_t;
/* Describes data fields of a RADIUS packet. */
typedef struct radius_packet_data {
uint8_t code; /* RADIUS code, section 3, RFC 2865. */
uint8_t identifier;
uint8_t authenticator[RAD_AUTHENTICATOR_LEN];
int num_of_attrs;
radius_attr_t attrs[4]; /* For this implementation each */
/* outbound RADIUS packet will only */
/* have 3 attributes associated with */
/* it thus the chosen size should be */
/* good enough. */
} radius_packet_data_t;
/*
* Send a request to a RADIUS server.
*
* Returns > 0 on success, <= 0 on failure .
*
*/
int
iscsit_snd_radius_request(ksocket_t socket,
iscsi_ipaddr_t rsvr_ip_addr,
uint32_t rsvr_port,
radius_packet_data_t *packet_data);
#define RAD_RSP_RCVD_SUCCESS 0
#define RAD_RSP_RCVD_NO_DATA 1
#define RAD_RSP_RCVD_TIMEOUT 2
#define RAD_RSP_RCVD_PROTOCOL_ERR 3
#define RAD_RSP_RCVD_AUTH_FAILED 4
/*
* Receives a response from a RADIUS server.
*
* Return receive status.
*/
int
iscsit_rcv_radius_response(ksocket_t socket,
uint8_t *shared_secret,
uint32_t shared_secret_len,
uint8_t *req_authenticator,
radius_packet_data_t *resp_data);
#ifdef __cplusplus
}
#endif
#endif /* _RADIUS_PACKET_H */
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _RADIUS_PROTOCOL_H
#define _RADIUS_PROTOCOL_H
#ifdef __cplusplus
extern "C" {
#endif
/* Packet type. RFC 2865 section 4. */
#define RAD_ACCESS_REQ 1 /* Authentication Request */
#define RAD_ACCESS_ACPT 2 /* Authentication Accepted */
#define RAD_ACCESS_REJ 3 /* Authentication Rejected */
/* RADIUS Attribute Types. RFC 2865 section 5. */
#define RAD_USER_NAME 1
#define RAD_CHAP_PASSWORD 3
#define RAD_CHAP_CHALLENGE 60
/* RFC 2865 Section 3. The Identifier field is one octet. */
#define RAD_IDENTIFIER_LEN 1
/* RFC 2865 Section 5.3. The String field is 16 octets. */
#define RAD_CHAP_PASSWD_STR_LEN 16
/* RFC 2865 Section 3. Authenticator field is 16 octets. */
#define RAD_AUTHENTICATOR_LEN 16
/* RFC 2865 Section 5: 1-253 octets */
#define MAX_RAD_ATTR_VALUE_LEN 253
/* RFC 2865 Section 3. Minimum length 20 octets. */
#define MIN_RAD_PACKET_LEN 20
/* RFC 2865 Section 3. Maximum length 4096 octets. */
#define MAX_RAD_PACKET_LEN 4096
/* Maximum RADIUS shared secret length (in fact there is no defined limit) */
#define MAX_RAD_SHARED_SECRET_LEN 128
/* RFC 2865 Section 3. Minimum RADIUS shared secret length */
#define MIN_RAD_SHARED_SECRET_LEN 16
/* Raw RADIUS packet. RFC 2865 section 3. */
typedef struct radius_packet {
uint8_t code; /* RADIUS code, section 3, RFC 2865 */
uint8_t identifier; /* 1 octet in length. RFC 2865 section 3 */
uint8_t length[2]; /* 2 octets, or sizeof (u_short) */
uint8_t authenticator[RAD_AUTHENTICATOR_LEN];
uint8_t data[1];
} radius_packet_t;
/* Length of a RADIUS packet minus the payload */
#define RAD_PACKET_HDR_LEN 20
#ifdef __cplusplus
}
#endif
#endif /* _RADIUS_PROTOCOL_H */
|