UbixOS
2.0
bot.c
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2001, Swedish Institute of Computer Science.
3
* All rights reserved.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
7
* are met:
8
* 1. Redistributions of source code must retain the above copyright
9
* notice, this list of conditions and the following disclaimer.
10
* 2. Redistributions in binary form must reproduce the above copyright
11
* notice, this list of conditions and the following disclaimer in the
12
* documentation and/or other materials provided with the distribution.
13
* 3. Neither the name of the Institute nor the names of its contributors
14
* may be used to endorse or promote products derived from this software
15
* without specific prior written permission.
16
*
17
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
* SUCH DAMAGE.
28
*
29
* This file is part of the lwIP TCP/IP stack.
30
*
31
* Author: Adam Dunkels <adam@sics.se>
32
*
33
* $Id: bot.c 54 2016-01-11 01:29:55Z reddawg $
34
*/
35
36
#include <
lib/kmalloc.h
>
37
#include <
lib/kprintf.h
>
38
#include <
string.h
>
39
40
#include "
net/mem.h
"
41
#include "
net/debug.h
"
42
#include "
net/def.h
"
43
#include "
net/api.h
"
44
#include "
net/stats.h
"
45
46
/* UBU
47
static void sendstr(const char *str, struct netconn *conn) {
48
netconn_write(conn, (void *)str, strlen(str), NETCONN_NOCOPY);
49
}
50
51
static void botErr() {
52
kprintf("ERRROR\n");
53
}
54
*/
55
56
static
void
bot_thread(
void
*arg) {
57
struct
netconn *conn;
58
int
len;
59
char
bufr[1500];
60
struct
ip_addr ipaddr;
61
struct
netbuf *
buf
= 0x0;
62
63
IP4_ADDR(&ipaddr,216,152,77,10);
64
conn = netconn_new(NETCONN_TCP);
65
kprintf
(
"Starting UbixOS Bot\n"
);
66
while
(1) {
67
kprintf
(
"[A"
);
68
kprintf
(
"\n\nCONNECT: [%i]\n"
,netconn_connect(conn,&ipaddr,6667));
69
kprintf
(
"B]"
);
70
while
(1);
71
if
(
buf
!=
NULL
) {
72
buf
= netconn_recv(conn);
73
netbuf_copy(
buf
, bufr, 1024);
74
len = netbuf_len(
buf
);
75
netbuf_delete(
buf
);
76
bufr[len-2] =
'\0'
;
77
kprintf
(
"Bufr: [%s:%i]"
,bufr,len);
78
//sendstr("BLah\n",conn);
79
}
80
}
81
}
82
83
void
bot_init
(
void
) {
84
sys_thread_new
(bot_thread,
NULL
);
85
}
86
87
/***
88
END
89
***/
90
def.h
string.h
sys_thread_new
sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stacksize, int prio)
Definition:
sys_arch.c:378
stats.h
kprintf.h
buf
Definition:
buf.h:35
bot_init
void bot_init(void)
Definition:
bot.c:83
mem.h
kprintf
int kprintf(const char *,...)
Definition:
kprintf.c:259
kmalloc.h
debug.h
api.h
NULL
#define NULL
Definition:
fat_string.h:17
net
net
bot.c
Generated by
1.8.16