@@ -124,7 +124,7 @@ static int rtpp_command_ul_pre_parse(const struct rtpp_command *,
124124}
125125
126126void
127- ul_reply_port (struct rtpp_command * cmd , struct ul_reply * ulr )
127+ ul_reply_port (const struct rtpp_command * cmd , struct ul_reply * ulr )
128128{
129129 int rport , r ;
130130 const char subc_err [] = " && -1" ;
@@ -535,19 +535,20 @@ handle_nomem(struct rtpp_command *cmd, int ecode, struct rtpp_session *spa)
535535 CALL_SMETHOD (cmd -> reply , deliver_error , ecode );
536536}
537537
538- static int
539- format_ul_reply_result (const struct ul_reply * ulr , struct rtpp_subc_resp * rsp )
538+ int
539+ format_ul_reply_result (const struct ul_opts * ulop , char * buf_t , size_t blen )
540540{
541541 const rtpp_str_const_t * sap ;
542542 rtpp_str_const_t sad ;
543543 char saddr [MAX_ADDR_STRLEN ];
544544 const char * at ;
545545 int plen ;
546+ const struct ul_reply * ulr = & ulop -> reply ;
546547
547548 if (ulr == NULL || ulr -> ia == NULL || ishostnull (ulr -> ia -> addr )) {
548- plen = snprintf (rsp -> buf_t , sizeof ( rsp -> buf_t ) , "%d" ,
549+ plen = snprintf (buf_t , blen , "%d" ,
549550 (ulr != NULL ) ? ulr -> port : 0 );
550- return (plen > -1 && plen < sizeof ( rsp -> buf_t ) ) ? 0 : -1 ;
551+ return (plen > -1 && plen < blen ) ? 0 : -1 ;
551552 }
552553 sap = & ulr -> ia -> params .advaddr ;
553554 if (sap -> s == NULL ) {
@@ -557,15 +558,14 @@ format_ul_reply_result(const struct ul_reply *ulr, struct rtpp_subc_resp *rsp)
557558 sap = & sad ;
558559 }
559560 at = (ulr -> ia -> addr -> sa_family == AF_INET ) ? "" : " 6" ;
560- plen = snprintf (rsp -> buf_t , sizeof ( rsp -> buf_t ) , "%d %.*s%s" ,
561+ plen = snprintf (buf_t , blen , "%d %.*s%s" ,
561562 ulr -> port , FMTSTR (sap ), at );
562- return (plen > -1 && plen < sizeof ( rsp -> buf_t ) ) ? 0 : -1 ;
563+ return (plen > -1 && plen < blen ) ? 0 : -1 ;
563564}
564565
565566int
566567rtpp_command_ul_handle_impl (const struct rtpp_cfg * cfsp ,
567- struct rtpp_command * cmd , int sidx , struct rtpp_subc_resp * rsp ,
568- struct rtpp_command_stats * csp , const struct rtpp_sockaddr * raddrp )
568+ struct rtpp_command * cmd , int sidx )
569569{
570570 int pidx , lport , sessions_active ;
571571 struct rtpp_socket * fds [2 ];
@@ -582,7 +582,7 @@ rtpp_command_ul_handle_impl(const struct rtpp_cfg *cfsp,
582582 ulop = cmd -> cca .opts .ul ;
583583
584584#define UL_FAIL (_ecode ) do { \
585- if (rsp = = NULL) \
585+ if (cmd->reply ! = NULL) \
586586 CALL_SMETHOD(cmd->reply, deliver_error, (_ecode)); \
587587 goto err_undo_0; \
588588} while (0)
@@ -626,8 +626,8 @@ rtpp_command_ul_handle_impl(const struct rtpp_cfg *cfsp,
626626 spa -> rtp -> stream [sidx ]-> port = lport ;
627627 spa -> rtcp -> stream [sidx ]-> port = lport + 1 ;
628628 if (spa -> complete == 0 ) {
629- if (csp != NULL )
630- csp -> nsess_complete .cnt ++ ;
629+ if (cmd -> csp != NULL )
630+ cmd -> csp -> nsess_complete .cnt ++ ;
631631 CALL_SMETHOD (spa -> rtp -> stream [0 ]-> ttl , reset_with ,
632632 spa -> rtp -> stream [0 ]-> stream_ttl );
633633 CALL_SMETHOD (spa -> rtp -> stream [1 ]-> ttl , reset_with ,
@@ -693,8 +693,8 @@ rtpp_command_ul_handle_impl(const struct rtpp_cfg *cfsp,
693693 UL_FAIL (ECODE_LSTFAIL_2 );
694694 }
695695
696- if (csp != NULL )
697- csp -> nsess_created .cnt ++ ;
696+ if (cmd -> csp != NULL )
697+ cmd -> csp -> nsess_created .cnt ++ ;
698698
699699 hte = CALL_SMETHOD (cfsp -> sessions_ht , append_str_refcnt , spa -> call_id ,
700700 spa -> rcnt , NULL );
@@ -744,11 +744,11 @@ rtpp_command_ul_handle_impl(const struct rtpp_cfg *cfsp,
744744 }
745745 if (ulop -> notify_socket != NULL ) {
746746 struct rtpp_tnotify_target * rttp ;
747- struct rtpp_sockaddr raddr = (raddrp != NULL ) ? * raddrp :
748- (struct rtpp_sockaddr ){.l = 0 };
747+ RTPP_DBG_ASSERT (cmd -> raddr != NULL );
749748
750749 rttp = CALL_METHOD (cfsp -> rtpp_tnset_cf , lookup , ulop -> notify_socket -> s ,
751- (raddr .l > 0 ) ? sstosa (raddr .a ) : NULL , (raddr .l > 0 ) ? cmd -> laddr : NULL );
750+ (cmd -> raddr -> l > 0 ) ? sstosa (cmd -> raddr -> a ) : NULL ,
751+ (cmd -> raddr -> l > 0 ) ? cmd -> laddr : NULL );
752752 if (rttp == NULL ) {
753753 RTPP_LOG (spa -> log , RTPP_LOG_ERR , "invalid socket name %.*s" ,
754754 FMTSTR (ulop -> notify_socket ));
@@ -833,26 +833,18 @@ rtpp_command_ul_handle_impl(const struct rtpp_cfg *cfsp,
833833 if (rsc .resp -> result != 0 )
834834 break ;
835835 }
836- if (rsp = = NULL ) {
836+ if (cmd -> reply ! = NULL ) {
837837 ul_reply_port (cmd , & ulop -> reply );
838- } else if (format_ul_reply_result (& ulop -> reply , rsp ) != 0 ) {
839- goto err_undo_0 ;
840838 }
841- #undef UL_FAIL
842839 return (0 );
843840
844841err_undo_0 :
845- #undef UL_FAIL
846842 return (-1 );
847843}
848844
849845int
850846rtpp_command_ul_handle (const struct rtpp_cfg * cfsp , struct rtpp_command * cmd , int sidx )
851847{
852- struct rtpp_command_stats * csp ;
853- struct rtpp_sockaddr raddr ;
854848
855- csp = rtpp_command_get_stats (cmd );
856- raddr = rtpp_command_get_raddr (cmd );
857- return (rtpp_command_ul_handle_impl (cfsp , cmd , sidx , NULL , csp , & raddr ));
849+ return (rtpp_command_ul_handle_impl (cfsp , cmd , sidx ));
858850}
0 commit comments