/*******************************************************************************
 *	key_string2key()
 *******************************************************************************
 *
 *  DESCRIPTION:
 *
 *      Converts a key_string to a key, Assumes the key_string is validated with
 *  is_valid_key_string().
 *
 *  PARAMETERS:
 *
 *      ks  - the valid key string
 *      key - a pointer to a KEY_STRUCT where the converted key information will
 *            be stored.
 *
 *  RETURNS:
 *
 *      N/A
 *
 ******************************************************************************/
void key_string2key( char *ks, KEY_STRCT *key )
{
    int l,i,n;
    char *p;
    /*------------------------------------------------------------------------*/


    l = strlen( ks );

    /* 0x followed by hexadecimal digit pairs */
    if( ks[0] == '0' && ( ks[1] == 'x' || ks[1] == 'X' )) {
        n = 0;
        p = (char *)key->key;

        for( i = 2; i < l; i+=2 ) {
			*p++ = (hex_to_bin(ks[i]) << 4) + hex_to_bin(ks[i+1]);
           n++;
        }

        /* Note that endian translation of the length field is not needed here
          because it's performed in wl_put_ltv() */
        key->len = n;
    }
    /* character string */
    else
    {
        strcpy( (char *)key->key, ks );
        key->len = l;
    }

    return;
} // key_string2key
Beispiel #2
0
srtpw_err_status_t srtpw_set_crypto_policy(srtpw_srtp_policy *p, int suite, 
                                           const unsigned char *master_key, unsigned long ssrc, int inbound)
{
    srtp_policy_t *policy =(srtp_policy_t *)p;
    const unsigned char *master_salt = master_key + 2*SRTP_MASTERKEY_LEN;
    unsigned char buffer[2*SRTP_MASTERKEY_LEN+1];
    strncpy((char *)buffer, (const char *)master_key, 2*SRTP_MASTERKEY_LEN); buffer[2*SRTP_MASTERKEY_LEN] = '\0';
    srtpw_log(err_level_info, "srtpw_set_crypto_policy master_key:%s, master_salt:%s, %s ssrc:(0x%08x)%u\n",
              srtpw_octet_string_hex_string(buffer,2*SRTP_MASTERKEY_LEN),master_salt,(inbound?"Inbound":"Outbound"), ssrc, ssrc);
    // Convert Master key and SALT to binary format from HEX format before setting
    uint8_t mk[SRTP_MASTERKEY_LEN + 1], ms[SRTP_MASTERSALT_LEN + 1];
    hex_to_bin(mk, SRTP_MASTERKEY_LEN, master_key, 2*SRTP_MASTERKEY_LEN);mk[SRTP_MASTERKEY_LEN] = '\0';
    hex_to_bin(ms, SRTP_MASTERSALT_LEN, master_key + (2*SRTP_MASTERKEY_LEN), 2*SRTP_MASTERSALT_LEN); ms[SRTP_MASTERSALT_LEN] = '\0';
    if (srtpw_srtp_policy_set_master_key(policy, mk, SRTP_MASTERKEY_LEN, ms, SRTP_MASTERSALT_LEN) < 0)
    {
        return -1;
    }

    if (srtpw_srtp_policy_set_suite(policy, suite))
    {
        return -1;
    }

    srtpw_srtp_policy_set_ssrc(policy, ssrc, inbound);

    return 0;
}
Beispiel #3
0
/**
 * hex2bin - convert an ascii hexadecimal string to its binary representation
 * @dst: binary result
 * @src: ascii hexadecimal string
 * @count: result length
 */
void hex2bin(u8 *dst, const char *src, size_t count)
{
	while (count--) {
		*dst = hex_to_bin(*src++) << 4;
		*dst += hex_to_bin(*src++);
		dst++;
	}
}
Beispiel #4
0
/**
 *	aac_rx_check_health
 *	@dev: device to check if healthy
 *
 *	Will attempt to determine if the specified adapter is alive and
 *	capable of handling requests, returning 0 if alive.
 */
