bgpd: Move up flag-check calls, parcel up attr-parser args, and other cleanups

* bgp_attr.h: (struct bgp_attr_parser_args) Attribute parsing context,
  containing common arguments.
* bgp_attr.c: (general) Move the bgp_attr_flag_invalid flag-check calls up,
  out of each individual attr parser function, to be done once in attr_parse.

  Similarly move the calculation of the 'total' attribute length field up
  to attr_parse.

  Bundle together common arguments to attr-parsing functions and helpers
  into (struct bgp_attr_parser_args), so it can be passed by reference down
  the stack & also de-clutter the argument lists & make it easier to
  add/modify the context for attr-parsing - add local const aliases to avoid
  modifying body of code too much. This also should help avoid cut & paste
  errors, where calls to helpers with hard-coded attribute types are pasted
  to other functions but the code isn't changed.

  (bgp_attr_flags_diagnose) as above.
  (bgp_attr_flag_invalid) as above.
  (bgp_attr_{origin,aspath,as4_path,nexthop,med,local_pref,atomic}) as above.
  (bgp_attr_{aggregator,as4_aggregator,community,originator_id}) as above
  (bgp_attr_{cluster_list,ext_communities},bgp_mp_{un,}reach_parse) as above
  (bgp_attr_unknown) as above.

  (bgp_attr_malformed) as above. Also, startp and length have to be
  special-cased, because whether or not to send attribute data depends
  on the particular error - a separate length argument, distinct from
  args->length, indicates whether or not the attribute data should be sent
  in the NOTIFY.
  (bgp_attr_aspath_check) Call to bgp_attr_malformed is wrong here, there is
  no attribute parsing context - e.g. the 'flag' argument is unlikely to be
  right, remove it. Explicitly handle the error instead.
  (bgp_attr_munge_as4_attrs) Flag argument is pointless.

  As the comment notes, the check here is pointless as AS_PATH presence
  already checked elsewhere.

  (bgp_attr_parse) Do bgp_attr_flag_invalid call here.
  Use (struct bgp_attr_parser_args) for args to attr parser functions.
  Remove out-of-context 'flag' argument to as4 checking functions.
diff --git a/bgpd/bgp_attr.h b/bgpd/bgp_attr.h
index e630074..df87c86 100644
--- a/bgpd/bgp_attr.h
+++ b/bgpd/bgp_attr.h
@@ -179,10 +179,19 @@
 /* Transit attribute prototypes. */
 void transit_unintern (struct transit *);
 
-/* Exported for unit-test purposes only */
-extern int bgp_mp_reach_parse (struct peer *, const bgp_size_t, struct attr *,
-			       const u_char, u_char *, struct bgp_nlri *);
-extern int bgp_mp_unreach_parse (struct peer *, const bgp_size_t, const u_char,
-                                 u_char *, struct bgp_nlri *);
+/* Below exported for unit-test purposes only */
+struct bgp_attr_parser_args {
+  struct peer *peer;
+  bgp_size_t length; /* attribute data length; */
+  bgp_size_t total; /* total length, inc header */
+  struct attr *attr;
+  u_int8_t type;
+  u_int8_t flags;
+  u_char *startp;   
+};
+extern int bgp_mp_reach_parse (struct bgp_attr_parser_args *args, 
+			       struct bgp_nlri *);
+extern int bgp_mp_unreach_parse (struct bgp_attr_parser_args *args,
+                                 struct bgp_nlri *);
 
 #endif /* _QUAGGA_BGP_ATTR_H */