public SceNetAdhocctlConnectPacketS2C(string nickName, pspNetMacAddress mac, int ip) : base(null) { opcode = OPCODE_CONNECT; this.nickName = nickName; this.mac = mac; this.ip = ip; }
public virtual int create(pspNetMacAddress macAddress, int port, int bufSize) { int result = Id; MacAddress = macAddress; Port = port; BufSize = bufSize; try { openSocket(); } catch (BindException e) { //if (log.DebugEnabled) { Console.WriteLine("create", e); } result = SceKernelErrors.ERROR_NET_ADHOC_PORT_IN_USE; } catch (SocketException e) { Console.WriteLine("create", e); } catch (UnknownHostException e) { Console.WriteLine("create", e); } catch (IOException e) { Console.WriteLine("create", e); } return(result); }
public virtual int send(pspNetMacAddress macAddress, int dataLen, int data) { int result = 0; try { AdhocMatchingEventMessage adhocMatchingEventMessage = createMessage(PSP_ADHOC_MATCHING_EVENT_DATA, data, dataLen, macAddress.macAddress); send(adhocMatchingEventMessage, macAddress, dataLen, data); result = dataLen; } catch (SocketException e) { Console.WriteLine("send", e); } catch (UnknownHostException e) { Console.WriteLine("send", e); } catch (IOException e) { Console.WriteLine("send", e); } return(result); }
public virtual int send(pspNetMacAddress destMacAddress, int destPort, TPointer data, int Length, int timeout, int nonblock) { int result = 0; try { openSocket(); setTimeout(timeout, nonblock); AdhocMessage adhocMessage = networkAdapter.createAdhocPdpMessage(data.Address, Length, destMacAddress.macAddress); send(adhocMessage, destPort); } catch (SocketException e) { Console.WriteLine("send", e); } catch (UnknownHostException e) { result = SceKernelErrors.ERROR_NET_ADHOC_INVALID_ADDR; Console.WriteLine("send", e); } catch (SocketTimeoutException e) { Console.WriteLine("send", e); } catch (IOException e) { Console.WriteLine("send", e); } return(result); }
public virtual void processScan() { // User is disconnected if (currentUser.group == null) { // Iterate game groups foreach (Group group in currentUser.game.groups) { pspNetMacAddress mac = new pspNetMacAddress(); if (group.players.Count > 0) { // Founder of the group is the first player mac = group.players[0].mac; } try { sendToUser(currentUser, new PacketFactory.SceNetAdhocctlScanPacketS2C(group.name, mac)); } catch (IOException e) { Console.WriteLine("processScan", e); } } } else { Console.WriteLine(string.Format("{0} attempted to scan for {1} groups without disconnecting from {2} first.", currentUser, currentUser.game.name, currentUser.group.name)); logoutUser(currentUser); } }
public virtual void processLogin(pspNetMacAddress mac, string nickName, string gameName) { if (gameName.matches("[A-Z0-9]{9}")) { currentUser.game = null; foreach (Game game in games) { if (game.name.Equals(gameName)) { currentUser.game = game; break; } } if (currentUser.game == null) { currentUser.game = new Game(gameName); games.Add(currentUser.game); } currentUser.game.playerCount++; currentUser.mac = mac; currentUser.nickName = nickName; Console.WriteLine(string.Format("{0} started playing {1}.", currentUser, currentUser.game.name)); } else { Console.WriteLine(string.Format("Invalid login for game '{0}'", gameName)); } }
protected internal virtual void addFriend(string nickName, pspNetMacAddress mac, int ip) { lock (this) { //if (log.DebugEnabled) { Console.WriteLine(string.Format("Adding friend nickName='{0}', mac={1}, ip={2}", nickName, mac, convertIpToString(ip))); } Modules.sceNetAdhocctlModule.hleNetAdhocctlAddPeer(nickName, mac); if (chatGUI != null) { chatGUI.updateMembers(Modules.sceNetAdhocctlModule.PeersNickName); } bool found = false; foreach (MacIp macIp in macIps) { if (mac.Equals(macIp.mac)) { macIp.Ip = ip; found = true; break; } } if (!found) { MacIp macIp = new MacIp(mac.macAddress, ip); macIps.Add(macIp); portManager.addHost(convertIpToString(ip)); } } }
public virtual int sceNetAttachIfhandleEther(TPointer handleAddr, TPointer8 macAddress, PspString interfaceName) { pspNetMacAddress netMacAddress = new pspNetMacAddress(); netMacAddress.read(macAddress); return(hleNetAttachIfhandleEther(handleAddr, netMacAddress, interfaceName.String)); }
protected internal override void init(sbyte[] bytes, int Length) { base.init(bytes, Length); if (Length >= Length) { mac = copyMacFromBytes(bytes); } }
public CallbackEvent(int @event, int macAddr, int optLen, int optData) { this.@event = @event; macAddress = new pspNetMacAddress(); macAddress.read(Memory.Instance, macAddr); this.optLen = optLen; this.optData = optData; }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public pspsharp.HLE.kernel.types.pspNetMacAddress readMacAddress(int Length) throws java.io.EOFException public virtual pspNetMacAddress readMacAddress(int Length) { pspNetMacAddress macAddress = new pspNetMacAddress(); readBytes(macAddress.macAddress, 0, System.Math.Min(Length, MAC_ADDRESS_LENGTH)); skip8(Length - MAC_ADDRESS_LENGTH); return(macAddress); }
public virtual int sceNet_lib_D60225A3(TPointer macAddr) { pspNetMacAddress macAddress = new pspNetMacAddress(); macAddress.read(macAddr); return(0x11223344); }
public virtual void sceNetEtherNtostr(pspNetMacAddress macAddress, TPointer strAddr) { // This syscall is only doing something when both parameters are not 0. if (macAddress.NotNull && strAddr.NotNull) { // Convert 6-byte Mac address into string representation (XX:XX:XX:XX:XX:XX). Utilities.writeStringZ(Memory.Instance, strAddr.Address, convertMacAddressToString(macAddress.macAddress)); } }
protected internal virtual pspNetMacAddress copyMacFromBytes(sbyte[] bytes) { pspNetMacAddress mac = new pspNetMacAddress(); mac.setMacAddress(bytes, offset); offset += MAC_ADDRESS_LENGTH; return(mac); }
public virtual int sceNetAdhocMatchingCancelTargetWithOpt(int matchingId, pspNetMacAddress macAddress, int optLen, TPointer optData) { if (log.TraceEnabled) { log.trace(string.Format("Opt data: {0}", Utilities.getMemoryDump(optData.Address, optLen))); } return(matchingObjects[matchingId].cancelTarget(macAddress, optLen, optData.Address)); }
public virtual int sceNetAdhocMatchingSendData(int matchingId, pspNetMacAddress macAddress, int dataLen, TPointer data) { if (log.TraceEnabled) { log.trace(string.Format("Send data: {0}", Utilities.getMemoryDump(data.Address, dataLen))); } return(matchingObjects[matchingId].send(macAddress, dataLen, data.Address)); }
protected internal override void init(sbyte[] bytes, int Length) { base.init(bytes, Length); if (Length >= Length) { group = copyStringFromBytes(bytes, GROUP_NAME_LENGTH); mac = copyMacFromBytes(bytes); } }
protected internal override void init(sbyte[] bytes, int Length) { base.init(bytes, Length); if (Length >= Length) { nickName = copyStringFromBytes(bytes, NICK_NAME_LENGTH); mac = copyMacFromBytes(bytes); ip = copyInt32FromBytes(bytes); } }
public virtual int sceNetGetLocalEtherAddr(TPointer etherAddr) { // Return WLAN MAC address pspNetMacAddress macAddress = new pspNetMacAddress(); macAddress.MacAddress = Wlan.MacAddress; macAddress.write(etherAddr); return(0); }
protected internal override void read() { dstMacAddress = new pspNetMacAddress(); read(dstMacAddress); // Offset 0 srcMacAddress = new pspNetMacAddress(); read(srcMacAddress); // Offset 6 protocolType = endianSwap16((short)read16()); // Offset 12 protocolSubType = endianSwap16((short)read16()); // Offset 14 unknown16 = read8(); // Offset 16 controlType = read8(); // Offset 17 contentLength = endianSwap16((short)read16()); // Offset 18 }
public virtual void sceNetEtherStrton(PspString str, TPointer etherAddr) { // This syscall is only doing something when both parameters are not 0. if (str.NotNull && etherAddr.NotNull) { // Convert string Mac address string representation (XX:XX:XX:XX:XX:XX) // into 6-byte representation. pspNetMacAddress macAddress = new pspNetMacAddress(); macAddress.MacAddress = convertStringToMacAddress(str.String); macAddress.write(etherAddr); } }
public virtual int selectTarget(pspNetMacAddress macAddress, int optLen, int optData) { int result = 0; try { int @event; if (pendingJoinRequest != null && sceNetAdhoc.isSameMacAddress(pendingJoinRequest, macAddress.macAddress)) { @event = PSP_ADHOC_MATCHING_EVENT_ACCEPT; //if (log.DebugEnabled) { Console.WriteLine(string.Format("Sending accept to port {0:D}", Port)); } if (Mode == sceNetAdhocMatching.PSP_ADHOC_MATCHING_MODE_HOST) { addMember(macAddress.macAddress); connected = true; inConnection = false; } } else { @event = PSP_ADHOC_MATCHING_EVENT_JOIN; //if (log.DebugEnabled) { Console.WriteLine(string.Format("Sending join to port {0:D}", Port)); } } AdhocMatchingEventMessage adhocMatchingEventMessage = createMessage(@event, optData, optLen, macAddress.macAddress); send(adhocMatchingEventMessage, macAddress, optLen, optData); inConnection = true; } catch (SocketException e) { Console.WriteLine("selectTarget", e); } catch (UnknownHostException e) { Console.WriteLine("selectTarget", e); } catch (IOException e) { Console.WriteLine("selectTarget", e); } return(result); }
public virtual int cancelTarget(pspNetMacAddress macAddress, int optLen, int optData) { int result = 0; try { int @event; if (connected) { @event = PSP_ADHOC_MATCHING_EVENT_LEFT; //if (log.DebugEnabled) { Console.WriteLine(string.Format("Sending leave to port {0:D}", Port)); } } else { @event = PSP_ADHOC_MATCHING_EVENT_CANCEL; //if (log.DebugEnabled) { Console.WriteLine(string.Format("Sending cancel to port {0:D}", Port)); } } AdhocMatchingEventMessage adhocMatchingEventMessage = createMessage(@event, optData, optLen, macAddress.macAddress); send(adhocMatchingEventMessage, macAddress, optLen, optData); } catch (SocketException e) { Console.WriteLine("cancelTarget", e); } catch (UnknownHostException e) { Console.WriteLine("cancelTarget", e); } catch (IOException e) { Console.WriteLine("cancelTarget", e); } removeMember(macAddress.macAddress); connected = false; inConnection = false; return(result); }
protected internal override void read() { readUnknown(20); // Offset 0 interfaceName = readStringNZ(16); // Offset 20 readUnknown(148); // Offset 36 unknownCallbackAddr184 = read32(); // Offset 184 unknownCallbackAddr188 = read32(); // Offset 188 readUnknown(44); // Offset 192 macAddress = new pspNetMacAddress(); read(macAddress); // Offset 236 readUnknown(2); // Offset 242 sceNetIfhandleIfUp = read32(); // Offset 244 sceNetIfhandleIfDown = read32(); // Offset 248 sceNetIfhandleIfIoctl = read32(); // Offset 252 ioctlSemaId = read32(); // Offset 256 ioctlOKSemaId = read32(); // Offset 260 readUnknown(4); // Offset 264 errorCode = read32(); // Offset 268 }
private void addMember(sbyte[] macAddr) { foreach (pspNetMacAddress member in members) { if (sceNetAdhoc.isSameMacAddress(macAddr, member.macAddress)) { // Already in the members list return; } } pspNetMacAddress member = new pspNetMacAddress(); member.MacAddress = macAddr; members.AddLast(member); //if (log.DebugEnabled) { Console.WriteLine(string.Format("Adding member {0}", member)); } }
private AccessPoint() { // Generate a random MAC address for the Address Point apMacAddress = new pspNetMacAddress(pspNetMacAddress.RandomMacAddress); apIpAddress = getIpAddress(sceNetApctl.Gateway); localIpAddress = getIpAddress(sceNetApctl.LocalHostIP); tcpConnectionStates = new LinkedList <>(); random = new System.Random(); apThread = new AccessPointThread(this); apThread.Daemon = true; apThread.Name = "Access Point Thread"; apThread.Start(); //if (log.DebugEnabled) { Console.WriteLine(string.Format("AccessPoint using MAC={0}, IP={1}", apMacAddress, getIpAddressString(apIpAddress))); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void writeMacAddress(pspsharp.HLE.kernel.types.pspNetMacAddress macAddress, int Length) throws java.io.EOFException public virtual void writeMacAddress(pspNetMacAddress macAddress, int Length) { writeBytes(macAddress.macAddress, 0, System.Math.Min(Length, MAC_ADDRESS_LENGTH)); skip8(Length - MAC_ADDRESS_LENGTH); }
public virtual bool inputLoop() { if (socket == null || !started) { return(false); } // Execute all the pending callback events while (pendingCallbackEvents.Count > 0) { CallbackEvent callbackEvent = pendingCallbackEvents.RemoveFirst(); pspNetMacAddress macAddress = callbackEvent.MacAddress; macAddress.write(Memory.Instance, buffer.addr); notifyCallbackEvent(callbackEvent.Event, macAddress.BaseAddress, callbackEvent.OptLen, callbackEvent.OptData); } try { sbyte[] bytes = new sbyte[BufSize + MAX_HEADER_SIZE]; int Length = socket.receive(bytes, bytes.Length); if (Length > 0) { int receivedPort = socket.ReceivedPort; InetAddress receivedAddress = socket.ReceivedAddress; AdhocMatchingEventMessage adhocMatchingEventMessage = createMessage(bytes, Length); if (isForMe(adhocMatchingEventMessage, receivedPort, receivedAddress)) { int @event = adhocMatchingEventMessage.Event; int macAddr = buffer.addr; int optData = buffer.addr + 8; int optLen = adhocMatchingEventMessage.DataLength; adhocMatchingEventMessage.writeDataToMemory(optData); pspNetMacAddress macAddress = new pspNetMacAddress(); macAddress.MacAddress = adhocMatchingEventMessage.FromMacAddress; macAddress.write(Memory.Instance, macAddr); //if (log.DebugEnabled) { Console.WriteLine(string.Format("Received message Length={0:D}, event={1:D}, fromMac={2}, port={3:D}: {4}", adhocMatchingEventMessage.DataLength, @event, macAddress, socket.ReceivedPort, adhocMatchingEventMessage)); if (log.TraceEnabled && optLen > 0) { log.trace(string.Format("Message data: {0}", Utilities.getMemoryDump(optData, optLen))); } } // Keep track that we received a new message from this MAC address Modules.sceNetAdhocctlModule.hleNetAdhocctlPeerUpdateTimestamp(adhocMatchingEventMessage.FromMacAddress); if (@event == PSP_ADHOC_MATCHING_EVENT_JOIN) { pendingJoinRequest = adhocMatchingEventMessage.FromMacAddress; inConnection = true; } adhocMatchingEventMessage.processOnReceive(macAddr, optData, optLen); if (@event == PSP_ADHOC_MATCHING_EVENT_ACCEPT) { addMember(adhocMatchingEventMessage.FromMacAddress); //if (log.DebugEnabled) { Console.WriteLine(string.Format("Sending complete to port {0:D}", Port)); } adhocMatchingEventMessage = createMessage(PSP_ADHOC_MATCHING_EVENT_COMPLETE, optData, optLen, macAddress.macAddress); send(adhocMatchingEventMessage); pendingComplete = true; connected = true; inConnection = false; } else if (@event == PSP_ADHOC_MATCHING_EVENT_COMPLETE) { addMember(adhocMatchingEventMessage.FromMacAddress); if (!pendingComplete) { //if (log.DebugEnabled) { Console.WriteLine(string.Format("Sending complete to port {0:D}", Port)); } adhocMatchingEventMessage = createMessage(PSP_ADHOC_MATCHING_EVENT_COMPLETE, optData, optLen, macAddress.macAddress); send(adhocMatchingEventMessage); } connected = true; inConnection = false; } else if (@event == PSP_ADHOC_MATCHING_EVENT_DATA) { //if (log.DebugEnabled) { Console.WriteLine(string.Format("Sending data confirm to port {0:D}", Port)); } adhocMatchingEventMessage = createMessage(PSP_ADHOC_MATCHING_EVENT_DATA_CONFIRM, 0, 0, macAddress.macAddress); send(adhocMatchingEventMessage); } else if (@event == PSP_ADHOC_MATCHING_EVENT_DISCONNECT || @event == PSP_ADHOC_MATCHING_EVENT_LEFT) { //if (log.DebugEnabled) { Console.WriteLine(string.Format("Received disconnect/leave from {0}", macAddress)); } removeMember(adhocMatchingEventMessage.FromMacAddress); if (members.Count <= 1) { connected = false; inConnection = false; } } } else { //if (log.DebugEnabled) { Console.WriteLine(string.Format("Received message not for me: {0}", adhocMatchingEventMessage)); } } } } catch (SocketTimeoutException) { // Nothing available } catch (IOException e) { Console.WriteLine("inputLoop", e); } return(true); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: protected void send(AdhocMatchingEventMessage adhocMatchingEventMessage, pspsharp.HLE.kernel.types.pspNetMacAddress macAddress, int dataLen, int data) throws java.io.IOException protected internal virtual void send(AdhocMatchingEventMessage adhocMatchingEventMessage, pspNetMacAddress macAddress, int dataLen, int data) { base.send(adhocMatchingEventMessage); if (adhocMatchingEventMessage != null) { adhocMatchingEventMessage.processOnSend(macAddress.BaseAddress, data, dataLen); } }
public virtual int cancelTarget(pspNetMacAddress macAddress) { return(cancelTarget(macAddress, 0, 0)); }