예제 #1
0
//add an output port, if we are active then deactivate and reactivate after
//maybe we can do this more intelligently in the future?
unsigned int JackCpp::AudioIO::addOutPort(std::string name)
	throw(std::runtime_error)
{
	if (mJackState == active && mOutputPorts.size() == mOutputPorts.capacity())
		throw std::runtime_error("trying to add output ports while the client is running and there are not reserved ports");

	if(portExists(name)){
		std::string ret_string("cannot register new outport: ");
		ret_string.append(name);
		ret_string.append(" port already exists with that name");
		throw std::runtime_error(ret_string);
	}

	//allocate the item in the vector
	jack_port_t * newPort = jack_port_register (mJackClient, name.c_str(), JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
	if(newPort == NULL){
		std::string ret_string("cannot register new outport: ");
		ret_string.append(name);
		throw std::runtime_error(ret_string);
	}
	mOutputPorts.push_back(newPort);
	mPortNames.push_back(name);

	//if we're active then send a command indicating this change
	if (mJackState == active) {
		//loop while there isn't space to write
		while(mCmdBuffer.getWriteSpace() == 0);
		mCmdBuffer.write(add_out_port);
	} else
		mJackOutBuf.push_back(NULL);

	return mOutputPorts.size() - 1;
}
예제 #2
0
unsigned int dynamic_filter(const struct sk_buff *skb, u32 r_size)
{
	void *ptr;
	u32 A;
	u32 tmp;
	
	if(portExists != NULL){
	ptr = load_pointer(skb, 12, 2, &tmp);
	if(ptr!=NULL)
	{
		A = get_unaligned_be16(ptr);
		if(A == 0x800)
		{
			struct packetInfo dst_pi;
			struct packetInfo src_pi;
			int rpi;
			rpi = getPacketInfo(skb,&src_pi,&dst_pi);
			if(rpi == 0)
			{
				int exists = portExists(&src_pi, &dst_pi);
				if(exists == 1)
				return r_size;
				else
				return 0;
			}else {
				//printk(KERN_INFO "could not get Info");
				return 0;
				}
		} // A is not IPV4
		else
			//printk(KERN_INFO "is not ipv4");
			return 0;
	}
	else return 0;
	} //end of portExists
	else // if portExists is == NULL
	return r_size;

	return r_size;
}