28 #include <linux/kernel.h>
29 #include <linux/string.h>
30 #include <linux/ctype.h>
32 #include <linux/export.h>
33 #include <scsi/scsi.h>
78 pr_debug(
"sas transport_id: invalid hex string\n");
112 char **port_nexus_ptr)
122 *port_nexus_ptr =
NULL;
125 return (
char *)&buf[4];
174 for (i = 0; i < 24; ) {
175 if (!
strncmp(&ptr[i],
":", 1)) {
179 ret =
hex2bin(&buf[off++], &ptr[i], 1);
181 pr_debug(
"fc transport_id: invalid hex string\n");
195 char **port_nexus_ptr)
202 *port_nexus_ptr =
NULL;
205 return (
char *)&buf[8];
282 buf[off+len] = 0x2c; off++;
283 buf[off+len] = 0x69; off++;
284 buf[off+len] = 0x2c; off++;
285 buf[off+len] = 0x30; off++;
286 buf[off+len] = 0x78; off++;
294 buf[off+len] =
'\0'; off++;
307 buf[2] = ((len >> 8) & 0xff);
308 buf[3] = (len & 0xff);
369 char **port_nexus_ptr)
375 u8 format_code = (buf[0] & 0xc0);
389 if ((format_code != 0x00) && (format_code != 0x40)) {
390 pr_err(
"Illegal format code: 0x%02x for iSCSI"
391 " Initiator Transport ID\n", format_code);
398 if (out_tid_len !=
NULL) {
399 add_len = ((buf[2] >> 8) & 0xff);
400 add_len |= (buf[3] & 0xff);
402 tid_len =
strlen(&buf[4]);
405 padding = ((-tid_len) & 3);
409 if ((add_len + 4) != tid_len) {
410 pr_debug(
"LIO-Target Extracted add_len: %hu "
411 "does not match calculated tid_len: %u,"
412 " using tid_len instead\n", add_len+4, tid_len);
413 *out_tid_len = tid_len;
415 *out_tid_len = (add_len + 4);
422 if (format_code == 0x40) {
423 p =
strstr(&buf[4],
",i,0x");
425 pr_err(
"Unable to locate \",i,0x\" separator"
426 " for Initiator port identifier: %s\n",
440 for (i = 0; i < 12; i++) {
450 return (
char *)&buf[4];