|
@@ -97,15 +97,24 @@ void _cmRtNetRpt( cmRtNet_t* p, const cmChar_t* fmt, ... )
|
97
|
97
|
va_end(vl);
|
98
|
98
|
}
|
99
|
99
|
|
100
|
|
-cmRtNetNode_t* _cmRtNetFindNode( cmRtNet_t* p, const cmChar_t* label )
|
|
100
|
+cmRtNetNode_t* _cmRtNetFindNode( cmRtNet_t* p, const cmChar_t* label, unsigned* idxRef )
|
101
|
101
|
{
|
102
|
102
|
if( label == NULL )
|
103
|
103
|
return NULL;
|
104
|
104
|
|
|
105
|
+ if( idxRef != NULL )
|
|
106
|
+ *idxRef = cmInvalidIdx;
|
|
107
|
+
|
105
|
108
|
cmRtNetNode_t* np = p->nodes;
|
106
|
|
- for(; np!=NULL; np=np->link)
|
|
109
|
+ unsigned i;
|
|
110
|
+ for(i=0; np!=NULL; np=np->link,++i)
|
107
|
111
|
if( strcmp(label,np->label)==0)
|
|
112
|
+ {
|
|
113
|
+ if( idxRef != NULL )
|
|
114
|
+ *idxRef = i;
|
|
115
|
+
|
108
|
116
|
return np;
|
|
117
|
+ }
|
109
|
118
|
|
110
|
119
|
return NULL;
|
111
|
120
|
}
|
|
@@ -190,8 +199,8 @@ cmRtNetRC_t _cmRtNetCreateNode( cmRtNet_t* p, const cmChar_t* label, unsigned rt
|
190
|
199
|
if( cmTextIsEmpty(label) )
|
191
|
200
|
return cmErrMsg(&p->err,kInvalidLabelNetRC,"A null or blank node label was encountered.");
|
192
|
201
|
|
193
|
|
- if((np = _cmRtNetFindNode(p,label)) != NULL )
|
194
|
|
- cmErrWarnMsg(&p->err,kDuplLabelNetRC,"The node label '%s' is already in use.",cmStringNullGuard(label));
|
|
202
|
+ if((np = _cmRtNetFindNode(p,label,NULL)) != NULL )
|
|
203
|
+ cmErrWarnMsg(&p->err,kOkNetRC/*kDuplLabelNetRC*/,"The node label '%s' is being reused.",cmStringNullGuard(label));
|
195
|
204
|
else
|
196
|
205
|
{
|
197
|
206
|
np = cmMemAllocZ(cmRtNetNode_t,1);
|
|
@@ -569,7 +578,7 @@ cmRtNetRC_t _cmRtNetSyncModeRecv( cmRtNet_t* p, const char* data, unsigned data
|
569
|
578
|
{
|
570
|
579
|
case kHelloSelNetId:
|
571
|
580
|
// if this is a response to a broadcast from the local node then ignore it
|
572
|
|
- if(m.label!=NULL && p->localNode->label!=NULL && (np = _cmRtNetFindNode(p,m.label)) != NULL && strcmp(p->localNode->label,m.label)==0 )
|
|
581
|
+ if(m.label!=NULL && p->localNode->label!=NULL && (np = _cmRtNetFindNode(p,m.label,NULL)) != NULL && strcmp(p->localNode->label,m.label)==0 )
|
573
|
582
|
{
|
574
|
583
|
const cmChar_t* fromAddrStr = cmUdpAddrToString(p->udpH,fromAddr);
|
575
|
584
|
const cmChar_t* localAddrStr = cmUdpAddrToString(p->udpH,cmUdpLocalAddr(p->udpH));
|
|
@@ -794,12 +803,6 @@ cmRtNetRC_t cmRtNetReceive( cmRtNetH_t h )
|
794
|
803
|
return rc;
|
795
|
804
|
}
|
796
|
805
|
|
797
|
|
-unsigned cmRtNetAddrToNodeIndex( cmRtNetH_t h, const struct sockaddr_in* a )
|
798
|
|
-{
|
799
|
|
- cmRtNet_t* p = _cmRtNetHandleToPtr(h);
|
800
|
|
- return _cmRtNetAddrToNodeIndex(p,a);
|
801
|
|
-}
|
802
|
|
-
|
803
|
806
|
|
804
|
807
|
cmRtNetRC_t cmRtNetEndpointHandle( cmRtNetH_t h, const cmChar_t* nodeLabel, const cmChar_t* endptLabel, cmRtNetEndptH_t* hp )
|
805
|
808
|
{
|
|
@@ -808,7 +811,7 @@ cmRtNetRC_t cmRtNetEndpointHandle( cmRtNetH_t h, const cmChar_t* nodeLabel, cons
|
808
|
811
|
cmRtNetNode_t* np;
|
809
|
812
|
cmRtNetEnd_t* ep;
|
810
|
813
|
|
811
|
|
- if(( np = _cmRtNetFindNode(p,nodeLabel)) == NULL )
|
|
814
|
+ if(( np = _cmRtNetFindNode(p,nodeLabel,NULL)) == NULL )
|
812
|
815
|
return cmErrMsg(&p->err,kNodeNotFoundNetRC,"The node '%s' was not found.",cmStringNullGuard(nodeLabel));
|
813
|
816
|
|
814
|
817
|
|
|
@@ -966,6 +969,22 @@ unsigned cmRtNetRemoteNodeCount( cmRtNetH_t h )
|
966
|
969
|
return n;
|
967
|
970
|
}
|
968
|
971
|
|
|
972
|
+unsigned cmRtNetAddrToNodeIndex( cmRtNetH_t h, const struct sockaddr_in* a )
|
|
973
|
+{
|
|
974
|
+ cmRtNet_t* p = _cmRtNetHandleToPtr(h);
|
|
975
|
+ return _cmRtNetAddrToNodeIndex(p,a);
|
|
976
|
+}
|
|
977
|
+
|
|
978
|
+unsigned cmRtNetRemoteNodeIndex( cmRtNetH_t h, const cmChar_t* label )
|
|
979
|
+{
|
|
980
|
+ cmRtNet_t* p = _cmRtNetHandleToPtr( h );
|
|
981
|
+ unsigned idx = cmInvalidIdx;
|
|
982
|
+
|
|
983
|
+ _cmRtNetFindNode(p,label,&idx);
|
|
984
|
+
|
|
985
|
+ return idx;
|
|
986
|
+}
|
|
987
|
+
|
969
|
988
|
const cmChar_t* cmRtNetRemoteNodeLabel( cmRtNetH_t h, unsigned idx )
|
970
|
989
|
{
|
971
|
990
|
cmRtNet_t* p = _cmRtNetHandleToPtr( h );
|