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-04-09 22:27:39.000000000 +0300
5 +++ live//groupsock/Groupsock.cpp 2010-04-17 19:51:07.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-04-09 22:27:39.000000000 +0300
37 +++ live//groupsock/include/GroupsockHelper.hh 2010-04-17 19:43:44.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-04-09 22:27:39.000000000 +0300
49 +++ live//groupsock/inet.c 2010-04-17 19:42:52.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 + return inet_ntop(AF_INET, &in, result, 16);
70 - /* according the man pages of inet_ntoa :
73 - The return value from inet_ntoa() points to a buffer which
74 - is overwritten on each call. This buffer is implemented as
75 - thread-specific data in multithreaded applications.
77 - the vxworks version of inet_ntoa allocates a buffer for each
78 - ip address string, and does not reuse the same buffer.
80 - this is merely to simulate the same behaviour (not multithread
83 - static char result[INET_ADDR_LEN];
84 inet_ntoa_b(in, result);
87 diff -ru live.orig//liveMedia/DarwinInjector.cpp live//liveMedia/DarwinInjector.cpp
88 --- live.orig//liveMedia/DarwinInjector.cpp 2010-04-09 22:27:39.000000000 +0300
89 +++ live//liveMedia/DarwinInjector.cpp 2010-04-17 19:45:19.000000000 +0300
91 NetAddress const* address = addresses.firstAddress();
92 addr.s_addr = *(unsigned*)(address->data());
94 - char const* remoteRTSPServerAddressStr = our_inet_ntoa(addr);
96 + char const* remoteRTSPServerAddressStr = our_inet_ntoa(addr, buf);
98 // Construct a SDP description for the session that we'll be streaming:
99 char const* const sdpFmt =
100 diff -ru live.orig//liveMedia/OnDemandServerMediaSubsession.cpp live//liveMedia/OnDemandServerMediaSubsession.cpp
101 --- live.orig//liveMedia/OnDemandServerMediaSubsession.cpp 2010-04-09 22:27:39.000000000 +0300
102 +++ live//liveMedia/OnDemandServerMediaSubsession.cpp 2010-04-17 19:50:05.000000000 +0300
104 char const* mediaType = rtpSink->sdpMediaType();
105 unsigned char rtpPayloadType = rtpSink->rtpPayloadType();
106 struct in_addr serverAddrForSDP; serverAddrForSDP.s_addr = fServerAddressForSDP;
107 - char* const ipAddressStr = strDup(our_inet_ntoa(serverAddrForSDP));
108 + char ipAddressStr[16];
109 + our_inet_ntoa(serverAddrForSDP, ipAddressStr);
110 char* rtpmapLine = rtpSink->rtpmapLine();
111 char const* rangeLine = rangeSDPLine();
112 char const* auxSDPLine = getAuxSDPLine(rtpSink, inputSource);
114 rangeLine, // a=range:... (if present)
115 auxSDPLine, // optional extra SDP line
116 trackId()); // a=control:<track-id>
117 - delete[] (char*)rangeLine; delete[] rtpmapLine; delete[] ipAddressStr;
118 + delete[] (char*)rangeLine; delete[] rtpmapLine;
120 fSDPLines = strDup(sdpLines);
122 diff -ru live.orig//liveMedia/PassiveServerMediaSubsession.cpp live//liveMedia/PassiveServerMediaSubsession.cpp
123 --- live.orig//liveMedia/PassiveServerMediaSubsession.cpp 2010-04-09 22:27:39.000000000 +0300
124 +++ live//liveMedia/PassiveServerMediaSubsession.cpp 2010-04-17 19:46:28.000000000 +0300
126 char const* auxSDPLine = fRTPSink.auxSDPLine();
127 if (auxSDPLine == NULL) auxSDPLine = "";
129 - char* const ipAddressStr = strDup(our_inet_ntoa(ipAddress));
130 + char ipAddressStr[16];
131 + our_inet_ntoa(ipAddress, ipAddressStr);
133 char const* const sdpFmt =
134 "m=%s %d RTP/AVP %d\r\n"
136 rangeLine, // a=range:... (if present)
137 auxSDPLine, // optional extra SDP line
138 trackId()); // a=control:<track-id>
139 - delete[] ipAddressStr; delete[] (char*)rangeLine; delete[] rtpmapLine;
140 + delete[] (char*)rangeLine; delete[] rtpmapLine;
142 fSDPLines = strDup(sdpLines);
144 diff -ru live.orig//liveMedia/RTCP.cpp live//liveMedia/RTCP.cpp
145 --- live.orig//liveMedia/RTCP.cpp 2010-04-09 22:27:39.000000000 +0300
146 +++ live//liveMedia/RTCP.cpp 2010-04-17 19:46:44.000000000 +0300
151 - fprintf(stderr, "[%p]saw incoming RTCP packet (from address %s, port %d)\n", this, our_inet_ntoa(fromAddress.sin_addr), ntohs(fromAddress.sin_port));
153 + 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));
154 unsigned char* p = pkt;
155 for (unsigned i = 0; i < packetSize; ++i) {
156 if (i%4 == 0) fprintf(stderr, " ");
157 diff -ru live.orig//liveMedia/RTSPOverHTTPServer.cpp live//liveMedia/RTSPOverHTTPServer.cpp
158 --- live.orig//liveMedia/RTSPOverHTTPServer.cpp 2010-04-09 22:27:39.000000000 +0300
159 +++ live//liveMedia/RTSPOverHTTPServer.cpp 2010-04-17 19:50:41.000000000 +0300
161 makeSocketNonBlocking(clientSocket);
162 increaseSendBufferTo(envir(), clientSocket, 50*1024);
163 #if defined(DEBUG) || defined(DEBUG_CONNECTIONS)
164 - fprintf(stderr, "accept()ed connection from %s\n", our_inet_ntoa(clientAddr.sin_addr));
166 + fprintf(stderr, "accept()ed connection from %s\n", our_inet_ntoa(clientAddr.sin_addr, buf));
169 // Create a new object for handling this HTTP connection:
170 diff -ru live.orig//liveMedia/RTSPServer.cpp live//liveMedia/RTSPServer.cpp
171 --- live.orig//liveMedia/RTSPServer.cpp 2010-04-09 22:27:39.000000000 +0300
172 +++ live//liveMedia/RTSPServer.cpp 2010-04-17 19:49:32.000000000 +0300
173 @@ -112,11 +112,12 @@
174 char urlBuffer[100]; // more than big enough for "rtsp://<ip-address>:<port>/"
176 portNumBits portNumHostOrder = ntohs(fServerPort.num());
178 if (portNumHostOrder == 554 /* the default port number */) {
179 - sprintf(urlBuffer, "rtsp://%s/", our_inet_ntoa(ourAddress.sin_addr));
180 + sprintf(urlBuffer, "rtsp://%s/", our_inet_ntoa(ourAddress.sin_addr, buf));
182 sprintf(urlBuffer, "rtsp://%s:%hu/",
183 - our_inet_ntoa(ourAddress.sin_addr), portNumHostOrder);
184 + our_inet_ntoa(ourAddress.sin_addr, buf), portNumHostOrder);
187 return strDup(urlBuffer);
189 increaseSendBufferTo(envir(), clientSocket, 50*1024);
191 #if defined(DEBUG) || defined(DEBUG_CONNECTIONS)
192 - envir() << "accept()ed connection from " << our_inet_ntoa(clientAddr.sin_addr) << '\n';
194 + envir() << "accept()ed connection from " << our_inet_ntoa(clientAddr.sin_addr, buf) << '\n';
197 // Create a new object for this RTSP session.
198 @@ -747,10 +749,12 @@
199 serverRTPPort, serverRTCPPort,
200 fStreamStates[streamNum].streamToken);
201 struct in_addr destinationAddr; destinationAddr.s_addr = destinationAddress;
202 - char* destAddrStr = strDup(our_inet_ntoa(destinationAddr));
203 + char destAddrStr[16];
204 + our_inet_ntoa(destinationAddr, destAddrStr);
205 struct sockaddr_in sourceAddr; SOCKLEN_T namelen = sizeof sourceAddr;
206 getsockname(fClientSocket, (struct sockaddr*)&sourceAddr, &namelen);
207 - char* sourceAddrStr = strDup(our_inet_ntoa(sourceAddr.sin_addr));
208 + char sourceAddrStr[16];
209 + our_inet_ntoa(sourceAddr.sin_addr, sourceAddrStr);
211 switch (streamingMode) {
217 - delete[] destAddrStr; delete[] sourceAddrStr; delete[] streamingModeString;
218 + delete[] streamingModeString;
221 void RTSPServer::RTSPClientSession
222 @@ -1226,7 +1230,8 @@
223 // If this gets called, the client session is assumed to have timed out,
226 - fprintf(stderr, "RTSP client session from %s has timed out (due to inactivity)\n", our_inet_ntoa(clientSession->fClientAddr.sin_addr));
228 + fprintf(stderr, "RTSP client session from %s has timed out (due to inactivity)\n", our_inet_ntoa(clientSession->fClientAddr.sin_addr, buf));
230 delete clientSession;
232 diff -ru live.orig//liveMedia/ServerMediaSession.cpp live//liveMedia/ServerMediaSession.cpp
233 --- live.orig//liveMedia/ServerMediaSession.cpp 2010-04-09 22:27:39.000000000 +0300
234 +++ live//liveMedia/ServerMediaSession.cpp 2010-04-17 19:50:31.000000000 +0300
236 char* ServerMediaSession::generateSDPDescription() {
237 struct in_addr ipAddress;
238 ipAddress.s_addr = ourIPAddress(envir());
239 - char* const ipAddressStr = strDup(our_inet_ntoa(ipAddress));
240 + char ipAddressStr[16];
241 + our_inet_ntoa(ipAddress, ipAddressStr);
242 unsigned ipAddressStrSize = strlen(ipAddressStr);
244 // For a SSM sessions, we need a "a=source-filter: incl ..." line also:
249 - delete[] rangeLine; delete[] sourceFilterLine; delete[] ipAddressStr;
250 + delete[] rangeLine; delete[] sourceFilterLine;
254 diff -ru live.orig//liveMedia/SIPClient.cpp live//liveMedia/SIPClient.cpp
255 --- live.orig//liveMedia/SIPClient.cpp 2010-04-09 22:27:39.000000000 +0300
256 +++ live//liveMedia/SIPClient.cpp 2010-04-17 19:47:42.000000000 +0300
259 struct in_addr ourAddress;
260 ourAddress.s_addr = ourIPAddress(env); // hack
261 - fOurAddressStr = strDup(our_inet_ntoa(ourAddress));
263 + fOurAddressStr = strDup(our_inet_ntoa(ourAddress, buf));
264 fOurAddressStrSize = strlen(fOurAddressStr);
266 fOurSocket = new Groupsock(env, ourAddress, 0, 255);
267 if (fOurSocket == NULL) {
268 env << "ERROR: Failed to create socket for addr "
269 - << our_inet_ntoa(ourAddress) << ": "
270 + << our_inet_ntoa(ourAddress, buf) << ": "
271 << env.getResultMsg() << "\n";
275 fOurSocket = new Groupsock(env, ourAddress, fOurPortNum, 255);
276 if (fOurSocket == NULL) {
277 env << "ERROR: Failed to create socket for addr "
278 - << our_inet_ntoa(ourAddress) << ", port "
279 + << our_inet_ntoa(ourAddress, buf) << ", port "
280 << fOurPortNum << ": "
281 << env.getResultMsg() << "\n";
283 diff -ru live.orig//testProgs/sapWatch.cpp live//testProgs/sapWatch.cpp
284 --- live.orig//testProgs/sapWatch.cpp 2010-04-09 22:27:39.000000000 +0300
285 +++ live//testProgs/sapWatch.cpp 2010-04-17 19:51:29.000000000 +0300
287 struct sockaddr_in fromAddress;
288 while (inputGroupsock.handleRead(packet, maxPacketSize,
289 packetSize, fromAddress)) {
291 printf("\n[packet from %s (%d bytes)]\n",
292 - our_inet_ntoa(fromAddress.sin_addr), packetSize);
293 + our_inet_ntoa(fromAddress.sin_addr, buf), packetSize);
295 // Ignore the first 8 bytes (SAP header).
296 if (packetSize < 8) {
297 *env << "Ignoring short packet from "
298 - << our_inet_ntoa(fromAddress.sin_addr) << "%s!\n";
299 + << our_inet_ntoa(fromAddress.sin_addr, buf) << "%s!\n";