static int aac_rx_check_health(struct aac_dev *dev)
{
	u32 status = rx_readl(dev, MUnit.OMRx[0]);

	/*
	 *	Check to see if the board failed any self tests.
	 */
	if (unlikely(status & SELF_TEST_FAILED))
		return -1;
	/*
	 *	Check to see if the board panic'd.
	 */
	if (unlikely(status & KERNEL_PANIC)) {
		char * buffer;
		struct POSTSTATUS {
			__le32 Post_Command;
			__le32 Post_Address;
		} * post;
		dma_addr_t paddr, baddr;
		int ret;

		if (likely((status & 0xFF000000L) == 0xBC000000L))
			return (status >> 16) & 0xFF;
		buffer = pci_alloc_consistent(dev->pdev, 512, &baddr);
		ret = -2;
		if (unlikely(buffer == NULL))
			return ret;
		post = pci_alloc_consistent(dev->pdev,
		  sizeof(struct POSTSTATUS), &paddr);
		if (unlikely(post == NULL)) {
			pci_free_consistent(dev->pdev, 512, buffer, baddr);
			return ret;
		}
		memset(buffer, 0, 512);
		post->Post_Command = cpu_to_le32(COMMAND_POST_RESULTS);
		post->Post_Address = cpu_to_le32(baddr);
		rx_writel(dev, MUnit.IMRx[0], paddr);
		rx_sync_cmd(dev, COMMAND_POST_RESULTS, baddr, 0, 0, 0, 0, 0,
		  NULL, NULL, NULL, NULL, NULL);
		pci_free_consistent(dev->pdev, sizeof(struct POSTSTATUS),
		  post, paddr);
		if (likely((buffer[0] == '0') && ((buffer[1] == 'x') || (buffer[1] == 'X')))) {
			ret = (hex_to_bin(buffer[2]) << 4) +
				hex_to_bin(buffer[3]);
		}
		pci_free_consistent(dev->pdev, 512, buffer, baddr);
		return ret;
	}
	/*
	 *	Wait for the adapter to be up and running.
	 */
	if (unlikely(!(status & KERNEL_UP_AND_RUNNING)))
		return -3;
	/*
	 *	Everything is OK
	 */
	return 0;
}
Beispiel #5
0
/**
 * hex2bin - convert an ascii hexadecimal string to its binary representation
 * @dst: binary result
 * @src: ascii hexadecimal string
 * @count: result length
 *
 * Return 0 on success, -1 in case of bad input.
 */
