Implement the calling of user defined callback. Basically, the callback is called from target_redirected() to get redirect address, redirect port and redirect reason in "string_addr:string_port:string_reason" syntax. Signed-Off-By: Chandra Seetharaman <sekharan at us.ibm.com> --- usr/iscsi/target.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) Index: tgt-1.0.8/usr/iscsi/target.c =================================================================== --- tgt-1.0.8.orig/usr/iscsi/target.c +++ tgt-1.0.8/usr/iscsi/target.c @@ -197,7 +197,38 @@ int target_redirected(struct iscsi_targe socklen_t len; int ret, rsn; char *p, *q, *str, *port, *addr; + char buffer[NI_MAXHOST + NI_MAXSERV + 4]; + if (target->redirect_info.callback) { + bzero(buffer, NI_MAXHOST + NI_MAXSERV + 4); + ret = call_program(target->redirect_info.callback, + NULL, NULL, buffer, NI_MAXHOST + NI_MAXSERV + 4, 0); + if (ret) + goto predefined; + + /* syntax is string_addr:string_port:string_reason */ + addr = p = buffer; + while (*p != ':' && *p != '\0') + p++; + if (!*p) + goto predefined; + *p = '\0'; + port = ++p; + while (*p != ':' && *p != '\0') + p++; + if (!*p) + goto predefined; + *p = '\0'; + p++; + if (!strncmp(p, "Temporary", 9)) + rsn = ISCSI_LOGIN_STATUS_TGT_MOVED_TEMP; + else if (!strncmp(p, "Permanent", 9)) + rsn = ISCSI_LOGIN_STATUS_TGT_MOVED_PERM; + else + goto predefined; + goto process; + } +predefined: if (!strlen(target->redirect_info.addr)) return 0; @@ -205,6 +236,7 @@ int target_redirected(struct iscsi_targe port = target->redirect_info.port; rsn = target->redirect_info.reason; +process: if (rsn != ISCSI_LOGIN_STATUS_TGT_MOVED_TEMP && rsn != ISCSI_LOGIN_STATUS_TGT_MOVED_PERM) return 0; -- To unsubscribe from this list: send the line "unsubscribe stgt" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html |