[svn-commits] sruffell: branch linux/sruffell/dahdi-transcoder r4610 - /linux/team/sruffell...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Jul 17 16:24:44 CDT 2008


Author: sruffell
Date: Thu Jul 17 16:24:44 2008
New Revision: 4610

URL: http://svn.digium.com/view/dahdi?view=rev&rev=4610
Log:
I'm still looking forward to that day when I do a merge-ish operation and do
not forget to add some files.  This last time wasn't it.


Added:
    linux/team/sruffell/dahdi-transcoder/drivers/dahdi/wctc4xxp/wcdte_commands.c   (with props)
    linux/team/sruffell/dahdi-transcoder/drivers/dahdi/wctc4xxp/wcdte_net.h   (with props)

Added: linux/team/sruffell/dahdi-transcoder/drivers/dahdi/wctc4xxp/wcdte_commands.c
URL: http://svn.digium.com/view/dahdi/linux/team/sruffell/dahdi-transcoder/drivers/dahdi/wctc4xxp/wcdte_commands.c?view=auto&rev=4610
==============================================================================
--- linux/team/sruffell/dahdi-transcoder/drivers/dahdi/wctc4xxp/wcdte_commands.c (added)
+++ linux/team/sruffell/dahdi-transcoder/drivers/dahdi/wctc4xxp/wcdte_commands.c Thu Jul 17 16:24:44 2008
@@ -1,0 +1,167 @@
+/*
+ * Copyright (C) 2006-2008, Digium, Inc.
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
+ *
+ */
+#include "dahdi/kernel.h"
+#include "wctc4xxp.h"
+#include "wcdte_commands.h"
+
+/* Returns the size, in bytes, of a CSM_ENCAPS packet, given the number of
+ * parameters used. */
+#define SIZE_WITH_N_PARAMETERS(__n) (sizeof(struct csm_encaps_hdr) + ((__n) * (sizeof(u16))))
+
+/* There are 20 bytes in the ethernet header and the common CSM_ENCAPS header
+ * that we don't want in the length of the actual CSM_ENCAPS command */
+#define LENGTH_WITH_N_PARAMETERS(__n) (SIZE_WITH_N_PARAMETERS(__n) - 20)
+
+static const u8 dst_mac[6] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55};
+static const u8 src_mac[6] = {0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF};
+
+void 
+setup_common_header(struct wcdte *wc, struct csm_encaps_hdr *hdr)
+{
+	memcpy(hdr->ethhdr.h_dest, dst_mac, sizeof(dst_mac));
+	memcpy(hdr->ethhdr.h_source, src_mac, sizeof(src_mac));
+	hdr->ethhdr.h_proto = cpu_to_be16(ETH_P_CSM_ENCAPS);
+}
+
+static void 
+setup_supervisor_header(struct wcdte *wc, struct csm_encaps_hdr *hdr)
+{
+	setup_common_header(wc, hdr);
+
+	hdr->op_code = cpu_to_be16(CONTROL_PACKET_OPCODE);
+	hdr->control = LITTLE_ENDIAN;
+	hdr->seq_num = (wc->seq_num++)&0xf;
+	hdr->channel = cpu_to_be16(SUPERVISOR_CHANNEL);
+}
+
+static void  
+__dte_create_channel_cmd(struct wcdte *wc, struct dte_cmd *cmd, u16 timeslot)
+{
+	struct csm_create_channel_cmd *c; 
+	c = hdr_from_cmd(cmd);
+
+	BUG_ON(timeslot > 0x01ff);
+
+	setup_supervisor_header(wc, &c->hdr);
+
+	c->hdr.length =    LENGTH_WITH_N_PARAMETERS(2);
+	c->hdr.index =     0x0;
+	c->hdr.type  =     CONFIG_CHANGE_TYPE;
+	c->hdr.class =     CONFIG_DEVICE_CLASS;
+	c->hdr.function =  cpu_to_le16(SUPVSR_CREATE_CHANNEL);
+	c->hdr.reserved =  0x0000;
+
+	c->channel_type = cpu_to_le16(0x0002); /* Channel type is VoIP */
+	c->timeslot =     cpu_to_le16(timeslot);
+
+	cmd->flags |= WAIT_FOR_RESPONSE;
+	cmd->data_len = sizeof(*c);
+}
+
+struct dte_cmd * 
+dte_create_channel_cmd(struct wcdte *wc, u16 timeslot)
+{
+	struct dte_cmd *cmd;
+	if (!(cmd = alloc_cmd())) {
+		return NULL;
+	}
+	__dte_create_channel_cmd(wc, cmd, timeslot);
+	return cmd;
+}
+
+void 
+__dte_create_set_arm_clk_cmd(struct wcdte *wc, struct dte_cmd *cmd)
+{
+	struct csm_encaps_hdr *hdr = cmd->data;
+	BUG_ON(SIZE_WITH_N_PARAMETERS(2) > cmd->data_len);
+
+	setup_supervisor_header(wc, hdr);
+
+	hdr->length =		LENGTH_WITH_N_PARAMETERS(2);
+	hdr->index =		0x0;
+	hdr->type =		CONFIG_CHANGE_TYPE;
+	hdr->class =		CONFIG_DEVICE_CLASS;
+	hdr->function =		cpu_to_le16(0x0411);
+	hdr->reserved =		0x0000;
+	hdr->params[0] =	cpu_to_le16(0x012c);
+	hdr->params[1] =	cpu_to_le16(0x0000);
+
+	cmd->flags |= WAIT_FOR_RESPONSE;
+	cmd->data_len = SIZE_WITH_N_PARAMETERS(2);
+	return;
+}
+
+struct dte_cmd *
+dte_create_rtp_cmd(struct wcdte *wc, struct dahdi_transcoder_channel *dtc, size_t inbytes)
+{
+	const struct channel_pvt *cpvt = dtc->pvt;
+	struct rtp_packet *packet;
+	struct dte_cmd *cmd;
+
+	if (!(cmd = alloc_cmd())) {
+		return NULL;
+	}
+
+	packet = cmd->data;
+
+	BUG_ON(cmd->data_len < sizeof(*packet));
+	
+	/* setup the ethernet header */
+	memcpy(packet->ethhdr.h_dest, dst_mac, sizeof(dst_mac));
+	memcpy(packet->ethhdr.h_source, src_mac, sizeof(src_mac));
+	packet->ethhdr.h_proto = cpu_to_be16(ETH_P_IP);
+	
+	/* setup the IP header */
+	packet->iphdr.ihl =	5;
+	packet->iphdr.version =	4;
+	packet->iphdr.tos =	0;
+	packet->iphdr.tot_len =	cpu_to_be16(inbytes+40);
+	packet->iphdr.id =	cpu_to_be16(cpvt->seqno);
+	packet->iphdr.frag_off=	cpu_to_be16(0x4000);
+	packet->iphdr.ttl =	64;
+	packet->iphdr.protocol=	0x11; /* UDP */
+	packet->iphdr.check =	0;
+	packet->iphdr.saddr =	cpu_to_be32(0xc0a80903);
+	packet->iphdr.daddr =	cpu_to_be32(0xc0a80903);
+	packet->iphdr.check =	ip_fast_csum((void*)&packet->iphdr, sizeof(struct iphdr));
+
+	/* setup the UDP header */
+	packet->udphdr.source =	cpu_to_be16(cpvt->timeslot_out_num + 0x5000);
+	packet->udphdr.dest =	cpu_to_be16(cpvt->timeslot_in_num + 0x5000);
+	packet->udphdr.len  =	cpu_to_be16(inbytes + sizeof(struct rtphdr) + sizeof(struct udphdr));
+	packet->udphdr.check =	0;
+
+	/* Setup the RTP header */
+	packet->rtphdr.ver =		2;
+	packet->rtphdr.padding =	0;
+	packet->rtphdr.extension =	0;
+	packet->rtphdr.csrc_count =	0;
+	packet->rtphdr.marker =		0;
+	packet->rtphdr.type =		wcdte_dahdifmt_to_dtefmt(dtc->srcfmt);
+	packet->rtphdr.seqno =		cpu_to_be16(cpvt->seqno);
+	packet->rtphdr.timestamp =	cpu_to_be32(cpvt->timestamp);
+	packet->rtphdr.ssrc =		cpu_to_be32(cpvt->ssrc);
+
+	cmd->data_len = sizeof(*packet) + inbytes;
+
+	return cmd;
+}
+

