3
A brief file description
5
@section license License
7
Licensed to the Apache Software Foundation (ASF) under one
8
or more contributor license agreements. See the NOTICE file
9
distributed with this work for additional information
10
regarding copyright ownership. The ASF licenses this file
11
to you under the Apache License, Version 2.0 (the
12
"License"); you may not use this file except in compliance
13
with the License. You may obtain a copy of the License at
15
http://www.apache.org/licenses/LICENSE-2.0
17
Unless required by applicable law or agreed to in writing, software
18
distributed under the License is distributed on an "AS IS" BASIS,
19
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
See the License for the specific language governing permissions and
21
limitations under the License.
24
/****************************************************************************
27
This file provides UDP interface. To be included in I_Net.h
30
****************************************************************************/
35
#include "I_Version.h"
36
#include "I_EventSystem.h"
40
You can create UDPConnections for asynchronous send/receive or call
41
directly (inefficiently) into network layer.
43
class UDPNetProcessor:public Processor
46
virtual int start(int n_upd_threads) = 0;
48
//this function was interanal intially.. this is required for public and
49
//interface probably should change.
50
bool CreateUDPSocket(int *resfd, struct sockaddr_in *addr,
52
int my_port, unsigned int my_ip = 0, int send_bufsize = 0, int recv_bufsize = 0);
57
Why was this implemented as an asynchronous call? Just in case
58
Windows requires it...
61
cont->handleEvent( NET_EVENT_DATAGRAM_OPEN, UDPConnection *) is
62
called for new socket.
64
@param c Continuation that is called back with newly created
66
@param my_port Local port to be bound (required)
67
@param my_ip Local IP to be bound (optional). Defaults to '0' (INADDR_ANY)
68
@param send_bufsize (optional) Socket buffer size for sending.
69
Limits how much outstanding data to OS before it is able to send
71
@param recv_bufsize (optional) Socket buffer size for sending.
72
Limits how much can be queued by OS before we read it.
73
@return Action* Always returns ACTION_RESULT_DONE if socket was
74
created successfuly, or ACTION_IO_ERROR if not.
76
inkcoreapi Action *UDPBind(Continuation * c, int my_port, int my_ip = 0, int send_bufsize = 0, int recv_bufsize = 0);
78
// The mess again: the complier won't let me stick UDPConnection here.
79
void UDPClassifyConnection(Continuation * udpConn, int destIP);
81
// create pairs of UDPConnections in which the first connection is
82
// on a even-#'ed port and the second connection is on the next
83
// odd-#'ed port. Create "nPairs" of such connections.
84
Action *UDPCreatePortPairs(Continuation *, int nPairs,
85
unsigned int myIP = 0,
86
unsigned int destIP = 0, int send_bufsize = 0, int recv_bufsize = 0);
88
// Regarding sendto_re, sendmsg_re, recvfrom_re:
89
// * You may be called back on 'c' with completion or error status.
90
// * 'token' is an opaque which can be used by caller to match up the I/O
91
// with the completion event.
92
// * If IOBufferBlock * is passed in the interface, it is reference
93
// counted internally.
94
// * For recvfrom_re, data is written beginning at IOBufferBlock::end() and
95
// the IOBufferBlock is not fill()'ed until I/O actually occurs. This
96
// kind of implies that you can only have one outstanding I/O per
99
// * callback signature is: handleEvent(int event,CompletionEvent *cevent);
100
// where event is one of:
101
// NET_EVENT_DATAGRAM_WRITE_COMPLETE
102
// NET_EVENT_DATAGRAM_WRITE_ERROR
103
// * You can get the value of 'token' that you passed in by calling
104
// completionUtil::getHandle(cevent);
105
// * You can get other info about the completed operation through use
106
// of the completionUtil class.
107
Action *sendto_re(Continuation * c, void *token, int fd,
108
struct sockaddr *toaddr, int toaddrlen, IOBufferBlock * buf, int len);
109
// I/O buffers referenced by msg must be pinned by the caller until
110
// continuation is called back.
111
Action *sendmsg_re(Continuation * c, void *token, int fd, struct msghdr *msg);
113
Action *recvfrom_re(Continuation * c, void *token, int fd,
114
struct sockaddr *fromaddr, socklen_t *fromaddrlen,
115
IOBufferBlock * buf, int len, bool useReadCont = true, int timeout = 0);
116
// Continuation is really a UDPConnection; due to the include mess, we stick in the
117
// base-class of UDPConnection.
118
bool AllocBandwidth(Continuation * udpConn, double desiredMbps);
119
bool ChangeBandwidth(Continuation * udpConn, double desiredMbps);
120
void FreeBandwidth(Continuation * udpConn);
121
double GetAvailableBandwidth();
123
virtual void UDPNetProcessor_is_abstract() = 0;
127
inkcoreapi extern UDPNetProcessor & udpNet;
129
#include "I_UDPPacket.h"
130
#include "I_UDPConnection.h"