From: David M. <mc...@ci...> - 2006-11-17 15:47:26
|
Hi Francesco, On Nov 16, 2006, at 3:43 AM, Francesco Andrisani wrote: > > Hi all, > i want to insert a srtp protection into my code. I read with a > socket an RTP flow from an IP camera (i use socket functions to do > it) and send rtp flow to another workstation. > My code is: > > ....... > ....... > sec_serv_t sec_servs = sec_serv_none; > > sec_servs |= sec_serv_conf; > sec_servs |= sec_serv_auth; > > status = srtp_init(); > if (status) > { > printf("error: srtp initialization failed with error code %d > \n", status); > return -1; > } > > crypto_policy_set_rtp_default(&policy.rtp); > crypto_policy_set_rtcp_default(&policy.rtcp); > > > policy.ssrc.type = ssrc_specific; > policy.ssrc.value = ssrc; > policy.key = (uint8_t *)key; > policy.next = NULL; > policy.rtp.sec_serv = sec_servs; > policy.rtcp.sec_serv = sec_serv_none; > > status = srtp_create(&session, &policy); > if (status) > { > printf("error: srtp create failed with error code %d\n", status); > return -1; > } > > char rtp_buffer[2048]; > unsigned lenPacket; > > while(1) > { > > > lenPacket = recvfrom(sockfd1, rtp_buffer, 2048, 0, (struct > sockaddr*)&serv_addr1, &len); > > printf("\nRead from socket %d bytes\n",lenPacket); > > m = 0; > status = srtp_protect(session, rtp_buffer, &lenPacket); > if (status) > { > printf("\nSRTP protection error with code: %d\n",status); > return -1; > } > else > { > printf("\nRTP protection passed ----> SRTP packet create!\n"); > srtp_packet_to_string((srtp_hdr_t *)rtp_buffer, lenPacket); > printf("%s",packet_string); > } > > if (lenPacket >0) > { > m = sendto(sockfd1, rtp_buffer,lenPacket, 0, (struct > sockaddr*)&to_addr, len1); > printf("\nSend to socket %d bytes\n",m); > } > > n = 0; > bzero(rtp_buffer,2048); > } > > My code stop when it process srtp_protection...and exit with code > 13 (err_status_no_ctx). > Where is my error? > with the lines policy.ssrc.value = ssrc; policy.ssrc.type = ssrc_specific; you're setting the policy to be specific to a particular RTP source (e.g. a particular SSRC). Probably no context is being found because there is no context corresponding to the SSRC that srtp_protect() is seeing. You either need to make sure that the SSRC that you're setting here is the one actually being used, or you need to use a 'wildcard SSRC'. best regards, David > Regards > > ---------------------------------------------------------------------- > --- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to > share your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php? > page=join.php&p=sourceforge&CID=DEVDEV________________________________ > _______________ > Srtp-development mailing list > Srt...@li... > https://lists.sourceforge.net/lists/listinfo/srtp-development |