[SCM] Mumudvb packaging branch, upstream, updated. 24c2efb080b56abb8e7be67bae30ba7fe457759e

Brice Dubost dubost at poulet.adm.crans.org
Sat Nov 1 13:31:04 UTC 2008


The following commit has been merged in the upstream branch:
commit 2ab1eeadded2e0c9d778d9f9d7aad987a9db27a3
Author: Brice Dubost <dubost at poulet.adm.crans.org>
Date:   Mon Sep 22 22:04:39 2008 +0200

    Sap groups, sap organisation, and sap sender ip address + small changes

diff --git a/src/mumudvb.c b/src/mumudvb.c
index e3a0dfe..c83e649 100644
--- a/src/mumudvb.c
+++ b/src/mumudvb.c
@@ -87,6 +87,7 @@ int  write_streamed_channels=1;
 mumudvb_sap_message_t sap_messages[MAX_CHANNELS]; //the sap message... //TODO : allocate dynamically
 int sap=0; //do we send sap announces ?
 int sap_interval=SAP_DEFAULT_INTERVAL;
+char sap_sending_ip[20]="0.0.0.0";
 
 //autoconfiguration
 int autoconfiguration = 0;           //Do we use autoconfiguration ?
@@ -405,7 +406,7 @@ main (int argc, char **argv)
       else if (!strcmp (substring, "sap_organisation"))
 	{
 	  // other substring extraction method in order to keep spaces
-	  substring = strtok (NULL, delimiteurs);
+	  substring = strtok (NULL, "=");
 	  if (!(strlen (substring) >= 255 - 1))
 	    strcpy(sap_organisation,strtok(substring,"\n"));	
 	  else
@@ -413,6 +414,17 @@ main (int argc, char **argv)
 		log_message( MSG_INFO,"Sap Organisation name too long\n");
 	    }
 	}
+      else if (!strcmp (substring, "sap_sending_ip"))
+	{
+	  substring = strtok (NULL, delimiteurs);
+	  if(strlen(substring)>19)
+	    {
+	      log_message( MSG_ERROR,
+			   "The sap sending ip is too long\n");
+	      exit(ERROR_CONF);
+	    }
+	  sscanf (substring, "%s\n", sap_sending_ip);
+	}
       else if (!strcmp (substring, "freq"))
 	{
 	  substring = strtok (NULL, delimiteurs);
@@ -460,6 +472,23 @@ main (int argc, char **argv)
 	  sscanf (substring, "%s\n", channels[curr_channel].ipOut);
 	  ip_ok = 1;
 	}
+      else if (!strcmp (substring, "sap_group"))
+	{
+	  if (sap==0)
+	    {
+	      log_message( MSG_WARN,
+			"Warning : you have not activated sap, the sap group will not be taken in account\n");
+
+	    }
+	  substring = strtok (NULL, "=");
+	  if(strlen(substring)>19)
+	    {
+	      log_message( MSG_ERROR,
+			   "The sap group is too long\n");
+	      exit(ERROR_CONF);
+	    }
+	  sscanf (substring, "%s\n", channels[curr_channel].sap_group);
+	}
       else if (!strcmp (substring, "common_port"))
 	{
 	  substring = strtok (NULL, delimiteurs);
diff --git a/src/mumudvb.h b/src/mumudvb.h
index 2a61848..a31fec2 100644
--- a/src/mumudvb.h
+++ b/src/mumudvb.h
@@ -90,6 +90,7 @@ typedef struct{
   int autoconfigurated;            //is the channel autoconfigurated ?
 
   char ipOut[20];
+  char sap_group[20];
   int portOut;
   struct sockaddr_in sOut;
   int socketOut;
diff --git a/src/sap.c b/src/sap.c
index 2ac4224..c62b8fc 100644
--- a/src/sap.c
+++ b/src/sap.c
@@ -30,18 +30,24 @@
 #include "udp.h"
 #include <string.h>
 
+extern char sap_sending_ip[20];
+
 
 //SAP_send : send the sap message
 void sap_send(mumudvb_sap_message_t *sap_messages, int num_messages)
 {
   int curr_message;
-  log_message(MSG_DEBUG,"DEBUG : SAP sending\n");
+  int sent_messages=0;
 
   for( curr_message=0; curr_message<num_messages;curr_message++)
     {
       if(sap_messages[curr_message].to_be_sent)
-	sendudp (sap_socketOut, &sap_sOut, sap_messages[curr_message].buf, sap_messages[curr_message].len);
+	{
+	  sendudp (sap_socketOut, &sap_sOut, sap_messages[curr_message].buf, sap_messages[curr_message].len);
+	  sent_messages++;
+	}
     }
+  log_message(MSG_DEBUG,"DEBUG : SAP sending. %d message(s) sent\n", sent_messages);
 
   return;
 }
@@ -55,6 +61,9 @@ int sap_update(mumudvb_channel_t channel, mumudvb_sap_message_t *sap_message)
   //This function is called when the channel changes so it increases the version and update the packet
   char temp_string[256];
 
+  struct in_addr ip_struct;
+  in_addr_t ip;
+
   //paranoia
   memset(sap_message->buf,0, MAX_UDP_SIZE * sizeof (unsigned char));
 
@@ -64,11 +73,21 @@ int sap_update(mumudvb_channel_t channel, mumudvb_sap_message_t *sap_message)
   sap_message->buf[2]=(sap_message->version&0xff00)>>8;
   sap_message->buf[3]=sap_message->version&0xff;
 
-  //TODO TODO   //sap_message->buf[4 5 6 7]= IP;
-  sap_message->buf[4]=0;
-  sap_message->buf[5]=0;
-  sap_message->buf[6]=0;
-  sap_message->buf[7]=0;
+  if( inet_aton(sap_sending_ip, &ip_struct))
+    {
+      ip=ip_struct.s_addr;
+      /* Bytes 4-7 (or 4-19) byte: Originating source */
+      log_message(MSG_DEBUG,"DEBUG : sap sending ip address : 0x%x\n", ip);
+      memcpy (sap_message->buf + 4, &ip, 4);
+    }
+  else
+    {
+      log_message(MSG_WARN,"WARNING : Invalid SAP sending Ip address, using 0.0.0.0 as Ip adress\n");
+      sap_message->buf[4]=0;
+      sap_message->buf[5]=0;
+      sap_message->buf[6]=0;
+      sap_message->buf[7]=0;
+    }
 
 
   //the mime type
@@ -156,7 +175,17 @@ int sap_add_program(mumudvb_channel_t channel, mumudvb_sap_message_t *sap_messag
   memcpy(sap_message->buf + sap_message->len + payload_len, temp_string, strlen(temp_string));
   payload_len+=strlen(temp_string);
 
-  
+  if(strlen(channel.sap_group))
+    {
+      sprintf(temp_string,"a=x-plgroup:%s\r\n", channel.sap_group);
+      if( (sap_message->len+payload_len+strlen(temp_string))>1024)
+	{
+	  log_message(MSG_WARN,"Warning : SAP message too long for channel %s\n",channel.name);
+	  return 1;
+	}
+      memcpy(sap_message->buf + sap_message->len + payload_len, temp_string, strlen(temp_string));
+      payload_len+=strlen(temp_string);
+    }
   log_message(MSG_DEBUG,"DEBUG : SAP payload\n");
   log_message(MSG_DEBUG, &sap_message->buf[sap_message->len]);
   log_message(MSG_DEBUG,"DEBUG : end of SAP payload\n\n");

-- 
Mumudvb packaging



More information about the pkg-vdr-dvb-changes mailing list