void Vc4Shader::Emit_ShaderOutput_VS(boolean bVS)
{
    assert(this->uShaderType == D3D10_SB_VERTEX_SHADER);
    
    Vc4Register vpm(VC4_QPU_ALU_REG_B, VC4_QPU_WADDR_VPM);

    Vc4Register pos[4]; // X/Y/Z/W.
    for (uint8_t iPos = 0; iPos < this->cOutput; iPos++)
    {
        if (this->OutputRegister[iPos / 4][iPos % 4].GetFlags().position)
        {
            for (uint8_t i = iPos; i < iPos + 4; i++)
            {
                Vc4Register reg = this->OutputRegister[i / 4][i % 4];
                assert(reg.GetFlags().position);
                pos[this->SwizzleMaskToIndex(reg.GetSwizzleMask())] = reg;
            }
            break;
        }
    }

    // Only CS emits raw coordinates.
    if (!bVS)
    {
        // Xc, Yc, Zc, Wc
        for (uint8_t i = 0; i < 4; i++)
        {
            Vc4Register src = pos[i];
            Vc4Instruction Vc4Inst;
            Vc4Inst.Vc4_m_MOV(vpm, src);
            Vc4Inst.Emit(CurrentStorage);
        }
    }

    // calculate 1/W
    {
        // send W to sfu_recip.
        {
            Vc4Register sfu_recip((pos[3].GetMux() == VC4_QPU_ALU_REG_A ? VC4_QPU_ALU_REG_B : VC4_QPU_ALU_REG_A), VC4_QPU_WADDR_SFU_RECIP);
            Vc4Instruction Vc4Inst;
            Vc4Inst.Vc4_a_MOV(sfu_recip, pos[3]);
            Vc4Inst.Emit(CurrentStorage);
        }

        // Issue 2 NOPs to wait result of sfu_recip.
        for (uint8_t i = 0; i < 2; i++)
        {
            Vc4Instruction Vc4Inst;
            Vc4Inst.Emit(CurrentStorage);
        }
    }

    // Now, r4 is 1/W.
    Vc4Register r4(VC4_QPU_ALU_R4);
    
    // Ys/Xs
    {
        // scale by RT dimension (read from uniform). Result in r0/r1.
        {
            for (uint8_t i = 0; i < 2; i++)
            {
                Vc4Register rX(VC4_QPU_ALU_R0 + i, VC4_QPU_WADDR_ACC0 + i); // r0 and r1.
                
                { // divide Xc/Yc by W.
                    Vc4Instruction Vc4Inst;
                    Vc4Inst.Vc4_m_FMUL(rX, pos[i], r4);
                    Vc4Inst.Emit(CurrentStorage);
                }

                { // Scale Xc/Yc with viewport.
                    Vc4Instruction Vc4Inst;
                    Vc4Register unif((rX.GetMux() == VC4_QPU_ALU_REG_A ? VC4_QPU_ALU_REG_B : VC4_QPU_ALU_REG_A), VC4_QPU_RADDR_UNIFORM); // use opossit register file.
                    Vc4Inst.Vc4_m_FMUL(rX, rX, unif);
                    Vc4Inst.Emit(CurrentStorage);
                    {
                        VC4_UNIFORM_FORMAT u;
                        u.Type = (i == 0 ? VC4_UNIFORM_TYPE_VIEWPORT_SCALE_X : VC4_UNIFORM_TYPE_VIEWPORT_SCALE_Y);
                        this->AddUniformReference(u);
                    }
                }
            }
        }

        // Convert r0/r1 to 16bits float and pack them into ra16, then output to vpm.
        {
            Vc4Register ra16(VC4_QPU_ALU_REG_A, 16);

            for (uint8_t i = 0; i < 2; i++)
            {
                Vc4Register rX(VC4_QPU_ALU_R0 + i); // r0 and r1.
                Vc4Instruction Vc4Inst;
                Vc4Inst.Vc4_a_FTOI(ra16, rX); // REUSE ra16 as temp is no longer needed.
                Vc4Inst.Vc4_a_Pack(VC4_QPU_PACK_A_16a + i); // Pack to 16a or 16b.
                Vc4Inst.Emit(CurrentStorage);
            }

            // Issue NOP as ra16 is just written.
            {
                Vc4Instruction Vc4Inst;
                Vc4Inst.Emit(CurrentStorage);
            }

            // Output to vpm.
            {
                Vc4Instruction Vc4Inst;
                Vc4Inst.Vc4_m_MOV(vpm, ra16);
                Vc4Inst.Emit(CurrentStorage);
            }
        }
    }

    // Zs
    { // Zs = Zc / W // TODO: Z offset
        Vc4Instruction Vc4Inst;
        Vc4Inst.Vc4_m_FMUL(vpm, pos[2], r4);
        Vc4Inst.Emit(CurrentStorage);
    }

    // 1/Wc
    {
        // Move result of sfu_recip (come up at r4) to vpm.
        {
            Vc4Instruction Vc4Inst;
            Vc4Inst.Vc4_m_MOV(vpm, r4);
            Vc4Inst.Emit(CurrentStorage);
        }
    }

    // Only VS emits "varying" (everything read from vpm except position data).
    if (bVS)
    {
        for (uint8_t i = 0, iRegUsed = 0; iRegUsed < this->cOutput; i++ )
        {
            Vc4Register src = this->OutputRegister[i / 4][i % 4];
            if (src.GetFlags().valid)
            {
                if (src.GetFlags().linkage)
                {
                    Vc4Instruction Vc4Inst;
                    Vc4Inst.Vc4_m_MOV(vpm, src);
                    // Vc4Inst.Vc4_m_FMUL(vpm, src, r4);
                    Vc4Inst.Emit(CurrentStorage);
                }
                iRegUsed++;
            }
        }
    }
}
Пример #2
0
/** The RadiusClass is C++ library for RADIUS authentication and accounting.
 * Features:
 * - Sending and Receiving RADIUS packets.
 * - Generates password and authentication packet fields at sending, 
 * 		you only need to set the plain text password for the user for ACCESS_REQUEST packets
 * - password length optional
 * - timeouts for waiting on response packets
 * - sending retries if no response from server
 * - sending to optional number of servers:
 * 		- the first server from the config file is taken
 * 			- config parameter: e.g. wait=5 : wait 5s on a response
 * 			- config parameter: e.g. retry=2 : retry sending the packet 2 times after timeout
 * 		- if the first server do not response -> take the next server from config file
 * - extract attributes from the response packet, e.g. FramedIp or FramedRoutes
 * - functions to convert values from the response packets for integers and ip address as string (see function parseResponsePacket())
 **/
