| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: iscsid_lists.c,v 1.6 2012/05/27 23:54:45 riz Exp $ */ | | 1 | /* $NetBSD: iscsid_lists.c,v 1.7 2012/05/28 00:37:55 riz Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2005,2006,2011 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2005,2006,2011 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Wasabi Systems, Inc. | | 8 | * by Wasabi Systems, Inc. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -222,28 +222,28 @@ find_TargetName(iscsid_list_kind_t lst, | | | @@ -222,28 +222,28 @@ find_TargetName(iscsid_list_kind_t lst, |
222 | { | | 222 | { |
223 | generic_entry_t *curr; | | 223 | generic_entry_t *curr; |
224 | target_t *t = NULL; | | 224 | target_t *t = NULL; |
225 | | | 225 | |
226 | if (lst == PORTAL_LIST) | | 226 | if (lst == PORTAL_LIST) |
227 | lst = TARGET_LIST; | | 227 | lst = TARGET_LIST; |
228 | | | 228 | |
229 | TAILQ_FOREACH(curr, &list[lst].list, link) { | | 229 | TAILQ_FOREACH(curr, &list[lst].list, link) { |
230 | t = (void *)curr; | | 230 | t = (void *)curr; |
231 | if (strcmp((char *)t->TargetName, (char *)name) == 0) | | 231 | if (strcmp((char *)t->TargetName, (char *)name) == 0) |
232 | break; | | 232 | break; |
233 | } | | 233 | } |
234 | | | 234 | |
| | | 235 | /* return curr instead of t because curr==NULL if name not found */ |
235 | DEB(10, ("Find_TargetName returns %p\n", curr)); | | 236 | DEB(10, ("Find_TargetName returns %p\n", curr)); |
236 | | | | |
237 | return (target_t *)curr; | | 237 | return (target_t *)curr; |
238 | } | | 238 | } |
239 | | | 239 | |
240 | | | 240 | |
241 | /* | | 241 | /* |
242 | * find_portal_by_addr: | | 242 | * find_portal_by_addr: |
243 | * Find a Portal by Address. | | 243 | * Find a Portal by Address. |
244 | * | | 244 | * |
245 | * Parameter: the associated target, and the address | | 245 | * Parameter: the associated target, and the address |
246 | * | | 246 | * |
247 | * Returns: The pointer to the portal (or NULL if not found) | | 247 | * Returns: The pointer to the portal (or NULL if not found) |
248 | */ | | 248 | */ |
249 | | | 249 | |
| @@ -256,55 +256,57 @@ find_portal_by_addr(target_t * target, i | | | @@ -256,55 +256,57 @@ find_portal_by_addr(target_t * target, i |
256 | TAILQ_FOREACH(curr, &list[PORTAL_LIST].list, link) { | | 256 | TAILQ_FOREACH(curr, &list[PORTAL_LIST].list, link) { |
257 | p = (void *)curr; | | 257 | p = (void *)curr; |
258 | DEB(10, ("Find_portal_by_addr - addr %s port %d target %p\n", | | 258 | DEB(10, ("Find_portal_by_addr - addr %s port %d target %p\n", |
259 | p->addr.address, | | 259 | p->addr.address, |
260 | p->addr.port, | | 260 | p->addr.port, |
261 | p->target)); | | 261 | p->target)); |
262 | | | 262 | |
263 | if (strcmp((char *)p->addr.address, (char *)addr->address) == 0 && | | 263 | if (strcmp((char *)p->addr.address, (char *)addr->address) == 0 && |
264 | (!addr->port || p->addr.port == addr->port) && | | 264 | (!addr->port || p->addr.port == addr->port) && |
265 | p->target == target) | | 265 | p->target == target) |
266 | break; | | 266 | break; |
267 | } | | 267 | } |
268 | | | 268 | |
| | | 269 | /* return curr instead of p because curr==NULL if not found */ |
269 | DEB(10, ("Find_portal_by_addr returns %p\n", curr)); | | 270 | DEB(10, ("Find_portal_by_addr returns %p\n", curr)); |
270 | return p; | | 271 | return (portal_t *)curr; |
271 | } | | 272 | } |
272 | | | 273 | |
273 | | | 274 | |
274 | /* | | 275 | /* |
275 | * find_send_target_by_addr: | | 276 | * find_send_target_by_addr: |
276 | * Find a Send Target by Address. | | 277 | * Find a Send Target by Address. |
277 | * | | 278 | * |
278 | * Parameter: the address | | 279 | * Parameter: the address |
279 | * | | 280 | * |
280 | * Returns: The pointer to the portal (or NULL if not found) | | 281 | * Returns: The pointer to the portal (or NULL if not found) |
281 | */ | | 282 | */ |
282 | | | 283 | |
283 | send_target_t * | | 284 | send_target_t * |
284 | find_send_target_by_addr(iscsi_portal_address_t * addr) | | 285 | find_send_target_by_addr(iscsi_portal_address_t * addr) |
285 | { | | 286 | { |
286 | generic_entry_t *curr; | | 287 | generic_entry_t *curr; |
287 | send_target_t *t = NULL; | | 288 | send_target_t *t = NULL; |
288 | | | 289 | |
289 | TAILQ_FOREACH(curr, &list[SEND_TARGETS_LIST].list, link) { | | 290 | TAILQ_FOREACH(curr, &list[SEND_TARGETS_LIST].list, link) { |
290 | t = (void *)curr; | | 291 | t = (void *)curr; |
291 | if (strcmp((char *)t->addr.address, (char *)addr->address) == 0 && | | 292 | if (strcmp((char *)t->addr.address, (char *)addr->address) == 0 && |
292 | (!addr->port || t->addr.port == addr->port)) | | 293 | (!addr->port || t->addr.port == addr->port)) |
293 | break; | | 294 | break; |
294 | } | | 295 | } |
295 | | | 296 | |
| | | 297 | /* return curr instead of p because curr==NULL if not found */ |
296 | DEB(10, ("Find_send_target_by_addr returns %p\n", curr)); | | 298 | DEB(10, ("Find_send_target_by_addr returns %p\n", curr)); |
297 | return t; | | 299 | return (send_target_t *)curr; |
298 | } | | 300 | } |
299 | | | 301 | |
300 | | | 302 | |
301 | /* | | 303 | /* |
302 | * get_list: | | 304 | * get_list: |
303 | * Handle GET_LIST request: Return the list of IDs contained in the list. | | 305 | * Handle GET_LIST request: Return the list of IDs contained in the list. |
304 | * | | 306 | * |
305 | * Parameter: | | 307 | * Parameter: |
306 | * par The request parameters. | | 308 | * par The request parameters. |
307 | * prsp Pointer to address of response buffer. | | 309 | * prsp Pointer to address of response buffer. |
308 | * prsp_temp Will be set to TRUE if buffer was allocated, FALSE | | 310 | * prsp_temp Will be set to TRUE if buffer was allocated, FALSE |
309 | * for static buffer. | | 311 | * for static buffer. |
310 | */ | | 312 | */ |
| @@ -684,28 +686,29 @@ get_connection_info(iscsid_get_connectio | | | @@ -684,28 +686,29 @@ get_connection_info(iscsid_get_connectio |
684 | | | 686 | |
685 | static initiator_t * | | 687 | static initiator_t * |
686 | find_initiator_by_addr(uint8_t * addr) | | 688 | find_initiator_by_addr(uint8_t * addr) |
687 | { | | 689 | { |
688 | generic_entry_t *curr; | | 690 | generic_entry_t *curr; |
689 | initiator_t *i = NULL; | | 691 | initiator_t *i = NULL; |
690 | | | 692 | |
691 | TAILQ_FOREACH(curr, &list[INITIATOR_LIST].list, link) { | | 693 | TAILQ_FOREACH(curr, &list[INITIATOR_LIST].list, link) { |
692 | i = (void *)curr; | | 694 | i = (void *)curr; |
693 | if (strcmp((char *)i->address, (char *)addr) == 0) | | 695 | if (strcmp((char *)i->address, (char *)addr) == 0) |
694 | break; | | 696 | break; |
695 | } | | 697 | } |
696 | | | 698 | |
| | | 699 | /* return curr instead of i because if not found, curr==NULL */ |
697 | DEB(9, ("Find_initiator_by_addr returns %p\n", curr)); | | 700 | DEB(9, ("Find_initiator_by_addr returns %p\n", curr)); |
698 | return i; | | 701 | return (initiator_t *)curr; |
699 | } | | 702 | } |
700 | | | 703 | |
701 | | | 704 | |
702 | /* | | 705 | /* |
703 | * add_initiator_portal: | | 706 | * add_initiator_portal: |
704 | * Add an initiator portal. | | 707 | * Add an initiator portal. |
705 | * | | 708 | * |
706 | * Parameter: | | 709 | * Parameter: |
707 | * par The request parameters. | | 710 | * par The request parameters. |
708 | * prsp Pointer to address of response buffer. | | 711 | * prsp Pointer to address of response buffer. |
709 | * prsp_temp Will be set to TRUE if buffer was allocated, FALSE | | 712 | * prsp_temp Will be set to TRUE if buffer was allocated, FALSE |
710 | * for static buffer. | | 713 | * for static buffer. |
711 | */ | | 714 | */ |