|
Packit Service |
37dbff |
/*
|
|
Packit Service |
37dbff |
* iSCSI Administration library
|
|
Packit Service |
37dbff |
*
|
|
Packit Service |
37dbff |
* Copyright (C) 2008-2009 Red Hat, Inc. All rights reserved.
|
|
Packit Service |
37dbff |
* Copyright (C) 2008-2009 Hans de Goede <hdegoede@redhat.com>
|
|
Packit Service |
37dbff |
* maintained by open-iscsi@googlegroups.com
|
|
Packit Service |
37dbff |
*
|
|
Packit Service |
37dbff |
* This program is free software; you can redistribute it and/or modify
|
|
Packit Service |
37dbff |
* it under the terms of the GNU General Public License as published
|
|
Packit Service |
37dbff |
* by the Free Software Foundation; either version 2 of the License, or
|
|
Packit Service |
37dbff |
* (at your option) any later version.
|
|
Packit Service |
37dbff |
*
|
|
Packit Service |
37dbff |
* This program is distributed in the hope that it will be useful, but
|
|
Packit Service |
37dbff |
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
37dbff |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
37dbff |
* General Public License for more details.
|
|
Packit Service |
37dbff |
*
|
|
Packit Service |
37dbff |
* See the file COPYING included with this distribution for more details.
|
|
Packit Service |
37dbff |
*/
|
|
Packit Service |
37dbff |
|
|
Packit Service |
37dbff |
#include <stdio.h>
|
|
Packit Service |
37dbff |
#include <stdlib.h>
|
|
Packit Service |
37dbff |
#include <string.h>
|
|
Packit Service |
37dbff |
#include "libiscsi.h"
|
|
Packit Service |
37dbff |
|
|
Packit Service |
37dbff |
int main(void)
|
|
Packit Service |
37dbff |
{
|
|
Packit Service |
37dbff |
struct libiscsi_node node;
|
|
Packit Service |
37dbff |
struct libiscsi_context *context;
|
|
Packit Service |
37dbff |
struct libiscsi_auth_info auth_info;
|
|
Packit Service |
37dbff |
int rc = 0;
|
|
Packit Service |
37dbff |
|
|
Packit Service |
37dbff |
snprintf(node.name, LIBISCSI_VALUE_MAXLEN, "%s",
|
|
Packit Service |
37dbff |
"iqn.2009-01.com.example:testdisk");
|
|
Packit Service |
37dbff |
node.tpgt = 1;
|
|
Packit Service |
37dbff |
snprintf(node.address, NI_MAXHOST, "%s", "127.0.0.1");
|
|
Packit Service |
37dbff |
node.port = 3260;
|
|
Packit Service |
37dbff |
|
|
Packit Service |
37dbff |
context = libiscsi_init();
|
|
Packit Service |
37dbff |
if (!context) {
|
|
Packit Service |
37dbff |
fprintf(stderr, "Error initializing libiscsi\n");
|
|
Packit Service |
37dbff |
return 1;
|
|
Packit Service |
37dbff |
}
|
|
Packit Service |
37dbff |
|
|
Packit Service |
37dbff |
rc = libiscsi_node_get_auth(context, &node, &auth_info);
|
|
Packit Service |
37dbff |
if (rc) {
|
|
Packit Service |
37dbff |
fprintf(stderr, "Error setting authinfo: %s\n",
|
|
Packit Service |
37dbff |
libiscsi_get_error_string(context));
|
|
Packit Service |
37dbff |
goto leave;
|
|
Packit Service |
37dbff |
}
|
|
Packit Service |
37dbff |
|
|
Packit Service |
37dbff |
switch (auth_info.method) {
|
|
Packit Service |
37dbff |
case libiscsi_auth_none:
|
|
Packit Service |
37dbff |
printf("Method: \"None\"\n");
|
|
Packit Service |
37dbff |
break;
|
|
Packit Service |
37dbff |
case libiscsi_auth_chap:
|
|
Packit Service |
37dbff |
printf("Method: \"CHAP\"\n");
|
|
Packit Service |
37dbff |
printf("User: \"%s\"\n", auth_info.chap.username);
|
|
Packit Service |
37dbff |
printf("Pass: \"%s\"\n", auth_info.chap.password);
|
|
Packit Service |
37dbff |
printf("RevUser: \"%s\"\n",
|
|
Packit Service |
37dbff |
auth_info.chap.reverse_username);
|
|
Packit Service |
37dbff |
printf("RevPass: \"%s\"\n",
|
|
Packit Service |
37dbff |
auth_info.chap.reverse_password);
|
|
Packit Service |
37dbff |
break;
|
|
Packit Service |
37dbff |
}
|
|
Packit Service |
37dbff |
leave:
|
|
Packit Service |
37dbff |
libiscsi_cleanup(context);
|
|
Packit Service |
37dbff |
|
|
Packit Service |
37dbff |
return rc;
|
|
Packit Service |
37dbff |
}
|