int main_test (void)
{
	
	list<RadiusServer> * serverlist;
	list<RadiusServer>::iterator server;
	//create RadiusPacket: you can already specify the type
	RadiusPacket		packet_access(ACCESS_REQUEST);
	
	//the packets for accounting (start,update,stop)
	RadiusPacket		packet_accounting_start(ACCOUNTING_REQUEST);
	RadiusPacket		packet_accounting_update(ACCOUNTING_REQUEST);
	RadiusPacket		packet_accounting_stop(ACCOUNTING_REQUEST);
	
	//create RadiusAttributes: you can specify type and value.
	RadiusAttribute		ra1(ATTRIB_User_Name,"user1"),
						ra2(ATTRIB_User_Password),
						ra3(ATTRIB_NAS_Port,55),
						ra4(ATTRIB_Calling_Station_Id,"127.0.0.1"),
						ra5(ATTRIB_NAS_Identifier),
						ra6(ATTRIB_NAS_IP_Address),
						ra7(ATTRIB_NAS_Port_Type),
						ra8(ATTRIB_Service_Type),
						ra9(ATTRIB_Framed_IP_Address),
						ra10(ATTRIB_Acct_Session_ID, 99),
						//for accounting packet type (start/update/stop)
						ra11(ATTRIB_Acct_Status_Type),
						ra12(ATTRIB_Framed_Protocol),
						
						//for accounting update and stop packets
						ra13(ATTRIB_Acct_Input_Octets, 99),
						ra14(ATTRIB_Acct_Output_Octets, 10),
						ra15(ATTRIB_Acct_Session_Time, 12345),
						ra16(ATTRIB_Vendor_Specific);
						
	RadiusVendorSpecificAttribute rvsa;
	
	//read in the config
	RadiusConfig config(string("./exampleconfig"));
	
	cout << "*** Sampleprogramm for the RadiusClass. ***\n";
	cout << "---- Print Config ----\n";
	cout << config;
	cout << "-----------------------\n";
	
	// Send a ACCEPT-REQUEST-PACKET
	cout << "-----------------------------------------------------\n";
	cout << "-------- Send a ACCESS-REQUEST-PACKET ---------------\n";
	cout << "-----------------------------------------------------\n";
	
	/*set password (the method setValue() detects which type
	 * the attribut is from, and converts the value correct for
	 * this type)
	 */
	ra2.setValue(string("testing"));
	if(packet_access.addRadiusAttribute(&ra1))
	{
		cerr << getTime() << "RADIUS-CLASS: Fail to add attribute ATTRIB_User_Name.\n";
	}
	if (packet_access.addRadiusAttribute(&ra2))
	{
		cerr << getTime() << "RADIUS-CLASS: Fail to add attribute ATTRIB_User_Password.\n";
	}
	if (packet_access.addRadiusAttribute(&ra3))
	{
		cerr << getTime() << "RADIUS-CLASS: Fail to add attribute ATTRIB_NAS_Port.\n";
	}
	if (packet_access.addRadiusAttribute(&ra4))
	{
		cerr << getTime() << "RADIUS-CLASS: Fail to add attribute ATTRIB_Calling_Station_Id.\n";
	}
	//get information from the config and add it to the packet
	if(strcmp(config.getNASIdentifier(),""))
	{
			ra5.setValue(config.getNASIdentifier());
			if (packet_access.addRadiusAttribute(&ra5))
			{
				cerr << getTime() << "RADIUS-CLASS: Fail to add attribute ATTRIB_NAS_Identifier.\n";
			}
	}
	
	if(strcmp(config.getNASIpAddress(),""))
	{
			if(ra6.setValue(config.getNASIpAddress())!=0)
			{
				cerr << getTime() << "RADIUS-CLASS: Fail to set value ATTRIB_NAS_Ip_Address.\n";
			}
			else
			if (packet_access.addRadiusAttribute(&ra6))
			{
				cerr << getTime() << "RADIUS-CLASS: Fail to add attribute ATTRIB_NAS_Ip_Address.\n";
			}
	}
	if(strcmp(config.getNASPortType(),""))
	{
			ra7.setValue(config.getNASPortType());
			if (packet_access.addRadiusAttribute(&ra7))
			{
				cerr << getTime() << "RADIUS-CLASS: Fail to add attribute ATTRIB_NAS_Port_Type.\n";
			}
	}
	
	if(strcmp(config.getServiceType(),""))
	{
			ra8.setValue(config.getServiceType());
			if (packet_access.addRadiusAttribute(&ra8))
			{
				cerr << getTime() << "RADIUS-CLASS: Fail to add attribute ATTRIB_Service_Type.\n";
			}
	}
	
	//example for sending vendor specific attribute
	rvsa.setId(123);
	rvsa.setType(1);
	rvsa.setValue("Vendor Attribute");
	//integers can be set directly
	//rvsa.setValue(1981);
	Octet * tmp_rvsa=new Octet[rvsa.getLength()+4];
	
	rvsa.getShapedAttribute(tmp_rvsa);
	ra16.setValue((char *)tmp_rvsa);
	
	packet_access.addRadiusAttribute(&ra16);
	
	delete [] tmp_rvsa;
	
	
	//get the server list
	serverlist=config.getRadiusServer();
	
	//check if there are servers
	try
	{
		if(serverlist->empty()==true)
		{
			throw(string("RADIUS-CLASS: No servers defined!"));
		}
	}
	catch(string)
	{
		cerr<< "No servers!";
		//stop the programm if there are no server(s) in config
		return 0;
	}
	
	//set server to the first server
	server=serverlist->begin();
	
	//send the packet to the first server from the list
	if (packet_access.radiusSend(server)<0)
	{
		cerr << getTime() << "RADIUS-CLASS: Packet was not send.\n";
	}
	
	//receive the packet, if the server doesn't response send the packet to the next server in list.
	if (packet_access.radiusReceive(serverlist)==0)
	{
		//is it a accept?
		if(packet_access.getCode()==ACCESS_ACCEPT)
		{
			/*Parse the attributes for framedip, framedroutes and acctinteriminterval.
			This is only an example, so the function has no return values, the
			values are printed at stdout.*/
			parseResponsePacket(&packet_access);
				
		}
		//If the radius server denied the access or sends a ACCESS_CHALLANGE-packet.
		else
		{
			cerr << getTime() << "RADIUS-CLASS: Get ACCESS_REJECT or ACCESS_CHALLANGE-Packet.->ACCESS-DENIED.\n";
		}
		
	}
	else
	{
		cerr << getTime() << "RADIUS-CLASS: Got no or bad response from radius server.\n";
	}
	
	
	// Send a ACCOUNTING-REQUEST-PACKET, Status-Type:Start
	
	cout << "-----------------------------------------------------\n";
	cout << "-------- Send a ACCOUNTING-REQUEST-PACKET -----------\n";
	cout << "-----------------Status-Type: Start------------------\n";
	cout << "-----------------------------------------------------\n";
	
	
	//add the attributes to the packet
	if(packet_accounting_start.addRadiusAttribute(&ra1))
	{
		cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_User_Name.\n";
	}
	
	
	if (packet_accounting_start.addRadiusAttribute(&ra3))
	{
		cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_NAS_Port.\n";
	}
	if (packet_accounting_start.addRadiusAttribute(&ra4))
	{
		cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_Calling_Station_Id.\n";
	}
	
	
	
	if (packet_accounting_start.addRadiusAttribute(&ra10))
	{
		cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_Session_Id.\n";
	}
	
	//set status type: start = 1 (see RADIUS RFC)
	ra11.setValue(string("1"));
	if (packet_accounting_start.addRadiusAttribute(&ra11))
	{
		cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_Status_Type.\n";
	}
	
	
	//get information from the config and add the attributes to the packet
	if(strcmp(config.getNASIdentifier(),""))
	{
			ra5.setValue(config.getNASIdentifier());
			if (packet_accounting_start.addRadiusAttribute(&ra5))
			{
				cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_NAS_Identifier.\n";
			}
	}
	
	if(strcmp(config.getNASIpAddress(),""))
	{
			if(ra6.setValue(config.getNASIpAddress())!=0)
			{
				cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to set value ATTRIB_NAS_Ip_Address.\n";
			}
	
			if (packet_accounting_start.addRadiusAttribute(&ra6))
			{
				cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_NAS_Ip_Address.\n";
			}
	}
	if(strcmp(config.getNASPortType(),""))
	{
			ra7.setValue(config.getNASPortType());
			if (packet_accounting_start.addRadiusAttribute(&ra7))
			{
				cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_NAS_Port_Type.\n";
			}
	}
	
	if(strcmp(config.getServiceType(),""))
	{
			ra8.setValue(config.getServiceType());
			if (packet_accounting_start.addRadiusAttribute(&ra8))
			{
				cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_Service_Type.\n";
			}
	}
	if(strcmp(config.getFramedProtocol(),""))
	{
			ra12.setValue(config.getFramedProtocol());
			if (packet_accounting_start.addRadiusAttribute(&ra12))
			{
				cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_FramedProtocol.\n";
			}
	}
	ra9.setValue(string("111.222.111.111"));
	if (packet_accounting_start.addRadiusAttribute(&ra9))
	{
		cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_Acct_Session_ID.\n";
	}
	
	
	
	//send the packet_accounting_start	
	if (packet_accounting_start.radiusSend(server)<0)
	{
		cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Packet was not send.\n";
	}
	
	//receive the response
	if (packet_accounting_start.radiusReceive(serverlist)>=0)
	{
		//is is a accounting resopnse ?
		if(packet_accounting_start.getCode()==ACCOUNTING_RESPONSE)
		{
			cerr << getTime() << "RADIUS-CLASS:  Get ACCOUNTING_RESPONSET-Packet.\n";

		}
	}	
	else
	{
		cerr << getTime() << "RADIUS-CLASS: Got no or bad response from radius server.\n";
	}
	
	// Send a ACCOUNTING-REQUEST-PACKET, Status-Type:Update
	
	cout << "-----------------------------------------------------\n";
	cout << "-------- Send a ACCOUNTING-REQUEST-PACKET -----------\n";
	cout << "-----------------Status-Type: Update-----------------\n";
	cout << "-----------------------------------------------------\n";
	
	//add the attributes to the packet
	if(packet_accounting_update.addRadiusAttribute(&ra1))
	{
		cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_User_Name.\n";
	}
	
	
	if (packet_accounting_update.addRadiusAttribute(&ra3))
	{
		cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_NAS_Port.\n";
	}
	if (packet_accounting_update.addRadiusAttribute(&ra4))
	{
		cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_Calling_Station_Id.\n";
	}
	
	
	
	
	if (packet_accounting_update.addRadiusAttribute(&ra10))
	{
		cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_Session_Id.\n";
	}
	
	//set status type: update = 3(see RADIUS RFC)
	ra11.setValue(string("3"));
	if (packet_accounting_update.addRadiusAttribute(&ra11))
	{
		cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_Status_Type.\n";
	}
	
	
	
	if (packet_accounting_update.addRadiusAttribute(&ra13))
	{
		cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_Acct_Input_Octets.\n";
	}
	if (packet_accounting_update.addRadiusAttribute(&ra14))
	{
		cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_Acct_Output_Octets.\n";
	}
	if (packet_accounting_update.addRadiusAttribute(&ra14))
	{
		cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_Acct_Session_Time.\n";
	}
	
	//get information from the config and add the attributes to the packet
	if(strcmp(config.getNASIdentifier(),""))
	{
			ra5.setValue(config.getNASIdentifier());
			if (packet_accounting_update.addRadiusAttribute(&ra5))
			{
				cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_NAS_Identifier.\n";
			}
	}
	
	if(strcmp(config.getNASIpAddress(),""))
	{
			if(ra6.setValue(config.getNASIpAddress())!=0)
			{
				cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to set value ATTRIB_NAS_Ip_Address.\n";
			}
	
			if (packet_accounting_update.addRadiusAttribute(&ra6))
			{
				cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_NAS_Ip_Address.\n";
			}
	}
	if(strcmp(config.getNASPortType(),""))
	{
			ra7.setValue(config.getNASPortType());
			if (packet_accounting_update.addRadiusAttribute(&ra7))
			{
				cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_NAS_Port_Type.\n";
			}
	}
	
	if(strcmp(config.getServiceType(),""))
	{
			ra8.setValue(config.getServiceType());
			if (packet_accounting_update.addRadiusAttribute(&ra8))
			{
				cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_Service_Type.\n";
			}
	}
	if(strcmp(config.getFramedProtocol(),""))
	{
			ra12.setValue(config.getFramedProtocol());
			if (packet_accounting_update.addRadiusAttribute(&ra12))
			{
				cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_FramedProtocol.\n";
			}
	}
	ra9.setValue(string("111.222.111.111"));
	if (packet_accounting_update.addRadiusAttribute(&ra9))
	{
		cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_Acct_Session_ID.\n";
	}
	
	
	
	//send the packet_accounting_update	
	if (packet_accounting_update.radiusSend(server)<0)
	{
		cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Packet was not send.\n";
	}
	
	//receive the response
	if (packet_accounting_update.radiusReceive(serverlist)>=0)
	{
		//is is a accounting resopnse ?
		if(packet_accounting_update.getCode()==ACCOUNTING_RESPONSE)
		{
			cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Get ACCOUNTING_RESPONSET-Packet.\n";

		}
		
		
	}
	else
	{
		cerr << getTime() << "RADIUS-CLASS: Got no or bad response from radius server.\n";
	}
	
	// Send a ACCOUNTING-REQUEST-PACKET, Status-Type:Stop
	
	cout << "-----------------------------------------------------\n";
	cout << "-------- Send a ACCOUNTING-REQUEST-PACKET -----------\n";
	cout << "-----------------Status-Type: Stop-------------------\n";
	cout << "-----------------------------------------------------\n";
	
	//add the attributes to the packet
	if(packet_accounting_stop.addRadiusAttribute(&ra1))
	{
		cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_User_Name.\n";
	}
	
	
	if (packet_accounting_stop.addRadiusAttribute(&ra3))
	{
		cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_NAS_Port.\n";
	}
	if (packet_accounting_stop.addRadiusAttribute(&ra4))
	{
		cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_Calling_Station_Id.\n";
	}
	
	
	
	
	if (packet_accounting_stop.addRadiusAttribute(&ra10))
	{
		cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_Session_Id.\n";
	}
	
	//set status type: update = 2(see RADIUS RFC)
	ra11.setValue(string("2"));
	if (packet_accounting_stop.addRadiusAttribute(&ra11))
	{
		cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_Status_Type.\n";
	}
	
	
	
	if (packet_accounting_stop.addRadiusAttribute(&ra13))
	{
		cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_Acct_Input_Octets.\n";
	}
	if (packet_accounting_stop.addRadiusAttribute(&ra14))
	{
		cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_Acct_Output_Octets.\n";
	}
	if (packet_accounting_stop.addRadiusAttribute(&ra14))
	{
		cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_Acct_Session_Time.\n";
	}
	
	//get information from the config and add the attributes to the packet
	if(strcmp(config.getNASIdentifier(),""))
	{
			ra5.setValue(config.getNASIdentifier());
			if (packet_accounting_stop.addRadiusAttribute(&ra5))
			{
				cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_NAS_Identifier.\n";
			}
	}
	
	if(strcmp(config.getNASIpAddress(),""))
	{
			if(ra6.setValue(config.getNASIpAddress())!=0)
			{
				cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to set value ATTRIB_NAS_Ip_Address.\n";
			}
	
			if (packet_accounting_stop.addRadiusAttribute(&ra6))
			{
				cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_NAS_Ip_Address.\n";
			}
	}
	if(strcmp(config.getNASPortType(),""))
	{
			ra7.setValue(config.getNASPortType());
			if (packet_accounting_stop.addRadiusAttribute(&ra7))
			{
				cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_NAS_Port_Type.\n";
			}
	}
	
	if(strcmp(config.getServiceType(),""))
	{
			ra8.setValue(config.getServiceType());
			if (packet_accounting_stop.addRadiusAttribute(&ra8))
			{
				cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_Service_Type.\n";
			}
	}
	if(strcmp(config.getFramedProtocol(),""))
	{
			ra12.setValue(config.getFramedProtocol());
			if (packet_accounting_stop.addRadiusAttribute(&ra12))
			{
				cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_FramedProtocol.\n";
			}
	}
	ra9.setValue(string("111.222.111.111"));
	if (packet_accounting_stop.addRadiusAttribute(&ra9))
	{
		cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Fail to add attribute ATTRIB_Acct_Session_ID.\n";
	}
	
	
	
	//send the packet_accounting_stop	
	if (packet_accounting_stop.radiusSend(server)<0)
	{
		cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Packet was not send.\n";
	}
	
	//receive the response
	if (packet_accounting_stop.radiusReceive(serverlist)>=0)
	{
		//is is a accounting resopnse ?
		if(packet_accounting_stop.getCode()==ACCOUNTING_RESPONSE)
		{
			cerr << getTime() << "RADIUS-CLASS: BACKGROUND-ACCT:  Get ACCOUNTING_RESPONSET-Packet.\n";

		}
	}
	else
	{
		cerr << getTime() << "RADIUS-CLASS: Got no or bad response from radius server.\n";
	}
	
	cout << "\n---- End ----";
	return (0);


}