Announcement

Collapse
No announcement yet.

Getting started with ps2smap

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

  • #16
    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.

    Comment


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

      Comment


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

        Comment


        • #19
          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.

          Comment


          • #20
            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.

            Comment

            Working...
            X