--------------------- PatchSet 8792 Date: 2006/12/03 12:54:17 Author: adri Branch: s26_wccp2 Tag: (none) Log: Finish off the mask assignment conversion; this stuff isn't tested at all. Members: src/wccp2.c:1.26.2.6->1.26.2.7 Index: squid/src/wccp2.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/wccp2.c,v retrieving revision 1.26.2.6 retrieving revision 1.26.2.7 diff -u -r1.26.2.6 -r1.26.2.7 --- squid/src/wccp2.c 3 Dec 2006 12:24:56 -0000 1.26.2.6 +++ squid/src/wccp2.c 3 Dec 2006 12:54:17 -0000 1.26.2.7 @@ -1,6 +1,6 @@ /* - * $Id: wccp2.c,v 1.26.2.6 2006/12/03 12:24:56 adri Exp $ + * $Id: wccp2.c,v 1.26.2.7 2006/12/03 12:54:17 adri Exp $ * * DEBUG: section 80 WCCP Support * AUTHOR: Steven WIlton @@ -1889,13 +1889,14 @@ wccp2_out_add_mask_assignment_info(struct wccp2_out_packet_t *p, struct wccp2_service_list_t *sl, struct wccp2_router_list_t *rl) { int num_seen_routers = service_get_num_seen_routers(sl); - struct wccp2_item_header_t ah; + struct wccp2_item_header_t ah, am; struct assignment_key_t ak; struct wccp2_mask_element_t me; uint32_t num_maskval, tmp; uint32_t service_flags; struct wccp2_value_element_t ve; struct wccp2_cache_list_t *cache_list_ptr; + struct wccp2_router_assign_element_t ra; int valuecounter, value; debug(80, 3) ("wccp2_out_add_mask_assignment_info: service %p; beginning for router %s\n", @@ -1903,15 +1904,23 @@ /* alt assignment */ ah.type = htons(WCCP2_ALT_ASSIGNMENT); - /* XXX I really, really hate magic numbers! */ - /* ah.length = htons(sizeof(ak) + 4 + (sizeof(ra) * num_seen_routers) + 4 + (4 * num_caches) + WCCP_BUCKETS); */ - wccp2_out_packet_append(p, &ah, sizeof(ah)); /* mask assignment - has a seperate length just for the alternate assignment body */ - ah.type = htons(WCCP2_MASK_ASSIGNMENT); - /* XXX must update this */ - ah.length = -1; + am.type = htons(WCCP2_MASK_ASSIGNMENT); + /* + * Assignment body length: key + 4 bytes for routers seen + router elements + * + 4 bytes for assignment element count + one assignment element + * + 64 value elements. + */ + am.length = htons(sizeof(ak) + 4 + (sizeof(ra) * num_seen_routers) + 4 + sizeof(me) + (64 * sizeof(ve))); + + /* And the alt assignment length is the above mask assignment length plus the am header */ + ah.length = htons(ntohs(am.length) + sizeof(am)); + + /* Now add them */ wccp2_out_packet_append(p, &ah, sizeof(ah)); + wccp2_out_packet_append(p, &am, sizeof(am)); + /* assignment key */ ak.master_number = htonl(++sl->change_num); @@ -1997,11 +2006,6 @@ else cache_list_ptr = &rl->cache_list_head; } -#if 0 - /* Fill in length */ - alt_assignment_type_header->length = htons(offset - alt_assignment_offset); - /* And also need to fill in assignment header length */ -#endif }