Propchange: linux/team/sruffell/dahdi-transcoder/drivers/dahdi/wctc4xxp/wcdte_commands.c
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: linux/team/sruffell/dahdi-transcoder/drivers/dahdi/wctc4xxp/wcdte_commands.c
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: linux/team/sruffell/dahdi-transcoder/drivers/dahdi/wctc4xxp/wcdte_commands.c
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: linux/team/sruffell/dahdi-transcoder/drivers/dahdi/wctc4xxp/wcdte_net.h
URL: http://svn.digium.com/view/dahdi/linux/team/sruffell/dahdi-transcoder/drivers/dahdi/wctc4xxp/wcdte_net.h?view=auto&rev=4610
==============================================================================
--- linux/team/sruffell/dahdi-transcoder/drivers/dahdi/wctc4xxp/wcdte_net.h (added)
+++ linux/team/sruffell/dahdi-transcoder/drivers/dahdi/wctc4xxp/wcdte_net.h Thu Jul 17 16:24:44 2008
@@ -1,0 +1,17 @@
+#ifndef __WCDTE_NET_H__
+#define __WCDTE_NET_H__
+
+struct wcdte;
+struct dte_cmd;
+
+#ifdef CONFIG_WCDTE_NETWORK_IF
+extern int wcdte_net_register(struct wcdte *wc);
+extern void wcdte_net_unregister(struct wcdte *wc);
+extern void wcdte_net_capture_cmd(struct wcdte *wc, const struct dte_cmd *cmd);
+#else
+static inline int wcdte_net_register(struct wcdte *wc) { return 0; }
+#define wcdte_net_unregister(__x) do {;} while(0)
+#define wcdte_net_capture_cmd(__x, __b) do {;} while(0)
+#endif
+
+#endif

Propchange: linux/team/sruffell/dahdi-transcoder/drivers/dahdi/wctc4xxp/wcdte_net.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: linux/team/sruffell/dahdi-transcoder/drivers/dahdi/wctc4xxp/wcdte_net.h
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: linux/team/sruffell/dahdi-transcoder/drivers/dahdi/wctc4xxp/wcdte_net.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain




More information about the svn-commits mailing list