Skip to content

Commit

Permalink
Cleaned up net headers: moved socket, poll, select to sys. Put lv2 sy…
Browse files Browse the repository at this point in the history
…sNet functions in their own header in sysutil. Moved netdb.h to root of include/. I know this will address ps3dev#5
  • Loading branch information
dee12452 committed Jul 3, 2020
1 parent ac6fce1 commit 663a59a
Show file tree
Hide file tree
Showing 17 changed files with 298 additions and 317 deletions.
1 change: 0 additions & 1 deletion ppu/include/arpa/inet.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef __INET_H__
#define __INET_H__

#include <stdint.h>
#include <netinet/in.h>

#define htonl(hostlong) (hostlong)
Expand Down
18 changes: 9 additions & 9 deletions ppu/include/net/net.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#ifndef __LV2_NET_H__
#define __LV2_NET_H__
#ifndef __NET_H__
#define __NET_H__

#include <net/socket.h>
#include <net/select.h>
#include <net/poll.h>
#include <socket.h>
#include <select.h>
#include <poll.h>

#ifdef __cplusplus
extern "C" {
#endif

#define NET_EPERM 1
#define NET_ENOENT 2
Expand Down Expand Up @@ -103,10 +107,6 @@
#define net_errno (*netErrnoLoc())
#define net_h_errno (*netHErrnoLoc())

#ifdef __cplusplus
extern "C" {
#endif

struct net_msghdr
{
u32 _pad0;
Expand Down
90 changes: 0 additions & 90 deletions ppu/include/net/netdb.h

This file was deleted.

29 changes: 0 additions & 29 deletions ppu/include/net/select.h

This file was deleted.

121 changes: 0 additions & 121 deletions ppu/include/net/socket.h

This file was deleted.

91 changes: 90 additions & 1 deletion ppu/include/netdb.h
Original file line number Diff line number Diff line change
@@ -1 +1,90 @@
#include <net/netdb.h>
#ifndef __NETDB_H__
#define __NETDB_H__

#include <socket.h>

#define NETDB_INTERNAL -1
#define NETDB_SUCCESS 0x00
#define HOST_NOT_FOUND 0x01
#define TRY_AGAIN 0x02
#define NO_RECOVERY 0x03
#define NO_DATA 0x04
#define NO_ADDRESS NO_DATA

#define NI_MAXHOST 1025
#define NI_MAXSERV 32

#define NI_NUMERICHOST 1 /* Don't try to look up hostname. */
#define NI_NUMERICSERV 2 /* Don't convert port number to name. */
#define NI_NOFQDN 4 /* Only return nodename portion. */
#define NI_NAMEREQD 8 /* Don't return numeric addresses. */
#define NI_DGRAM 16 /* Look up UDP service rather than TCP. */
#define NI_IDN 32 /* Convert name from IDN format. */
#define NI_IDN_ALLOW_UNASSIGNED 64 /* Don't reject unassigned Unicode
code points. */
#define NI_IDN_USE_STD3_ASCII_RULES 128 /* Validate strings according to
STD3 rules. */
/* Possible values for `ai_flags' field in `addrinfo' structure. */
#define AI_PASSIVE 0x0001 /* Socket address is intended for `bind'. */
#define AI_CANONNAME 0x0002 /* Request for canonical name. */
#define AI_NUMERICHOST 0x0004 /* Don't use name resolution. */
#define AI_V4MAPPED 0x0008 /* IPv4 mapped addresses are acceptable. */
#define AI_ALL 0x0010 /* Return IPv4 mapped and IPv6 addresses. */
#define AI_ADDRCONFIG 0x0020 /* Use configuration of this host to choose
returned address type.. */
#define AI_IDN 0x0040 /* IDN encode input (assuming it is encoded
in the current locale's character set)
before looking it up. */
#define AI_CANONIDN 0x0080 /* Translate canonical name from IDN format. */
#define AI_IDN_ALLOW_UNASSIGNED 0x0100 /* Don't reject unassigned Unicode
code points. */
#define AI_IDN_USE_STD3_ASCII_RULES 0x0200 /* Validate strings according to
STD3 rules. */

extern int h_errno;

struct hostent
{
char *h_name;
char **h_aliases;
int h_addrtype;
int h_length;
char **h_addr_list;
#define h_addr h_addr_list[0]
};


struct servent
{
char *s_name; /* Official service name. */
char **s_aliases; /* Alias list. */
int s_port; /* Port number. */
char *s_proto; /* Protocol to use. */
};

/* Structure to contain information about address of a service provider. */
struct addrinfo
{
int ai_flags; /* Input flags. */
int ai_family; /* Protocol family for socket. */
int ai_socktype; /* Socket type. */
int ai_protocol; /* Protocol for socket. */
socklen_t ai_addrlen; /* Length of socket address. */
struct sockaddr *ai_addr; /* Socket address for socket. */
char *ai_canonname; /* Canonical name for service location. */
struct addrinfo *ai_next; /* Pointer to next in list. */
};

#ifdef __cplusplus
extern "C" {
#endif

struct hostent* gethostbyaddr(const char *addr,socklen_t len,int tpye);
struct hostent* gethostbyname(const char *name);
struct servent *getservbyport(int port, const char *proto);

#ifdef __cplusplus
}
#endif

#endif
6 changes: 1 addition & 5 deletions ppu/include/netinet/in.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#ifndef __IN_H__
#define __IN_H__

#include <socket.h>
#include <ppu-types.h>
#include <net/socket.h>


#define IPPROTO_IP 0x00
#define IPPROTO_ICMP 0x01
Expand Down Expand Up @@ -88,7 +87,4 @@ struct ip_mreq
struct in_addr imr_interface;
};


#include <arpa/inet.h>

#endif
Loading

0 comments on commit 663a59a

Please sign in to comment.