Esempio n. 1
0
int mainServer(int cargs, char *vargs[])
{
    nsfw::initNetworking();

    nsfw::Socket mysocket;
    mysocket.open(50000);
 
    nsfw::Address out_addr("10.15.22.54:50000");
    nsfw::Address in_addr;

    char out_pack[256] {"Message Recieved!"};
    char in_pack[256];
    
    mysocket.send(out_pack, 256, out_addr );
    bool ignoreFirst = true;
    // 10.15.22.54 : 50000
    while (true)
    {
        while (mysocket.recv(in_pack, 256, in_addr))
        {
            if(!ignoreFirst) mysocket.send(out_pack, 256, in_addr);
            
            ignoreFirst = false;

            char buff[256];
            in_addr.toString(buff,256);
            std::cout << in_pack << "  (" << buff << ")" << std::endl;
        } 

    }

    mysocket.close();
    nsfw::termNetworking();
}
Esempio n. 2
0
static void NetworkUDPAdvertiseThread(void *pntr)
{
	/* Find somewhere to send */
	NetworkAddress out_addr(NETWORK_MASTER_SERVER_HOST, NETWORK_MASTER_SERVER_PORT);

	DEBUG(net, 1, "[udp] advertising to master server");

	/* Add a bit more messaging when we cannot get a session key */
	static byte session_key_retries = 0;
	if (_session_key == 0 && session_key_retries++ == 2) {
		DEBUG(net, 0, "[udp] advertising to the master server is failing");
		DEBUG(net, 0, "[udp]   we are not receiving the session key from the server");
		DEBUG(net, 0, "[udp]   please allow udp packets from %s to you to be delivered", out_addr.GetAddressAsString(false));
		DEBUG(net, 0, "[udp]   please allow udp packets from you to %s to be delivered", out_addr.GetAddressAsString(false));
	}
	if (_session_key != 0 && _network_advertise_retries == 0) {
		DEBUG(net, 0, "[udp] advertising to the master server is failing");
		DEBUG(net, 0, "[udp]   we are not receiving the acknowledgement from the server");
		DEBUG(net, 0, "[udp]   this usually means that the master server cannot reach us");
		DEBUG(net, 0, "[udp]   please allow udp and tcp packets to port %u to be delivered", _settings_client.network.server_port);
		DEBUG(net, 0, "[udp]   please allow udp and tcp packets from port %u to be delivered", _settings_client.network.server_port);
	}

	/* Send the packet */
	Packet p(PACKET_UDP_SERVER_REGISTER);
	/* Packet is: WELCOME_MESSAGE, Version, server_port */
	p.Send_string(NETWORK_MASTER_SERVER_WELCOME_MESSAGE);
	p.Send_uint8 (NETWORK_MASTER_SERVER_VERSION);
	p.Send_uint16(_settings_client.network.server_port);
	p.Send_uint64(_session_key);

	_network_udp_mutex->BeginCritical();
	if (_udp_master_socket != NULL) _udp_master_socket->SendPacket(&p, &out_addr, true);
	_network_udp_mutex->EndCritical();
}
Esempio n. 3
0
/* Request the the server-list from the master server */
void NetworkUDPQueryMasterServer()
{
	Packet p(PACKET_UDP_CLIENT_GET_LIST);
	NetworkAddress out_addr(NETWORK_MASTER_SERVER_HOST, NETWORK_MASTER_SERVER_PORT);

	/* packet only contains protocol version */
	p.Send_uint8(NETWORK_MASTER_SERVER_VERSION);
	p.Send_uint8(SLT_AUTODETECT);

	_udp_client_socket->SendPacket(&p, &out_addr, true);

	DEBUG(net, 2, "[udp] master server queried at %s", out_addr.GetAddressAsString());
}
Esempio n. 4
0
static void NetworkUDPRemoveAdvertiseThread(void *pntr)
{
	DEBUG(net, 1, "[udp] removing advertise from master server");

	/* Find somewhere to send */
	NetworkAddress out_addr(NETWORK_MASTER_SERVER_HOST, NETWORK_MASTER_SERVER_PORT);

	/* Send the packet */
	Packet p(PACKET_UDP_SERVER_UNREGISTER);
	/* Packet is: Version, server_port */
	p.Send_uint8 (NETWORK_MASTER_SERVER_VERSION);
	p.Send_uint16(_settings_client.network.server_port);

	_network_udp_mutex->BeginCritical();
	if (_udp_master_socket != NULL) _udp_master_socket->SendPacket(&p, &out_addr, true);
	_network_udp_mutex->EndCritical();
}
Esempio n. 5
0
wr_nv_ident_help(FILE *outfile, struct Addrblock *addrp)
#endif
{
    int eltcount = 0;

    if (addrp == (struct Addrblock *) NULL)
	return;

    if (addrp -> isarray) {
	frexpr (addrp -> memoffset);
	addrp -> memoffset = ICON(0);
	eltcount = addrp -> ntempelt;
	addrp -> ntempelt = 0;
	addrp -> isarray = 0;
    } /* if */
    out_addr (outfile, addrp);
    if (eltcount)
	nice_printf (outfile, "[%d]", eltcount);
} /* wr_nv_ident_help */
Esempio n. 6
0
int main(void)
{
    int value, i;
    unsigned char data[0x4000];
    FILE *file;

    ioperm(PORT_BASE,8,1);

    out_port(0,0);
    out_port(0,1); // CS on
    out_port(0,2); //
    out_port(0,6); // vpp off

    out_port(4,3); // VCC on, VCC=5V, Socket=24pin, /OE=0, read

    wait_ticks (100000);

//	for (i=0; i<0x40; i++) {
    for (i=0; i<0x4000; i++) {
        out_addr(i);
        wait_ticks(100);
        value=inb(PORT_BASE+4);
        data[i]=value;
        if ((i&0xf)==0) printf("%.4x:",i);
        printf(" %.2x", value);
        if ((i&0xf)==0xf) printf("\n");
    }
    out_port(0xf8,2); // led off
    out_port(0,3); //VCC off
    out_port(0,6); //VPP off
    out_port(0,0);

    file=fopen("dil24.bin","wb");
    fwrite(data,1,sizeof(data),file);
    fclose(file);

    return 0;
}
Esempio n. 7
0
File: out.cpp Progetto: nealey/vera
// Output an operand
bool outop(op_t &op) {
    switch ( op.type ) {
        // Data / Code memory address
        case o_near:
        case o_mem:
            BEG_TAG(op);
            out_addr(op);
            END_TAG(op);
            break;

        // Immediate value
        case o_imm:
            BEG_TAG(op);
            {
                const ioport_t * port = find_sym(op.value);

                // this immediate is represented in the .cfg file
                if ( port != NULL )
                    // output the port name instead of the numeric value
                    out_line(port->name, COLOR_IMPNAME);
                // otherwise, simply print the value
                else
                    out_imm(op);
            }
            END_TAG(op);
            break;

        // Displacement
        case o_displ:
            out_addr(op, false);
            out_symbol('(');
            out_reg(op);
            out_symbol(')');
            break;

        // Register
        case o_reg:
            BEG_TAG(op);
            out_reg(op);
            END_TAG(op);
            if ( is_reg_with_bit(op) ) {
                out_symbol('.');
                if ( is_bit_compl(op) )
                    out_symbol('!');
                out_imm(op, true);
            }
            break;

        // Phrase
        case o_phrase:
            switch ( op.specflag2 ) {
                case fPI:   // post increment
                    out_symbol('(');
                    out_reg(op);
                    out_symbol(')');
                    out_symbol('+');
                    break;

                case fPD:   // pre decrement
                    out_symbol('-');
                    out_symbol('(');
                    out_reg(op);
                    out_symbol(')');
                    break;

                case fDISP: // displacement
                    out_reg(op);
                    out_symbol('(');
                    {
                        ushort reg = op.specflag2 << 8;
                        reg |= op.specflag3;
                        out_reg(reg);
                    }
                    out_symbol(')');
                    break;

                default:
                    IDA_ERROR("Invalid phrase type in outop()");
            }
            break;

        // No operand
        case o_void:
            break;

        default:
            IDA_ERROR("Invalid op.type in outop()");
    }

    return 1;
}