source: abuse/tags/pd/abuse/src/net/dos4gw/bwtcp.c @ 49

Last change on this file since 49 was 49, checked in by Sam Hocevar, 12 years ago
  • Imported original public domain release, for future reference.
  • Property svn:keywords set to Id
File size: 1.9 KB
Line 
1
2unsigned long bw_tcp_protocol::bw_get_server_ip(char *sn)
3{
4  int a,b,c,d;
5  if (sscanf(sn,"%d.%d.%d.%d",&a,&b,&c,&d)==4 &&
6      a>=0 && b>=0 && c>=0 && d>=0 &&
7      a<256 && b<256 && c<256 && d<256)
8  {
9    unsigned char c[4];
10    c[0]=a;  c[1]=b;  c[2]=c;  c[3]=d;
11    return ((unsigned long *)c);
12  }
13  return 0;
14}
15
16
17bw_tcp_protocol::bw_tcpip_protocol()
18{
19}
20
21net_address *bw_tcp_protocol::get_node_address(char *&server_name, int def_port, int force_port)
22{
23  char name[256],*np;
24  np=name;
25  while (*server_name && *server_name!=':' && *server_name!='/')
26    *(np++)=*(server_name)++;
27  *np=0;
28  if (*server_name==':')
29  {
30    server_name++;
31    char port[256],*p;
32    p=port;
33    while (*server_name && *server_name!='/')
34      *(p++)=*(server_name++);
35    *p=0;
36    int x;
37    if (!force_port)
38    {
39      if (sscanf(port,"%d",&x)==1) def_port=x;
40      else return 0;
41    }
42  }
43
44  if (*server_name=='/') server_name++;
45  unsigned long x=bw_get_server_ip(server_name);
46  if (x)
47    return new bwip_address(x,def_port);
48  else return NULL;
49}
50
51
52net_socket *bw_tcp_protocol::connect_to_server(net_address *addr,
53                                               net_socket::socket_type sock_type=net_socket::SOCKET_SECURE)
54{
55  if (sock_type==net_socket::SOCKET_SECURE)
56  {
57   
58int bwt_socket()
59{
60  memset(&rm,0,sizeof(rm));
61
62  strcpy((char *)low_sock_mem, "TCP-IP10");
63  rm.eax = 0x3d42;
64  rm.ds = low_sock_mem_seg;
65  rm.edx = low_sock_mem_off;
66  RM_intr(0x21,&rm);
67  if (rm.flags & 1)
68  {
69    current_sock_err=SOCK_CREATE_FAIL;
70    sprintf(last_sock_err,"Unable to create socket");   
71    return -1;
72  } 
73  int fd = (rm.eax&0xffff);
74
75
76  rm.eax=0x4401;
77  rm.edx=0x60;
78  rm.ebx=fd;
79  RM_intr(0x21,&rm);
80
81
82  // internal layer must be told to reclaim internal buffers
83  low_sock_mem[0]=6;
84  low_sock_mem[1]=0x80;
85  bwt_ioctl_write(fd, 2);
86  return fd;
87
88}
89
90
91  } else
92  {
93  }
94}
95
96  net_socket *create_listen_socket(int port, net_socket::socket_type sock_type);
97  int select_sockets();
Note: See TracBrowser for help on using the repository browser.