Beispiel #1
0
//从已经存在的socket创建
_ossSocket::_ossSocket(int *sock, int timeout)
{
	int rc = EDB_OK;
	_fd = *sock;
	_init = true;
	_timeout = timeout;
	
	_addressLen = sizoef(_sockAddress);
	
	memset(&_peerAddress, 0, sizeof(sockaddr));
	_peerAddressLen = sizeof(_peerAddress);
	
	rc = getsockname(_fd, (sockaddr*)&_sockAddress, &_addressLen);
	
	if(rc)
	{
		printf("Failed to get sock name, error = %d", SOCKET_GETLASTERROR);
	}
	else
	{
		rc = getpeername(_fd, (sockaddr*)&_peerAddress, &_peerAddressLen);
		if(rc)
		{
			priintf("Failed to get peer name, error = %d", SOCKET_GETLASTERROR);
		}
	}
}
Beispiel #2
0
static unsigned int ipt_ipid_target(struct sk_buff **pskb, unsigned int hooknum,
		const struct net_device *in, const struct net_device *out,
		const void *targinfo, void *userinfo)
{
	struct iphdr *iph = (*pskb)->nh.iph;
	const struct ipt_IPID_info *info = targinfo;
	static u_int16_t new_ipid[255];
	u_int16_t id=0;

	id = get_id(out->name);
	switch(info->mode){
		case IP_IPID_PACE:
		new_ipid[id] += info->ipid;
		break;
		case IP_IPID_CHAOTIC:
		default:
		get_random_bytes(&(new_ipid[id]),sizoef(new_ipid[i]));
	}			
	iph->id = htons(new_ipid[id]);
	iph->check = 0;
	iph->check = ip_fast_csum((char *)iph,iph->ihl);

	return IPT_CONTINUE;
}