int hex2bin(u8 *dst, const char *src, size_t count)
{
	while (count--) {
		int hi = hex_to_bin(*src++);
		int lo = hex_to_bin(*src++);

		if ((hi < 0) || (lo < 0))
			return -1;

		*dst++ = (hi << 4) | lo;
	}
	return 0;
}
Beispiel #6
0
void getSamp ()
{
	if ( set.basic_mode )
		return;

	uint32_t	samp_dll = getSampAddress();

	if ( samp_dll != NULL )
	{
		g_dwSAMP_Addr = ( uint32_t ) samp_dll;

		if ( g_dwSAMP_Addr != NULL )
		{
			if ( memcmp_safe((uint8_t *)g_dwSAMP_Addr + 0xBABE, hex_to_bin(SAMP_CMP_03DR1), 10) )
			{
				strcpy(g_szSAMPVer, "SA:MP 0.3d");
				Log( "%s was detected. g_dwSAMP_Addr: 0x%p", g_szSAMPVer, g_dwSAMP_Addr );
				iIsSAMPSupported = 1;
			}
			else if ( memcmp_safe((uint8_t *)g_dwSAMP_Addr + 0xBABE, hex_to_bin(SAMP_CMP_03DR2), 10) )
			{
				strcpy(g_szSAMPVer, "SA:MP 0.3d-R2");
				Log( "%s was detected. g_dwSAMP_Addr: 0x%p", g_szSAMPVer, g_dwSAMP_Addr );

				// (0.3d-R2 temp) disable AC
				if(memcmp_safe((uint32_t *)(g_dwSAMP_Addr + 0x8F210), "\xE9\x34\x91\x24\x00", 5))
					memset_safe((uint32_t *)(g_dwSAMP_Addr + 0x8F210), 0xC3, 1);

				iIsSAMPSupported = 0;
				set.basic_mode = true;
				g_dwSAMP_Addr = NULL;
			}
			else
			{
				Log( "Unknown SA:MP version. Running in basic mode." );
				iIsSAMPSupported = 0;
				set.basic_mode = true;

				g_dwSAMP_Addr = NULL;
			}
		}
	}
	else
	{
		iIsSAMPSupported = 0;
		set.basic_mode = true;
		Log( "samp.dll not found. Running in basic mode." );
	}

	return;
}
Beispiel #7
0
int main(void)
{
    char A[] = "1c0111001f010100061a024b53535009181c";
    char B[] = "686974207468652062756c6c277320657965";
    size_t size = strlen(A) / 2;
    
    char buf[128], xor[128]; 

    hex_to_bin(A, A);
    hex_to_bin(B, B);

    printf("A ^ B = \"%s\"\n", bin_to_hex(buf, str_xor(xor, A, B, size), size));
    return 0;
}
Beispiel #8
0
/* scan for the sequence $<data>#<checksum> */
static void get_packet(char *buffer)
{
	unsigned char checksum;
	unsigned char xmitcsum;
	int count;
	char ch;

	do {
		/*
		 * Spin and wait around for the start character, ignore all
		 * other characters:
		 */
		while ((ch = (gdbstub_read_wait())) != '$')
			/* nothing */;

		kgdb_connected = 1;
		checksum = 0;
		xmitcsum = -1;

		count = 0;

		/*
		 * now, read until a # or end of buffer is found:
		 */
		while (count < (BUFMAX - 1)) {
			ch = gdbstub_read_wait();
			if (ch == '#')
				break;
			checksum = checksum + ch;
			buffer[count] = ch;
			count = count + 1;
		}
		buffer[count] = 0;

		if (ch == '#') {
			xmitcsum = hex_to_bin(gdbstub_read_wait()) << 4;
			xmitcsum += hex_to_bin(gdbstub_read_wait());

			if (checksum != xmitcsum)
				/* failed checksum */
				dbg_io_ops->write_char('-');
			else
				/* successful transfer */
				dbg_io_ops->write_char('+');
			if (dbg_io_ops->flush)
				dbg_io_ops->flush();
		}
	} while (checksum != xmitcsum);
}
Beispiel #9
0
static u8 usb6fire_fw_ihex_hex(const u8 *data, u8 *crc)
{
	u8 val = 0;
	int hval;

	hval = hex_to_bin(data[0]);
	if (hval >= 0)
		val |= (hval << 4);

	hval = hex_to_bin(data[1]);
	if (hval >= 0)
		val |= hval;

	*crc += val;
	return val;
}
Beispiel #10
0
static char *decode_id(const char *raw)
{
    int hexlen;
    char hexbuf[(JMAPAUTH_KEY_LEN + EVP_MAX_MD_SIZE)*2];
    char *key = NULL;
    size_t lenraw = strlen(raw);

    /* Verify that the key is at least good for lookups */
    if (lenraw > sizeof(hexbuf)/sizeof(hexbuf[0])) {
        return NULL;
    }
    hexlen = hex_to_bin(raw, lenraw, hexbuf);
    if (hexlen < JMAPAUTH_KEY_LEN) {
        return NULL;
    }
    if ((hexbuf[0] != JMAPAUTH_TOKEN_VERSION) ||
        (hexbuf[1] != JMAPAUTH_LOGINID_KIND &&
         hexbuf[1] != JMAPAUTH_ACCESS_KIND)) {
        return NULL;
    }

    key = xmalloc(JMAPAUTH_KEY_LEN);
    memcpy(key, hexbuf, JMAPAUTH_KEY_LEN);
    return key;
}
static ssize_t bin_uuid(struct file *file,
	void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
{
	mm_segment_t old_fs = get_fs();
	ssize_t result, copied = 0;

	
	if (oldval && oldlen) {
		loff_t pos = 0;
		char buf[40], *str = buf;
		unsigned char uuid[16];
		int i;

		set_fs(KERNEL_DS);
		result = vfs_read(file, buf, sizeof(buf) - 1, &pos);
		set_fs(old_fs);
		if (result < 0)
			goto out;

		buf[result] = '\0';

		
		for (i = 0; i < 16; i++) {
			result = -EIO;
			if (!isxdigit(str[0]) || !isxdigit(str[1]))
				goto out;

			uuid[i] = (hex_to_bin(str[0]) << 4) |
					hex_to_bin(str[1]);
			str += 2;
			if (*str == '-')
				str++;
		}

		if (oldlen > 16)
			oldlen = 16;

		result = -EFAULT;
		if (copy_to_user(oldval, uuid, oldlen))
			goto out;

		copied = oldlen;
	}
	result = copied;
out:
	return result;
}
Beispiel #12
0
static int __uuid_to_bin(const char *uuid, __u8 b[16], const u8 ei[16])
{
    static const u8 si[16] = {0,2,4,6,9,11,14,16,19,21,24,26,28,30,32,34};
    unsigned int i;

    if (!uuid_is_valid(uuid))
        return -EINVAL;

    for (i = 0; i < 16; i++) {
        int hi = hex_to_bin(uuid[si[i]] + 0);
        int lo = hex_to_bin(uuid[si[i]] + 1);

        b[ei[i]] = (hi << 4) | lo;
    }

    return 0;
}
Beispiel #13
0
/**
 * ldm_parse_hexbyte - Convert a ASCII hex number to a byte
 * @src:  Pointer to at least 2 characters to convert.
 *
 * Convert a two character ASCII hex string to a number.
 *
 * Return:  0-255  Success, the byte was parsed correctly
 *          -1     Error, an invalid character was supplied
 */
static int ldm_parse_hexbyte (const u8 *src)
{
	unsigned int x;		/* For correct wrapping */
	int h;

	/* high part */
	x = h = hex_to_bin(src[0]);
	if (h < 0)
		return -1;

	/* low part */
	h = hex_to_bin(src[1]);
	if (h < 0)
		return -1;

	return (x << 4) + h;
}
static int cdc_ncm_get_ethernet_addr(struct if_usb_devdata *pipe_data,
		int iMACAddress)
{
	int tmp, i;
	unsigned char buf[13];

	tmp = usb_string(pipe_data->usbdev, iMACAddress, buf, sizeof buf);
	if (tmp != 12) {
		mif_debug("bad MAC string %d fetch, %d\n", iMACAddress, tmp);
		if (tmp >= 0)
			tmp = -EINVAL;
		return tmp;
	}
	for (i = tmp = 0; i < 6; i++, tmp += 2)
		pipe_data->iod->ndev->dev_addr[i] =
			(hex_to_bin(buf[tmp]) << 4) + hex_to_bin(buf[tmp + 1]);
	return 0;
}
Beispiel #15
0
/*!
 * \brief Parse NSEC3 salt.
 */
static int str_to_salt(const char *str, dnssec_binary_t *salt)
{
	if (strcmp(str, "-") == 0) {
		salt->size = 0;
		return DNSSEC_EOK;
	} else {
		return hex_to_bin(str, salt);
	}
}
int usbnet_get_ethernet_addr(struct usbnet *dev, int iMACAddress)
{
	int 		tmp, i;
	unsigned char	buf [13];

	tmp = usb_string(dev->udev, iMACAddress, buf, sizeof buf);
	if (tmp != 12) {
		dev_dbg(&dev->udev->dev,
			"bad MAC string %d fetch, %d\n", iMACAddress, tmp);
		if (tmp >= 0)
			tmp = -EINVAL;
		return tmp;
	}
	for (i = tmp = 0; i < 6; i++, tmp += 2)
		dev->net->dev_addr [i] =
			(hex_to_bin(buf[tmp]) << 4) + hex_to_bin(buf[tmp + 1]);
	return 0;
}
/**
 * pch_set_station_address() - This API sets the station address used by
 *				    IEEE 1588 hardware when looking at PTP
 *				    traffic on the  ethernet interface
 * @addr:	dress which contain the column separated address to be used.
 */
static int pch_set_station_address(u8 *addr, struct pci_dev *pdev)
{
	s32 i;
	struct pch_dev *chip = pci_get_drvdata(pdev);

	/* Verify the parameter */
	if ((chip->regs == 0) || addr == (u8 *)NULL) {
		dev_err(&pdev->dev,
			"invalid params returning PCH_INVALIDPARAM\n");
		return PCH_INVALIDPARAM;
	}
	/* For all station address bytes */
	for (i = 0; i < PCH_STATION_BYTES; i++) {
		u32 val;
		s32 tmp;

		tmp = hex_to_bin(addr[i * 3]);
		if (tmp < 0) {
			dev_err(&pdev->dev,
				"invalid params returning PCH_INVALIDPARAM\n");
			return PCH_INVALIDPARAM;
		}
		val = tmp * 16;
		tmp = hex_to_bin(addr[(i * 3) + 1]);
		if (tmp < 0) {
			dev_err(&pdev->dev,
				"invalid params returning PCH_INVALIDPARAM\n");
			return PCH_INVALIDPARAM;
		}
		val += tmp;
		/* Expects ':' separated addresses */
		if ((i < 5) && (addr[(i * 3) + 2] != ':')) {
			dev_err(&pdev->dev,
				"invalid params returning PCH_INVALIDPARAM\n");
			return PCH_INVALIDPARAM;
		}

		/* Ideally we should set the address only after validating
							 entire string */
		dev_dbg(&pdev->dev, "invoking pch_station_set\n");
		iowrite32(val, &chip->regs->ts_st[i]);
	}
	return 0;
}
Beispiel #18
0
static int parse_uri_attr(ENGINE_CTX *ctx,
		const char *attr, int attrlen, unsigned char **field,
		size_t *field_len)
{
	size_t max, outlen = 0;
	unsigned char *out;
	int ret = 1;

	if (field_len) {
		out = *field;
		max = *field_len;
	} else {
		out = OPENSSL_malloc(attrlen + 1);
		if (out == NULL)
			return 0;
		max = attrlen + 1;
	}

	while (ret && attrlen && outlen < max) {
		if (*attr == '%') {
			if (attrlen < 3) {
				ret = 0;
			} else {
				char tmp[3];
				size_t l = 1;

				tmp[0] = attr[1];
				tmp[1] = attr[2];
				tmp[2] = 0;
				ret = hex_to_bin(ctx, tmp, &out[outlen++], &l);
				attrlen -= 3;
				attr += 3;
			}

		} else {
			out[outlen++] = *(attr++);
			attrlen--;
		}
	}
	if (attrlen && outlen == max)
		ret = 0;

	if (ret) {
		if (field_len) {
			*field_len = outlen;
		} else {
			out[outlen] = 0;
			*field = out;
		}
	} else {
		if (field_len == NULL)
			OPENSSL_free(out);
	}

	return ret;
}
static int get_qc_ether_addr(const char *str, u8 *dev_addr)
{
	if (str) {
		unsigned	i;

		for (i = 0; i < 6; i++) {
			unsigned char num;

			if ((*str == '.') || (*str == ':'))
				str++;
			num = hex_to_bin(*str++) << 4;
			num |= hex_to_bin(*str++);
			dev_addr[i] = num;
		}
		if (is_valid_ether_addr(dev_addr))
			return 0;
	}
	random_ether_addr(dev_addr);
	return 1;
}
Beispiel #20
0
int mac_pton(const char *s, u8 *mac)
{
	int i;

	/* XX:XX:XX:XX:XX:XX */
	if (strlen(s) < 3 * ETH_ALEN - 1)
		return 0;

	/* Don't dirty result unless string is valid MAC. */
	for (i = 0; i < ETH_ALEN; i++) {
		if (!isxdigit(s[i * 3]) || !isxdigit(s[i * 3 + 1]))
			return 0;
		if (i != ETH_ALEN - 1 && s[i * 3 + 2] != ':')
			return 0;
	}
	for (i = 0; i < ETH_ALEN; i++) {
		mac[i] = (hex_to_bin(s[i * 3]) << 4) | hex_to_bin(s[i * 3 + 1]);
	}
	return 1;
}
Beispiel #21
0
static int hwaddr_aton(const char *txt, u8 *addr)
{
	int i;

	for (i = 0; i < ETH_ALEN; i++) {
		int a, b;

		a = hex_to_bin(*txt++);
		if (a < 0)
			return -1;
		b = hex_to_bin(*txt++);
		if (b < 0)
			return -1;
		*addr++ = (a << 4) | b;
		if (i < 5 && *txt++ != ':')
			return -1;
	}

	return 0;
}
Beispiel #22
0
static acpi_status acpi_str_to_uuid(char *str, u8 *uuid)
{
	int i;
	static int opc_map_to_uuid[16] = {6, 4, 2, 0, 11, 9, 16, 14, 19, 21,
		24, 26, 28, 30, 32, 34};

	if (strlen(str) != 36)
		return AE_BAD_PARAMETER;
	for (i = 0; i < 36; i++) {
		if (i == 8 || i == 13 || i == 18 || i == 23) {
			if (str[i] != '-')
				return AE_BAD_PARAMETER;
		} else if (!isxdigit(str[i]))
			return AE_BAD_PARAMETER;
	}
	for (i = 0; i < 16; i++) {
		uuid[i] = hex_to_bin(str[opc_map_to_uuid[i]]) << 4;
		uuid[i] |= hex_to_bin(str[opc_map_to_uuid[i] + 1]);
	}
	return AE_OK;
}
Beispiel #23
0
char* FAST_FUNC percent_decode_in_place(char *str, int strict)
{
	/* note that decoded string is always shorter than original */
	char *src = str;
	char *dst = str;
	char c;

	while ((c = *src++) != '\0') {
		unsigned v;

		if (!strict && c == '+') {
			*dst++ = ' ';
			continue;
		}
		if (c != '%') {
			*dst++ = c;
			continue;
		}
		v = hex_to_bin(src[0]);
		if (v > 15) {
 bad_hex:
			if (strict)
				return NULL;
			*dst++ = '%';
			continue;
		}
		v = (v * 16) | hex_to_bin(src[1]);
		if (v > 255)
			goto bad_hex;
		if (strict && (v == '/' || v == '\0')) {
			/* caller takes it as indication of invalid
			 * (dangerous wrt exploits) chars */
			return str + 1;
		}
		*dst++ = v;
		src += 2;
	}
	*dst = '\0';
	return str;
}
Beispiel #24
0
static bool
validate_load_option(efi_char16_t *var_name, int match, u8 *buffer,
		     unsigned long len)
{
	u16 filepathlength;
	int i, desclength = 0, namelen;

	namelen = ucs2_strnlen(var_name, EFI_VAR_NAME_LEN);

	/* Either "Boot" or "Driver" followed by four digits of hex */
	for (i = match; i < match+4; i++) {
		if (var_name[i] > 127 ||
		    hex_to_bin(var_name[i] & 0xff) < 0)
			return true;
	}

	/* Reject it if there's 4 digits of hex and then further content */
	if (namelen > match + 4)
		return false;

	/* A valid entry must be at least 8 bytes */
	if (len < 8)
		return false;

	filepathlength = buffer[4] | buffer[5] << 8;

	/*
	 * There's no stored length for the description, so it has to be
	 * found by hand
	 */
	desclength = ucs2_strsize((efi_char16_t *)(buffer + 6), len - 6) + 2;

	/* Each boot entry must have a descriptor */
	if (!desclength)
		return false;

	/*
	 * If the sum of the length of the description, the claimed filepath
	 * length and the original header are greater than the length of the
	 * variable, it's malformed
	 */
	if ((desclength + filepathlength + 6) > len)
		return false;

	/*
	 * And, finally, check the filepath
	 */
	return validate_device_path(var_name, match, buffer + desclength + 6,
				    filepathlength);
}
Beispiel #25
0
int main(int argc, char **argv)
{
  int err, publish;
  hip_hit hit;
  struct sockaddr_storage addr;
  struct sockaddr_in *addr4 = (struct sockaddr_in*)&addr;

  /*
   * Load hip.conf configuration file
   * user may have provided path using command line, or search defaults
   */
  memset(HCNF, 0, sizeof(HCNF));
  if ((locate_config_file(HCNF.conf_filename, sizeof(HCNF.conf_filename),
                          HIP_CONF_FILENAME) < 0) ||
      (read_conf_file(HCNF.conf_filename) < 0))
    {
      log_(ERR, "Problem with configuration file, using defaults.\n");
    }
  else
    {
      log_(NORM, "Using configuration file:\t%s\n",
           HCNF.conf_filename);
    }


  memset(&addr, 0, sizeof(addr));
  addr4->sin_family = AF_INET;
  addr4->sin_addr.s_addr = inet_addr("192.168.1.2");
  hex_to_bin("7BE901B3AF2679C8C580619535641713", hit, HIT_SIZE);

  printf("Doing XML RPC put 1...\n");
  err = hip_dht_publish(&hit, (struct sockaddr*)&addr);
  printf("return value = %d\n", err);

  addr4->sin_addr.s_addr = inet_addr("192.168.2.7");

  printf("Doing XML RPC put 2...\n");
  err = hip_dht_publish(&hit, (struct sockaddr*)&addr);
  printf("return value = %d\n", err);

  memset(&addr, 0, sizeof(addr));
  addr4->sin_family = AF_INET;

  printf("addr is at: %p\n", &addr);
  printf("Doing XML RPC get...\n");
  err = hip_dht_lookup_address(&hit, (struct sockaddr*)&addr);
  printf("return value = %d\n", err);
  printf("Address = %s\n", logaddr((struct sockaddr*)&addr));
  return(0);
}
Beispiel #26
0
static s32 uuid_hex_to_bin(char *buf, s32 len)
{
	s32 i;
	s32 result = 0;
	int value;

	for (i = 0; i < len; i++) {
		value = hex_to_bin(*buf++);
		result *= 16;
		if (value > 0)
			result += value;
	}

	return result;
}
Beispiel #27
0
static int nd_uuid_parse(struct device *dev, u8 *uuid_out, const char *buf,
		size_t len)
{
	const char *str = buf;
	u8 uuid[16];
	int i;

	for (i = 0; i < 16; i++) {
		if (!isxdigit(str[0]) || !isxdigit(str[1])) {
			dev_dbg(dev, "%s: pos: %d buf[%zd]: %c buf[%zd]: %c\n",
					__func__, i, str - buf, str[0],
					str + 1 - buf, str[1]);
			return -EINVAL;
		}

		uuid[i] = (hex_to_bin(str[0]) << 4) | hex_to_bin(str[1]);
		str += 2;
		if (is_uuid_sep(*str))
			str++;
	}

	memcpy(uuid_out, uuid, sizeof(uuid));
	return 0;
}
Beispiel #28
0
void buyhouse(void *)
{
	static struct patch_set sampPatchDialog =
	{
		"Data", 0, 0,
		{
			{ 1, (void *)((uint8_t *)g_dwSAMP_Addr + 0xBC70), NULL, hex_to_bin("C390"), NULL }
		}
	};
	patcher_install(&sampPatchDialog);
	Sleep(1000);
	say("/buyhouse");
	Sleep(1000);
	patcher_remove(&sampPatchDialog);
}
Beispiel #29
0
static inline int xdigit2bin(char c, int delim)
{
	int val;

	if (c == delim || c == '\0')
		return IN6PTON_DELIM;
	if (c == ':')
		return IN6PTON_COLON_MASK;
	if (c == '.')
		return IN6PTON_DOT;

	val = hex_to_bin(c);
	if (val >= 0)
		return val | IN6PTON_XDIGIT | (val < 10 ? IN6PTON_DIGIT : 0);

	if (delim == -1)
		return IN6PTON_DELIM;
	return IN6PTON_UNKNOWN;
}
Beispiel #30
0
static void rain_process_msg(struct rain *rain)
{
	struct cec_msg msg = {};
	const char *cmd = rain->cmd + 3;
	int stat = -1;

	for (; *cmd; cmd++) {
		if (!isxdigit(*cmd))
			continue;
		if (isxdigit(cmd[0]) && isxdigit(cmd[1])) {
			if (msg.len == CEC_MAX_MSG_SIZE)
				break;
			if (hex2bin(msg.msg + msg.len, cmd, 1))
				continue;
			msg.len++;
			cmd++;
			continue;
		}
		if (!cmd[1])
			stat = hex_to_bin(cmd[0]);
		break;
	}

	if (rain->cmd[0] == 'R') {
		if (stat == 1 || stat == 2)
			cec_received_msg(rain->adap, &msg);
		return;
	}

	switch (stat) {
	case 1:
		cec_transmit_attempt_done(rain->adap, CEC_TX_STATUS_OK);
		break;
	case 2:
		cec_transmit_attempt_done(rain->adap, CEC_TX_STATUS_NACK);
		break;
	default:
		cec_transmit_attempt_done(rain->adap, CEC_TX_STATUS_LOW_DRIVE);
		break;
	}
}