Ejemplo n.º 1
0
vector<uia::comm::endpoint>
sim_socket::local_endpoints()
{
    vector<uia::comm::endpoint> result;
    for (auto ep : host_->local_endpoints()) {
        result.emplace_back(ep.address(), local_port());
    }
    return result;
}
Ejemplo n.º 2
0
/************************************************************************
 * 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);
}
Ejemplo n.º 3
0
	std::string str_local_port(void) const
	{
		std::stringstream ss;
		ss << local_port();
		return ss.str();
	}
Ejemplo n.º 4
0
	Socket_Info local_socket_info(void) const
	{
		return Socket_Info(local_address(), local_port());
	}