summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorintel-ethernet <eric_mann@mail.intel.com>2013-06-12 19:37:15 -0700
committerintel-ethernet <eric_mann@mail.intel.com>2013-06-12 19:37:15 -0700
commit7da028f82b3043adccbf231819180b8e8e5a165c (patch)
tree3c8b43131973500137555291ed03c29a5db606dc
parent734f00a72b9b94dcbf2e9548a1fb31e1c414d113 (diff)
parent06f9e00982bd331552a31a5f033edf9fc1f60bd3 (diff)
downloadOpen-AVB-7da028f82b3043adccbf231819180b8e8e5a165c.tar.gz
Merge branch 'asi-for-upstream' of github.com:audioscience/Open-AVB into audioscience-asi-for-upstream
-rw-r--r--daemons/gptp/windows/daemon_cl/daemon_cl.vcxproj22
-rw-r--r--daemons/gptp/windows/daemon_cl/daemon_cl.vcxproj.filters10
-rw-r--r--daemons/mrpd/mmrp.c80
-rw-r--r--daemons/mrpd/mrp.c25
-rw-r--r--daemons/mrpd/mrp.h5
-rw-r--r--daemons/mrpd/mrpd.c24
-rw-r--r--daemons/mrpd/mrpd.h2
-rw-r--r--daemons/mrpd/mrpw.c295
-rw-r--r--daemons/mrpd/mrpw.h42
-rw-r--r--daemons/mrpd/msrp.c792
-rw-r--r--daemons/mrpd/mvrp.c83
-rwxr-xr-xexamples/mrp_client/mrpdhelper.c167
-rwxr-xr-xexamples/mrp_client/mrpdhelper.h3
13 files changed, 885 insertions, 665 deletions
diff --git a/daemons/gptp/windows/daemon_cl/daemon_cl.vcxproj b/daemons/gptp/windows/daemon_cl/daemon_cl.vcxproj
index 94736461..0a0d902c 100644
--- a/daemons/gptp/windows/daemon_cl/daemon_cl.vcxproj
+++ b/daemons/gptp/windows/daemon_cl/daemon_cl.vcxproj
@@ -28,7 +28,6 @@
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
- <PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
@@ -41,7 +40,6 @@
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
- <PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
@@ -84,13 +82,13 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WPCAP;HAVE_REMOTE</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>C:\Users\John\src\pcap\Include;C:\Users\John\src\gptp\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>$(PcapDir)\include;..\..\common;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>wpcap.lib;Iphlpapi.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>C:\Users\John\src\pcap\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories>$(PcapDir)\Lib\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@@ -116,14 +114,14 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WPCAP;HAVE_REMOTE</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>C:\Users\John\src\pcap\Include;C:\Users\John\src\gptp\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>$(PcapDir)\include;..\..\common;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
- <AdditionalLibraryDirectories>C:\Users\John\src\pcap\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories>$(PcapDir)\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>wpcap.lib;Iphlpapi.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateMapFile>true</GenerateMapFile>
</Link>
@@ -172,21 +170,17 @@
<ClInclude Include="windows_hal.hpp" />
</ItemGroup>
<ItemGroup>
- <ClCompile Include="..\..\..\common\avbts_osnet.cpp">
+ <ClCompile Include="..\..\common\avbts_osnet.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
- <ClCompile Include="..\..\..\common\ieee1588clock.cpp">
+ <ClCompile Include="..\..\common\ieee1588clock.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
- <ClCompile Include="..\..\..\common\ieee1588port.cpp">
+ <ClCompile Include="..\..\common\ieee1588port.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
- <ClCompile Include="..\..\..\common\ptp_message.cpp">
+ <ClCompile Include="..\..\common\ptp_message.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="daemon_cl.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
diff --git a/daemons/gptp/windows/daemon_cl/daemon_cl.vcxproj.filters b/daemons/gptp/windows/daemon_cl/daemon_cl.vcxproj.filters
index 09509efe..af6915bb 100644
--- a/daemons/gptp/windows/daemon_cl/daemon_cl.vcxproj.filters
+++ b/daemons/gptp/windows/daemon_cl/daemon_cl.vcxproj.filters
@@ -80,19 +80,19 @@
<ClCompile Include="daemon_cl.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="..\..\..\common\ieee1588port.cpp">
+ <ClCompile Include="packet.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="..\..\..\common\ieee1588clock.cpp">
+ <ClCompile Include="..\..\common\avbts_osnet.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="..\..\..\common\ptp_message.cpp">
+ <ClCompile Include="..\..\common\ieee1588clock.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="..\..\..\common\avbts_osnet.cpp">
+ <ClCompile Include="..\..\common\ieee1588port.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="packet.cpp">
+ <ClCompile Include="..\..\common\ptp_message.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
diff --git a/daemons/mrpd/mmrp.c b/daemons/mrpd/mmrp.c
index 5d60e75b..53ea2ee0 100644
--- a/daemons/mrpd/mmrp.c
+++ b/daemons/mrpd/mmrp.c
@@ -208,7 +208,8 @@ int mmrp_event(int event, struct mmrp_attribute *rattrib)
#if LOG_MMRP
mrpd_log_printf("MMRP -> mrp_applicant_fsm\n");
#endif
- mrp_applicant_fsm(&(MMRP_db->mrp_db), &(attrib->applicant), MRP_EVENT_TXLA);
+ mrp_applicant_fsm(&(MMRP_db->mrp_db),
+ &(attrib->applicant), MRP_EVENT_TXLA);
mrp_registrar_fsm(&(attrib->registrar),
&(MMRP_db->mrp_db), MRP_EVENT_TXLA);
attrib = attrib->next;
@@ -227,7 +228,8 @@ int mmrp_event(int event, struct mmrp_attribute *rattrib)
#if LOG_MMRP
mrpd_log_printf("MMRP -> mrp_applicant_fsm\n");
#endif
- mrp_applicant_fsm(&(MMRP_db->mrp_db), &(attrib->applicant), MRP_EVENT_RLA);
+ mrp_applicant_fsm(&(MMRP_db->mrp_db),
+ &(attrib->applicant), MRP_EVENT_RLA);
mrp_registrar_fsm(&(attrib->registrar),
&(MMRP_db->mrp_db), MRP_EVENT_RLA);
attrib = attrib->next;
@@ -244,7 +246,8 @@ int mmrp_event(int event, struct mmrp_attribute *rattrib)
#if LOG_MMRP
mrpd_log_printf("MMRP -> mrp_applicant_fsm\n");
#endif
- mrp_applicant_fsm(&(MMRP_db->mrp_db), &(attrib->applicant), MRP_EVENT_TX);
+ mrp_applicant_fsm(&(MMRP_db->mrp_db),
+ &(attrib->applicant), MRP_EVENT_TX);
attrib = attrib->next;
}
@@ -271,7 +274,8 @@ int mmrp_event(int event, struct mmrp_attribute *rattrib)
#if LOG_MMRP
mrpd_log_printf("MMRP -> mrp_applicant_fsm\n");
#endif
- mrp_applicant_fsm(&(MMRP_db->mrp_db), &(attrib->applicant),
+ mrp_applicant_fsm(&(MMRP_db->mrp_db),
+ &(attrib->applicant),
MRP_EVENT_PERIODIC);
attrib = attrib->next;
}
@@ -303,7 +307,8 @@ int mmrp_event(int event, struct mmrp_attribute *rattrib)
#if LOG_MMRP
mrpd_log_printf("MMRP -> mrp_applicant_fsm\n");
#endif
- mrp_applicant_fsm(&(MMRP_db->mrp_db), &(attrib->applicant), event);
+ mrp_applicant_fsm(&(MMRP_db->mrp_db), &(attrib->applicant),
+ event);
/* remap local requests into registrar events */
switch (event) {
case MRP_EVENT_NEW:
@@ -476,7 +481,8 @@ int mmrp_recv_msg()
&& (mrpdu_msg_ptr[1] == 0))) {
numvalues =
MRPDU_VECT_NUMVALUES(ntohs
- (mrpdu_vectorptr->VectorHeader));
+ (mrpdu_vectorptr->
+ VectorHeader));
if (0 == numvalues)
/* Malformed - cant tell how long the trailing vectors are */
@@ -500,8 +506,8 @@ int mmrp_recv_msg()
vectidx <= (numvectorbytes + 1);
vectidx++) {
vect_3pack =
- mrpdu_vectorptr->FirstValue_VectorEvents
- [vectidx];
+ mrpdu_vectorptr->
+ FirstValue_VectorEvents[vectidx];
vectevt[0] = vect_3pack / 36;
vectevt[1] =
(vect_3pack - vectevt[0] * 36) / 6;
@@ -527,9 +533,9 @@ int mmrp_recv_msg()
attrib->attribute.svcreq =
svcreq_firstval;
svcreq_firstval++;
- memcpy(attrib->
- registrar.macaddr,
- eth->srcaddr, 6);
+ memcpy(attrib->registrar.
+ macaddr, eth->srcaddr,
+ 6);
switch (vectevt[vectevt_idx]) {
case MRPDU_NEW:
@@ -603,7 +609,8 @@ int mmrp_recv_msg()
&& (mrpdu_msg_ptr[1] == 0))) {
numvalues =
MRPDU_VECT_NUMVALUES(ntohs
- (mrpdu_vectorptr->VectorHeader));
+ (mrpdu_vectorptr->
+ VectorHeader));
if (0 == numvalues)
/* Malformed - cant tell how long the trailing vectors are */
@@ -628,8 +635,8 @@ int mmrp_recv_msg()
vectidx <= (numvectorbytes + 6);
vectidx++) {
vect_3pack =
- mrpdu_vectorptr->FirstValue_VectorEvents
- [vectidx];
+ mrpdu_vectorptr->
+ FirstValue_VectorEvents[vectidx];
vectevt[0] = vect_3pack / 36;
vectevt[1] =
(vect_3pack - vectevt[0] * 36) / 6;
@@ -649,15 +656,15 @@ int mmrp_recv_msg()
goto out; /* oops - internal error */
attrib->type = MMRP_MACVEC_TYPE;
- memcpy(attrib->
- attribute.macaddr,
- macvec_firstval, 6);
+ memcpy(attrib->attribute.
+ macaddr, macvec_firstval,
+ 6);
mmrp_increment_macaddr
(macvec_firstval);
- memcpy(attrib->
- registrar.macaddr,
- eth->srcaddr, 6);
+ memcpy(attrib->registrar.
+ macaddr, eth->srcaddr,
+ 6);
switch (vectevt[vectevt_idx]) {
case MRPDU_NEW:
@@ -1310,9 +1317,9 @@ int mmrp_txpdu(void)
int mmrp_send_notifications(struct mmrp_attribute *attrib, int notify)
{
char *msgbuf;
- char *stage;
char *variant;
char *regsrc;
+ char mrp_state[8];
client_t *client;
if (NULL == attrib)
@@ -1322,13 +1329,12 @@ int mmrp_send_notifications(struct mmrp_attribute *attrib, int notify)
if (NULL == msgbuf)
return -1;
- stage = variant = regsrc = NULL;
+ variant = regsrc = NULL;
- stage = (char *)malloc(128);
variant = (char *)malloc(128);
regsrc = (char *)malloc(128);
- if ((NULL == stage) || (NULL == variant) || (NULL == regsrc))
+ if ((NULL == variant) || (NULL == regsrc))
goto free_msgbuf;
memset(msgbuf, 0, MAX_MRPD_CMDSZ);
@@ -1351,29 +1357,19 @@ int mmrp_send_notifications(struct mmrp_attribute *attrib, int notify)
attrib->registrar.macaddr[2],
attrib->registrar.macaddr[3],
attrib->registrar.macaddr[4], attrib->registrar.macaddr[5]);
- switch (attrib->registrar.mrp_state) {
- case MRP_IN_STATE:
- sprintf(stage, "MIN %s %s\n", variant, regsrc);
- break;
- case MRP_LV_STATE:
- sprintf(stage, "MLV %s %s\n", variant, regsrc);
- break;
- case MRP_MT_STATE:
- sprintf(stage, "MMT %s %s\n", variant, regsrc);
- break;
- default:
- break;
- }
+
+ mrp_decode_state(&attrib->registrar, &attrib->applicant,
+ mrp_state, sizeof(mrp_state));
switch (notify) {
case MRP_NOTIFY_NEW:
- snprintf(msgbuf, MAX_MRPD_CMDSZ - 1, "MNE %s\n", stage);
+ snprintf(msgbuf, MAX_MRPD_CMDSZ - 1, "MNE %s %s %s\n", variant, regsrc, mrp_state);
break;
case MRP_NOTIFY_JOIN:
- snprintf(msgbuf, MAX_MRPD_CMDSZ - 1, "MJO %s\n", stage);
+ snprintf(msgbuf, MAX_MRPD_CMDSZ - 1, "MJO %s %s %s\n", variant, regsrc, mrp_state);
break;
case MRP_NOTIFY_LV:
- snprintf(msgbuf, MAX_MRPD_CMDSZ - 1, "MLE %s\n", stage);
+ snprintf(msgbuf, MAX_MRPD_CMDSZ - 1, "MLE %s %s %s\n", variant, regsrc, mrp_state);
break;
default:
goto free_msgbuf;
@@ -1389,8 +1385,6 @@ int mmrp_send_notifications(struct mmrp_attribute *attrib, int notify)
free_msgbuf:
if (variant)
free(variant);
- if (stage)
- free(stage);
if (regsrc)
free(regsrc);
free(msgbuf);
@@ -1598,7 +1592,7 @@ int mmrp_recv_cmd(char *buf, int buflen, struct sockaddr_in *client)
if (rc)
goto out_ERI;
} else if ((strncmp(buf, "M++:M", 5) == 0)
- || (strncmp(buf, "M+?:M", 5) == 0)) {
+ || (strncmp(buf, "M+?:M", 5) == 0)) {
/* buf[] should look similar to 'M+?:M=010203040506' */
rc = mmrp_cmd_parse_mac(buf, buflen, macvec_param, &err_index);
if (rc)
diff --git a/daemons/mrpd/mrp.c b/daemons/mrpd/mrp.c
index 90b2652c..cf34320f 100644
--- a/daemons/mrpd/mrp.c
+++ b/daemons/mrpd/mrp.c
@@ -94,7 +94,6 @@ char *mrp_event_string(int e)
}
}
-#if LOG_MRP
static char *mrp_state_string(int s)
{
switch (s) {
@@ -143,7 +142,6 @@ static char *mrp_lvatimer_state_string(int s)
else
return "??";
}
-#endif /* #if LOG_MRP */
static int client_lookup(client_t * list, struct sockaddr_in *newclient)
{
@@ -248,7 +246,7 @@ int mrp_jointimer_start(struct mrp_database *mrp_db)
else
mrpd_log_printf("MRP join timer start \n");
#endif
- if (!mrp_db->join_timer_running ) {
+ if (!mrp_db->join_timer_running) {
ret = mrpd_timer_start(mrp_db->join_timer, MRP_JOINTIMER_VAL);
}
if (ret >= 0)
@@ -308,12 +306,13 @@ int mrp_lvatimer_start(struct mrp_database *mrp_db)
timeout = MRP_LVATIMER_VAL + (random() % (MRP_LVATIMER_VAL / 2));
#if LOG_TIMERS
if (mrp_db->lva_timer_running)
- mrpd_log_printf("MRP leaveAll timer already running \n", timeout);
+ mrpd_log_printf("MRP leaveAll timer already running \n",
+ timeout);
else
mrpd_log_printf("MRP start leaveAll timer (%d ms)\n", timeout);
#endif
if (!mrp_db->lva_timer_running)
- ret = mrpd_timer_start(mrp_db->lva_timer, timeout);
+ ret = mrpd_timer_start(mrp_db->lva_timer, timeout);
if (ret >= 0)
mrp_db->lva_timer_running = 1;
return ret;
@@ -362,7 +361,8 @@ int mrp_lvatimer_fsm(struct mrp_database *mrp_db, int event)
mrp_lvatimer_start(mrp_db);
break;
default:
- printf("mrp_lvatimer_fsm:unexpected event (%d)\n", event);
+ printf("mrp_lvatimer_fsm:unexpected event (%d), state %s\n",
+ event, mrp_lvatimer_state_string(la_state));
return -1;
break;
}
@@ -418,7 +418,8 @@ int mrp_periodictimer_fsm(struct mrp_database *mrp_db, int event)
}
break;
default:
- printf("mrp_periodictimer_fsm:unexpected event (%d)\n", event);
+ printf("mrp_periodictimer_fsm:unexpected event (%d), state %s\n",
+ event, mrp_lvatimer_state_string(p_state));
return;
break;
}
@@ -432,7 +433,8 @@ int mrp_periodictimer_fsm(struct mrp_database *mrp_db, int event)
* per-attribute MRP FSM
*/
-int mrp_applicant_fsm(struct mrp_database *mrp_db, mrp_applicant_attribute_t * attrib, int event)
+int mrp_applicant_fsm(struct mrp_database *mrp_db,
+ mrp_applicant_attribute_t * attrib, int event)
{
int tx = 0;
int optional = 0;
@@ -764,7 +766,8 @@ int mrp_applicant_fsm(struct mrp_database *mrp_db, mrp_applicant_attribute_t * a
break;
default:
- printf("mrp_applicant_fsm:unexpected event %s (%d)\n", mrp_event_string(event), event);
+ printf("mrp_applicant_fsm:unexpected event %s (%d)\n",
+ mrp_event_string(event), event);
return -1;
break;
}
@@ -892,7 +895,9 @@ mrp_registrar_fsm(mrp_registrar_attribute_t * attrib,
/* ignore on soon to be deleted attributes */
break;
default:
- printf("mrp_registrar_fsm:unexpected event %s (%d)\n", mrp_event_string(event), event);
+ printf("mrp_registrar_fsm:unexpected event %s (%d), state %s\n",
+ mrp_event_string(event), event,
+ mrp_state_string(mrp_state));
return -1;
break;
}
diff --git a/daemons/mrpd/mrp.h b/daemons/mrpd/mrp.h
index 19f050e9..f740188a 100644
--- a/daemons/mrpd/mrp.h
+++ b/daemons/mrpd/mrp.h
@@ -41,7 +41,7 @@
#define LOG_CLIENT_RECV 0
#define LOG_CLIENT_SEND 0
-#define MRP_DEFAULT_POINT_TO_POINT_MAC 1 /* operPointToPointMAC */
+#define MRP_DEFAULT_POINT_TO_POINT_MAC 1 /* operPointToPointMAC */
#define MRP_ENCODE_YES 0 /* must send */
#define MRP_ENCODE_OPTIONAL 1 /* send if smaller */
@@ -199,7 +199,8 @@ int mrp_lvtimer_stop(struct mrp_database *mrp_db);
int mrp_lvatimer_start(struct mrp_database *mrp_db);
int mrp_lvatimer_stop(struct mrp_database *mrp_db);
int mrp_lvatimer_fsm(struct mrp_database *mrp_db, int event);
-int mrp_applicant_fsm(struct mrp_database *mrp_db, mrp_applicant_attribute_t * attrib, int event);
+int mrp_applicant_fsm(struct mrp_database *mrp_db,
+ mrp_applicant_attribute_t * attrib, int event);
int mrp_registrar_fsm(mrp_registrar_attribute_t * attrib,
struct mrp_database *mrp_db, int event);
int mrp_decode_state(mrp_registrar_attribute_t * rattrib,
diff --git a/daemons/mrpd/mrpd.c b/daemons/mrpd/mrpd.c
index a74dd30c..dec271f7 100644
--- a/daemons/mrpd/mrpd.c
+++ b/daemons/mrpd/mrpd.c
@@ -239,7 +239,8 @@ mrpd_send_ctl_msg(struct sockaddr_in *client_addr, char *notify_data,
#if LOG_CLIENT_SEND
if (logging_enable) {
mrpd_log_printf("[%02d] CLT MSG %05d:%s",
- gc_ctl_msg_count, client_addr->sin_port, notify_data);
+ gc_ctl_msg_count, client_addr->sin_port,
+ notify_data);
gc_ctl_msg_count = (gc_ctl_msg_count + 1) % 100;
}
#endif
@@ -840,21 +841,30 @@ int main(int argc, char *argv[])
goto out;
rc = mmrp_init(mmrp_enable);
- if (rc)
+ if (rc) {
+ printf("mmrp_enable failed\n");
goto out;
+ }
rc = mvrp_init(mvrp_enable);
- if (rc)
+ if (rc) {
+ printf("mvrp_enable failed\n");
goto out;
+ }
rc = msrp_init(msrp_enable);
- if (rc)
+ if (rc) {
+ printf("msrp_enable failed\n");
goto out;
+ }
rc = init_timers();
- if (rc)
+ if (rc) {
+ printf("init_timers failed\n");
goto out;
+ }
+ printf("process_events()\n");
process_events();
out:
if (rc)
@@ -891,9 +901,7 @@ void mrpd_log_printf(const char *fmt, ...)
va_start(arglist, fmt);
vsnprintf(sz, 512, fmt, arglist);
printf("MRPD %03d.%06d %s",
- (int)(tv.tv_sec % 1000),
- (int)tv.tv_usec,
- sz);
+ (int)(tv.tv_sec % 1000), (int)tv.tv_usec, sz);
va_end(arglist);
}
}
diff --git a/daemons/mrpd/mrpd.h b/daemons/mrpd/mrpd.h
index a7b593e2..94875bed 100644
--- a/daemons/mrpd/mrpd.h
+++ b/daemons/mrpd/mrpd.h
@@ -102,8 +102,6 @@ typedef struct mrpdu_message {
#pragma warning(pop)
#endif
-
-
typedef struct mrpdu {
uint8_t ProtocolVersion;
/* Microsoft does not support embedded arrays of 0 length
diff --git a/daemons/mrpd/mrpw.c b/daemons/mrpd/mrpw.c
index 9e2d6dc7..e761bfc6 100644
--- a/daemons/mrpd/mrpw.c
+++ b/daemons/mrpd/mrpw.c
@@ -47,6 +47,7 @@
#include "mvrp.h"
#include "msrp.h"
#include "mmrp.h"
+#include "mrpw.h"
#include "que.h"
@@ -603,8 +604,7 @@ int mrpd_send_ctl_msg(struct sockaddr_in *client_addr,
return 0;
#if LOG_CLIENT_SEND
- printf("CTL MSG:%s to CLNT %d\n", notify_data,
- client_addr->sin_port);
+ printf("CTL MSG:%s to CLNT %d\n", notify_data, client_addr->sin_port);
#endif
rc = sendto(control_socket, notify_data, notify_len,
0, (struct sockaddr *)client_addr, sizeof(struct sockaddr));
@@ -729,21 +729,14 @@ int mrpd_reclaim()
}
-
HANDLE kill_packet_capture;
-void process_events(void)
+int mrpw_init_threads(void)
{
HANDLE hThread1, hThread2;
DWORD dwThreadID1, dwThreadID2;
- uint16_t length = 0;
- uint8_t *payload;
- uint16_t protocol;
- uint8_t *proto;
struct avb_avtpdu *avtpdu = NULL;
uint64_t src_mac_address = 0;
- struct ctl_thread_params localhost_pkt;
- struct netif_thread_data wpcap_pkt;
int i;
timer_check_tick = mrpd_timer_create();
@@ -762,8 +755,7 @@ void process_events(void)
ExitProcess(0);
}
}
- pkt_events[pkt_event_wpcap] =
- que_data_available_object(que_wpcap);
+ pkt_events[pkt_event_wpcap] = que_data_available_object(que_wpcap);
pkt_events[pkt_event_localhost] =
que_data_available_object(que_localhost);
@@ -776,7 +768,7 @@ void process_events(void)
if (hThread1 == NULL) {
fprintf(stderr, "CreateThread error: %d\n", GetLastError());
- ExitProcess(0);
+ return -1;
}
hThread2 = CreateThread(NULL, // default security attributes
@@ -787,134 +779,140 @@ void process_events(void)
if (hThread2 == NULL) {
fprintf(stderr, "CreateThread error: %d\n", GetLastError());
- ExitProcess(0);
+ return -1;
}
+ return 0;
+}
- while (1) {
- DWORD dwEvent =
- WaitForMultipleObjects(sizeof(pkt_events) / sizeof(HANDLE),
- pkt_events,
- FALSE,
- 100); /* 100ms wait */
-
- /* special exit case */
- if (WAIT_OBJECT_0 + app_event_kill_all == dwEvent)
- break;
+int mrpw_run_once(void)
+{
+ struct netif_thread_data wpcap_pkt;
+ struct ctl_thread_params localhost_pkt;
+ uint16_t length = 0;
+ uint8_t *payload;
+ uint16_t protocol;
+ uint8_t *proto;
- switch (dwEvent) {
- case WAIT_TIMEOUT:
- case WAIT_OBJECT_0 + loop_time_tick:
- /* timeout - run protocols */
- if (mmrp_enable) {
- if (mrpd_timer_timeout(MMRP_db->mrp_db.lva_timer))
- mmrp_event(MRP_EVENT_LVATIMER, NULL);
- if (mrpd_timer_timeout(MMRP_db->mrp_db.lv_timer))
- mmrp_event(MRP_EVENT_LVTIMER, NULL);
- if (mrpd_timer_timeout(MMRP_db->mrp_db.join_timer))
- mmrp_event(MRP_EVENT_TX, NULL);
- }
+ DWORD dwEvent =
+ WaitForMultipleObjects(sizeof(pkt_events) / sizeof(HANDLE),
+ pkt_events,
+ FALSE,
+ 100); /* 100ms wait */
- if (mvrp_enable) {
- if (mrpd_timer_timeout(MVRP_db->mrp_db.lva_timer))
- mvrp_event(MRP_EVENT_LVATIMER, NULL);
- if (mrpd_timer_timeout(MVRP_db->mrp_db.lv_timer))
- mvrp_event(MRP_EVENT_LVTIMER, NULL);
- if (mrpd_timer_timeout(MVRP_db->mrp_db.join_timer))
- mvrp_event(MRP_EVENT_TX, NULL);
- }
+ /* special exit case */
+ if (WAIT_OBJECT_0 + app_event_kill_all == dwEvent)
+ return -1;
- if (msrp_enable) {
- if (mrpd_timer_timeout(MSRP_db->mrp_db.lva_timer))
- msrp_event(MRP_EVENT_LVATIMER, NULL);
- if (mrpd_timer_timeout(MSRP_db->mrp_db.lv_timer))
- msrp_event(MRP_EVENT_LVTIMER, NULL);
- if (mrpd_timer_timeout(MSRP_db->mrp_db.join_timer))
- msrp_event(MRP_EVENT_TX, NULL);
- }
+ switch (dwEvent) {
+ case WAIT_TIMEOUT:
+ case WAIT_OBJECT_0 + loop_time_tick:
+ /* timeout - run protocols */
+ if (mmrp_enable) {
+ if (mrpd_timer_timeout(MMRP_db->mrp_db.lva_timer))
+ mmrp_event(MRP_EVENT_LVATIMER, NULL);
+ if (mrpd_timer_timeout(MMRP_db->mrp_db.lv_timer))
+ mmrp_event(MRP_EVENT_LVTIMER, NULL);
+ if (mrpd_timer_timeout(MMRP_db->mrp_db.join_timer))
+ mmrp_event(MRP_EVENT_TX, NULL);
+ }
- if (mrpd_timer_timeout(periodic_timer)) {
- //printf("mrpd_timer_timeout(periodic_timer)\n");
- if (mmrp_enable)
- mmrp_event(MRP_EVENT_PERIODIC, NULL);
- if (mvrp_enable)
- mvrp_event(MRP_EVENT_PERIODIC, NULL);
- if (msrp_enable)
- msrp_event(MRP_EVENT_PERIODIC, NULL);
- mrpd_timer_restart(periodic_timer);
- }
- if (mrpd_timer_timeout(gc_timer)) {
- mrpd_reclaim();
- }
- mrpd_timer_restart(timer_check_tick);
- break;
+ if (mvrp_enable) {
+ if (mrpd_timer_timeout(MVRP_db->mrp_db.lva_timer))
+ mvrp_event(MRP_EVENT_LVATIMER, NULL);
+ if (mrpd_timer_timeout(MVRP_db->mrp_db.lv_timer))
+ mvrp_event(MRP_EVENT_LVTIMER, NULL);
+ if (mrpd_timer_timeout(MVRP_db->mrp_db.join_timer))
+ mvrp_event(MRP_EVENT_TX, NULL);
+ }
- case WAIT_OBJECT_0 + pkt_event_wpcap:
- que_pop_nowait(que_wpcap, &wpcap_pkt);
- proto = &wpcap_pkt.frame[12];
- protocol =
- (uint16_t) proto[0] << 8 | (uint16_t) proto[1];
- payload = proto + 2;
-
- last_pdu_buffer = wpcap_pkt.frame;
- last_pdu_buffer_size = wpcap_pkt.length;
-
- switch (protocol) {
- case MVRP_ETYPE:
- if (mvrp_enable)
- mvrp_recv_msg();
- break;
-
- case MMRP_ETYPE:
- if (mmrp_enable)
- mmrp_recv_msg();
- break;
-
- case MSRP_ETYPE:
- if (msrp_enable)
- msrp_recv_msg();
- break;
- }
- if (mrpd_timer_timeout(&timer_check_tick)) {
- if (!SetEvent(pkt_events[loop_time_tick])) {
- printf
- ("SetEvent loop_time_tick failed (%d)\n",
- GetLastError());
- exit(-1);
- }
- }
- break;
+ if (msrp_enable) {
+ if (mrpd_timer_timeout(MSRP_db->mrp_db.lva_timer))
+ msrp_event(MRP_EVENT_LVATIMER, NULL);
+ if (mrpd_timer_timeout(MSRP_db->mrp_db.lv_timer))
+ msrp_event(MRP_EVENT_LVTIMER, NULL);
+ if (mrpd_timer_timeout(MSRP_db->mrp_db.join_timer))
+ msrp_event(MRP_EVENT_TX, NULL);
+ }
+
+ if (mrpd_timer_timeout(periodic_timer)) {
+ //printf("mrpd_timer_timeout(periodic_timer)\n");
+ if (mmrp_enable)
+ mmrp_event(MRP_EVENT_PERIODIC, NULL);
+ if (mvrp_enable)
+ mvrp_event(MRP_EVENT_PERIODIC, NULL);
+ if (msrp_enable)
+ msrp_event(MRP_EVENT_PERIODIC, NULL);
+ mrpd_timer_restart(periodic_timer);
+ }
+ if (mrpd_timer_timeout(gc_timer)) {
+ mrpd_reclaim();
+ }
+ mrpd_timer_restart(timer_check_tick);
+ break;
+
+ case WAIT_OBJECT_0 + pkt_event_wpcap:
+ que_pop_nowait(que_wpcap, &wpcap_pkt);
+ proto = &wpcap_pkt.frame[12];
+ protocol = (uint16_t) proto[0] << 8 | (uint16_t) proto[1];
+ payload = proto + 2;
- case WAIT_OBJECT_0 + pkt_event_wpcap_timeout:
- //printf("pkt_event_wpcap_timeout\n");
+ last_pdu_buffer = wpcap_pkt.frame;
+ last_pdu_buffer_size = wpcap_pkt.length;
+
+ switch (protocol) {
+ case MVRP_ETYPE:
+ if (mvrp_enable)
+ mvrp_recv_msg();
break;
- case WAIT_OBJECT_0 + pkt_event_localhost:
- que_pop_nowait(que_localhost, &localhost_pkt);
- process_ctl_msg(localhost_pkt.msgbuf,
- localhost_pkt.bytes,
- (struct sockaddr_in *)
- &localhost_pkt.client_addr);
- if (mrpd_timer_timeout(&timer_check_tick)) {
- if (!SetEvent(pkt_events[loop_time_tick])) {
- printf
- ("SetEvent loop_time_tick failed (%d)\n",
- GetLastError());
- exit(-1);
- }
- }
+ case MMRP_ETYPE:
+ if (mmrp_enable)
+ mmrp_recv_msg();
break;
- case WAIT_OBJECT_0 + pkt_event_localhost_timeout:
- //printf("pkt_event_localhost_timeout\n");
+ case MSRP_ETYPE:
+ if (msrp_enable)
+ msrp_recv_msg();
break;
+ }
+ if (mrpd_timer_timeout(&timer_check_tick)) {
+ if (!SetEvent(pkt_events[loop_time_tick])) {
+ printf("SetEvent loop_time_tick failed (%d)\n",
+ GetLastError());
+ exit(-1);
+ }
+ }
+ break;
+
+ case WAIT_OBJECT_0 + pkt_event_wpcap_timeout:
+ //printf("pkt_event_wpcap_timeout\n");
+ break;
- default:
- printf("Unknown event %d\n", dwEvent);
+ case WAIT_OBJECT_0 + pkt_event_localhost:
+ que_pop_nowait(que_localhost, &localhost_pkt);
+ process_ctl_msg(localhost_pkt.msgbuf,
+ localhost_pkt.bytes, (struct sockaddr_in *)
+ &localhost_pkt.client_addr);
+ if (mrpd_timer_timeout(&timer_check_tick)) {
+ if (!SetEvent(pkt_events[loop_time_tick])) {
+ printf("SetEvent loop_time_tick failed (%d)\n",
+ GetLastError());
+ exit(-1);
+ }
}
+ break;
+
+ case WAIT_OBJECT_0 + pkt_event_localhost_timeout:
+ //printf("pkt_event_localhost_timeout\n");
+ break;
+
+ default:
+ printf("Unknown event %d\n", dwEvent);
}
+ return 0;
}
-int main(int argc, char *argv[])
+int mrpw_init_protocols(void)
{
uint16_t ether_types[4];
WSADATA wsa_data;
@@ -933,7 +931,7 @@ int main(int argc, char *argv[])
net_if = netif_open(TIME_PERIOD_25_MILLISECONDS); // time out is 25ms
if (!net_if) {
fprintf(stderr, "ERROR - opening network interface\n");
- exit(-1);
+ return -1;
}
ether_types[0] = MVRP_ETYPE;
@@ -941,7 +939,7 @@ int main(int argc, char *argv[])
ether_types[2] = MSRP_ETYPE;
if (netif_set_capture_ethertype(net_if, ether_types, 3)) {
fprintf(stderr, "ERROR - setting netif capture ethertype\n");
- exit(-1);
+ return -1;
}
rc = mrp_init();
@@ -974,13 +972,49 @@ int main(int argc, char *argv[])
if (rc)
goto out;
- process_events();
+ return 0;
+
out:
- if (rc)
- printf("Error starting. Run as sudo?\n");
+ return -1;
+
+}
+void mrpw_cleanup(void)
+{
WSACleanup();
- return rc;
+}
+
+void process_events(void)
+{
+ int status;
+ while (1) {
+ status = mrpw_run_once();
+ if (status < 0)
+ break;
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ int status;
+
+ status = mrpw_init_protocols();
+
+ if (status < 0) {
+ mrpw_cleanup();
+ return status;
+ }
+
+ status = mrpw_init_threads();
+ if (status < 0) {
+ mrpw_cleanup();
+ return status;
+ }
+
+ process_events();
+
+ mrpw_cleanup();
+ return status;
}
@@ -994,7 +1028,8 @@ void mrpd_log_printf(const char *fmt, ...)
/* get time stamp in ms */
QueryPerformanceCounter(&count);
QueryPerformanceFrequency(&freq);
- ms = (unsigned int)((count.QuadPart * 1000/freq.QuadPart) & 0xfffffff);
+ ms = (unsigned int)((count.QuadPart * 1000 / freq.QuadPart) &
+ 0xfffffff);
printf("MRPD %03d.%03d ", ms / 1000, ms % 1000);
diff --git a/daemons/mrpd/mrpw.h b/daemons/mrpd/mrpw.h
new file mode 100644
index 00000000..76690615
--- /dev/null
+++ b/daemons/mrpd/mrpw.h
@@ -0,0 +1,42 @@
+/******************************************************************************
+
+ Copyright (c) 2012, Intel Corporation
+ Copyright (c) 2012, AudioScience, Inc
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Intel Corporation nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
+******************************************************************************/
+#ifndef _MRPW_H_
+#define _MPRW_H_
+
+void mrpw_cleanup(void);
+int mrpw_init_protocols(void);
+int mrpw_run_once(void);
+int mrpw_init_threads(void);
+
+#endif \ No newline at end of file
diff --git a/daemons/mrpd/msrp.c b/daemons/mrpd/msrp.c
index e2101ef2..3405d598 100644
--- a/daemons/mrpd/msrp.c
+++ b/daemons/mrpd/msrp.c
@@ -71,8 +71,6 @@ static char *msrp_attrib_type_string(int t)
}
}
-
-
struct msrp_attribute *msrp_lookup(struct msrp_attribute *rattrib)
{
struct msrp_attribute *attrib;
@@ -90,10 +88,10 @@ struct msrp_attribute *msrp_lookup(struct msrp_attribute *rattrib)
} else {
/* compare on the stream ID */
mac_eq =
- memcmp(attrib->attribute.
- talk_listen.StreamID,
- rattrib->attribute.
- talk_listen.StreamID, 8);
+ memcmp(attrib->attribute.talk_listen.
+ StreamID,
+ rattrib->attribute.talk_listen.
+ StreamID, 8);
if (0 == mac_eq)
return attrib;
}
@@ -155,10 +153,10 @@ int msrp_add(struct msrp_attribute *rattrib)
}
} else {
mac_eq =
- memcmp(attrib->attribute.
- talk_listen.StreamID,
- rattrib->attribute.
- talk_listen.StreamID, 8);
+ memcmp(attrib->attribute.talk_listen.
+ StreamID,
+ rattrib->attribute.talk_listen.
+ StreamID, 8);
if (mac_eq < 0) {
/* possible tail insertion ... */
@@ -234,12 +232,12 @@ int msrp_merge(struct msrp_attribute *rattrib)
case MSRP_TALKER_ADV_TYPE:
case MSRP_TALKER_FAILED_TYPE:
attrib->attribute.talk_listen.FailureInformation.FailureCode =
- rattrib->attribute.talk_listen.
- FailureInformation.FailureCode;
- memcpy(attrib->attribute.talk_listen.
- FailureInformation.BridgeID,
- rattrib->attribute.talk_listen.
- FailureInformation.BridgeID, 8);
+ rattrib->attribute.talk_listen.FailureInformation.
+ FailureCode;
+ memcpy(attrib->attribute.talk_listen.FailureInformation.
+ BridgeID,
+ rattrib->attribute.talk_listen.FailureInformation.
+ BridgeID, 8);
#ifdef ENABLE_MERGED_LATENCY
attrib->attribute.talk_listen.AccumulatedLatency =
rattrib->attribute.talk_listen.AccumulatedLatency;
@@ -276,7 +274,8 @@ int msrp_event(int event, struct msrp_attribute *rattrib)
#if LOG_MSRP
mrpd_log_printf("MSRP -> mrp_applicant_fsm\n");
#endif
- mrp_applicant_fsm(&(MSRP_db->mrp_db), &(attrib->applicant), MRP_EVENT_TXLA);
+ mrp_applicant_fsm(&(MSRP_db->mrp_db),
+ &(attrib->applicant), MRP_EVENT_TXLA);
mrp_registrar_fsm(&(attrib->registrar),
&(MSRP_db->mrp_db), MRP_EVENT_TXLA);
attrib = attrib->next;
@@ -295,7 +294,8 @@ int msrp_event(int event, struct msrp_attribute *rattrib)
#if LOG_MSRP
mrpd_log_printf("MSRP -> mrp_applicant_fsm\n");
#endif
- mrp_applicant_fsm(&(MSRP_db->mrp_db), &(attrib->applicant), MRP_EVENT_RLA);
+ mrp_applicant_fsm(&(MSRP_db->mrp_db),
+ &(attrib->applicant), MRP_EVENT_RLA);
mrp_registrar_fsm(&(attrib->registrar),
&(MSRP_db->mrp_db), MRP_EVENT_RLA);
attrib = attrib->next;
@@ -312,7 +312,8 @@ int msrp_event(int event, struct msrp_attribute *rattrib)
#if LOG_MSRP
mrpd_log_printf("MSRP -> mrp_applicant_fsm\n");
#endif
- mrp_applicant_fsm(&(MSRP_db->mrp_db), &(attrib->applicant), MRP_EVENT_TX);
+ mrp_applicant_fsm(&(MSRP_db->mrp_db),
+ &(attrib->applicant), MRP_EVENT_TX);
attrib = attrib->next;
}
@@ -339,7 +340,8 @@ int msrp_event(int event, struct msrp_attribute *rattrib)
#if LOG_MSRP
mrpd_log_printf("MSRP -> mrp_applicant_fsm\n");
#endif
- mrp_applicant_fsm(&(MSRP_db->mrp_db), &(attrib->applicant),
+ mrp_applicant_fsm(&(MSRP_db->mrp_db),
+ &(attrib->applicant),
MRP_EVENT_PERIODIC);
attrib = attrib->next;
}
@@ -368,7 +370,8 @@ int msrp_event(int event, struct msrp_attribute *rattrib)
free(rattrib);
}
- mrp_applicant_fsm(&(MSRP_db->mrp_db), &(attrib->applicant), event);
+ mrp_applicant_fsm(&(MSRP_db->mrp_db), &(attrib->applicant),
+ event);
/* remap local requests into registrar events */
switch (event) {
@@ -394,9 +397,10 @@ int msrp_event(int event, struct msrp_attribute *rattrib)
rc = mrp_registrar_fsm(&(attrib->registrar),
&(MSRP_db->mrp_db), event);
if (-1 == rc) {
- printf("MSRP registrar error on attrib->type = %s (%d)\n",
- msrp_attrib_type_string(attrib->type),
- attrib->type);
+ printf
+ ("MSRP registrar error on attrib->type = %s (%d)\n",
+ msrp_attrib_type_string(attrib->type),
+ attrib->type);
}
break;
}
@@ -557,7 +561,8 @@ int msrp_recv_msg()
endmarks = 0;
#if LOG_MSRP
- mrpd_log_printf("MSRP msrp_recv_msg() msg addr 0x%X\n", ((int)mrpdu_msg_ptr) & 0x3);
+ mrpd_log_printf("MSRP msrp_recv_msg() msg addr 0x%X\n",
+ ((int)mrpdu_msg_ptr) & 0x3);
#endif
switch (mrpdu_msg->AttributeType) {
@@ -576,7 +581,8 @@ int msrp_recv_msg()
&& (mrpdu_msg_ptr[1] == 0))) {
numvalues =
MRPDU_VECT_NUMVALUES(ntohs
- (mrpdu_vectorptr->VectorHeader));
+ (mrpdu_vectorptr->
+ VectorHeader));
if (0 == numvalues) {
/* skip this null attribute ... some switches generate these ... */
@@ -600,7 +606,8 @@ int msrp_recv_msg()
srclassprio_firstval =
mrpdu_vectorptr->FirstValue_VectorEvents[1];
srclassvid_firstval = ((uint16_t)
- mrpdu_vectorptr->FirstValue_VectorEvents
+ mrpdu_vectorptr->
+ FirstValue_VectorEvents
[2]) << 8 |
mrpdu_vectorptr->FirstValue_VectorEvents[3];
@@ -614,8 +621,8 @@ int msrp_recv_msg()
vectidx <= (numvectorbytes + 4);
vectidx++) {
vect_3pack =
- mrpdu_vectorptr->FirstValue_VectorEvents
- [vectidx];
+ mrpdu_vectorptr->
+ FirstValue_VectorEvents[vectidx];
vectevt[0] = vect_3pack / 36;
vectevt[1] =
(vect_3pack - vectevt[0] * 36) / 6;
@@ -635,22 +642,22 @@ int msrp_recv_msg()
goto out; /* oops - internal error */
attrib->type = MSRP_DOMAIN_TYPE;
- attrib->attribute.
- domain.SRclassID =
+ attrib->attribute.domain.
+ SRclassID =
srclassID_firstval;
- attrib->attribute.
- domain.SRclassPriority =
+ attrib->attribute.domain.
+ SRclassPriority =
srclassprio_firstval;
- attrib->attribute.
- domain.SRclassVID =
+ attrib->attribute.domain.
+ SRclassVID =
srclassvid_firstval;
srclassID_firstval++;
srclassprio_firstval++;
- memcpy(attrib->
- registrar.macaddr,
- eth->srcaddr, 6);
+ memcpy(attrib->registrar.
+ macaddr, eth->srcaddr,
+ 6);
switch (vectevt[vectevt_idx]) {
case MRPDU_NEW:
@@ -720,17 +727,18 @@ int msrp_recv_msg()
&& (mrpdu_msg_ptr[1] == 0))) {
numvalues =
MRPDU_VECT_NUMVALUES(ntohs
- (mrpdu_vectorptr->VectorHeader));
+ (mrpdu_vectorptr->
+ VectorHeader));
#if LOG_MSRP
- mrpd_log_printf("MSRP msrp_recv_msg() LISTENER vector addr 0x%X, n = %d, VectorHeader (ntohs) %d, VectorHeader read %d\n",
- ((int)mrpdu_vectorptr) & 0x3, numvalues,
- ntohs(mrpdu_vectorptr->VectorHeader),
- ((uint8_t *)mrpdu_vectorptr)[0] << 8 | ((uint8_t *)mrpdu_vectorptr)[1]);
+ mrpd_log_printf
+ ("MSRP msrp_recv_msg() LISTENER vector addr 0x%X, n = %d, VectorHeader (ntohs) %d, VectorHeader read %d\n",
+ ((int)mrpdu_vectorptr) & 0x3, numvalues,
+ ntohs(mrpdu_vectorptr->VectorHeader),
+ ((uint8_t *) mrpdu_vectorptr)[0] << 8 |
+ ((uint8_t *) mrpdu_vectorptr)[1]);
#endif
-
-
if (0 == numvalues) {
/* 2 byte numvalues + 8 byte FirstValue + (0) vector bytes */
mrpdu_msg_ptr =
@@ -790,8 +798,8 @@ int msrp_recv_msg()
for (; vectidx < listener_endbyte; vectidx++) {
vect_4pack =
- mrpdu_vectorptr->FirstValue_VectorEvents
- [vectidx];
+ mrpdu_vectorptr->
+ FirstValue_VectorEvents[vectidx];
vectevt[3] =
vect_4pack -
@@ -841,7 +849,8 @@ int msrp_recv_msg()
numvalues =
MRPDU_VECT_NUMVALUES(ntohs
- (mrpdu_vectorptr->VectorHeader));
+ (mrpdu_vectorptr->
+ VectorHeader));
/* if not an even multiple ... */
if (numvalues != ((numvalues / 3) * 3))
@@ -855,8 +864,8 @@ int msrp_recv_msg()
vectidx <= (numvectorbytes + 8);
vectidx++) {
vect_3pack =
- mrpdu_vectorptr->FirstValue_VectorEvents
- [vectidx];
+ mrpdu_vectorptr->
+ FirstValue_VectorEvents[vectidx];
vectevt[0] = vect_3pack / 36;
vectevt[1] =
(vect_3pack - vectevt[0] * 36) / 6;
@@ -885,9 +894,8 @@ int msrp_recv_msg()
attrib->type =
MSRP_LISTENER_TYPE;
- memcpy(attrib->
- attribute.talk_listen.
- StreamID,
+ memcpy(attrib->attribute.
+ talk_listen.StreamID,
streamid_firstval, 8);
attrib->substate =
listener_vectevt
@@ -896,15 +904,15 @@ int msrp_recv_msg()
(streamid_firstval);
listener_vectevt_idx++;
- memcpy(attrib->
- registrar.macaddr,
- eth->srcaddr, 6);
+ memcpy(attrib->registrar.
+ macaddr, eth->srcaddr,
+ 6);
#if LOG_MSRP
- mrpd_log_printf("MSRP msrp_recv_msg() Listener[%d][%d] attrib %d\n",
- vectidx,
- vectevt_idx,
- vectevt[vectevt_idx]);
+ mrpd_log_printf
+ ("MSRP msrp_recv_msg() Listener[%d][%d] attrib %d\n",
+ vectidx, vectevt_idx,
+ vectevt[vectevt_idx]);
#endif
switch (vectevt[vectevt_idx]) {
@@ -952,7 +960,8 @@ int msrp_recv_msg()
numvalues =
MRPDU_VECT_NUMVALUES(ntohs
- (mrpdu_vectorptr->VectorHeader));
+ (mrpdu_vectorptr->
+ VectorHeader));
if (numvalues != ((numvalues / 4) * 4))
numvectorbytes += (numvalues / 4) + 1;
else
@@ -995,7 +1004,8 @@ int msrp_recv_msg()
&& (mrpdu_msg_ptr[1] == 0))) {
numvalues =
MRPDU_VECT_NUMVALUES(ntohs
- (mrpdu_vectorptr->VectorHeader));
+ (mrpdu_vectorptr->
+ VectorHeader));
if (0 == numvalues) {
/* 2 byte numvalues + 25 byte FirstValue + (0) vector bytes */
@@ -1033,8 +1043,8 @@ int msrp_recv_msg()
vectidx <= (numvectorbytes + 25);
vectidx++) {
vect_3pack =
- mrpdu_vectorptr->FirstValue_VectorEvents
- [vectidx];
+ mrpdu_vectorptr->
+ FirstValue_VectorEvents[vectidx];
vectevt[0] = vect_3pack / 36;
vectevt[1] =
(vect_3pack - vectevt[0] * 36) / 6;
@@ -1060,12 +1070,13 @@ int msrp_recv_msg()
attrib->direction =
MSRP_DIRECTION_LISTENER;
- memcpy(attrib->
- attribute.talk_listen.
- StreamID,
+ memcpy(attrib->attribute.
+ talk_listen.StreamID,
streamid_firstval, 8);
- memcpy(attrib->
- attribute.talk_listen.DataFrameParameters.Dest_Addr,
+ memcpy(attrib->attribute.
+ talk_listen.
+ DataFrameParameters.
+ Dest_Addr,
destmac_firstval, 6);
msrp_increment_streamid
@@ -1073,93 +1084,80 @@ int msrp_recv_msg()
mmrp_increment_macaddr
(destmac_firstval);
- attrib->attribute.
- talk_listen.DataFrameParameters.Vlan_ID
- =
- mrpdu_vectorptr->FirstValue_VectorEvents
- [14];
- attrib->attribute.
- talk_listen.DataFrameParameters.Vlan_ID
- <<= 8;
- attrib->attribute.
- talk_listen.DataFrameParameters.Vlan_ID
- |=
- mrpdu_vectorptr->FirstValue_VectorEvents
- [15];
-
- attrib->attribute.
- talk_listen.TSpec.
- MaxFrameSize =
- mrpdu_vectorptr->FirstValue_VectorEvents
- [16];
- attrib->attribute.
- talk_listen.TSpec.
- MaxFrameSize <<= 8;
- attrib->attribute.
- talk_listen.TSpec.
- MaxFrameSize |=
- mrpdu_vectorptr->FirstValue_VectorEvents
- [17];
-
- attrib->attribute.
- talk_listen.TSpec.
- MaxIntervalFrames =
- mrpdu_vectorptr->FirstValue_VectorEvents
- [18];
- attrib->attribute.
- talk_listen.TSpec.MaxIntervalFrames
- <<= 8;
- attrib->attribute.
- talk_listen.TSpec.
- MaxIntervalFrames |=
- mrpdu_vectorptr->FirstValue_VectorEvents
- [19];
-
- attrib->attribute.
- talk_listen.PriorityAndRank
- =
- mrpdu_vectorptr->FirstValue_VectorEvents
- [20];
-
- attrib->attribute.
- talk_listen.AccumulatedLatency
- =
- mrpdu_vectorptr->FirstValue_VectorEvents
- [21];
- attrib->attribute.
- talk_listen.AccumulatedLatency
- <<= 8;
- attrib->attribute.
- talk_listen.AccumulatedLatency
- |=
- mrpdu_vectorptr->FirstValue_VectorEvents
- [22];
- attrib->attribute.
- talk_listen.AccumulatedLatency
- <<= 8;
- attrib->attribute.
- talk_listen.AccumulatedLatency
- |=
- mrpdu_vectorptr->FirstValue_VectorEvents
- [23];
- attrib->attribute.
- talk_listen.AccumulatedLatency
- <<= 8;
- attrib->attribute.
- talk_listen.AccumulatedLatency
- |=
- mrpdu_vectorptr->FirstValue_VectorEvents
- [24];
-
- memcpy(attrib->
- registrar.macaddr,
- eth->srcaddr, 6);
+ attrib->attribute.talk_listen.
+ DataFrameParameters.
+ Vlan_ID =
+ mrpdu_vectorptr->
+ FirstValue_VectorEvents[14];
+ attrib->attribute.talk_listen.
+ DataFrameParameters.
+ Vlan_ID <<= 8;
+ attrib->attribute.talk_listen.
+ DataFrameParameters.
+ Vlan_ID |=
+ mrpdu_vectorptr->
+ FirstValue_VectorEvents[15];
+
+ attrib->attribute.talk_listen.
+ TSpec.MaxFrameSize =
+ mrpdu_vectorptr->
+ FirstValue_VectorEvents[16];
+ attrib->attribute.talk_listen.
+ TSpec.MaxFrameSize <<= 8;
+ attrib->attribute.talk_listen.
+ TSpec.MaxFrameSize |=
+ mrpdu_vectorptr->
+ FirstValue_VectorEvents[17];
+
+ attrib->attribute.talk_listen.
+ TSpec.MaxIntervalFrames =
+ mrpdu_vectorptr->
+ FirstValue_VectorEvents[18];
+ attrib->attribute.talk_listen.
+ TSpec.
+ MaxIntervalFrames <<= 8;
+ attrib->attribute.talk_listen.
+ TSpec.MaxIntervalFrames |=
+ mrpdu_vectorptr->
+ FirstValue_VectorEvents[19];
+
+ attrib->attribute.talk_listen.
+ PriorityAndRank =
+ mrpdu_vectorptr->
+ FirstValue_VectorEvents[20];
+
+ attrib->attribute.talk_listen.
+ AccumulatedLatency =
+ mrpdu_vectorptr->
+ FirstValue_VectorEvents[21];
+ attrib->attribute.talk_listen.
+ AccumulatedLatency <<= 8;
+ attrib->attribute.talk_listen.
+ AccumulatedLatency |=
+ mrpdu_vectorptr->
+ FirstValue_VectorEvents[22];
+ attrib->attribute.talk_listen.
+ AccumulatedLatency <<= 8;
+ attrib->attribute.talk_listen.
+ AccumulatedLatency |=
+ mrpdu_vectorptr->
+ FirstValue_VectorEvents[23];
+ attrib->attribute.talk_listen.
+ AccumulatedLatency <<= 8;
+ attrib->attribute.talk_listen.
+ AccumulatedLatency |=
+ mrpdu_vectorptr->
+ FirstValue_VectorEvents[24];
+
+ memcpy(attrib->registrar.
+ macaddr, eth->srcaddr,
+ 6);
#if LOG_MSRP
- mrpd_log_printf("MSRP msrp_recv_msg() TalkerAdv[%d][%d] attrib %d\n",
- vectidx,
- vectevt_idx,
- vectevt[vectevt_idx]);
+ mrpd_log_printf
+ ("MSRP msrp_recv_msg() TalkerAdv[%d][%d] attrib %d\n",
+ vectidx, vectevt_idx,
+ vectevt[vectevt_idx]);
#endif
switch (vectevt[vectevt_idx]) {
@@ -1229,7 +1227,8 @@ int msrp_recv_msg()
&& (mrpdu_msg_ptr[1] == 0))) {
numvalues =
MRPDU_VECT_NUMVALUES(ntohs
- (mrpdu_vectorptr->VectorHeader));
+ (mrpdu_vectorptr->
+ VectorHeader));
if (0 == numvalues) {
/* 2 byte numvalues + 34 byte FirstValue + (0) vector bytes */
@@ -1264,8 +1263,8 @@ int msrp_recv_msg()
vectidx <= (numvectorbytes + 34);
vectidx++) {
vect_3pack =
- mrpdu_vectorptr->FirstValue_VectorEvents
- [vectidx];
+ mrpdu_vectorptr->
+ FirstValue_VectorEvents[vectidx];
vectevt[0] = vect_3pack / 36;
vectevt[1] =
(vect_3pack - vectevt[0] * 36) / 6;
@@ -1292,12 +1291,13 @@ int msrp_recv_msg()
attrib->direction =
MSRP_DIRECTION_LISTENER;
- memcpy(attrib->
- attribute.talk_listen.
- StreamID,
+ memcpy(attrib->attribute.
+ talk_listen.StreamID,
streamid_firstval, 8);
- memcpy(attrib->
- attribute.talk_listen.DataFrameParameters.Dest_Addr,
+ memcpy(attrib->attribute.
+ talk_listen.
+ DataFrameParameters.
+ Dest_Addr,
destmac_firstval, 6);
msrp_increment_streamid
@@ -1305,99 +1305,88 @@ int msrp_recv_msg()
mmrp_increment_macaddr
(destmac_firstval);
- attrib->attribute.
- talk_listen.DataFrameParameters.Vlan_ID
- =
- mrpdu_vectorptr->FirstValue_VectorEvents
- [14];
- attrib->attribute.
- talk_listen.DataFrameParameters.Vlan_ID
- <<= 8;
- attrib->attribute.
- talk_listen.DataFrameParameters.Vlan_ID
- |=
- mrpdu_vectorptr->FirstValue_VectorEvents
- [15];
-
- attrib->attribute.
- talk_listen.TSpec.
- MaxFrameSize =
- mrpdu_vectorptr->FirstValue_VectorEvents
- [16];
- attrib->attribute.
- talk_listen.TSpec.
- MaxFrameSize <<= 8;
- attrib->attribute.
- talk_listen.TSpec.
- MaxFrameSize |=
- mrpdu_vectorptr->FirstValue_VectorEvents
- [17];
-
- attrib->attribute.
- talk_listen.TSpec.
- MaxIntervalFrames =
- mrpdu_vectorptr->FirstValue_VectorEvents
- [18];
- attrib->attribute.
- talk_listen.TSpec.MaxIntervalFrames
- <<= 8;
- attrib->attribute.
- talk_listen.TSpec.
- MaxIntervalFrames |=
- mrpdu_vectorptr->FirstValue_VectorEvents
- [19];
-
- attrib->attribute.
- talk_listen.PriorityAndRank
- =
- mrpdu_vectorptr->FirstValue_VectorEvents
- [20];
-
- attrib->attribute.
- talk_listen.AccumulatedLatency
- =
- mrpdu_vectorptr->FirstValue_VectorEvents
- [21];
- attrib->attribute.
- talk_listen.AccumulatedLatency
- <<= 8;
- attrib->attribute.
- talk_listen.AccumulatedLatency
- |=
- mrpdu_vectorptr->FirstValue_VectorEvents
- [22];
- attrib->attribute.
- talk_listen.AccumulatedLatency
- <<= 8;
- attrib->attribute.
- talk_listen.AccumulatedLatency
- |=
- mrpdu_vectorptr->FirstValue_VectorEvents
- [23];
- attrib->attribute.
- talk_listen.AccumulatedLatency
- <<= 8;
- attrib->attribute.
- talk_listen.AccumulatedLatency
- |=
- mrpdu_vectorptr->FirstValue_VectorEvents
- [24];
-
- memcpy(attrib->
- attribute.talk_listen.FailureInformation.BridgeID,
- &
- (mrpdu_vectorptr->FirstValue_VectorEvents
- [25]), 8);
-
- attrib->attribute.
- talk_listen.FailureInformation.FailureCode
- =
- mrpdu_vectorptr->FirstValue_VectorEvents
- [33];
-
- memcpy(attrib->
- registrar.macaddr,
- eth->srcaddr, 6);
+ attrib->attribute.talk_listen.
+ DataFrameParameters.
+ Vlan_ID =
+ mrpdu_vectorptr->
+ FirstValue_VectorEvents[14];
+ attrib->attribute.talk_listen.
+ DataFrameParameters.
+ Vlan_ID <<= 8;
+ attrib->attribute.talk_listen.
+ DataFrameParameters.
+ Vlan_ID |=
+ mrpdu_vectorptr->
+ FirstValue_VectorEvents[15];
+
+ attrib->attribute.talk_listen.
+ TSpec.MaxFrameSize =
+ mrpdu_vectorptr->
+ FirstValue_VectorEvents[16];
+ attrib->attribute.talk_listen.
+ TSpec.MaxFrameSize <<= 8;
+ attrib->attribute.talk_listen.
+ TSpec.MaxFrameSize |=
+ mrpdu_vectorptr->
+ FirstValue_VectorEvents[17];
+
+ attrib->attribute.talk_listen.
+ TSpec.MaxIntervalFrames =
+ mrpdu_vectorptr->
+ FirstValue_VectorEvents[18];
+ attrib->attribute.talk_listen.
+ TSpec.
+ MaxIntervalFrames <<= 8;
+ attrib->attribute.talk_listen.
+ TSpec.MaxIntervalFrames |=
+ mrpdu_vectorptr->
+ FirstValue_VectorEvents[19];
+
+ attrib->attribute.talk_listen.
+ PriorityAndRank =
+ mrpdu_vectorptr->
+ FirstValue_VectorEvents[20];
+
+ attrib->attribute.talk_listen.
+ AccumulatedLatency =
+ mrpdu_vectorptr->
+ FirstValue_VectorEvents[21];
+ attrib->attribute.talk_listen.
+ AccumulatedLatency <<= 8;
+ attrib->attribute.talk_listen.
+ AccumulatedLatency |=
+ mrpdu_vectorptr->
+ FirstValue_VectorEvents[22];
+ attrib->attribute.talk_listen.
+ AccumulatedLatency <<= 8;
+ attrib->attribute.talk_listen.
+ AccumulatedLatency |=
+ mrpdu_vectorptr->
+ FirstValue_VectorEvents[23];
+ attrib->attribute.talk_listen.
+ AccumulatedLatency <<= 8;
+ attrib->attribute.talk_listen.
+ AccumulatedLatency |=
+ mrpdu_vectorptr->
+ FirstValue_VectorEvents[24];
+
+ memcpy(attrib->attribute.
+ talk_listen.
+ FailureInformation.
+ BridgeID,
+ &(mrpdu_vectorptr->
+ FirstValue_VectorEvents
+ [25]), 8);
+
+ attrib->attribute.talk_listen.
+ FailureInformation.
+ FailureCode =
+ mrpdu_vectorptr->
+ FirstValue_VectorEvents[33];
+
+ memcpy(attrib->registrar.
+ macaddr, eth->srcaddr,
+ 6);
switch (vectevt[vectevt_idx]) {
case MRPDU_NEW:
@@ -1455,8 +1444,9 @@ int msrp_recv_msg()
* we can seek for an endmark to recover .. but this version
* dumps the entire packet as malformed
*/
- printf("################## unrecognized attribute type (%d)\n",
- mrpdu_msg->AttributeType);
+ printf
+ ("################## unrecognized attribute type (%d)\n",
+ mrpdu_msg->AttributeType);
goto out;
}
}
@@ -1477,7 +1467,7 @@ int msrp_recv_msg()
int
msrp_emit_domainvectors(unsigned char *msgbuf, unsigned char *msgbuf_eof,
- int *bytes_used, int lva)
+ int *bytes_used, int lva)
{
mrpdu_vectorattrib_t *mrpdu_vectorptr;
uint16_t numvalues;
@@ -1489,7 +1479,11 @@ msrp_emit_domainvectors(unsigned char *msgbuf, unsigned char *msgbuf_eof,
uint8_t srclassprio_firstval;
uint16_t srclassvid_firstval;
int attriblistlen;
- struct msrp_attribute *attrib, *vattrib;
+ struct msrp_attribute *attrib;
+/* pending review and deletion */
+#ifdef MSRP_AGGREGATE_DOMAINS_VECTORS
+ struct msrp_attribute *vattrib;
+#endif
mrpdu_message_t *mrpdu_msg;
unsigned char *mrpdu_msg_ptr = msgbuf;
unsigned char *mrpdu_msg_eof = msgbuf_eof;
@@ -1504,7 +1498,7 @@ msrp_emit_domainvectors(unsigned char *msgbuf, unsigned char *msgbuf_eof,
attrib = MSRP_db->attrib_list;
- mrpdu_vectorptr = (mrpdu_vectorattrib_t *)&(mrpdu_msg->Data[2]);
+ mrpdu_vectorptr = (mrpdu_vectorattrib_t *) & (mrpdu_msg->Data[2]);
while ((mrpdu_msg_ptr < (mrpdu_msg_eof - 2)) && (NULL != attrib)) {
@@ -1528,11 +1522,14 @@ msrp_emit_domainvectors(unsigned char *msgbuf, unsigned char *msgbuf_eof,
srclassprio_firstval = attrib->attribute.domain.SRclassPriority;
srclassvid_firstval = attrib->attribute.domain.SRclassVID;
-
- mrpdu_vectorptr->FirstValue_VectorEvents[0] = srclassID_firstval;
- mrpdu_vectorptr->FirstValue_VectorEvents[1] = srclassprio_firstval;
- mrpdu_vectorptr->FirstValue_VectorEvents[2] = (uint8_t)(srclassvid_firstval >> 8);
- mrpdu_vectorptr->FirstValue_VectorEvents[3] = (uint8_t)srclassvid_firstval;
+ mrpdu_vectorptr->FirstValue_VectorEvents[0] =
+ srclassID_firstval;
+ mrpdu_vectorptr->FirstValue_VectorEvents[1] =
+ srclassprio_firstval;
+ mrpdu_vectorptr->FirstValue_VectorEvents[2] =
+ (uint8_t) (srclassvid_firstval >> 8);
+ mrpdu_vectorptr->FirstValue_VectorEvents[3] =
+ (uint8_t) srclassvid_firstval;
switch (attrib->applicant.sndmsg) {
case MRP_SND_IN:
@@ -1580,6 +1577,9 @@ msrp_emit_domainvectors(unsigned char *msgbuf, unsigned char *msgbuf_eof,
*/
vectidx = 4;
+
+/* pending review and deletion */
+#ifdef MSRP_AGGREGATE_DOMAINS_VECTORS
vattrib = attrib->next;
while (NULL != vattrib) {
@@ -1592,7 +1592,8 @@ msrp_emit_domainvectors(unsigned char *msgbuf, unsigned char *msgbuf_eof,
srclassID_firstval++;
srclassprio_firstval++;
- if (srclassID_firstval != vattrib->attribute.domain.SRclassID)
+ if (srclassID_firstval !=
+ vattrib->attribute.domain.SRclassID)
break;
vattrib->applicant.tx = 0;
@@ -1642,9 +1643,8 @@ msrp_emit_domainvectors(unsigned char *msgbuf, unsigned char *msgbuf_eof,
vectevt[1],
vectevt[2]);
- mrpdu_vectorptr->
- FirstValue_VectorEvents[vectidx] =
- vect_3pack;
+ mrpdu_vectorptr->FirstValue_VectorEvents
+ [vectidx] = vect_3pack;
vectidx++;
vectevt[0] = 0;
vectevt[1] = 0;
@@ -1658,6 +1658,7 @@ msrp_emit_domainvectors(unsigned char *msgbuf, unsigned char *msgbuf_eof,
vattrib = vattrib->next;
}
+#endif
/* handle any trailers */
if (vectevt_idx > 0) {
@@ -1689,7 +1690,7 @@ msrp_emit_domainvectors(unsigned char *msgbuf, unsigned char *msgbuf_eof,
}
- if (mrpdu_vectorptr == (mrpdu_vectorattrib_t *)&(mrpdu_msg->Data[2])) {
+ if (mrpdu_vectorptr == (mrpdu_vectorattrib_t *) & (mrpdu_msg->Data[2])) {
*bytes_used = 0;
return 0;
}
@@ -1719,9 +1720,6 @@ msrp_emit_domainvectors(unsigned char *msgbuf, unsigned char *msgbuf_eof,
return -1;
}
-
-
-
int
msrp_emit_talkvectors(unsigned char *msgbuf, unsigned char *msgbuf_eof,
int *bytes_used, int lva)
@@ -1786,19 +1784,19 @@ msrp_emit_talkvectors(unsigned char *msgbuf, unsigned char *msgbuf_eof,
memcpy(streamid_firstval,
attrib->attribute.talk_listen.StreamID, 8);
memcpy(destmac_firstval,
- attrib->attribute.talk_listen.
- DataFrameParameters.Dest_Addr, 6);
+ attrib->attribute.talk_listen.DataFrameParameters.
+ Dest_Addr, 6);
memcpy(mrpdu_vectorptr->FirstValue_VectorEvents,
streamid_firstval, 8);
memcpy(&(mrpdu_vectorptr->FirstValue_VectorEvents[8]),
destmac_firstval, 6);
mrpdu_vectorptr->FirstValue_VectorEvents[14] =
- attrib->attribute.talk_listen.
- DataFrameParameters.Vlan_ID >> 8;
+ attrib->attribute.talk_listen.DataFrameParameters.
+ Vlan_ID >> 8;
mrpdu_vectorptr->FirstValue_VectorEvents[15] =
- (uint8_t) attrib->attribute.talk_listen.DataFrameParameters.
- Vlan_ID;
+ (uint8_t) attrib->attribute.talk_listen.
+ DataFrameParameters.Vlan_ID;
mrpdu_vectorptr->FirstValue_VectorEvents[16] =
attrib->attribute.talk_listen.TSpec.MaxFrameSize >> 8;
@@ -1808,8 +1806,8 @@ msrp_emit_talkvectors(unsigned char *msgbuf, unsigned char *msgbuf_eof,
mrpdu_vectorptr->FirstValue_VectorEvents[18] =
attrib->attribute.talk_listen.TSpec.MaxIntervalFrames >> 8;
mrpdu_vectorptr->FirstValue_VectorEvents[19] =
- (uint8_t) attrib->attribute.talk_listen.TSpec.
- MaxIntervalFrames;
+ (uint8_t) attrib->attribute.talk_listen.
+ TSpec.MaxIntervalFrames;
mrpdu_vectorptr->FirstValue_VectorEvents[20] =
attrib->attribute.talk_listen.PriorityAndRank;
@@ -2038,8 +2036,18 @@ msrp_emit_listenvectors(unsigned char *msgbuf, unsigned char *msgbuf_eof,
if (NULL == listen_declare)
goto oops;
+ /* if we have a listener type registered, always send out an update,
+ * so mark all as ready.
+ */
attrib = MSRP_db->attrib_list;
+ while (attrib) {
+ if (MSRP_LISTENER_TYPE == attrib->type) {
+ attrib->applicant.tx = 1;
+ }
+ attrib = attrib->next;
+ }
+ attrib = MSRP_db->attrib_list;
mrpdu_vectorptr = (mrpdu_vectorattrib_t *) & (mrpdu_msg->Data[2]);
while ((mrpdu_msg_ptr < (mrpdu_msg_eof - 2)) && (NULL != attrib)) {
@@ -2049,6 +2057,11 @@ msrp_emit_listenvectors(unsigned char *msgbuf, unsigned char *msgbuf_eof,
continue;
}
+ if (0 == attrib->applicant.tx) {
+ attrib = attrib->next;
+ continue;
+ }
+
listen_declare_idx = 0;
/* if we have a listener type registered, we always will
@@ -2237,27 +2250,23 @@ msrp_emit_listenvectors(unsigned char *msgbuf, unsigned char *msgbuf_eof,
> (mrpdu_msg_eof - 2))
goto oops;
- if (vectevt_idx > 3) {
- vect_4pack =
- MRPDU_4PACK_ENCODE(listen_declare
- [listen_declare_idx],
- listen_declare
- [listen_declare_idx + 1],
- listen_declare
- [listen_declare_idx + 2],
- listen_declare
- [listen_declare_idx +
- 3]);
-
- mrpdu_vectorptr->FirstValue_VectorEvents
- [vectidx] = vect_4pack;
- vectidx++;
- }
+ vect_4pack =
+ MRPDU_4PACK_ENCODE(listen_declare
+ [listen_declare_idx],
+ listen_declare
+ [listen_declare_idx + 1],
+ listen_declare
+ [listen_declare_idx + 2],
+ listen_declare
+ [listen_declare_idx + 3]);
+
+ mrpdu_vectorptr->FirstValue_VectorEvents
+ [vectidx] = vect_4pack;
+ vectidx++;
if (&(mrpdu_vectorptr->FirstValue_VectorEvents[vectidx])
> (mrpdu_msg_eof - 3))
goto oops;
-
}
/* handle any trailers */
@@ -2424,9 +2433,9 @@ int msrp_txpdu(void)
int msrp_send_notifications(struct msrp_attribute *attrib, int notify)
{
char *msgbuf;
- char *stage;
char *variant;
char *regsrc;
+ char mrp_state[8];
client_t *client;
if (NULL == attrib)
@@ -2436,13 +2445,12 @@ int msrp_send_notifications(struct msrp_attribute *attrib, int notify)
if (NULL == msgbuf)
return -1;
- stage = variant = regsrc = NULL;
+ variant = regsrc = NULL;
- stage = (char *)malloc(128);
variant = (char *)malloc(128);
regsrc = (char *)malloc(128);
- if ((NULL == stage) || (NULL == variant) || (NULL == regsrc))
+ if ((NULL == variant) || (NULL == regsrc))
goto free_msgbuf;
memset(msgbuf, 0, MAX_MRPD_CMDSZ);
@@ -2481,42 +2489,42 @@ int msrp_send_notifications(struct msrp_attribute *attrib, int notify)
attrib->attribute.talk_listen.StreamID[5],
attrib->attribute.talk_listen.StreamID[6],
attrib->attribute.talk_listen.StreamID[7],
- attrib->attribute.talk_listen.
- DataFrameParameters.Dest_Addr[0],
- attrib->attribute.talk_listen.
- DataFrameParameters.Dest_Addr[1],
- attrib->attribute.talk_listen.
- DataFrameParameters.Dest_Addr[2],
- attrib->attribute.talk_listen.
- DataFrameParameters.Dest_Addr[3],
- attrib->attribute.talk_listen.
- DataFrameParameters.Dest_Addr[4],
- attrib->attribute.talk_listen.
- DataFrameParameters.Dest_Addr[5],
- attrib->attribute.talk_listen.
- DataFrameParameters.Vlan_ID,
+ attrib->attribute.talk_listen.DataFrameParameters.
+ Dest_Addr[0],
+ attrib->attribute.talk_listen.DataFrameParameters.
+ Dest_Addr[1],
+ attrib->attribute.talk_listen.DataFrameParameters.
+ Dest_Addr[2],
+ attrib->attribute.talk_listen.DataFrameParameters.
+ Dest_Addr[3],
+ attrib->attribute.talk_listen.DataFrameParameters.
+ Dest_Addr[4],
+ attrib->attribute.talk_listen.DataFrameParameters.
+ Dest_Addr[5],
+ attrib->attribute.talk_listen.DataFrameParameters.
+ Vlan_ID,
attrib->attribute.talk_listen.TSpec.MaxFrameSize,
attrib->attribute.talk_listen.TSpec.MaxIntervalFrames,
attrib->attribute.talk_listen.PriorityAndRank,
attrib->attribute.talk_listen.AccumulatedLatency,
- attrib->attribute.talk_listen.
- FailureInformation.BridgeID[0],
- attrib->attribute.talk_listen.
- FailureInformation.BridgeID[1],
- attrib->attribute.talk_listen.
- FailureInformation.BridgeID[2],
- attrib->attribute.talk_listen.
- FailureInformation.BridgeID[3],
- attrib->attribute.talk_listen.
- FailureInformation.BridgeID[4],
- attrib->attribute.talk_listen.
- FailureInformation.BridgeID[5],
- attrib->attribute.talk_listen.
- FailureInformation.BridgeID[6],
- attrib->attribute.talk_listen.
- FailureInformation.BridgeID[7],
- attrib->attribute.talk_listen.
- FailureInformation.FailureCode);
+ attrib->attribute.talk_listen.FailureInformation.
+ BridgeID[0],
+ attrib->attribute.talk_listen.FailureInformation.
+ BridgeID[1],
+ attrib->attribute.talk_listen.FailureInformation.
+ BridgeID[2],
+ attrib->attribute.talk_listen.FailureInformation.
+ BridgeID[3],
+ attrib->attribute.talk_listen.FailureInformation.
+ BridgeID[4],
+ attrib->attribute.talk_listen.FailureInformation.
+ BridgeID[5],
+ attrib->attribute.talk_listen.FailureInformation.
+ BridgeID[6],
+ attrib->attribute.talk_listen.FailureInformation.
+ BridgeID[7],
+ attrib->attribute.talk_listen.FailureInformation.
+ FailureCode);
}
sprintf(regsrc, "R=%02x%02x%02x%02x%02x%02x",
@@ -2526,15 +2534,18 @@ int msrp_send_notifications(struct msrp_attribute *attrib, int notify)
attrib->registrar.macaddr[3],
attrib->registrar.macaddr[4], attrib->registrar.macaddr[5]);
+ mrp_decode_state(&attrib->registrar, &attrib->applicant,
+ mrp_state, sizeof(mrp_state));
+
switch (notify) {
case MRP_NOTIFY_NEW:
- sprintf(msgbuf, "SNE %s %s\n", variant, regsrc);
+ sprintf(msgbuf, "SNE %s %s %s\n", variant, regsrc, mrp_state);
break;
case MRP_NOTIFY_JOIN:
- sprintf(msgbuf, "SJO %s %s\n", variant, regsrc);
+ sprintf(msgbuf, "SJO %s %s %s\n", variant, regsrc, mrp_state);
break;
case MRP_NOTIFY_LV:
- sprintf(msgbuf, "SLE %s %s\n", variant, regsrc);
+ sprintf(msgbuf, "SLE %s %s %s\n", variant, regsrc, mrp_state);
break;
default:
goto free_msgbuf;
@@ -2552,8 +2563,6 @@ int msrp_send_notifications(struct msrp_attribute *attrib, int notify)
free(regsrc);
if (variant)
free(variant);
- if (stage)
- free(stage);
free(msgbuf);
return 0;
}
@@ -2626,45 +2635,45 @@ int msrp_dumptable(struct sockaddr_in *client)
attrib->attribute.talk_listen.StreamID[5],
attrib->attribute.talk_listen.StreamID[6],
attrib->attribute.talk_listen.StreamID[7],
- attrib->attribute.
- talk_listen.DataFrameParameters.Dest_Addr[0],
- attrib->attribute.
- talk_listen.DataFrameParameters.Dest_Addr[1],
- attrib->attribute.
- talk_listen.DataFrameParameters.Dest_Addr[2],
- attrib->attribute.
- talk_listen.DataFrameParameters.Dest_Addr[3],
- attrib->attribute.
- talk_listen.DataFrameParameters.Dest_Addr[4],
- attrib->attribute.
- talk_listen.DataFrameParameters.Dest_Addr[5],
- attrib->attribute.
- talk_listen.DataFrameParameters.Vlan_ID,
attrib->attribute.talk_listen.
- TSpec.MaxFrameSize,
+ DataFrameParameters.Dest_Addr[0],
attrib->attribute.talk_listen.
- TSpec.MaxIntervalFrames,
+ DataFrameParameters.Dest_Addr[1],
+ attrib->attribute.talk_listen.
+ DataFrameParameters.Dest_Addr[2],
+ attrib->attribute.talk_listen.
+ DataFrameParameters.Dest_Addr[3],
+ attrib->attribute.talk_listen.
+ DataFrameParameters.Dest_Addr[4],
+ attrib->attribute.talk_listen.
+ DataFrameParameters.Dest_Addr[5],
+ attrib->attribute.talk_listen.
+ DataFrameParameters.Vlan_ID,
+ attrib->attribute.talk_listen.TSpec.
+ MaxFrameSize,
+ attrib->attribute.talk_listen.TSpec.
+ MaxIntervalFrames,
attrib->attribute.talk_listen.PriorityAndRank,
- attrib->attribute.
- talk_listen.AccumulatedLatency,
- attrib->attribute.
- talk_listen.FailureInformation.BridgeID[0],
- attrib->attribute.
- talk_listen.FailureInformation.BridgeID[1],
- attrib->attribute.
- talk_listen.FailureInformation.BridgeID[2],
- attrib->attribute.
- talk_listen.FailureInformation.BridgeID[3],
- attrib->attribute.
- talk_listen.FailureInformation.BridgeID[4],
- attrib->attribute.
- talk_listen.FailureInformation.BridgeID[5],
- attrib->attribute.
- talk_listen.FailureInformation.BridgeID[6],
- attrib->attribute.
- talk_listen.FailureInformation.BridgeID[7],
- attrib->attribute.
- talk_listen.FailureInformation.FailureCode);
+ attrib->attribute.talk_listen.
+ AccumulatedLatency,
+ attrib->attribute.talk_listen.
+ FailureInformation.BridgeID[0],
+ attrib->attribute.talk_listen.
+ FailureInformation.BridgeID[1],
+ attrib->attribute.talk_listen.
+ FailureInformation.BridgeID[2],
+ attrib->attribute.talk_listen.
+ FailureInformation.BridgeID[3],
+ attrib->attribute.talk_listen.
+ FailureInformation.BridgeID[4],
+ attrib->attribute.talk_listen.
+ FailureInformation.BridgeID[5],
+ attrib->attribute.talk_listen.
+ FailureInformation.BridgeID[6],
+ attrib->attribute.talk_listen.
+ FailureInformation.BridgeID[7],
+ attrib->attribute.talk_listen.
+ FailureInformation.FailureCode);
}
mrp_decode_state(&attrib->registrar, &attrib->applicant,
@@ -2702,8 +2711,8 @@ int msrp_dumptable(struct sockaddr_in *client)
/* S+? - (re)JOIN a stream */
/* S++ - NEW a stream */
static int msrp_cmd_parse_join_or_new_stream(char *buf, int buflen,
- struct msrpdu_talker_fail *talker_ad,
- int *err_index)
+ struct msrpdu_talker_fail
+ *talker_ad, int *err_index)
{
struct parse_param specs[] = {
{"S" PARSE_ASSIGN, parse_c64, talker_ad->StreamID},
@@ -2736,7 +2745,8 @@ static int msrp_cmd_parse_join_or_new_stream(char *buf, int buflen,
*
*/
-static int msrp_cmd_join_or_new_stream(struct msrpdu_talker_fail *talker_ad, int mrp_event)
+static int msrp_cmd_join_or_new_stream(struct msrpdu_talker_fail *talker_ad,
+ int mrp_event)
{
struct msrp_attribute *attrib;
@@ -2752,8 +2762,8 @@ static int msrp_cmd_join_or_new_stream(struct msrpdu_talker_fail *talker_ad, int
/* S-- - LV a stream */
static int msrp_cmd_parse_leave_stream(char *buf, int buflen,
- struct msrpdu_talker_fail *talker_ad,
- int *err_index)
+ struct msrpdu_talker_fail *talker_ad,
+ int *err_index)
{
struct parse_param specs[] = {
{"S" PARSE_ASSIGN, parse_c64, talker_ad->StreamID},
@@ -2782,8 +2792,10 @@ static int msrp_cmd_leave_stream(struct msrpdu_talker_fail *talker_ad)
/* S+L Report a listener status */
static int msrp_cmd_parse_report_listener_status(char *buf, int buflen,
- struct msrpdu_talker_fail *talker_ad,
- uint32_t * substate, int *err_index)
+ struct msrpdu_talker_fail
+ *talker_ad,
+ uint32_t * substate,
+ int *err_index)
{
struct parse_param specs[] = {
{"L" PARSE_ASSIGN, parse_c64, talker_ad->StreamID},
@@ -2797,7 +2809,7 @@ static int msrp_cmd_parse_report_listener_status(char *buf, int buflen,
}
static int msrp_cmd_report_listener_status(struct msrpdu_talker_fail *talker_ad,
- uint32_t substate)
+ uint32_t substate)
{
struct msrp_attribute *attrib;
@@ -2815,9 +2827,8 @@ static int msrp_cmd_report_listener_status(struct msrpdu_talker_fail *talker_ad,
}
/* S-L Withdraw a listener status */
-static int msrp_cmd_parse_withdraw_listener_status(char *buf, int buflen,
- struct msrpdu_talker_fail
- *talker_ad, int *err_index)
+static int msrp_cmd_parse_withdraw_listener_status(char *buf, int buflen, struct msrpdu_talker_fail
+ *talker_ad, int *err_index)
{
struct parse_param specs[] = {
{"L" PARSE_ASSIGN, parse_c64, talker_ad->StreamID},
@@ -2830,7 +2841,8 @@ static int msrp_cmd_parse_withdraw_listener_status(char *buf, int buflen,
return parse(buf + 4, buflen - 4, specs, err_index);
}
-static int msrp_cmd_withdraw_listener_status(struct msrpdu_talker_fail *talker_ad)
+static int msrp_cmd_withdraw_listener_status(struct msrpdu_talker_fail
+ *talker_ad)
{
struct msrp_attribute *attrib;
@@ -2848,7 +2860,8 @@ static int msrp_cmd_withdraw_listener_status(struct msrpdu_talker_fail *talker_a
/* S+D Report a domain status */
/* S-D Withdraw a domain status */
static int msrp_cmd_parse_domain_status(char *buf, int buflen,
- struct msrpdu_domain *domain, int *err_index)
+ struct msrpdu_domain *domain,
+ int *err_index)
{
struct parse_param specs[] = {
{"C" PARSE_ASSIGN, parse_u8, &domain->SRclassID},
@@ -2862,7 +2875,8 @@ static int msrp_cmd_parse_domain_status(char *buf, int buflen,
return parse(buf + 4, buflen - 4, specs, err_index);
}
-static int msrp_cmd_report_domain_status(struct msrpdu_domain *domain, int report)
+static int msrp_cmd_report_domain_status(struct msrpdu_domain *domain,
+ int report)
{
struct msrp_attribute *attrib;
diff --git a/daemons/mrpd/mvrp.c b/daemons/mrpd/mvrp.c
index 2ca2f9ae..fdad327c 100644
--- a/daemons/mrpd/mvrp.c
+++ b/daemons/mrpd/mvrp.c
@@ -143,7 +143,6 @@ int mvrp_event(int event, struct mvrp_attribute *rattrib)
struct mvrp_attribute *attrib;
int rc;
-
#if LOG_MVRP
mrpd_log_printf("MVRP event %s\n", mrp_event_string(event));
#endif
@@ -159,7 +158,8 @@ int mvrp_event(int event, struct mvrp_attribute *rattrib)
#if LOG_MVRP
mrpd_log_printf("MVRP -> mrp_applicant_fsm\n");
#endif
- mrp_applicant_fsm(&(MVRP_db->mrp_db), &(attrib->applicant), MRP_EVENT_TXLA);
+ mrp_applicant_fsm(&(MVRP_db->mrp_db),
+ &(attrib->applicant), MRP_EVENT_TXLA);
mrp_registrar_fsm(&(attrib->registrar),
&(MVRP_db->mrp_db), MRP_EVENT_TXLA);
attrib = attrib->next;
@@ -178,7 +178,8 @@ int mvrp_event(int event, struct mvrp_attribute *rattrib)
#if LOG_MVRP
mrpd_log_printf("MVRP -> mrp_applicant_fsm\n");
#endif
- mrp_applicant_fsm(&(MVRP_db->mrp_db), &(attrib->applicant), MRP_EVENT_RLA);
+ mrp_applicant_fsm(&(MVRP_db->mrp_db),
+ &(attrib->applicant), MRP_EVENT_RLA);
mrp_registrar_fsm(&(attrib->registrar),
&(MVRP_db->mrp_db), MRP_EVENT_RLA);
attrib = attrib->next;
@@ -195,7 +196,8 @@ int mvrp_event(int event, struct mvrp_attribute *rattrib)
#if LOG_MVRP
mrpd_log_printf("MVRP -> mrp_applicant_fsm\n");
#endif
- mrp_applicant_fsm(&(MVRP_db->mrp_db), &(attrib->applicant), MRP_EVENT_TX);
+ mrp_applicant_fsm(&(MVRP_db->mrp_db),
+ &(attrib->applicant), MRP_EVENT_TX);
attrib = attrib->next;
}
@@ -222,7 +224,8 @@ int mvrp_event(int event, struct mvrp_attribute *rattrib)
#if LOG_MVRP
mrpd_log_printf("MVRP -> mrp_applicant_fsm\n");
#endif
- mrp_applicant_fsm(&(MVRP_db->mrp_db), &(attrib->applicant),
+ mrp_applicant_fsm(&(MVRP_db->mrp_db),
+ &(attrib->applicant),
MRP_EVENT_PERIODIC);
attrib = attrib->next;
}
@@ -254,7 +257,8 @@ int mvrp_event(int event, struct mvrp_attribute *rattrib)
#if LOG_MVRP
mrpd_log_printf("MVRP -> mrp_applicant_fsm\n");
#endif
- mrp_applicant_fsm(&(MVRP_db->mrp_db), &(attrib->applicant), event);
+ mrp_applicant_fsm(&(MVRP_db->mrp_db), &(attrib->applicant),
+ event);
/* remap local requests into registrar events */
switch (event) {
case MRP_EVENT_NEW:
@@ -439,7 +443,8 @@ int mvrp_recv_msg(void)
&& (mrpdu_msg_ptr[1] == 0))) {
numvalues =
MRPDU_VECT_NUMVALUES(ntohs
- (mrpdu_vectorptr->VectorHeader));
+ (mrpdu_vectorptr->
+ VectorHeader));
if (0 == numvalues)
/* Malformed - cant tell how long the trailing vectors are */
@@ -451,10 +456,11 @@ int mvrp_recv_msg(void)
goto out;
vid_firstval = (((uint16_t)
- mrpdu_vectorptr->FirstValue_VectorEvents
- [0]) << 8)
- |
- mrpdu_vectorptr->FirstValue_VectorEvents[1];
+ mrpdu_vectorptr->
+ FirstValue_VectorEvents[0]) <<
+ 8)
+ | mrpdu_vectorptr->
+ FirstValue_VectorEvents[1];
/* if not an even multiple ... */
if (numvalues != ((numvalues / 3) * 3))
@@ -466,8 +472,8 @@ int mvrp_recv_msg(void)
vectidx <= (numvectorbytes + 2);
vectidx++) {
vect_3pack =
- mrpdu_vectorptr->FirstValue_VectorEvents
- [vectidx];
+ mrpdu_vectorptr->
+ FirstValue_VectorEvents[vectidx];
vectevt[0] = vect_3pack / 36;
vectevt[1] =
(vect_3pack - vectevt[0] * 36) / 6;
@@ -492,9 +498,9 @@ int mvrp_recv_msg(void)
attrib->attribute =
vid_firstval;
vid_firstval++;
- memcpy(attrib->
- registrar.macaddr,
- eth->srcaddr, 6);
+ memcpy(attrib->registrar.
+ macaddr, eth->srcaddr,
+ 6);
switch (vectevt[vectevt_idx]) {
case MRPDU_NEW:
@@ -616,7 +622,7 @@ mvrp_emit_vidvectors(unsigned char *msgbuf, unsigned char *msgbuf_eof,
switch (attrib->applicant.sndmsg) {
case MRP_SND_IN:
/*
- * If 'In' in indicated by the applicant attribute, the
+ * If 'In' is indicated by the applicant attribute, then
* look at the registrar state to determine whether to
* send an In (if registrar is also In) or an Mt if the
* registrar is either Mt or Lv.
@@ -633,7 +639,7 @@ mvrp_emit_vidvectors(unsigned char *msgbuf, unsigned char *msgbuf_eof,
vectevt[0] = MRPDU_LV;
break;
case MRP_SND_JOIN:
- /* IF 'Join' in indicated by the applicant, look at
+ /* If 'Join' in indicated by the applicant, look at
* the corresponding registrar state to determine whether
* to send a JoinIn (if the registar state is 'In') or
* a JoinMt if the registrar state is MT or LV.
@@ -675,7 +681,7 @@ mvrp_emit_vidvectors(unsigned char *msgbuf, unsigned char *msgbuf_eof,
switch (vattrib->applicant.sndmsg) {
case MRP_SND_IN:
/*
- * If 'In' in indicated by the applicant attribute, the
+ * If 'In' is indicated by the applicant attribute, then
* look at the registrar state to determine whether to
* send an In (if registrar is also In) or an Mt if the
* registrar is either Mt or Lv.
@@ -693,7 +699,7 @@ mvrp_emit_vidvectors(unsigned char *msgbuf, unsigned char *msgbuf_eof,
vectevt[vectevt_idx] = MRPDU_LV;
break;
case MRP_SND_JOIN:
- /* IF 'Join' in indicated by the applicant, look at
+ /* If 'Join' in indicated by the applicant, look at
* the corresponding registrar state to determine whether
* to send a JoinIn (if the registar state is 'In') or
* a JoinMt if the registrar state is MT or LV.
@@ -901,9 +907,9 @@ int mvrp_txpdu(void)
int mvrp_send_notifications(struct mvrp_attribute *attrib, int notify)
{
char *msgbuf;
- char *stage;
char *variant;
char *regsrc;
+ char mrp_state[8];
client_t *client;
if (NULL == attrib)
@@ -913,13 +919,12 @@ int mvrp_send_notifications(struct mvrp_attribute *attrib, int notify)
if (NULL == msgbuf)
return -1;
- stage = variant = regsrc = NULL;
+ variant = regsrc = NULL;
- stage = (char *)malloc(128);
variant = (char *)malloc(128);
regsrc = (char *)malloc(128);
- if ((NULL == stage) || (NULL == variant) || (NULL == regsrc))
+ if ((NULL == variant) || (NULL == regsrc))
goto free_msgbuf;
memset(msgbuf, 0, MAX_MRPD_CMDSZ);
@@ -931,32 +936,21 @@ int mvrp_send_notifications(struct mvrp_attribute *attrib, int notify)
attrib->registrar.macaddr[1],
attrib->registrar.macaddr[2],
attrib->registrar.macaddr[3],
- attrib->registrar.macaddr[4],
- attrib->registrar.macaddr[5]);
+ attrib->registrar.macaddr[4], attrib->registrar.macaddr[5]);
+
+ mrp_decode_state(&attrib->registrar, &attrib->applicant,
+ mrp_state, sizeof(mrp_state));
- switch (attrib->registrar.mrp_state) {
- case MRP_IN_STATE:
- sprintf(stage, "VIN %s %s", variant, regsrc);
- break;
- case MRP_LV_STATE:
- sprintf(stage, "VLV %s %s", variant, regsrc);
- break;
- case MRP_MT_STATE:
- sprintf(stage, "VMT %s %s", variant, regsrc);
- break;
- default:
- break;
- }
switch (notify) {
case MRP_NOTIFY_NEW:
- snprintf(msgbuf, MAX_MRPD_CMDSZ - 1, "VNE %s\n", stage);
+ snprintf(msgbuf, MAX_MRPD_CMDSZ - 1, "VNE %s %s %s\n", variant, regsrc, mrp_state);
break;
case MRP_NOTIFY_JOIN:
- snprintf(msgbuf, MAX_MRPD_CMDSZ - 1, "VJO %s\n", stage);
+ snprintf(msgbuf, MAX_MRPD_CMDSZ - 1, "VJO %s %s %s\n", variant, regsrc, mrp_state);
break;
case MRP_NOTIFY_LV:
- snprintf(msgbuf, MAX_MRPD_CMDSZ - 1, "VLE %s\n", stage);
+ snprintf(msgbuf, MAX_MRPD_CMDSZ - 1, "VLE %s %s %s\n", variant, regsrc, mrp_state);
break;
default:
goto free_msgbuf;
@@ -974,8 +968,6 @@ int mvrp_send_notifications(struct mvrp_attribute *attrib, int notify)
free(regsrc);
if (variant)
free(variant);
- if (stage)
- free(stage);
free(msgbuf);
return 0;
}
@@ -1024,8 +1016,7 @@ int mvrp_dumptable(struct sockaddr_in *client)
attrib->registrar.macaddr[2],
attrib->registrar.macaddr[3],
attrib->registrar.macaddr[4],
- attrib->registrar.macaddr[5],
- mrp_state);
+ attrib->registrar.macaddr[5], mrp_state);
sprintf(stage, "%s %s\n", variant, regsrc);
sprintf(msgbuf_wrptr, "%s", stage);
diff --git a/examples/mrp_client/mrpdhelper.c b/examples/mrp_client/mrpdhelper.c
index 7db0e6ad..9a26ca7b 100755
--- a/examples/mrp_client/mrpdhelper.c
+++ b/examples/mrp_client/mrpdhelper.c
@@ -37,6 +37,7 @@ and parses them into a machine readable structure.
******************************************************************************/
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <stdint.h> // for uint8_t etc
#ifdef __linux__
@@ -51,7 +52,8 @@ and parses them into a machine readable structure.
struct app_state_to_enum {
char *s;
enum mrpdhelper_applicant_state value;
-} mrp_app_state_mapping[12] = {
+} mrp_app_state_mapping[13] = {
+ {"nl", mrpdhelper_applicant_state_null},
{"VO", mrpdhelper_applicant_state_VO},
{"VP", mrpdhelper_applicant_state_VP},
{"VN", mrpdhelper_applicant_state_VN},
@@ -70,6 +72,15 @@ struct app_state_to_enum {
static int parse_app_state(char *sz, struct mrpdhelper_notify *n)
{
int i;
+ char *r;
+
+ r = strstr(sz, "R=");
+ if (r)
+ r = strchr(r, ' ');
+ if (!r)
+ return -1;
+
+ sz = r + 1;
/* loop over mrp_app_state_mapping struct */
for (i=0; i < 12; i++) {
@@ -86,11 +97,20 @@ static int parse_app_state(char *sz, struct mrpdhelper_notify *n)
static int parse_state(char *sz, struct mrpdhelper_notify *n)
{
+ char *r;
+
+ r = strstr(sz, "R=");
+ if (r)
+ r = strchr(r, ' ');
+ if (!r)
+ return -1;
+ sz = r + 4;
+
if (strncmp(sz, "IN", 2) == 0) {
n->state = mrpdhelper_state_in;
- } else if (strncmp(sz, "LV", 3) == 0) {
+ } else if (strncmp(sz, "LV", 2) == 0) {
n->state = mrpdhelper_state_leave;
- } else if (strncmp(sz, "MT", 3) == 0) {
+ } else if (strncmp(sz, "MT", 2) == 0) {
n->state = mrpdhelper_state_empty;
} else {
return -1;
@@ -131,7 +151,7 @@ static int parse_registrar(char *sz, struct mrpdhelper_notify *n, char **rpos)
static int parse_mvrp(char *sz, size_t len, struct mrpdhelper_notify *n)
{
/* format
- VIN VJO 1234 R=112233445566
+ VJO 1234 R=112233445566
len = 28
*/
if (len < 28)
@@ -140,13 +160,17 @@ static int parse_mvrp(char *sz, size_t len, struct mrpdhelper_notify *n)
if (parse_notification(&sz[1], n) < 0)
return -1;
- if (parse_state(&sz[5], n) < 0)
+ n->attrib = mrpdhelper_attribtype_mvrp;
+ if (sscanf(&sz[4], "%04x ", &n->u.v.vid) != 1)
return -1;
- n->attrib = mrpdhelper_attribtype_mvrp;
- if (sscanf(&sz[8], "%04x ", &n->u.v.vid) != 1)
+ if (parse_registrar(sz, n, NULL) < 0)
return -1;
- return parse_registrar(sz, n, NULL);
+
+ if (parse_app_state(sz, n) < 0)
+ return -1;
+
+ return parse_state(sz, n);
}
static int parse_msrp_string(char *sz, size_t len, struct mrpdhelper_notify *n)
@@ -207,7 +231,13 @@ static int parse_msrp(char *sz, size_t len, struct mrpdhelper_notify *n)
if (parse_msrp_string(&sz[4], len - 4, n) < 0)
return -1;
- return parse_registrar(sz, n, NULL);
+ if (parse_registrar(sz, n, NULL) < 0)
+ return -1;
+
+ if (parse_app_state(sz, n) < 0)
+ return -1;
+
+ return parse_state(sz, n);
}
@@ -229,13 +259,6 @@ static int parse_msrp_query(char *sz, size_t len, struct mrpdhelper_notify *n)
static int parse_mmrp(char *sz, size_t len, struct mrpdhelper_notify *n)
{
- /* format
- MIN MJO M=112233445566 R=112233445566
- len = 38
- */
- if (len < 38)
- return -1;
-
if (parse_notification(&sz[1], n) < 0)
return -1;
@@ -304,3 +327,115 @@ int mrpdhelper_notify_equal(struct mrpdhelper_notify *n1,
}
return 1;
}
+
+int mrpdhelper_to_string(struct mrpdhelper_notify *mrpd_data,
+ char *sz, size_t len)
+{
+ char *szString;
+ char *szNotify;
+ char *szState;
+ char *szAppState;
+ int status = 0;
+
+ szString = (char *)malloc(128);
+ if (!szString) {
+ return snprintf(sz, len, "malloc error");
+ }
+ /* state and registrar */
+ switch (mrpd_data->notify)
+ {
+ case mrpdhelper_notification_new:
+ szNotify = "NE";
+ break;
+ case mrpdhelper_notification_join:
+ szNotify = "JO";
+ break;
+ case mrpdhelper_notification_leave:
+ szNotify = "LE";
+ break;
+ default:
+ szNotify = "??";
+ break;
+ }
+
+ switch (mrpd_data->state)
+ {
+ case mrpdhelper_state_in:
+ szState = "IN";
+ break;
+ case mrpdhelper_state_leave:
+ szState = "LV";
+ break;
+ case mrpdhelper_state_empty:
+ szState = "MT";
+ break;
+ default:
+ szState = "??";
+ break;
+ }
+
+ szAppState = mrp_app_state_mapping[mrpd_data->app_state].s;
+
+ status = snprintf(szString, 128, "R=%" SCNx64 " %s,%s,%s",
+ mrpd_data->registrar,
+ szNotify, szState, szAppState);
+ if (status < 0)
+ return status;
+
+ switch (mrpd_data->attrib) {
+ case mrpdhelper_attribtype_mmrp:
+ status = snprintf(sz, len, "MMRP...");
+ break;
+ case mrpdhelper_attribtype_mvrp:
+ status = snprintf(sz, len, "MVRP id=%d, %s",
+ mrpd_data->u.v.vid,
+ szString);
+ break;
+ case mrpdhelper_attribtype_msrp_domain:
+ status = snprintf(sz, len, "D:C=%d,P=%d,V=0x%04x %s",
+ mrpd_data->u.sd.id,
+ mrpd_data->u.sd.priority,
+ mrpd_data->u.sd.vid,
+ szString);
+ break;
+ case mrpdhelper_attribtype_msrp_talker:
+ status = snprintf(sz, len, "T:S=%" SCNx64
+ ",A=%" SCNx64
+ ",V=%04x"
+ ",Z=%d"
+ ",I=%d"
+ ",P=%d"
+ ",L=%d"
+ ",B=%" SCNx64
+ ",C=%d"
+ " %s",
+ mrpd_data->u.st.id,
+ mrpd_data->u.st.dest_mac,
+ mrpd_data->u.st.vid,
+ mrpd_data->u.st.max_frame_size,
+ mrpd_data->u.st.max_interval_frames,
+ mrpd_data->u.st.priority_and_rank,
+ mrpd_data->u.st.accum_latency,
+ mrpd_data->u.st.bridge_id,
+ mrpd_data->u.st.failure_code,
+ szString
+ );
+ break;
+ case mrpdhelper_attribtype_msrp_talker_fail:
+ status = snprintf(sz, len, "MSRP talker failed");
+ break;
+ case mrpdhelper_attribtype_msrp_listener:
+ status = snprintf(sz, len, "L:D=%d,S=%" SCNx64 " %s",
+ mrpd_data->u.sl.substate,
+ mrpd_data->u.sl.id,
+ szString);
+ break;
+ case mrpdhelper_attribtype_msrp_listener_fail:
+ status = snprintf(sz, len, "MSRP listener failed");
+ break;
+ default:
+ status = snprintf(sz, len, "MRP unknown");
+ }
+ free(szString);
+ return status;
+}
diff --git a/examples/mrp_client/mrpdhelper.h b/examples/mrp_client/mrpdhelper.h
index 398d5435..07e0682f 100755
--- a/examples/mrp_client/mrpdhelper.h
+++ b/examples/mrp_client/mrpdhelper.h
@@ -131,4 +131,7 @@ int mrpdhelper_parse_notification(char *sz,
int mrpdhelper_notify_equal(struct mrpdhelper_notify *n1,
struct mrpdhelper_notify *n2);
+int mrpdhelper_to_string(struct mrpdhelper_notify *mrp_data,
+ char *sz, size_t len);
+
#endif