+int parse_crc8_profile(char *optarg, struct cgw_csum_crc8 *crc8)
+{
+ int ret = 1;
+ char *ptr;
+
+ if (sscanf(optarg, "%hhd:", &crc8->profile) != 1)
+ return ret;
+
+ switch (crc8->profile) {
+
+ case CGW_CRC8PRF_1U8:
+
+ if (sscanf(optarg, "%hhd:%2hhx", &crc8->profile, &crc8->profile_data[0]) == 2)
+ ret = 0;
+
+ break;
+
+ case CGW_CRC8PRF_16U8:
+
+ ptr = strchr(optarg, ':');
+
+ /* check if length contains 16 base64 hex values */
+ if (ptr != NULL &&
+ strlen(ptr) == strlen(":00112233445566778899AABBCCDDEEFF") &&
+ b64hex(ptr+1, (unsigned char *)&crc8->profile_data[0], 16) == 0)
+ ret = 0;
+
+ break;
+
+ case CGW_CRC8PRF_SFFID_XOR:
+
+ /* no additional parameters needed */
+ ret = 0;
+ break;
+ }
+
+ return ret;
+}
+