コード例 #1
0
static int ca_get_slot_caps(struct dst_state *state, struct ca_caps *p_ca_caps, void __user *arg)
{
	int i;
	u8 slot_cap[256];
	static u8 slot_command[8] = {0x07, 0x40, 0x02, 0x00, 0x02, 0x00, 0x00, 0xff};

	put_checksum(&slot_command[0], slot_command[0]);
	if ((dst_put_ci(state, slot_command, sizeof (slot_command), slot_cap, GET_REPLY)) < 0) {
		dprintk(verbose, DST_CA_ERROR, 1, " -->dst_put_ci FAILED !");
		return -1;
	}
	dprintk(verbose, DST_CA_NOTICE, 1, " -->dst_put_ci SUCCESS !");

	/*	Will implement the rest soon		*/

	dprintk(verbose, DST_CA_INFO, 1, " Slot cap = [%d]", slot_cap[7]);
	dprintk(verbose, DST_CA_INFO, 0, "===================================\n");
	for (i = 0; i < 8; i++)
		dprintk(verbose, DST_CA_INFO, 0, " %d", slot_cap[i]);
	dprintk(verbose, DST_CA_INFO, 0, "\n");

	p_ca_caps->slot_num = 1;
	p_ca_caps->slot_type = 1;
	p_ca_caps->descr_num = slot_cap[7];
	p_ca_caps->descr_type = 1;

	if (copy_to_user(arg, p_ca_caps, sizeof (struct ca_caps)))
		return -EFAULT;

	return 0;
}
コード例 #2
0
ファイル: udp.c プロジェクト: eriks03/Regelplattform
/************************************************************************
 * void udp_send(WORD datalength)
 * This function is called by the application to send a UDP
 * packet. Values from global variables, common memory
 * space and the passed data length are used.
 * Optionally, a pseudo header is constructed and the UDP
 * checksum calculated.
 ***********************************************************************/
void udp_send(WORD datalength, BYTE ephemeral)
{
	WORD cssum;
	
	ipstat.udptx++;
	/* total size of IP datagram is the size of IP header */
	/* plus UDP header, plus UDP data */
	ip.totallen=IPSIZE+UDPHSIZE+datalength;
	/* place IP header and start of trasnmit buffer */
	txpos=0;
	ip_header(PROTUDP);
	/* use an ephemeral source port, this depends on the
	 * application, and must be specified when calling
	 * the function */
	if (ephemeral) tx_word(local_port());
	else tx_word(udph.dest);
	/* destination port, as source port from incoming packet */
	tx_word(udph.src);
	/* UDP length, header length plus data length */
	tx_word(UDPHSIZE+datalength);
	/* UDP checksum */
	tx_word(0x00);
	
	/* UDP checksumming is specified at compile time
	 * if checksumming is disabled, a zero value is sent
	 * otherwise the pseudo header is added and checksummed
	 * but NOT sent */
	#ifdef UPDCHECKSUM
		txpos+=datalength;
		tx_byte(IP1);
		tx_byte(IP2);
		tx_byte(IP3);
		tx_byte(IP4);
		tx_byte(ip.destaddr[0]);
		tx_byte(ip.destaddr[1]);
		tx_byte(ip.destaddr[2]);
		tx_byte(ip.destaddr[3]);
		tx_byte(0x00);
		tx_byte(PROTUDP);
		tx_word(10+udpdatal);
		
		cssum = chksm(&txbuffer[20],8+datalength+12);
		put_checksum(cssum,&txbuffer[IPSIZE+6]);
	#endif
	
	/* call SLIP to send out the packet */
	slip_send(txbuffer,IPSIZE+UDPHSIZE+datalength);
}
コード例 #3
0
static int ca_set_pmt(struct dst_state *state, struct ca_msg *p_ca_message, struct ca_msg *hw_buffer, u8 reply, u8 query)
{
	u32 length = 0;
	u8 tag_length = 8;

	length = asn_1_decode(&p_ca_message->msg[3]);
	dprintk(verbose, DST_CA_DEBUG, 1, " CA Message length=[%d]", length);
	debug_string(&p_ca_message->msg[4], length, 0); /*	length is excluding tag & length	*/

	memset(hw_buffer->msg, '\0', length);
	handle_dst_tag(state, p_ca_message, hw_buffer, length);
	put_checksum(hw_buffer->msg, hw_buffer->msg[0]);

	debug_string(hw_buffer->msg, (length + tag_length), 0); /*	tags too	*/
	write_to_8820(state, hw_buffer, (length + tag_length), reply);

	return 0;
}
コード例 #4
0
static int ca_get_app_info(struct dst_state *state)
{
	static u8 command[8] = {0x07, 0x40, 0x01, 0x00, 0x01, 0x00, 0x00, 0xff};

	put_checksum(&command[0], command[0]);
	if ((dst_put_ci(state, command, sizeof(command), state->messages, GET_REPLY)) < 0) {
		dprintk(verbose, DST_CA_ERROR, 1, " -->dst_put_ci FAILED !");
		return -1;
	}
	dprintk(verbose, DST_CA_INFO, 1, " -->dst_put_ci SUCCESS !");
	dprintk(verbose, DST_CA_INFO, 1, " ================================ CI Module Application Info ======================================");
	dprintk(verbose, DST_CA_INFO, 1, " Application Type=[%d], Application Vendor=[%d], Vendor Code=[%d]\n%s: Application info=[%s]",
		state->messages[7], (state->messages[8] << 8) | state->messages[9],
		(state->messages[10] << 8) | state->messages[11], __FUNCTION__, (char *)(&state->messages[12]));
	dprintk(verbose, DST_CA_INFO, 1, " ==================================================================================================");

	return 0;
}
コード例 #5
0
static int ca_get_slot_info(struct dst_state *state, struct ca_slot_info *p_ca_slot_info, void __user *arg)
{
	int i;
	static u8 slot_command[8] = {0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff};

	u8 *slot_info = state->messages;

	put_checksum(&slot_command[0], 7);
	if ((dst_put_ci(state, slot_command, sizeof (slot_command), slot_info, GET_REPLY)) < 0) {
		dprintk(verbose, DST_CA_ERROR, 1, " -->dst_put_ci FAILED !");
		return -1;
	}
	dprintk(verbose, DST_CA_INFO, 1, " -->dst_put_ci SUCCESS !");

	/*	Will implement the rest soon		*/

	dprintk(verbose, DST_CA_INFO, 1, " Slot info = [%d]", slot_info[3]);
	dprintk(verbose, DST_CA_INFO, 0, "===================================\n");
	for (i = 0; i < 8; i++)
		dprintk(verbose, DST_CA_INFO, 0, " %d", slot_info[i]);
	dprintk(verbose, DST_CA_INFO, 0, "\n");

	if (slot_info[4] & 0x80) {
		p_ca_slot_info->flags = CA_CI_MODULE_PRESENT;
		p_ca_slot_info->num = 1;
		p_ca_slot_info->type = CA_CI;
	} else if (slot_info[4] & 0x40) {
		p_ca_slot_info->flags = CA_CI_MODULE_READY;
		p_ca_slot_info->num = 1;
		p_ca_slot_info->type = CA_CI;
	} else
		p_ca_slot_info->flags = 0;

	if (copy_to_user(arg, p_ca_slot_info, sizeof (struct ca_slot_info)))
		return -EFAULT;

	return 0;
}