Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3927 kaitz 1
eax = 74 - Work directly with network interface
2
ebx = -1 (Get number of active network devices)
3
 
4
    out:
5
        eax = number of active network devices
6
 
7
bh = device number, for all following functions !
8
 
9
bl = 0 (Get device type)
10
 
11
    out:
12
        eax = device type number
13
 
14
bl = 1 (Get device name)
15
 
16
    in:
17
        ecx = pointer to 64 byte buffer
18
    out:
19
        name is copied into the buffer
20
        eax = -1 on error
21
 
22
bl = 2 (Reset the device)
23
 
24
    in
25
        none
26
    out
27
        eax = -1 on error
28
 
29
bl = 3 (Stop device)
30
 
31
    in
32
        none
33
    out
34
        eax = -1 on error
35
 
36
TO BE FIGURED OUT
37
 
38
eax = 75 - Work with Sockets
39
 
40
These functions work like the ones found in UNIX (and windows)
41
for more info, please read http://beej.us/guide/bgnet/
42
 
43
bl = 0 (Open Socket)
44
 
45
    in:
46
        ecx = domain
47
        edx = type
48
        esi = protocol
49
    out:
50
        eax = socket number, -1 on error
51
 
52
bl = 1 (Close Socket)
53
 
54
    in:
55
        ecx = socket number
56
    out:
57
        eax = -1 on error
58
 
59
bl = 2 (Bind)
60
 
61
    in:
62
        ecx = socket number
63
        edx = pointer to sockaddr structure
64
        esi = length of sockaddr structure
65
    out:
66
        eax = -1 on error
67
 
68
bl = 3 (Listen)
69
 
70
    in:
71
        ecx = socket number
72
        edx = backlog
73
    out:
74
        eax = -1 on error
75
 
76
bl = 4 (connect)
77
 
78
    in:
79
        ecx = socket number
80
        edx = pointer to sockaddr structure
81
        esi = length of sockaddr structure
82
    out:
83
        eax = -1 on error
84
 
85
bl = 5 (accept)
86
 
87
    in:
88
        ecx = socket number
89
        edx = pointer to sockaddr structure
90
        esi = length of sockaddr structure
91
    out:
92
        eax = socket number, -1 on error
93
 
94
bl = 6 (send)
95
 
96
    in:
97
        ecx = socket number
98
        edx = pointer to buffer
99
        esi = length of buffer
100
        edi = flags
101
    out:
102
        eax = -1 on error
103
 
104
bl = 7 (receive)
105
 
106
    in:
107
        ecx = socket number
108
        edx = pointer to buffer
109
        esi = length of buffer
110
        edi = flags
111
    out:
112
        eax = number of bytes copied, -1 on error
113
 
114
bl = 8 (set socket options)
115
 
116
    in:
117
        ecx = socket number
118
        edx = level
119
        esi = optionname
120
        edi = ptr to buffer
121
 
122
The buffer's first dword is the length of the buffer, minus the first dword offcourse
123
 
124
    out:
125
        eax = -1 on error
126
 
127
bl = 9 (get socket options
128
 
129
    in:
130
        ecx = socket number
131
        edx = level
132
        esi = optionname
133
        edi = ptr to buffer
134
 
135
The buffer's first dword is the length of the buffer, minus the first dword offcourse
136
 
137
    out:
138
        eax = -1 on error, socket option otherwise
139
 
140
TIP
141
 
142
when you import 'network.inc' and 'macros.inc' into your source code, you can use the following syntax to work with sockets:
143
 
144
 
145
for example, to open a socket
146
 
147
mcall socket, AF_INET, SOCK_DGRAM,0
148
mov [socketnum], eax
149
 
150
then to connect to a server
151
 
152
mcall connect, [socketnum], sockaddr, 18
153
 
154
 
155
eax = 76 - Work with protocols
156
 
157
high half of ebx = protocol number (for all subfunctions!)
158
bh = device number (for all subfunctions!)
159
bl = subfunction number, depends on protocol type
160
 
161
For Ethernet protocol
162
 
163
 
164
1 - Read # Packets received
165
2 - Read # Bytes send
166
3 - Read # Bytes received
167
4 - Read MAC
168
5 - Write MAC
169
6 - Read IN-QUEUE size
170
7 - Read OUT-QUEUE size
171
For IPv4 protocol
172
 
173
 
174
1 - Read # IP packets received
175
2 - Read IP
176
3 - Write IP
177
4 - Read DNS
178
5 - Write DNS
179
6 - Read subnet
180
7 - Write subnet
181
8 - Read gateway
182
9 - Write gateway
183
For ARP protocol
184
 
185
 
186
1 - Read # ARP packets received
187
2 - Get # ARP entry's
188
3 - Read ARP entry
189
4 - Add static ARP entry
190
5 - Remove ARP entry (-1 = remove all)
191
For ICMP protocol
192
 
193
 
194
1 - Read # ICMP packets received
195
3 - enable/disable ICMP echo reply
196
For UDP protocol
197
 
198
 
199
1 - Read # UDP packets received
200
For TCP protocol
201
 
202
 
203
1 - Read # TCP packets received