+/** Copy all attributes of type \a type from \a src to \a dst.
+ *
+ * If all attributes were copied successfully, the number of
+ * attributes copied is returned.
+ *
+ * If copying failed, a negative number is returned. */
+int radmsg_copy_attrs(struct radmsg *dst,
+ const struct radmsg *src,
+ uint8_t type)
+{
+ struct list_node *node = NULL;
+ struct list *list = radmsg_getalltype(src, type);
+ int n = 0;
+
+ for (node = list_first(list); node; node = list_next(node)) {
+ if (radmsg_add(dst, copytlv((struct tlv *) node->data)) != 1) {
+ n = -1;
+ break;
+ }
+ n++;
+ }
+ list_free(list);
+ return n;
+}
+