int rad_lockfd(int fd, int lock_len);
int rad_lockfd_nonblock(int fd, int lock_len);
int rad_unlockfd(int fd, int lock_len);
+char *fr_abin2hex(TALLOC_CTX *ctx, uint8_t const *bin, size_t inlen);
size_t fr_bin2hex(char *hex, uint8_t const *bin, size_t inlen);
size_t fr_hex2bin(uint8_t *bin, size_t outlen, char const *hex, size_t inlen);
uint32_t fr_strtoul(char const *value, char **end);
return i;
}
-
/** Convert binary data to a hex string
*
* Ascii encoded hex string will not be prefixed with '0x'
return inlen * 2;
}
+/** Convert binary data to a hex string
+ *
+ * Ascii encoded hex string will not be prefixed with '0x'
+ *
+ * @param[in] ctx to alloc buffer in.
+ * @param[in] bin input.
+ * @param[in] inlen of bin input.
+ * @return length of data written to buffer.
+ */
+char *fr_abin2hex(TALLOC_CTX *ctx, uint8_t const *bin, size_t inlen)
+{
+ char *buff;
+ buff = talloc_array(ctx, char, (inlen << 2));
+ if (!buff) return NULL;
+
+ fr_bin2hex(buff, bin, inlen);
+
+ return buff;
+}
/** Consume the integer (or hex) portion of a value string
*