Announcement

Collapse
No announcement yet.

Getting started with ps2smap

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • dnawrkshp
    replied
    I got a successful initialize and a successful socket creation and bind. Then it starts listening for connections with a port of 2345 and an IP of 10.0.1.100 (not taken). I can't even ping it. I am wondering if I have to set the PS2's IP also. Right now it just sets the sockets IP. Here's what I have so far, it loads all the IRX modules from the ELF and then begins the creation of the server.

    If I do have to set the IP for the PS2, I have attempted to use the 'ps2ip_setconfig()' function using a code snippet from http://forums.ps2dev.org/viewtopic.p...tconfighttp:// (3rd post). It seems to freeze on "strcpy(ipinfo->netif_name, "et");". PS2IP seems to use the same method in a function called IFLoop I believe.

    main.c:

    Code:
    #include <stdio.h>
    #include <debug.h>
    #include <kernel.h>
    #include "ps2ip.h"
    #include "smap/smap.h"
    #include <sifrpc.h>
    #include <iopcontrol.h>
    #include <loadfile.h>
    #include "Obj/PS2IP_IRX.c"
    #include "Obj/PS2IPS_IRX.c"
    #include "Obj/PS2DEV9_IRX.c"
    #include "Obj/SMAP_IRX.c"
    #include "Obj/DNS_IRX.c"
    #include "Obj/POWEROFF_IRX.c"
    
    int Initialize(void);
    int StartServer();
    
    
    int main(void)
    {
    
    	if (Initialize() != 0)
    	{
    		scr_printf("	Did not successfully initialize!\n");
    		return -1;
    	}
    
    	scr_printf("	Initialized!\n");
    
    	if (StartServer() != 0)
    	{
    		scr_printf("	Some error(s) have occurred!\n");
    		return -1;
    	}
    
    	return 0;
    
    }
    
    int Initialize(void)
    {
    
    	int a;
    	
    	SifInitRpc(0);
    	init_scr();
    
    	scr_printf("	Beginning initialization!\n");
    	
    	a = SifExecModuleBuffer(&POWEROFF_IRX, size_POWEROFF_IRX, 0, NULL, &a);
    	if (a <= 0 )
    	{
            scr_printf("	Could not load POWEROFF.IRX! %d\n", a);
    	return -1;
    	}
    
    	scr_printf("	Loaded POWEROFF.IRX!\n");
    
    	a = SifExecModuleBuffer(&PS2DEV9_IRX, size_PS2DEV9_IRX, 0, NULL, &a);
       	if (a <= 0 )
    	{
            scr_printf("	Could not load PS2DEV9.IRX! %d\n", a);
    	return -1;
    	}
    
    	scr_printf("	Loaded PS2DEV9.IRX!\n");
    
    	a = SifExecModuleBuffer(&PS2IP_IRX, size_PS2IP_IRX, 0, NULL, &a);
    	if (a <= 0 )
    	{
            scr_printf("	Could not load PS2IP.IRX!\n %d", a);
    	return -1;
    	}
    
    	scr_printf("	Loaded PS2IP.IRX!\n");
    
    	a = SifExecModuleBuffer(&DNS_IRX, size_DNS_IRX, 0, NULL, &a);
    	if (a <= 0)
    	{
            scr_printf("	Could not load DNS.IRX! %d\n", a);
    	return -1;
    	}
    
    	scr_printf("	Loaded DNS.IRX!\n");
    
    	a = SifExecModuleBuffer(&PS2IPS_IRX, size_PS2IPS_IRX, 0, NULL, &a);
    	if (a <= 0)
    	{
            scr_printf("	Could not load PS2IPS.IRX! %d\n", a);
    	return -1;
    	}
    
    	scr_printf("	Loaded PS2IPS.IRX!\n");
    
    	a = SifExecModuleBuffer(&SMAP_IRX, size_SMAP_IRX, 0, NULL, &a);
    	if (a <= 0)
    	{
            scr_printf("	Could not load SMAP.IRX! %d\n", a);
    	return -1;
    	}
    
    	scr_printf("	Loaded SMAP.IRX!\n");
    
    	scr_printf("	Loaded irx modules\n");
    
    	a = ps2ip_init();
    	if (a != 0)
    	{
    	scr_printf("	Could not initialize! %d\n", a);
    	return -1;
    	}
    
    
    	/*t_ip_info *info;
    	struct ip_addr ip, nm, gw;
    	char* name = "test";
    
    	scr_printf("	memset\n");
    
    	memset(&info, 0, sizeof(info));
    	scr_printf("	netif_name\n");
    	strcpy(info->netif_name, name);
    	scr_printf("	ip address\n");
    	IP4_ADDR(&ip, 10, 0, 1, 100);
    	scr_printf("	storing ip in ipinfo\n");
    	info->ipaddr.s_addr = ip.addr;
    	scr_printf("	net mask\n");
    	IP4_ADDR(&nm, 255, 255, 255, 0);
    	scr_printf("	storing netmask\n");
    	info->netmask.s_addr = nm.addr;
    	scr_printf("	gateway\n");
    	IP4_ADDR(&gw, 10, 0, 1, 1);
    	scr_printf("	storing gateway\n");
    	info->gw.s_addr = gw.addr;
    	scr_printf("	storing dns\n");
    	info->dns_server.s_addr = gw.addr;
    
    	scr_printf("	setting config\n");
    
    	a = ps2ip_setconfig(info);
    	if (a <= 0)
    	{
    		scr_printf("	Could not set IP config for PS2IP! %d\n", a);
    		return -1;
    	}
    
    	scr_printf("	PS2 IP set!\n");*/
    
    	return 0;
    
    }
    
    int StartServer()
    {
    
    	int x;
    	struct ip_addr addr;
    
    	for (x = 0; x < 200000000; x++) //Delay so I can see if there are any initialization errors
    	{
    	}
    	scr_clear();
    
    	scr_printf("	Creating socket...\n");
    
    	int sockfd, newsockfd, portno = 2345;
         	socklen_t clilen;
         	char buffer[256];
         	struct sockaddr_in serv_addr, cli_addr;
         	int n;
         	sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP );
         	if (sockfd < 0)
    	{
            scr_printf("	Could not create socket!\n");
    	return -1;
    	}
    
    	scr_printf("	Socket created!\n	Binding Socket...\n");
    
    	memset((char *) &serv_addr, 0, sizeof(serv_addr));
         	serv_addr.sin_family = AF_INET;
    	IP4_ADDR(&addr, 10, 0, 1, 100); 
         	serv_addr.sin_addr.s_addr = addr.addr;
         	serv_addr.sin_port = htons(portno);
         	if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0)
    	{
            scr_printf("	Could not bind socket!\n");
    	return -1;
    	}
    
    	scr_printf("	Socket binded!\n");
    
    	scr_printf("	Port: %d\n", portno);
    
    	scr_printf("	Listening for any incoming connection...\n");
    
    	listen(sockfd,5);
         	clilen = sizeof(cli_addr);
         	newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
    	
    	scr_printf("	Accepting incoming connection...\n");
    
    	if (newsockfd < 0) 
    	{
            scr_printf("	An error occured while trying to accept the connection!\n");
    	return -1;
    	}
    
    	scr_printf("	Connected accepted!\n");
    
    	scr_printf("	Waiting for data to be sent...\n");
    
    	memset(buffer, 0, 256);
         	n = read(newsockfd,buffer,255);
         	if (n <= 0) { scr_printf("	Data could not be recieved!\n"); return -1; }
         	scr_printf("	Here is the message: %s\n", buffer);
         	//n = write(newsockfd,"I got your message",18);
         	//if (n <= 0) { scr_printf("	Data could not be sent!\n"); }
         	close(newsockfd);
         	close(sockfd);
    
    	return 0;
    
    }
    Last edited by dnawrkshp; 08-10-2012, 03:21:17 AM.

    Leave a comment:


  • dnawrkshp
    replied
    Originally posted by misfire View Post
    This might be a cure for your problems: http://mlafeldt.github.com/blog/2012...2-development/ (I wrote this piece)
    Well I fixed this by merging (did not replace a single file, probably just needed to run 'make' on some makefiles under ee and iop, but I am a tad lazy) the win32 pre-compiled PS2SDK (by Lazy Bastard) folder with my PS2SDK folder and it fixed all the problems!
    Last edited by dnawrkshp; 08-09-2012, 11:35:40 AM.

    Leave a comment:


  • dnawrkshp
    replied
    struct ip_addr ..; Derp! Hadn't noticed that! Losing my eyes... Thanks misfire!

    Leave a comment:


  • misfire
    replied
    This might be a cure for your problems: http://mlafeldt.github.com/blog/2012...2-development/ (I wrote this piece)

    Leave a comment:


  • dnawrkshp
    replied
    Well it seems that my ps2sdk was not up-to-date... Odd since I ran the toolchain after installing linux only a couple of months ago. Woah, tons of errors... Guess it's time to rebuild a few things. Thanks though, would never have realized that I was running an older version.

    Well I installed the sdk and added a few headers to ps2sdk/common/include/. Now the ps2sdk can't find the library ps2ip...
    Last edited by dnawrkshp; 08-09-2012, 06:40:13 AM.

    Leave a comment:


  • misfire
    replied
    Originally posted by dnawrkshp View Post
    I've looked in everything in ps2eth as well as the tcpip sources and I can't find the header file that allows me to use ip_addr. If I add an include for ip_addr.h, the compiler gives me a ton of redefinition warnings and '[main.o] Error 1'. It would seem that ps2ip.h isn't compatible with ip_addr.h. So what allows me to declare an ip? In the all I just want to use the ps2ip_setconfig() and ps2ip_getconfig() functions.
    Protip: Clone https://github.com/ps2dev/ps2sdk and run a "git grep ip_addr" so see how it is used. That's one of the first things I would do.
    Last edited by misfire; 08-09-2012, 03:30:53 AM.

    Leave a comment:


  • misfire
    replied
    Originally posted by LiquidManZero View Post
    Here's a question. When was the last time you tested ps2rd through a router? And if this did occur, what was the resulting operation?
    Actually, I've never used a router for PS2 stuff; only a switch or crossover cable.

    Leave a comment:


  • dnawrkshp
    replied
    I've looked in everything in ps2eth as well as the tcpip sources and I can't find the header file that allows me to use ip_addr. If I add an include for ip_addr.h, the compiler gives me a ton of redefinition warnings and '[main.o] Error 1'. It would seem that ps2ip.h isn't compatible with ip_addr.h. So what allows me to declare an ip? In the all I just want to use the ps2ip_setconfig() and ps2ip_getconfig() functions.
    Last edited by dnawrkshp; 08-09-2012, 02:33:42 AM.

    Leave a comment:


  • LiquidManZero
    replied
    Here's a question. When was the last time you tested ps2rd through a router? And if this did occur, what was the resulting operation?

    Leave a comment:


  • misfire
    replied
    Originally posted by LiquidManZero View Post
    That option was tested. Regardless of value if there was a router or switch between the ps2 and pc ends... The packets just got lost. Unless something's been done about that about the past 6 months that's still the case.

    There's only one obvious point of failure when all other homebrew using either of those two modules will work networked with that kind of hardware involved.
    I checked the sources again. The functionality of PS2SDK's SMAP module hasn't been touched at all by PS2rd. So when you set sms_modules to false and your IP configuration is correct, the SMAP module should work as in every other homebrew using it.

    With the SMS modules, the situation is different. We applied a couple of patches to force 100 Mbps full duplex mode. It is quite likely that this is causing problems, especially on newer consoles where the network chips are different.

    Leave a comment:


  • dnawrkshp
    replied
    Figured it out: http://forums.ps2dev.org/viewtopic.p...ight=ps2ipinit

    Also didn't realize that if I added the irx.o's to the Makefile, it still meant I had to load the irx's with SifLoadModule().

    Now works fine, no Makefile changes (unless I should get rid of the irx.o's).

    ip_addr.h seems to have conflicting definitions for a bunch of ip4_addr?'s. Is there a way around that? I am trying to be able to declare an ip address with 'ip_addr'.

    main.c:

    Code:
    #include <stdio.h>
    #include <debug.h>
    #include <kernel.h>
    #include "ps2ip.h"
    #include "smap/smap.h"
    #include "sifrpc.h"
    #include <iopcontrol.h>
    #include <loadfile.h>
    
    int Initialize(void);
    
    int main(void)
    {
    
    	Initialize();
    
    	return 0;
    
    }
    
    int Initialize(void)
    {
    
    	int a;
    	SifInitRpc(0);
    	init_scr();
    
    
    	scr_printf("	Beginning initialization!\n");
    	
    	a = SifLoadModule("mc1:/irx/POWEROFF.IRX", 0, NULL);
    	if (a < 0 ) //I don't like using ps2client, so I have a folder on my mc1 with some IRX modules
    	{
            scr_printf("	Could not load POWEROFF.IRX! %d\n", a);
    	return -1;
    	}
    
    	scr_printf("	Loaded POWEROFF.IRX!\n");
    
    	a = SifLoadModule("mc1:/irx/PS2DEV9.IRX", 0, NULL);
       	if (a < 0 )
    	{
            scr_printf("	Could not load PS2DEV9.IRX! %d\n", a);
    	return -1;
    	}
    
    	scr_printf("	Loaded PS2DEV9.IRX!\n");
    
    	a = SifLoadModule("mc1:/irx/PS2IP.IRX", 0, NULL);
    	if (a < 0 )
    	{
            scr_printf("	Could not load PS2IP.IRX!\n %d", a);
    	return -1;
    	}
    
    	scr_printf("	Loaded PS2IP.IRX!\n");
    
    	a = SifLoadModule("mc1:/irx/DNS.IRX", 0, NULL);
    	if (a < 0)
    	{
            scr_printf("	Could not load DNS.IRX! %d\n", a);
    	return -1;
    	}
    
    	scr_printf("	Loaded DNS.IRX!\n");
    
    	a = SifLoadModule("mc1:/irx/PS2IPS.IRX", 0, NULL);
    	if (a < 0)
    	{
            scr_printf("	Could not load PS2IPS.IRX! %d\n", a);
    	return -1;
    	}
    
    	scr_printf("	Loaded PS2IPS.IRX!\n");
    
    	a = SifLoadModule("mc1:/irx/DNS.IRX", 0, NULL);
    	if (a < 0)
    	{
            scr_printf("	Could not load SMAPX.IRX! %d\n", a);
    	return -1;
    	}
    
    	scr_printf("	Loaded SMAPX.IRX!\n");
    
    	scr_printf("	Loaded irx modules\n");
    
    	a = ps2ip_init();
    	if (a < 0)
    	{
    	scr_printf("	Could not initialize ps2ip %d\n", a);
    	return -1;
    	}
    
    	scr_printf("	Initialized ps2ip!\n");
    
    	return 0;
    
    }
    Last edited by dnawrkshp; 08-08-2012, 07:24:04 AM.

    Leave a comment:


  • dnawrkshp
    replied
    Okay got that working thanks misfire.

    I am now trying to get ps2ip_init() to work. It seems to freeze.

    Pyriel: Here's the makefile and main.c;

    main.c:

    Code:
    #include <stdio.h>
    #include <debug.h>
    #include "ps2ip.h"
    #include "smap/smap.h"
    #include <sifrpc.h>
    #include <iopcontrol.h>
    
    #include <loadfile.h>
    
    int main(void)
    
    {
    
    	SifInitRpc(0);
    	init_scr();
    
    	scr_printf("	Begun\n");
    	
       	if (SifLoadModule("mc1:/irx/PS2DEV9.IRX", 0, NULL) < 0 ) //I don't like using ps2client, so I have a folder with some irx modules
    	{
            scr_printf("	Could not load PS2DEV9.IRX!\n");
    	return -1;
    	}
    
    	scr_printf("	Loaded irx modules\n");
    
    	ps2ip_init();
    
    	scr_printf("	Initialized ps2ip!\n");
    
    	return 0;
    
    }
    Makefile;

    Code:
    EE_BIN = ethtest.elf
    
    EE_OBJS = main.o Obj/ps2smap_irx.o Obj/ps2ip_irx.o Obj/ps2ips_irx.o
    
    EE_LIBS = -lps2ip -lc -ldebug
    
    
    
    all: $(EE_BIN)
    
    
    
    clean:
    
    	rm -f *.elf *.o
    
    
    
    include $(PS2SDK)/samples/Makefile.pref
    
    include $(PS2SDK)/samples/Makefile.eeglobal
    When I run that the screen prints out:

    Begun
    Loaded irx modules

    and then nothing.
    Last edited by dnawrkshp; 08-07-2012, 11:07:08 PM.

    Leave a comment:


  • LiquidManZero
    replied
    Originally posted by misfire View Post
    That's completely wrong.

    1) PS2rd allows you to select which SMAP implementation to use; either the standard PS2SDK module or the SMS variant. See https://github.com/mlafeldt/ps2rd/bl...p.txt#L102-105
    That option was tested. Regardless of value if there was a router or switch between the ps2 and pc ends... The packets just got lost. Unless something's been done about that about the past 6 months that's still the case.

    There's only one obvious point of failure when all other homebrew using either of those two modules will work networked with that kind of hardware involved.

    Leave a comment:


  • misfire
    replied
    Could it be that you're trying to call SMAPInit() from EE? Actually, it's a local function that is called from inside the SMAP IOP module (*.irx). More precisely, the SMAP module accepts IP, network mask, and gateway as arguments and then passes them to SMAPInit(). All that is done inside _start() which is run when the module is loaded from EE. See https://github.com/mlafeldt/ps2rd/bl...ain.c#L492-538

    Leave a comment:


  • Pyriel
    replied
    For one thing, if smap.h is part of your project, you should probably have its include in quotes rather than brackets. Your issue is how you're attempting to build smap into your project. Whether it's just a makefile issue or something a bit more expansive I can't say, since all you've provided is your C code.

    Leave a comment:

Working...
X