

exports.ParseAddr = function(addr){
	var pos = addr.indexOf(":");
	if(pos == -1){
		return null;
	}else{
		var ip = addr.substring(0,pos);
		var port = Number(addr.substr(pos+1));
		return {
			ip:ip,
			port:port
		};
	}
}

exports.Megra = function(des,src){
	for(var key in src){
		des[key] = src[key];
	}	
}

exports.ByteOr = function(a,b){
	var tmpa = a/2;
	var tmpb = b/2;
	var badd = false;
	if( (tmpa > Math.floor(tmpa)) || (tmpb > Math.floor(tmpb)) ){
		badd = true;
	}
	tmpa = Math.floor(tmpa);
	tmpb = Math.floor(tmpb);
	var res =  (tmpa | tmpb) * 2;
	return badd?res+1:res;
}

exports.ByteAnd = function(a,b){
	var tmpa = a/2;
	var tmpb = b/2;
	var badd = false;
	if( (tmpa > Math.floor(tmpa)) && (tmpb > Math.floor(tmpb)) ){
		badd = true;
	}
	tmpa = Math.floor(tmpa);
	tmpb = Math.floor(tmpb);
	var res =  (tmpa & tmpb) * 2;
	return badd?res+1:res;
}