2005-04-02 Andrew J. Schorr <ajschorr@alumni.princeton.edu>

	* if.h: (if_lookup_by_name_len, if_get_by_name_len) New functions.
	* if.c: (if_lookup_by_name_len, if_get_by_name_len) New functions.
	  (if_get_by_name) Tighten up code.
	  (interface) Use new function if_get_by_name_len.
	* zclient.c: (zebra_interface_add_read) Use new if_get_by_name_len
	  function.
	  (zebra_interface_state_read) Use new if_lookup_by_name_len function.
	* kernel_socket.c: (ifm_read) Use new if_lookup_by_name_len function
	  to save a memcpy.
	* if_ioctl_solaris.c: (interface_list_ioctl) Fix subtle bug with new
	  if_get_by_name_len function.
	* ospf_interface.c: (ospf_vl_new) Use strnlen to fix call to if_create.
diff --git a/lib/if.h b/lib/if.h
index df9ff60..4cfc9e7 100644
--- a/lib/if.h
+++ b/lib/if.h
@@ -214,11 +214,25 @@
 int if_cmp_func (struct interface *, struct interface *);
 struct interface *if_create (const char *name, int namelen);
 struct interface *if_lookup_by_index (unsigned int);
-struct interface *if_lookup_by_name (const char *);
 struct interface *if_lookup_exact_address (struct in_addr);
 struct interface *if_lookup_address (struct in_addr);
+
+/* Currently, the code assumes that the interface name arguments to these
+   functions have length <= INTERFACE_NAMSIZ, and they must be NUL-terminated
+   if they are shorter than INTERFACE_NAMSIZ.  After code cleanup, the
+   implementation will be changed to require the arguments to these functions
+   to terminate with a NUL character (no length limitation). */
+struct interface *if_lookup_by_name (const char *);
 struct interface *if_get_by_name (const char *);
 
+/* For these 2 functions, the 2nd argument should be the precise length
+   of the interface name (not counting a trailing NUL which may or may
+   not be present). */
+extern struct interface *if_lookup_by_name_len(const char *name,
+					       size_t namelen);
+extern struct interface *if_get_by_name_len(const char *name, size_t namelen);
+
+
 /* Delete the interface, but do not free the structure, and leave it in the
    interface list.  It is often advisable to leave the pseudo interface 
    structure because there may be configuration information attached. */