Ejemplo n.º 1
0
void
reaper_rtp_writer(const struct ip *ip, int sport, int dport, const u_char *hdr, const u_char *ep)
{
   int len = (int)(ep - hdr);
   if (len < 0)
       return;
   if ((dport % 2) != 0) {
	/* rtcp */
	   static const char *notify = "NOTIFY sip:rtcp.example.com SIP/2.0\r\nVia: SIP/2.0/UDP 192.168.1.2;branch=z9hG4bKnp149505178-438c528b192.168.1.2;rport\r\nFrom: <sip:[email protected]>;tag=4442\r\nTo: <sip:[email protected]>;tag=78923\r\nCall-Id: [email protected]\r\nCSeq: 20 NOTIFY\r\nContact: <sip:[email protected]>\r\nMax-Forwards: 10\r\nContent-Type: text/plain\r\nContent-Length: %d\r\n\r\n%s";
	   if ((hdr[0] & 0xE0) != 0x80) /* v2 */
	       return;
	   if ((hdr[1] < 0xc8) || (hdr[1] > 0xcf)) /* SR to XR */
	       return;
	   reaper_init();
	   int contentLength = reaper_rtcp_format(ip, sport, dport, hdr, len);
	   contentLength = sprintf(reaper_buffer_rtcp, notify, contentLength, reaper_packet_buffer_rtcp);
	   printf("%s\n", reaper_buffer_rtcp);
	   reaper_writer(reaper_buffer_rtcp, contentLength);
   } else {
	/* rtp */
	   if ((hdr[0] & 0xE0) != 0x80) /* v2 */
	       return;
	   reaper_init();
	   reaper_rtp_format(ip, sport, dport, hdr, len);
	   reaper_rtp_flush(FALSE);
   }
}
Ejemplo n.º 2
0
void reaper_sip_writer(const u_char *data, int len)
{
   reaper_init();
   char *ptr;
   if (((ptr = index(data, '\r')) == NULL) ||
       ((ptr = index(data, '\n')) == NULL)) {
         fprintf(stderr, "Error unexpected packet\n");
         return;
   }
   int lineLen = (ptr - (char*)data);
   reaper_rtp_flush(TRUE);
   fprintf(stderr, "Sending SIP: %.*s\n", lineLen, (char*)data);
   reaper_writer(data, len);
   return;
}
Ejemplo n.º 3
0
static void nfs_Start_threads(void)
{
	int rc = 0;
	pthread_attr_t attr_thr;

	LogDebug(COMPONENT_THREAD, "Starting threads");

	/* Init for thread parameter (mostly for scheduling) */
	if (pthread_attr_init(&attr_thr) != 0)
		LogDebug(COMPONENT_THREAD, "can't init pthread's attributes");

	if (pthread_attr_setscope(&attr_thr, PTHREAD_SCOPE_SYSTEM) != 0)
		LogDebug(COMPONENT_THREAD, "can't set pthread's scope");

	if (pthread_attr_setdetachstate(&attr_thr,
					PTHREAD_CREATE_JOINABLE) != 0)
		LogDebug(COMPONENT_THREAD, "can't set pthread's join state");

	LogEvent(COMPONENT_THREAD, "Starting delayed executor.");
	delayed_start();

	/* Starting the thread dedicated to signal handling */
	rc = pthread_create(&sigmgr_thrid, &attr_thr, sigmgr_thread, NULL);
	if (rc != 0) {
		LogFatal(COMPONENT_THREAD,
			 "Could not create sigmgr_thread, error = %d (%s)",
			 errno, strerror(errno));
	}
	LogDebug(COMPONENT_THREAD, "sigmgr thread started");

	rc = worker_init();
	if (rc != 0) {
		LogFatal(COMPONENT_THREAD, "Could not start worker threads: %d",
			 errno);
	}

	/* Start event channel service threads */
	nfs_rpc_dispatch_threads(&attr_thr);

#ifdef _USE_9P
	/* Starting the 9P/TCP dispatcher thread */
	rc = pthread_create(&_9p_dispatcher_thrid, &attr_thr,
			    _9p_dispatcher_thread, NULL);
	if (rc != 0) {
		LogFatal(COMPONENT_THREAD,
			 "Could not create  9P/TCP dispatcher, error = %d (%s)",
			 errno, strerror(errno));
	}
	LogEvent(COMPONENT_THREAD,
		 "9P/TCP dispatcher thread was started successfully");
#endif

#ifdef _USE_9P_RDMA
	/* Starting the 9P/RDMA dispatcher thread */
	rc = pthread_create(&_9p_rdma_dispatcher_thrid, &attr_thr,
			    _9p_rdma_dispatcher_thread, NULL);
	if (rc != 0) {
		LogFatal(COMPONENT_THREAD,
			 "Could not create  9P/RDMA dispatcher, error = %d (%s)",
			 errno, strerror(errno));
	}
	LogEvent(COMPONENT_THREAD,
		 "9P/RDMA dispatcher thread was started successfully");
#endif

#ifdef USE_DBUS
	/* DBUS event thread */
	rc = pthread_create(&gsh_dbus_thrid, &attr_thr, gsh_dbus_thread, NULL);
	if (rc != 0) {
		LogFatal(COMPONENT_THREAD,
			 "Could not create gsh_dbus_thread, error = %d (%s)",
			 errno, strerror(errno));
	}
	LogEvent(COMPONENT_THREAD, "gsh_dbusthread was started successfully");
#endif

	/* Starting the admin thread */
	rc = pthread_create(&admin_thrid, &attr_thr, admin_thread, NULL);
	if (rc != 0) {
		LogFatal(COMPONENT_THREAD,
			 "Could not create admin_thread, error = %d (%s)",
			 errno, strerror(errno));
	}
	LogEvent(COMPONENT_THREAD, "admin thread was started successfully");

	/* Starting the reaper thread */
	rc = reaper_init();
	if (rc != 0) {
		LogFatal(COMPONENT_THREAD,
			 "Could not create reaper_thread, error = %d (%s)",
			 errno, strerror(errno));
	}
	LogEvent(COMPONENT_THREAD, "reaper thread was started successfully");

	/* Starting the general fridge */
	rc = general_fridge_init();
	if (rc != 0) {
		LogFatal(COMPONENT_THREAD,
			 "Could not create general fridge, error = %d (%s)",
			 errno, strerror(errno));
	}
	LogEvent(COMPONENT_THREAD, "General fridge was started successfully");

}