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
|
/*
* 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) 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <assert.h>
#include <ctype.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <unistd.h>
#include <libscf.h>
#include "libnwam_impl.h"
#include <libnwam_priv.h>
#include <libnwam.h>
/*
* Functions to support creating, modifying, destroying, querying the
* state of and changing the state of location objects. Locations
* represent the configuration to be applied once basic network configuration
* has been established - name services, IPsec config, etc, and can be enabled
* either manually or conditionally for a combination of the set of
* available conditions (an IP address is present, an ENM is active etc).
*/
#define NSSWITCH_PREFIX "/etc/nsswitch."
typedef nwam_error_t (*nwam_loc_prop_validate_func_t)(nwam_value_t);
static nwam_error_t valid_loc_activation_mode(nwam_value_t);
static nwam_error_t valid_loc_condition(nwam_value_t);
static nwam_error_t valid_nameservices(nwam_value_t);
static nwam_error_t valid_configsrc(nwam_value_t);
struct nwam_prop_table_entry loc_prop_table_entries[] = {
{NWAM_LOC_PROP_ACTIVATION_MODE, NWAM_VALUE_TYPE_UINT64, B_FALSE, 1, 1,
valid_loc_activation_mode,
"specifies the location activation mode - valid values are:\n"
"\'manual\', \'conditional-any\' and \'conditional-all\'",
NWAM_TYPE_ANY, NWAM_CLASS_ANY},
{NWAM_LOC_PROP_CONDITIONS, NWAM_VALUE_TYPE_STRING, B_FALSE, 0,
NWAM_MAX_NUM_VALUES, valid_loc_condition,
"specifies the activation condition. Conditions are of the form:\n"
"ncp|ncu|enm name is|is-not active\n"
"ip-address is|is-not|is-in-range|is-not-in-range| 1.2.3.4[/24]\n"
"advertised-domain is|is-not|contains|does-not-contain string\n"
"system-domain is|is-not|contains|does-not-contain string\n"
"essid is|is-not|contains|does-not-contain string\n"
"bssid is|is-not string",
NWAM_TYPE_ANY, NWAM_CLASS_ANY},
{NWAM_LOC_PROP_ENABLED, NWAM_VALUE_TYPE_BOOLEAN, B_TRUE, 1, 1,
nwam_valid_boolean,
"specifies if location is to be enabled",
NWAM_TYPE_ANY, NWAM_CLASS_ANY},
{NWAM_LOC_PROP_NAMESERVICES, NWAM_VALUE_TYPE_UINT64, B_FALSE, 1,
NWAM_MAX_NUM_VALUES, valid_nameservices,
"specifies name service(s) to be used - valid values are:\n"
"\'files\', \'dns\', \'nis\', and \'ldap\'",
NWAM_TYPE_ANY, NWAM_CLASS_ANY},
{NWAM_LOC_PROP_NAMESERVICES_CONFIG_FILE, NWAM_VALUE_TYPE_STRING,
B_FALSE, 0, 1, nwam_valid_file,
"specifies path to configuration file for name services switch "
"for this location - see nsswitch.conf(5)",
NWAM_TYPE_ANY, NWAM_CLASS_ANY},
{NWAM_LOC_PROP_DNS_NAMESERVICE_CONFIGSRC, NWAM_VALUE_TYPE_UINT64,
B_FALSE, 0, NWAM_MAX_NUM_VALUES, valid_configsrc,
"specifies sources of DNS configuration parameters - valid values "
"are:\n\'dhcp\', or \'manual\'",
NWAM_TYPE_ANY, NWAM_CLASS_ANY},
{NWAM_LOC_PROP_DNS_NAMESERVICE_DOMAIN, NWAM_VALUE_TYPE_STRING, B_FALSE,
0, 1, nwam_valid_domain,
"specifies DNS domain name to be set for this location",
NWAM_TYPE_ANY, NWAM_CLASS_ANY},
{NWAM_LOC_PROP_DNS_NAMESERVICE_SERVERS, NWAM_VALUE_TYPE_STRING, B_FALSE,
0, NWAM_MAX_NUM_VALUES, nwam_valid_host_any,
"specifies DNS server host address(es)",
NWAM_TYPE_ANY, NWAM_CLASS_ANY},
{NWAM_LOC_PROP_DNS_NAMESERVICE_SEARCH, NWAM_VALUE_TYPE_STRING, B_FALSE,
0, NWAM_MAX_NUM_VALUES, nwam_valid_domain,
"specifies DNS search list for host name lookup",
NWAM_TYPE_ANY, NWAM_CLASS_ANY},
{NWAM_LOC_PROP_NIS_NAMESERVICE_CONFIGSRC, NWAM_VALUE_TYPE_UINT64,
B_FALSE, 0, NWAM_MAX_NUM_VALUES, valid_configsrc,
"specifies sources of NIS configuration parameters - valid values "
"are:\n\'dhcp\', or \'manual\'",
NWAM_TYPE_ANY, NWAM_CLASS_ANY},
{NWAM_LOC_PROP_NIS_NAMESERVICE_SERVERS, NWAM_VALUE_TYPE_STRING, B_FALSE,
0, NWAM_MAX_NUM_VALUES, nwam_valid_host_any,
"specifies NIS server host address(es)",
NWAM_TYPE_ANY, NWAM_CLASS_ANY},
{NWAM_LOC_PROP_LDAP_NAMESERVICE_CONFIGSRC, NWAM_VALUE_TYPE_UINT64,
B_FALSE, 0, NWAM_MAX_NUM_VALUES, valid_configsrc,
"specifies sources of NIS configuration parameters - currently, "
"the only valid value is \'manual\'",
NWAM_TYPE_ANY, NWAM_CLASS_ANY},
{NWAM_LOC_PROP_LDAP_NAMESERVICE_SERVERS, NWAM_VALUE_TYPE_STRING,
B_FALSE, 0, NWAM_MAX_NUM_VALUES, nwam_valid_host_or_domain,
"specifies LDAP server host address(es)",
NWAM_TYPE_ANY, NWAM_CLASS_ANY},
{NWAM_LOC_PROP_DEFAULT_DOMAIN, NWAM_VALUE_TYPE_STRING, B_FALSE, 0, 1,
nwam_valid_domain,
"specifies the domainname(8) to be set for this location",
NWAM_TYPE_ANY, NWAM_CLASS_ANY},
{NWAM_LOC_PROP_NFSV4_DOMAIN, NWAM_VALUE_TYPE_STRING, B_FALSE, 0, 1,
nwam_valid_domain,
"specifies an NFSv4 domain for this location",
NWAM_TYPE_ANY, NWAM_CLASS_ANY},
{NWAM_LOC_PROP_IPFILTER_CONFIG_FILE, NWAM_VALUE_TYPE_STRING, B_FALSE,
0, 1, nwam_valid_file,
"specifies an absolute path to an ipf.conf(5) file for this "
"location",
NWAM_TYPE_ANY, NWAM_CLASS_ANY},
{NWAM_LOC_PROP_IPFILTER_V6_CONFIG_FILE, NWAM_VALUE_TYPE_STRING,
B_FALSE, 0, 1, nwam_valid_file,
"specifies an absolute path to an ipf6.conf file for this "
"location",
NWAM_TYPE_ANY, NWAM_CLASS_ANY},
{NWAM_LOC_PROP_IPNAT_CONFIG_FILE, NWAM_VALUE_TYPE_STRING, B_FALSE, 0,
1, nwam_valid_file,
"specifies an absolute path to an ipnat.conf(5) file for this "
"location",
NWAM_TYPE_ANY, NWAM_CLASS_ANY},
{NWAM_LOC_PROP_IPPOOL_CONFIG_FILE, NWAM_VALUE_TYPE_STRING, B_FALSE, 0,
1, nwam_valid_file,
"specifies an absolute path to an ippool.conf(5) file for this "
"location",
NWAM_TYPE_ANY, NWAM_CLASS_ANY},
{NWAM_LOC_PROP_IKE_CONFIG_FILE, NWAM_VALUE_TYPE_STRING, B_FALSE, 0, 1,
nwam_valid_file,
"specifies an absolute path to an ike config file "
"(see ike.config(5))",
NWAM_TYPE_ANY, NWAM_CLASS_ANY},
{NWAM_LOC_PROP_IPSECPOLICY_CONFIG_FILE, NWAM_VALUE_TYPE_STRING,
B_FALSE, 0, 1, nwam_valid_file,
"specifies an absolute path to an IPsec policy configuration file "
"(see ipsecconf(8)",
NWAM_TYPE_ANY, NWAM_CLASS_ANY},
};
#define NWAM_NUM_LOC_PROPS (sizeof (loc_prop_table_entries) / \
sizeof (*loc_prop_table_entries))
struct nwam_prop_table loc_prop_table =
{ NWAM_NUM_LOC_PROPS, loc_prop_table_entries };
static uint64_t
nwam_loc_activation_to_flag(nwam_activation_mode_t activation)
{
switch (activation) {
case NWAM_ACTIVATION_MODE_MANUAL:
return (NWAM_FLAG_ACTIVATION_MODE_MANUAL);
case NWAM_ACTIVATION_MODE_SYSTEM:
return (NWAM_FLAG_ACTIVATION_MODE_SYSTEM);
case NWAM_ACTIVATION_MODE_CONDITIONAL_ANY:
return (NWAM_FLAG_ACTIVATION_MODE_CONDITIONAL_ANY);
case NWAM_ACTIVATION_MODE_CONDITIONAL_ALL:
return (NWAM_FLAG_ACTIVATION_MODE_CONDITIONAL_ALL);
default:
return (0);
}
}
nwam_error_t
nwam_loc_read(const char *name, uint64_t flags, nwam_loc_handle_t *lochp)
{
return (nwam_read(NWAM_OBJECT_TYPE_LOC, NWAM_LOC_CONF_FILE, name,
flags, lochp));
}
nwam_error_t
nwam_loc_create(const char *name, nwam_loc_handle_t *lochp)
{
nwam_error_t err;
nwam_value_t val = NULL;
char *nsswitch = NULL;
assert(lochp != NULL && name != NULL);
if ((err = nwam_create(NWAM_OBJECT_TYPE_LOC, NWAM_LOC_CONF_FILE, name,
lochp)) != NWAM_SUCCESS)
return (err);
/* Create new object list for loc */
if ((err = nwam_alloc_object_list(&((*lochp)->nwh_data)))
!= NWAM_SUCCESS)
goto finish;
/* NWAM_LOC_PROP_ACTIVATION_MODE is mandatory */
if ((err = nwam_value_create_uint64(NWAM_ACTIVATION_MODE_MANUAL, &val))
!= NWAM_SUCCESS) {
goto finish;
}
if ((err = nwam_set_prop_value((*lochp)->nwh_data,
NWAM_LOC_PROP_ACTIVATION_MODE, val)) != NWAM_SUCCESS) {
goto finish;
}
nwam_value_free(val);
val = NULL;
/*
* NWAM_LOC_PROP_ENABLED defaults to false.
*/
if ((err = nwam_value_create_boolean(B_FALSE, &val)) != NWAM_SUCCESS)
goto finish;
if ((err = nwam_set_prop_value((*lochp)->nwh_data,
NWAM_LOC_PROP_ENABLED, val)) != NWAM_SUCCESS)
goto finish;
nwam_value_free(val);
val = NULL;
/*
* Initialize name service properties: use DNS, configured
* via DHCP, with default nsswitch (/etc/nsswitch.dns).
*/
if ((err = nwam_value_create_uint64(NWAM_NAMESERVICES_DNS, &val)) !=
NWAM_SUCCESS)
goto finish;
if ((err = nwam_set_prop_value((*lochp)->nwh_data,
NWAM_LOC_PROP_NAMESERVICES, val)) != NWAM_SUCCESS)
goto finish;
nwam_value_free(val);
val = NULL;
if ((err = nwam_value_create_uint64(NWAM_CONFIGSRC_DHCP, &val)) !=
NWAM_SUCCESS)
goto finish;
if ((err = nwam_set_prop_value((*lochp)->nwh_data,
NWAM_LOC_PROP_DNS_NAMESERVICE_CONFIGSRC, val)) != NWAM_SUCCESS)
goto finish;
nwam_value_free(val);
val = NULL;
/* concatenate these two strings */
nsswitch = strdup(NSSWITCH_PREFIX NWAM_NAMESERVICES_DNS_STRING);
if (nsswitch == NULL) {
err = NWAM_NO_MEMORY;
goto finish;
}
if ((err = nwam_value_create_string(nsswitch, &val)) != NWAM_SUCCESS)
goto finish;
err = nwam_set_prop_value((*lochp)->nwh_data,
NWAM_LOC_PROP_NAMESERVICES_CONFIG_FILE, val);
finish:
if (nsswitch != NULL)
free(nsswitch);
if (val != NULL)
nwam_value_free(val);
if (err != NWAM_SUCCESS) {
nwam_loc_free(*lochp);
*lochp = NULL;
}
return (err);
}
nwam_error_t
nwam_loc_get_name(nwam_loc_handle_t loch, char **namep)
{
return (nwam_get_name(loch, namep));
}
nwam_error_t
nwam_loc_set_name(nwam_loc_handle_t loch, const char *name)
{
return (nwam_set_name(loch, name));
}
boolean_t
nwam_loc_can_set_name(nwam_loc_handle_t loch)
{
return (!loch->nwh_committed);
}
/* ARGSUSED2 */
static int
loc_selectcb(struct nwam_handle *hp, uint64_t flags, void *data)
{
nwam_loc_handle_t loch = hp;
char *locname;
uint64_t activation, actflag, walkfilter;
nwam_value_t activationval;
/* Skip the Legacy location in all cases */
if (nwam_loc_get_name(loch, &locname) != NWAM_SUCCESS)
return (NWAM_INVALID_ARG);
if (strcmp(locname, NWAM_LOC_NAME_LEGACY) == 0) {
free(locname);
return (NWAM_INVALID_ARG);
}
free(locname);
/*
* Get a bitmapped flag value corresponding to this loc's
* activation.
*/
if (nwam_loc_get_prop_value(loch, NWAM_LOC_PROP_ACTIVATION_MODE,
&activationval) != NWAM_SUCCESS) {
return (NWAM_INVALID_ARG);
}
if (nwam_value_get_uint64(activationval, &activation) != NWAM_SUCCESS) {
nwam_value_free(activationval);
return (NWAM_INVALID_ARG);
}
actflag = nwam_loc_activation_to_flag(activation);
nwam_value_free(activationval);
if ((walkfilter = (flags & NWAM_WALK_FILTER_MASK)) == 0)
walkfilter = NWAM_FLAG_ACTIVATION_MODE_ALL;
if (actflag & walkfilter)
return (NWAM_SUCCESS);
return (NWAM_INVALID_ARG);
}
nwam_error_t
nwam_walk_locs(int(*cb)(nwam_loc_handle_t, void *), void *data, uint64_t flags,
int *retp)
{
nwam_error_t err = nwam_valid_flags(flags,
NWAM_FLAG_ACTIVATION_MODE_ALL | NWAM_FLAG_BLOCKING);
if (err != NWAM_SUCCESS)
return (err);
return (nwam_walk(NWAM_OBJECT_TYPE_LOC, NWAM_LOC_CONF_FILE,
cb, data, flags, retp, loc_selectcb));
}
void
nwam_loc_free(nwam_loc_handle_t loch)
{
nwam_free(loch);
}
nwam_error_t
nwam_loc_delete_prop(nwam_loc_handle_t loch, const char *propname)
{
nwam_error_t err;
boolean_t ro;
void *olddata;
assert(loch != NULL && propname != NULL);
if ((err = nwam_loc_prop_read_only(propname, &ro)) != NWAM_SUCCESS)
return (err);
if (ro)
return (NWAM_ENTITY_READ_ONLY);
/*
* Duplicate data, remove property and validate. If validation
* fails, revert to data duplicated prior to remove.
*/
if ((err = nwam_dup_object_list(loch->nwh_data, &olddata))
!= NWAM_SUCCESS)
return (err);
if ((err = nwam_delete_prop(loch->nwh_data, propname))
!= NWAM_SUCCESS) {
nwam_free_object_list(loch->nwh_data);
loch->nwh_data = olddata;
return (err);
}
if ((err = nwam_loc_validate(loch, NULL)) != NWAM_SUCCESS) {
nwam_free_object_list(loch->nwh_data);
loch->nwh_data = olddata;
return (err);
}
nwam_free_object_list(olddata);
return (NWAM_SUCCESS);
}
nwam_error_t
nwam_loc_set_prop_value(nwam_loc_handle_t loch, const char *propname,
nwam_value_t value)
{
nwam_error_t err;
boolean_t ro;
assert(loch != NULL && propname != NULL && value != NULL);
if ((err = nwam_loc_validate_prop(loch, propname, value))
!= NWAM_SUCCESS ||
(err = nwam_loc_prop_read_only(propname, &ro)) != NWAM_SUCCESS)
return (err);
if (ro)
return (NWAM_ENTITY_READ_ONLY);
return (nwam_set_prop_value(loch->nwh_data, propname, value));
}
nwam_error_t
nwam_loc_get_prop_value(nwam_loc_handle_t loch, const char *propname,
nwam_value_t *valuep)
{
return (nwam_get_prop_value(loch->nwh_data, propname, valuep));
}
nwam_error_t
nwam_loc_walk_props(nwam_loc_handle_t loch,
int (*cb)(const char *, nwam_value_t, void *),
void *data, uint64_t flags, int *retp)
{
return (nwam_walk_props(loch, cb, data, flags, retp));
}
nwam_error_t
nwam_loc_commit(nwam_loc_handle_t loch, uint64_t flags)
{
nwam_error_t err;
assert(loch != NULL && loch->nwh_data != NULL);
if ((err = nwam_loc_validate(loch, NULL)) != NWAM_SUCCESS)
return (err);
return (nwam_commit(NWAM_LOC_CONF_FILE, loch, flags));
}
nwam_error_t
nwam_loc_destroy(nwam_loc_handle_t loch, uint64_t flags)
{
nwam_error_t err;
nwam_value_t actval;
uint64_t activation;
/*
* Automatic and NoNet are not destroyable and Legacy is
* destroyable by netadm only. These have system activation-mode.
*/
if ((err = nwam_loc_get_prop_value(loch, NWAM_LOC_PROP_ACTIVATION_MODE,
&actval)) != NWAM_SUCCESS)
return (err);
err = nwam_value_get_uint64(actval, &activation);
nwam_value_free(actval);
if (err != NWAM_SUCCESS)
return (err);
if (activation == NWAM_ACTIVATION_MODE_SYSTEM) {
if (strcmp(loch->nwh_name, NWAM_LOC_NAME_LEGACY) == 0) {
if (!nwam_uid_is_special())
return (NWAM_ENTITY_NOT_DESTROYABLE);
} else {
return (NWAM_ENTITY_NOT_DESTROYABLE);
}
}
return (nwam_destroy(NWAM_LOC_CONF_FILE, loch, flags));
}
nwam_error_t
nwam_loc_get_prop_description(const char *propname, const char **descriptionp)
{
return (nwam_get_prop_description(loc_prop_table, propname,
descriptionp));
}
nwam_error_t
nwam_loc_prop_read_only(const char *propname, boolean_t *readp)
{
return (nwam_prop_read_only(loc_prop_table, propname, readp));
}
static nwam_error_t
valid_loc_activation_mode(nwam_value_t value)
{
uint64_t activation_mode;
if (nwam_value_get_uint64(value, &activation_mode) != NWAM_SUCCESS)
return (NWAM_ENTITY_INVALID_VALUE);
switch (activation_mode) {
case NWAM_ACTIVATION_MODE_MANUAL:
case NWAM_ACTIVATION_MODE_SYSTEM:
case NWAM_ACTIVATION_MODE_CONDITIONAL_ANY:
case NWAM_ACTIVATION_MODE_CONDITIONAL_ALL:
return (NWAM_SUCCESS);
}
return (NWAM_ENTITY_INVALID_VALUE);
}
/*
* Identical to nwam_valid_condition(), except locations cannot specify other
* location's activation as a condition, e.g. loc2 cannot specify
* "loc1 is active" since only one location is active at a time, and
* as a consequence the condition is unsatisfiable.
*/
nwam_error_t
valid_loc_condition(nwam_value_t value)
{
char **conditions;
uint_t i, numvalues;
nwam_condition_object_type_t object_type;
nwam_condition_t condition;
if (nwam_value_get_string_array(value, &conditions, &numvalues)
!= NWAM_SUCCESS)
return (NWAM_ENTITY_INVALID_VALUE);
for (i = 0; i < numvalues; i++) {
char *object_name = NULL;
if (nwam_condition_string_to_condition(conditions[i],
&object_type, &condition, &object_name) != NWAM_SUCCESS)
return (NWAM_ENTITY_INVALID_VALUE);
if (object_type == NWAM_CONDITION_OBJECT_TYPE_LOC &&
condition == NWAM_CONDITION_IS) {
free(object_name);
return (NWAM_ENTITY_INVALID_VALUE);
}
if (object_name != NULL)
free(object_name);
}
return (NWAM_SUCCESS);
}
static nwam_error_t
valid_nameservices(nwam_value_t value)
{
uint64_t *nameservices;
uint_t i, numvalues;
if (nwam_value_get_uint64_array(value, &nameservices, &numvalues)
!= NWAM_SUCCESS)
return (NWAM_ENTITY_INVALID_VALUE);
for (i = 0; i < numvalues; i++) {
if (nameservices[i] > NWAM_NAMESERVICES_LDAP)
return (NWAM_ENTITY_INVALID_VALUE);
}
return (NWAM_SUCCESS);
}
static nwam_error_t
valid_configsrc(nwam_value_t value)
{
uint64_t *configsrcs;
uint_t i, numvalues;
if (nwam_value_get_uint64_array(value, &configsrcs, &numvalues)
!= NWAM_SUCCESS)
return (NWAM_ENTITY_INVALID_VALUE);
for (i = 0; i < numvalues; i++) {
if (configsrcs[i] > NWAM_CONFIGSRC_DHCP)
return (NWAM_ENTITY_INVALID_VALUE);
}
return (NWAM_SUCCESS);
}
/*
* Validates that the activation-mode is system for Automatic and NoNet
* locations, and not system for all other locations.
*/
static nwam_error_t
nwam_loc_validate_activation_mode(nwam_loc_handle_t loch, nwam_value_t actval)
{
nwam_error_t err;
uint64_t activation;
if ((err = nwam_value_get_uint64(actval, &activation)) != NWAM_SUCCESS)
return (err);
if (NWAM_LOC_NAME_PRE_DEFINED(loch->nwh_name)) {
if (activation != NWAM_ACTIVATION_MODE_SYSTEM)
return (NWAM_ENTITY_INVALID_VALUE);
} else {
if (activation == NWAM_ACTIVATION_MODE_SYSTEM)
return (NWAM_ENTITY_INVALID_VALUE);
}
return (NWAM_SUCCESS);
}
/*
* Helper function to validate one nameservice, used by
* nwam_loc_validate_all_nameservices().
*
* requiredprop denotes the property that is mandatory when the
* configsrcprop is manual. errpropp is used to return the invalid
* property.
*/
static nwam_error_t
nwam_loc_validate_one_nameservice(nwam_loc_handle_t loch,
const char *configsrcprop, const char *requiredprop, const char **errpropp)
{
nwam_value_t configsrcval, requiredval;
uint64_t *configsrcs;
uint_t i, numvalues;
if (nwam_loc_get_prop_value(loch, configsrcprop, &configsrcval)
!= NWAM_SUCCESS) {
if (errpropp != NULL)
*errpropp = configsrcprop;
return (NWAM_ENTITY_MISSING_MEMBER);
}
if (nwam_value_get_uint64_array(configsrcval, &configsrcs, &numvalues)
!= NWAM_SUCCESS) {
if (errpropp != NULL)
*errpropp = configsrcprop;
nwam_value_free(configsrcval);
return (NWAM_ENTITY_NO_VALUE);
}
/* If -configsrc is manual, requiredprop is required */
for (i = 0; i < numvalues; i++) {
if (configsrcs[i] == NWAM_CONFIGSRC_MANUAL) {
if (nwam_loc_get_prop_value(loch, requiredprop,
&requiredval) != NWAM_SUCCESS) {
if (errpropp != NULL)
*errpropp = requiredprop;
return (NWAM_ENTITY_MISSING_MEMBER);
}
nwam_value_free(requiredval);
}
}
nwam_value_free(configsrcval);
return (NWAM_SUCCESS);
}
/*
* Helper function to validate LDAP nameservice, used by
* nwam_loc_validate_all_nameservices(). Separated because LDAP must be
* configured manually only and both default-domain and -servers are required.
*/
static nwam_error_t
nwam_loc_validate_ldap_nameservice(nwam_loc_handle_t loch,
const char **errpropp)
{
nwam_value_t val;
uint64_t *configsrcs;
uint_t i, numvalues;
if (nwam_loc_get_prop_value(loch,
NWAM_LOC_PROP_LDAP_NAMESERVICE_CONFIGSRC, &val) != NWAM_SUCCESS) {
if (errpropp != NULL)
*errpropp = NWAM_LOC_PROP_LDAP_NAMESERVICE_CONFIGSRC;
return (NWAM_ENTITY_MISSING_MEMBER);
}
/* -configsrc is defined as an array */
if (nwam_value_get_uint64_array(val, &configsrcs, &numvalues)
!= NWAM_SUCCESS) {
if (errpropp != NULL)
*errpropp = NWAM_LOC_PROP_LDAP_NAMESERVICE_CONFIGSRC;
nwam_value_free(val);
return (NWAM_ENTITY_NO_VALUE);
}
/* -configsrc must be manual */
for (i = 0; i < numvalues; i++) {
if (configsrcs[i] != NWAM_CONFIGSRC_MANUAL) {
if (errpropp != NULL)
*errpropp =
NWAM_LOC_PROP_LDAP_NAMESERVICE_CONFIGSRC;
nwam_value_free(val);
return (NWAM_ENTITY_INVALID_VALUE);
}
}
nwam_value_free(val);
/* both default-domain and -servers are required */
if (nwam_loc_get_prop_value(loch,
NWAM_LOC_PROP_DEFAULT_DOMAIN, &val) != NWAM_SUCCESS) {
if (errpropp != NULL)
*errpropp = NWAM_LOC_PROP_DEFAULT_DOMAIN;
return (NWAM_ENTITY_MISSING_MEMBER);
}
nwam_value_free(val);
if (nwam_loc_get_prop_value(loch,
NWAM_LOC_PROP_LDAP_NAMESERVICE_SERVERS, &val) != NWAM_SUCCESS) {
if (errpropp != NULL)
*errpropp = NWAM_LOC_PROP_LDAP_NAMESERVICE_SERVERS;
return (NWAM_ENTITY_MISSING_MEMBER);
}
nwam_value_free(val);
return (NWAM_SUCCESS);
}
/*
* Validates the different nameservices properties.
*
* If "nameservices" property has more than one nameservice to configure,
* "nameservices-config-file" must be specified. If only one nameservice
* is configured and "nameservices-config-file" is missing, set the
* property with the appropriately suffixed nsswitch file.
*
* For any nameservice being configured, the respective -configsrc property
* must be specified. For DNS, -servers is required if -configsrc is
* manual. For NIS and LDAP, default-domain is required if -configsrc is
* manual. For LDAP, -configsrc must be manual and -servers is required.
*/
static nwam_error_t
nwam_loc_validate_all_nameservices(nwam_loc_handle_t loch,
nwam_value_t nameservicesval, const char **errpropp)
{
nwam_error_t err;
nwam_value_t val;
uint64_t *nameservices;
uint_t i, numvalues;
if ((err = nwam_value_get_uint64_array(nameservicesval, &nameservices,
&numvalues)) != NWAM_SUCCESS)
return (err);
/*
* nameservices-config-file is required if nameservices has more
* than one value.
*/
if (numvalues > 1) {
if (nwam_loc_get_prop_value(loch,
NWAM_LOC_PROP_NAMESERVICES_CONFIG_FILE, &val)
!= NWAM_SUCCESS) {
if (errpropp != NULL)
*errpropp =
NWAM_LOC_PROP_NAMESERVICES_CONFIG_FILE;
return (NWAM_ENTITY_MISSING_MEMBER);
}
nwam_value_free(val);
} else if (numvalues == 1) {
/*
* If only one nameservice is being configured and
* nameservices-config-file doesn't exist, create it to
* point to the respective nsswitch file.
*/
err = nwam_loc_get_prop_value(loch,
NWAM_LOC_PROP_NAMESERVICES_CONFIG_FILE, &val);
if (err == NWAM_INVALID_ARG || err == NWAM_ENTITY_NOT_FOUND) {
char *nsswitch;
const char *nsswitch_suffix;
/* get the single nameservice being configured */
if ((err = nwam_uint64_get_value_string(
NWAM_LOC_PROP_NAMESERVICES, nameservices[0],
&nsswitch_suffix)) != NWAM_SUCCESS)
goto config_file_fail;
if ((nsswitch = malloc(MAXPATHLEN)) == NULL) {
err = NWAM_NO_MEMORY;
goto config_file_fail;
}
/* create appropriately suffixed nsswitch name */
(void) snprintf(nsswitch, MAXPATHLEN, "%s%s",
NSSWITCH_PREFIX, nsswitch_suffix);
if ((err = nwam_value_create_string(nsswitch, &val))
!= NWAM_SUCCESS) {
free(nsswitch);
goto config_file_fail;
}
err = nwam_set_prop_value(loch->nwh_data,
NWAM_LOC_PROP_NAMESERVICES_CONFIG_FILE, val);
free(nsswitch);
nwam_value_free(val);
if (err != NWAM_SUCCESS) {
nwam_value_free(val);
goto config_file_fail;
}
} else if (err != NWAM_SUCCESS) {
goto config_file_fail;
} else {
nwam_value_free(val);
}
}
/*
* validate the -configsrc property and the required default-domain
* and/or -servers property for each nameservice being configured.
*/
for (i = 0; i < numvalues; i++) {
switch (nameservices[i]) {
case NWAM_NAMESERVICES_DNS:
if ((err = nwam_loc_validate_one_nameservice(loch,
NWAM_LOC_PROP_DNS_NAMESERVICE_CONFIGSRC,
NWAM_LOC_PROP_DNS_NAMESERVICE_SERVERS, errpropp))
!= NWAM_SUCCESS)
return (err);
break;
case NWAM_NAMESERVICES_NIS:
if ((err = nwam_loc_validate_one_nameservice(loch,
NWAM_LOC_PROP_NIS_NAMESERVICE_CONFIGSRC,
NWAM_LOC_PROP_DEFAULT_DOMAIN, errpropp))
!= NWAM_SUCCESS)
return (err);
break;
case NWAM_NAMESERVICES_LDAP:
if ((err = nwam_loc_validate_ldap_nameservice(loch,
errpropp)) != NWAM_SUCCESS)
return (err);
break;
case NWAM_NAMESERVICES_FILES:
break;
default:
return (NWAM_ENTITY_INVALID_VALUE);
}
}
return (NWAM_SUCCESS);
config_file_fail:
if (errpropp != NULL)
*errpropp = NWAM_LOC_PROP_NAMESERVICES_CONFIG_FILE;
return (err);
}
nwam_error_t
nwam_loc_validate(nwam_loc_handle_t loch, const char **errpropp)
{
nwam_error_t err;
nwam_value_t activationval, conditionval, nameservicesval;
uint64_t activation;
char **conditions, *name;
uint_t i, numvalues;
nwam_condition_object_type_t object_type;
nwam_condition_t condition;
assert(loch != NULL);
/*
* Make sure loc is internally consistent: if activation type is
* conditional, the condition string must be specified.
*/
if (nwam_loc_get_prop_value(loch, NWAM_LOC_PROP_ACTIVATION_MODE,
&activationval) != NWAM_SUCCESS) {
if (errpropp != NULL)
*errpropp = NWAM_LOC_PROP_ACTIVATION_MODE;
return (NWAM_ENTITY_MISSING_MEMBER);
}
if (nwam_value_get_uint64(activationval, &activation)
!= NWAM_SUCCESS) {
if (errpropp != NULL)
*errpropp = NWAM_LOC_PROP_ACTIVATION_MODE;
nwam_value_free(activationval);
return (NWAM_ENTITY_NO_VALUE);
}
/* validate activation against the location first */
if ((err = nwam_loc_validate_activation_mode(loch, activationval))
!= NWAM_SUCCESS) {
if (errpropp != NULL)
*errpropp = NWAM_LOC_PROP_ACTIVATION_MODE;
nwam_value_free(activationval);
return (err);
}
nwam_value_free(activationval);
if (activation == NWAM_ACTIVATION_MODE_CONDITIONAL_ANY ||
activation == NWAM_ACTIVATION_MODE_CONDITIONAL_ALL) {
if (nwam_loc_get_prop_value(loch, NWAM_LOC_PROP_CONDITIONS,
&conditionval) != NWAM_SUCCESS) {
if (errpropp != NULL)
*errpropp = NWAM_LOC_PROP_CONDITIONS;
return (NWAM_ENTITY_MISSING_MEMBER);
}
/*
* Are conditions self-referential? In other words, do any
* of the activation conditions refer to this location?
*/
if (nwam_value_get_string_array(conditionval, &conditions,
&numvalues) != NWAM_SUCCESS) {
nwam_value_free(conditionval);
if (errpropp != NULL)
*errpropp = NWAM_LOC_PROP_CONDITIONS;
return (NWAM_ENTITY_INVALID_VALUE);
}
if (nwam_loc_get_name(loch, &name) != NWAM_SUCCESS) {
nwam_value_free(conditionval);
return (NWAM_INVALID_ARG);
}
for (i = 0; i < numvalues; i++) {
char *object_name = NULL;
if (nwam_condition_string_to_condition(conditions[i],
&object_type, &condition, &object_name)
!= NWAM_SUCCESS) {
if (errpropp != NULL)
*errpropp = NWAM_LOC_PROP_CONDITIONS;
free(name);
nwam_value_free(conditionval);
return (NWAM_ENTITY_INVALID_VALUE);
}
if (object_name != NULL &&
object_type == NWAM_CONDITION_OBJECT_TYPE_LOC &&
strcmp(object_name, name) == 0) {
if (errpropp != NULL)
*errpropp = NWAM_LOC_PROP_CONDITIONS;
free(name);
free(object_name);
nwam_value_free(conditionval);
return (NWAM_ENTITY_INVALID_VALUE);
}
free(object_name);
}
free(name);
nwam_value_free(conditionval);
}
/* validate namerservices */
if (nwam_loc_get_prop_value(loch, NWAM_LOC_PROP_NAMESERVICES,
&nameservicesval) != NWAM_SUCCESS) {
if (errpropp != NULL)
*errpropp = NWAM_LOC_PROP_NAMESERVICES;
return (NWAM_ENTITY_MISSING_MEMBER);
}
err = nwam_loc_validate_all_nameservices(loch, nameservicesval,
errpropp);
nwam_value_free(nameservicesval);
if (err != NWAM_SUCCESS)
return (err);
return (nwam_validate(loc_prop_table, loch, errpropp));
}
nwam_error_t
nwam_loc_validate_prop(nwam_loc_handle_t loch, const char *propname,
nwam_value_t value)
{
nwam_error_t err;
assert(loch != NULL);
if (strcmp(propname, NWAM_LOC_PROP_ACTIVATION_MODE) == 0) {
if ((err = nwam_loc_validate_activation_mode(loch, value))
!= NWAM_SUCCESS)
return (err);
}
return (nwam_validate_prop(loc_prop_table, loch, propname, value));
}
nwam_error_t
nwam_loc_copy(nwam_loc_handle_t oldloch, const char *newname,
nwam_loc_handle_t *newlochp)
{
nwam_error_t err;
nwam_value_t val;
if ((err = nwam_copy(NWAM_LOC_CONF_FILE, oldloch, newname, newlochp))
!= NWAM_SUCCESS)
return (err);
/* If the activation-mode is system, change it to manual */
if ((err = nwam_loc_get_prop_value(*newlochp,
NWAM_LOC_PROP_ACTIVATION_MODE, &val)) != NWAM_SUCCESS)
goto finish;
err = nwam_loc_validate_activation_mode(*newlochp, val);
nwam_value_free(val);
if (err != NWAM_SUCCESS) {
if ((err = nwam_value_create_uint64(NWAM_ACTIVATION_MODE_MANUAL,
&val)) != NWAM_SUCCESS)
goto finish;
err = nwam_set_prop_value((*newlochp)->nwh_data,
NWAM_LOC_PROP_ACTIVATION_MODE, val);
nwam_value_free(val);
if (err != NWAM_SUCCESS)
goto finish;
if ((err = nwam_value_create_boolean(B_FALSE, &val))
!= NWAM_SUCCESS)
goto finish;
err = nwam_set_prop_value((*newlochp)->nwh_data,
NWAM_LOC_PROP_ENABLED, val);
nwam_value_free(val);
if (err != NWAM_SUCCESS)
goto finish;
}
return (NWAM_SUCCESS);
finish:
nwam_loc_free(*newlochp);
*newlochp = NULL;
return (err);
}
/*
* Given a property, return expected property data type
*/
nwam_error_t
nwam_loc_get_prop_type(const char *propname, nwam_value_type_t *typep)
{
return (nwam_get_prop_type(loc_prop_table, propname, typep));
}
nwam_error_t
nwam_loc_prop_multivalued(const char *propname, boolean_t *multip)
{
return (nwam_prop_multivalued(loc_prop_table, propname, multip));
}
/*
* Determine if the location has manual activation-mode or not.
*/
nwam_error_t
nwam_loc_is_manual(nwam_loc_handle_t loch, boolean_t *manualp)
{
nwam_error_t err;
nwam_value_t actval;
uint64_t activation;
assert(loch != NULL);
if ((err = nwam_loc_get_prop_value(loch, NWAM_LOC_PROP_ACTIVATION_MODE,
&actval)) != NWAM_SUCCESS)
return (err);
err = nwam_value_get_uint64(actval, &activation);
nwam_value_free(actval);
if (err != NWAM_SUCCESS)
return (err);
if (activation == NWAM_ACTIVATION_MODE_MANUAL)
*manualp = B_TRUE;
else
*manualp = B_FALSE;
return (NWAM_SUCCESS);
}
/* Determine if location is enabled or not */
static nwam_error_t
nwam_loc_is_enabled(nwam_loc_handle_t loch, boolean_t *enabledp)
{
nwam_error_t err;
nwam_value_t enabledval;
assert(loch != NULL);
if ((err = nwam_loc_get_prop_value(loch, NWAM_LOC_PROP_ENABLED,
&enabledval)) != NWAM_SUCCESS)
return (err);
err = nwam_value_get_boolean(enabledval, enabledp);
nwam_value_free(enabledval);
return (err);
}
/*
* Callback to disable all locations other than one to enable, the handle
* of which we pass in as an argument. If the argument is NULL, we disable
* all locations.
*/
static int
loc_set_enabled(nwam_loc_handle_t loch, void *data)
{
nwam_value_t enabledval;
boolean_t curr_state, enabled = B_FALSE;
nwam_loc_handle_t testloch = data;
nwam_error_t err = NWAM_SUCCESS;
if (testloch != NULL) {
char *name, *testname;
if (nwam_loc_get_name(loch, &name) == NWAM_SUCCESS &&
nwam_loc_get_name(testloch, &testname) == NWAM_SUCCESS &&
strcmp(name, testname) == 0) {
/* We enable this location. */
enabled = B_TRUE;
}
}
/* If the enabled property is not changing, don't do anything. */
if (nwam_loc_is_enabled(loch, &curr_state) == NWAM_SUCCESS &&
curr_state == enabled)
return (0);
if (nwam_value_create_boolean(enabled, &enabledval) != NWAM_SUCCESS)
return (0);
if (nwam_set_prop_value(loch->nwh_data, NWAM_LOC_PROP_ENABLED,
enabledval) == NWAM_SUCCESS)
err = nwam_loc_commit(loch, NWAM_FLAG_ENTITY_ENABLE);
nwam_value_free(enabledval);
return (err);
}
/*
* Update the enabled property for this location (and for all others
* if necessary.
*/
static int
nwam_loc_update_enabled(nwam_loc_handle_t loch, boolean_t enabled)
{
nwam_error_t err;
int cb_ret;
if (enabled) {
/*
* Disable all other locations that are manually enabled
* and enable this one - a maximum of 1 location can be
* enabled at once.
*/
err = nwam_walk_locs(loc_set_enabled, loch, 0, &cb_ret);
if (err != NWAM_SUCCESS && err != NWAM_WALK_HALTED)
cb_ret = err;
} else {
cb_ret = loc_set_enabled(loch, NULL);
}
return (cb_ret);
}
nwam_error_t
nwam_loc_enable(nwam_loc_handle_t loch)
{
nwam_error_t err;
boolean_t enabled;
assert(loch != NULL);
/* Make sure location is not enabled */
if ((err = nwam_loc_is_enabled(loch, &enabled)) != NWAM_SUCCESS)
return (err);
if (enabled)
return (NWAM_SUCCESS);
if ((err = nwam_loc_update_enabled(loch, B_TRUE)) != NWAM_SUCCESS)
return (err);
err = nwam_enable(NULL, loch);
/* nwamd may not be running, that's okay. */
if (err == NWAM_ERROR_BIND)
return (NWAM_SUCCESS);
else
return (err);
}
nwam_error_t
nwam_loc_disable(nwam_loc_handle_t loch)
{
nwam_error_t err;
boolean_t enabled;
assert(loch != NULL);
/* Make sure location is enabled */
if ((err = nwam_loc_is_enabled(loch, &enabled)) != NWAM_SUCCESS)
return (err);
if (!enabled)
return (NWAM_SUCCESS);
if ((err = nwam_loc_update_enabled(loch, B_FALSE)) != NWAM_SUCCESS)
return (err);
err = nwam_disable(NULL, loch);
/* nwamd may not be running, that's okay. */
if (err == NWAM_ERROR_BIND)
return (NWAM_SUCCESS);
else
return (err);
}
nwam_error_t
nwam_loc_get_default_proplist(const char ***prop_list, uint_t *numvaluesp)
{
return (nwam_get_default_proplist(loc_prop_table,
NWAM_TYPE_ANY, NWAM_CLASS_ANY, prop_list, numvaluesp));
}
nwam_error_t
nwam_loc_get_state(nwam_loc_handle_t loch, nwam_state_t *statep,
nwam_aux_state_t *auxp)
{
return (nwam_get_state(NULL, loch, statep, auxp));
}
|