📄 lnet.h
字号:
/*
* LNet.h
*
* Created on: 2008-10-19
* Author: Administrator
*/
#ifndef LNET_H_
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/select.h>
#include <errno.h>
#include <pspsdk.h>
#include <pspwlan.h>
#include <pspnet_inet.h>
#include <pspnet_apctl.h>
#include <pspnet_resolver.h>
#include <psputility_netmodules.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <fcntl.h>
#include <sys/fd_set.h>
#include <time.h>
// #include <sys/tape.h>
#include <sys/signal.h>
#include <sys/errno.h>
#include <sys/types.h>
#include <fcntl.h> // #include <sys/ioctl.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netdb.h>
// #include <zlib.h>
#include <unistd.h>
#include <netinet/in.h>
#include <errno.h>
/* PSP includes */
#include <pspctrl.h>
#include <pspdisplay.h>
#include <pspnet.h>
#include <pspnet_resolver.h>
#include <psputility_netmodules.h>
#include <psputility.h>
typedef struct parsedmsg {
int errcode; //错误代码
int optcode; //业务代码
int ctlcode; //操作代码
char * databuf; //数据包
} parsedmsg;
typedef struct lnetconfig{
int netConfIndex;
netData name; //param0
netData ssid; //param1
netData localip; //param5
netData subnet; //param6
netData gateway; //param7
}lncfg;
typedef struct SocketsMsg { /* 套接字消息结构 */
int AcceptNum; /* 指示是否有外来连接等待接收 */
int ReadNum; /* 有外来数据等待读取的连接数 */
int ReadQueue[32]; /* 有外来数据等待读取的连接队列 */
int WriteNum; /* 可以发送数据的连接数 */
int WriteQueue[32]; /* 可以发送数据的连接队列 */
int ExceptNum; /* 有例外的连接数 */
int ExceptQueue[32]; /* 有例外的连接队列 */
} SocketsMsg;
typedef struct Sockets { /* 套接字结构 */
int DaemonSock; /* 主套接字 */
int SockNum; /* 数据套接字数目 */
int Sockets[8]; /* 数据套接字数组 */
fd_set readfds, writefds, exceptfds; /* 要被检测的可读、可写、例外的套接字集合 */
int Port; /* 端口号 */
} Sockets;
#define LNET_H_
class LNet {
public:
Sockets Mysock; /* 全局变量 */
SocketsMsg SockMsg;
LNet();
virtual ~LNet();
void LSock(char * LIp);
char * LSock();
void LPort(uint16_t m_LProt);
uint16_t LPort();
int LNetStart(char * LIp, uint16_t port, int config); //连接服务器
int CloseConnection(int Sockno);
int QuerySocketsMsg();
int LNetRecvBuff(int sockno, char * buff, int size);
int LNetSendBuff(int Sockno, char * buff, int len);
void getNetConfig(int config);
int getconfAcount();
char * getName();
char * getSSID();
char * getGateway();
parsedmsg getmsg(char * buf);
char * putpacket(parsedmsg * msg);
private:
int LMakeSocket(char * LIp, uint16_t port);
int LNetSetup();
int LNetconnect_to_apctl(int config);
int initflage;
char * m_LIp;
uint16_t m_LPort;
struct sockaddr_in m_LSocket;
char m_LRecvBuff[1024];
int confIndex;
lncfg *conf;
};
#endif /* LNET_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -