1 Copyright (C) 2010 RĂ©mi Denis-Courmont.
2 Licensed under GNU General Public License version 2 or higher.
3 diff -ru live.orig/groupsock/Groupsock.cpp live/groupsock/Groupsock.cpp
4 --- live.orig/groupsock/Groupsock.cpp 2010-05-30 01:20:31.000000000 +0300
5 +++ live/groupsock/Groupsock.cpp 2010-06-06 00:34:03.000000000 +0300
12 env() << *this << ": read " << bytesRead << " bytes from ";
13 - env() << our_inet_ntoa(fromAddress.sin_addr);
14 + env() << our_inet_ntoa(fromAddress.sin_addr, buf);
16 env() << "; relayed to " << numMembers << " members";
21 UsageEnvironment& operator<<(UsageEnvironment& s, const Groupsock& g) {
23 UsageEnvironment& s1 = s << timestampString() << " Groupsock("
24 << g.socketNum() << ": "
25 - << our_inet_ntoa(g.groupAddress())
26 + << our_inet_ntoa(g.groupAddress(), buf)
27 << ", " << g.port() << ", ";
29 return s1 << "SSM source: "
30 - << our_inet_ntoa(g.sourceFilterAddress()) << ")";
31 + << our_inet_ntoa(g.sourceFilterAddress(), buf) << ")";
33 return s1 << (unsigned)(g.ttl()) << ")";
35 diff -ru live.orig/groupsock/include/GroupsockHelper.hh live/groupsock/include/GroupsockHelper.hh
36 --- live.orig/groupsock/include/GroupsockHelper.hh 2010-05-30 01:20:31.000000000 +0300
37 +++ live/groupsock/include/GroupsockHelper.hh 2010-06-06 00:34:03.000000000 +0300
40 // The following are implemented in inet.c:
41 extern "C" netAddressBits our_inet_addr(char const*);
42 -extern "C" char* our_inet_ntoa(struct in_addr);
43 +extern "C" char* our_inet_ntoa(struct in_addr, char *);
44 extern "C" struct hostent* our_gethostbyname(char* name);
45 extern "C" void our_srandom(int x);
46 extern "C" long our_random();
47 diff -ru live.orig/groupsock/inet.c live/groupsock/inet.c
48 --- live.orig/groupsock/inet.c 2010-05-30 01:20:31.000000000 +0300
49 +++ live/groupsock/inet.c 2010-06-06 00:39:12.000000000 +0300
56 +our_inet_ntoa(in, result)
61 - return inet_ntoa(in);
63 + char *ret = inet_ntoa(in);
65 + strncpy(result, ret, 16);
67 +#elif !defined (VXWORKS)
68 + inet_ntop(AF_INET, &in, result, 16);
71 - /* according the man pages of inet_ntoa :
74 - The return value from inet_ntoa() points to a buffer which
75 - is overwritten on each call. This buffer is implemented as
76 - thread-specific data in multithreaded applications.
78 - the vxworks version of inet_ntoa allocates a buffer for each
79 - ip address string, and does not reuse the same buffer.
81 - this is merely to simulate the same behaviour (not multithread
84 - static char result[INET_ADDR_LEN];
85 inet_ntoa_b(in, result);
88 diff -ru live.orig/liveMedia/DarwinInjector.cpp live/liveMedia/DarwinInjector.cpp
89 --- live.orig/liveMedia/DarwinInjector.cpp 2010-05-30 01:20:31.000000000 +0300
90 +++ live/liveMedia/DarwinInjector.cpp 2010-06-06 00:34:03.000000000 +0300
92 NetAddress const* address = addresses.firstAddress();
93 addr.s_addr = *(unsigned*)(address->data());
95 - char const* remoteRTSPServerAddressStr = our_inet_ntoa(addr);
97 + char const* remoteRTSPServerAddressStr = our_inet_ntoa(addr, buf);
99 // Construct a SDP description for the session that we'll be streaming:
100 char const* const sdpFmt =
101 diff -ru live.orig/liveMedia/OnDemandServerMediaSubsession.cpp live/liveMedia/OnDemandServerMediaSubsession.cpp
102 --- live.orig/liveMedia/OnDemandServerMediaSubsession.cpp 2010-05-30 01:20:31.000000000 +0300
103 +++ live/liveMedia/OnDemandServerMediaSubsession.cpp 2010-06-06 00:34:03.000000000 +0300
105 char const* mediaType = rtpSink->sdpMediaType();
106 unsigned char rtpPayloadType = rtpSink->rtpPayloadType();
107 struct in_addr serverAddrForSDP; serverAddrForSDP.s_addr = fServerAddressForSDP;
108 - char* const ipAddressStr = strDup(our_inet_ntoa(serverAddrForSDP));
109 + char ipAddressStr[16];
110 + our_inet_ntoa(serverAddrForSDP, ipAddressStr);
111 char* rtpmapLine = rtpSink->rtpmapLine();
112 char const* rangeLine = rangeSDPLine();
113 char const* auxSDPLine = getAuxSDPLine(rtpSink, inputSource);
115 rangeLine, // a=range:... (if present)
116 auxSDPLine, // optional extra SDP line
117 trackId()); // a=control:<track-id>
118 - delete[] (char*)rangeLine; delete[] rtpmapLine; delete[] ipAddressStr;
119 + delete[] (char*)rangeLine; delete[] rtpmapLine;
121 fSDPLines = strDup(sdpLines);
123 diff -ru live.orig/liveMedia/PassiveServerMediaSubsession.cpp live/liveMedia/PassiveServerMediaSubsession.cpp
124 --- live.orig/liveMedia/PassiveServerMediaSubsession.cpp 2010-05-30 01:20:31.000000000 +0300
125 +++ live/liveMedia/PassiveServerMediaSubsession.cpp 2010-06-06 00:34:03.000000000 +0300
127 char const* auxSDPLine = fRTPSink.auxSDPLine();
128 if (auxSDPLine == NULL) auxSDPLine = "";
130 - char* const ipAddressStr = strDup(our_inet_ntoa(ipAddress));
131 + char ipAddressStr[16];
132 + our_inet_ntoa(ipAddress, ipAddressStr);
134 char const* const sdpFmt =
135 "m=%s %d RTP/AVP %d\r\n"
137 rangeLine, // a=range:... (if present)
138 auxSDPLine, // optional extra SDP line
139 trackId()); // a=control:<track-id>
140 - delete[] ipAddressStr; delete[] (char*)rangeLine; delete[] rtpmapLine;
141 + delete[] (char*)rangeLine; delete[] rtpmapLine;
143 fSDPLines = strDup(sdpLines);
145 diff -ru live.orig/liveMedia/RTCP.cpp live/liveMedia/RTCP.cpp
146 --- live.orig/liveMedia/RTCP.cpp 2010-05-30 01:20:31.000000000 +0300
147 +++ live/liveMedia/RTCP.cpp 2010-06-06 00:34:03.000000000 +0300
152 - fprintf(stderr, "[%p]saw incoming RTCP packet (from address %s, port %d)\n", this, our_inet_ntoa(fromAddress.sin_addr), ntohs(fromAddress.sin_port));
154 + fprintf(stderr, "[%p]saw incoming RTCP packet (from address %s, port %d)\n", this, our_inet_ntoa(fromAddress.sin_addr, buf), ntohs(fromAddress.sin_port));
155 unsigned char* p = pkt;
156 for (unsigned i = 0; i < packetSize; ++i) {
157 if (i%4 == 0) fprintf(stderr, " ");
158 diff -ru live.orig/liveMedia/RTSPClient.cpp live/liveMedia/RTSPClient.cpp
159 --- live.orig/liveMedia/RTSPClient.cpp 2010-05-30 01:20:31.000000000 +0300
160 +++ live/liveMedia/RTSPClient.cpp 2010-06-06 00:39:08.000000000 +0300
162 int RTSPClient::connectToServer(int socketNum, portNumBits remotePortNum) {
163 MAKE_SOCKADDR_IN(remoteName, fServerAddress, htons(remotePortNum));
164 if (fVerbosityLevel >= 1) {
165 - envir() << "Opening connection to " << our_inet_ntoa(remoteName.sin_addr) << ", port " << remotePortNum << "...\n";
167 + envir() << "Opening connection to " << our_inet_ntoa(remoteName.sin_addr, buf) << ", port " << remotePortNum << "...\n";
169 if (connect(socketNum, (struct sockaddr*) &remoteName, sizeof remoteName) != 0) {
170 if (envir().getErrno() == EINPROGRESS) {
171 diff -ru live.orig/liveMedia/RTSPOverHTTPServer.cpp live/liveMedia/RTSPOverHTTPServer.cpp
172 --- live.orig/liveMedia/RTSPOverHTTPServer.cpp 2010-05-30 01:20:31.000000000 +0300
173 +++ live/liveMedia/RTSPOverHTTPServer.cpp 2010-06-06 00:34:03.000000000 +0300
175 makeSocketNonBlocking(clientSocket);
176 increaseSendBufferTo(envir(), clientSocket, 50*1024);
177 #if defined(DEBUG) || defined(DEBUG_CONNECTIONS)
178 - fprintf(stderr, "accept()ed connection from %s\n", our_inet_ntoa(clientAddr.sin_addr));
180 + fprintf(stderr, "accept()ed connection from %s\n", our_inet_ntoa(clientAddr.sin_addr, buf));
183 // Create a new object for handling this HTTP connection:
184 diff -ru live.orig/liveMedia/RTSPServer.cpp live/liveMedia/RTSPServer.cpp
185 --- live.orig/liveMedia/RTSPServer.cpp 2010-05-30 01:20:31.000000000 +0300
186 +++ live/liveMedia/RTSPServer.cpp 2010-06-06 00:34:03.000000000 +0300
187 @@ -112,11 +112,12 @@
188 char urlBuffer[100]; // more than big enough for "rtsp://<ip-address>:<port>/"
190 portNumBits portNumHostOrder = ntohs(fServerPort.num());
192 if (portNumHostOrder == 554 /* the default port number */) {
193 - sprintf(urlBuffer, "rtsp://%s/", our_inet_ntoa(ourAddress.sin_addr));
194 + sprintf(urlBuffer, "rtsp://%s/", our_inet_ntoa(ourAddress.sin_addr, buf));
196 sprintf(urlBuffer, "rtsp://%s:%hu/",
197 - our_inet_ntoa(ourAddress.sin_addr), portNumHostOrder);
198 + our_inet_ntoa(ourAddress.sin_addr, buf), portNumHostOrder);
201 return strDup(urlBuffer);
203 increaseSendBufferTo(envir(), clientSocket, 50*1024);
205 #if defined(DEBUG) || defined(DEBUG_CONNECTIONS)
206 - envir() << "accept()ed connection from " << our_inet_ntoa(clientAddr.sin_addr) << '\n';
208 + envir() << "accept()ed connection from " << our_inet_ntoa(clientAddr.sin_addr, buf) << '\n';
211 // Create a new object for this RTSP session.
212 @@ -747,10 +749,12 @@
213 serverRTPPort, serverRTCPPort,
214 fStreamStates[streamNum].streamToken);
215 struct in_addr destinationAddr; destinationAddr.s_addr = destinationAddress;
216 - char* destAddrStr = strDup(our_inet_ntoa(destinationAddr));
217 + char destAddrStr[16];
218 + our_inet_ntoa(destinationAddr, destAddrStr);
219 struct sockaddr_in sourceAddr; SOCKLEN_T namelen = sizeof sourceAddr;
220 getsockname(fClientSocket, (struct sockaddr*)&sourceAddr, &namelen);
221 - char* sourceAddrStr = strDup(our_inet_ntoa(sourceAddr.sin_addr));
222 + char sourceAddrStr[16];
223 + our_inet_ntoa(sourceAddr.sin_addr, sourceAddrStr);
225 switch (streamingMode) {
231 - delete[] destAddrStr; delete[] sourceAddrStr; delete[] streamingModeString;
232 + delete[] streamingModeString;
235 void RTSPServer::RTSPClientSession
236 @@ -1226,7 +1230,8 @@
237 // If this gets called, the client session is assumed to have timed out,
240 - fprintf(stderr, "RTSP client session from %s has timed out (due to inactivity)\n", our_inet_ntoa(clientSession->fClientAddr.sin_addr));
242 + fprintf(stderr, "RTSP client session from %s has timed out (due to inactivity)\n", our_inet_ntoa(clientSession->fClientAddr.sin_addr, buf));
244 delete clientSession;
246 diff -ru live.orig/liveMedia/ServerMediaSession.cpp live/liveMedia/ServerMediaSession.cpp
247 --- live.orig/liveMedia/ServerMediaSession.cpp 2010-05-30 01:20:31.000000000 +0300
248 +++ live/liveMedia/ServerMediaSession.cpp 2010-06-06 00:34:03.000000000 +0300
250 char* ServerMediaSession::generateSDPDescription() {
251 struct in_addr ipAddress;
252 ipAddress.s_addr = ourIPAddress(envir());
253 - char* const ipAddressStr = strDup(our_inet_ntoa(ipAddress));
254 + char ipAddressStr[16];
255 + our_inet_ntoa(ipAddress, ipAddressStr);
256 unsigned ipAddressStrSize = strlen(ipAddressStr);
258 // For a SSM sessions, we need a "a=source-filter: incl ..." line also:
263 - delete[] rangeLine; delete[] sourceFilterLine; delete[] ipAddressStr;
264 + delete[] rangeLine; delete[] sourceFilterLine;
268 diff -ru live.orig/liveMedia/SIPClient.cpp live/liveMedia/SIPClient.cpp
269 --- live.orig/liveMedia/SIPClient.cpp 2010-05-30 01:20:31.000000000 +0300
270 +++ live/liveMedia/SIPClient.cpp 2010-06-06 00:34:03.000000000 +0300
273 struct in_addr ourAddress;
274 ourAddress.s_addr = ourIPAddress(env); // hack
275 - fOurAddressStr = strDup(our_inet_ntoa(ourAddress));
277 + fOurAddressStr = strDup(our_inet_ntoa(ourAddress, buf));
278 fOurAddressStrSize = strlen(fOurAddressStr);
280 fOurSocket = new Groupsock(env, ourAddress, 0, 255);
281 if (fOurSocket == NULL) {
282 env << "ERROR: Failed to create socket for addr "
283 - << our_inet_ntoa(ourAddress) << ": "
284 + << our_inet_ntoa(ourAddress, buf) << ": "
285 << env.getResultMsg() << "\n";
289 fOurSocket = new Groupsock(env, ourAddress, fOurPortNum, 255);
290 if (fOurSocket == NULL) {
291 env << "ERROR: Failed to create socket for addr "
292 - << our_inet_ntoa(ourAddress) << ", port "
293 + << our_inet_ntoa(ourAddress, buf) << ", port "
294 << fOurPortNum << ": "
295 << env.getResultMsg() << "\n";
297 diff -ru live.orig/testProgs/sapWatch.cpp live/testProgs/sapWatch.cpp
298 --- live.orig/testProgs/sapWatch.cpp 2010-05-30 01:20:31.000000000 +0300
299 +++ live/testProgs/sapWatch.cpp 2010-06-06 00:34:03.000000000 +0300
301 struct sockaddr_in fromAddress;
302 while (inputGroupsock.handleRead(packet, maxPacketSize,
303 packetSize, fromAddress)) {
305 printf("\n[packet from %s (%d bytes)]\n",
306 - our_inet_ntoa(fromAddress.sin_addr), packetSize);
307 + our_inet_ntoa(fromAddress.sin_addr, buf), packetSize);
309 // Ignore the first 8 bytes (SAP header).
310 if (packetSize < 8) {
311 *env << "Ignoring short packet from "
312 - << our_inet_ntoa(fromAddress.sin_addr) << "%s!\n";
313 + << our_inet_ntoa(fromAddress.sin_addr, buf) << "%s!\n";