Skip to content

Commit

Permalink
Merge pull request Avnu#238 from audioscience/asi-for-upstream-avb-next
Browse files Browse the repository at this point in the history
Asi for upstream avb next
  • Loading branch information
pinealservo committed Jun 20, 2015
2 parents 365cf04 + 58fd81f commit 81a3a7a
Show file tree
Hide file tree
Showing 7 changed files with 418 additions and 20 deletions.
19 changes: 13 additions & 6 deletions daemons/common/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ typedef unsigned __int64 uint64_t;
#define parse_log(a,b)
#endif

int parse(char *s, int len, struct parse_param *specs, int *err_index)
int parse(const char *s, int len, struct parse_param *specs, int *err_index)
{
int err = 0;
char *param;
Expand All @@ -65,9 +65,16 @@ int parse(char *s, int len, struct parse_param *specs, int *err_index)
uint64_t v_uint64;
int result = 0;
int count = 0;
int i;

/* look for a null starting at the end of the buffer until
we find one or hit the beginning of the buffer */
for (i = len - 1; s[i] != 0 && i >= 0; --i) {}

/* If a null wasn't found before the element at offset 0, counter will be negative */
if (i < 0)
return -1;

/* make sure string is null terminated */
s[len - 1] = 0;
guard = s + strlen(s);

parse_log("PARSE: %s\n", s);
Expand All @@ -93,7 +100,7 @@ int parse(char *s, int len, struct parse_param *specs, int *err_index)
case parse_null:
break;
case parse_u8:
result = sscanf(data, "%d", &v_uint);
result = sscanf(data, "%u", &v_uint);
if (result == 1) {
*(uint8_t *) specs->v = (uint8_t) v_uint;
} else {
Expand All @@ -110,7 +117,7 @@ int parse(char *s, int len, struct parse_param *specs, int *err_index)
}
break;
case parse_u16:
result = sscanf(data, "%d", &v_uint);
result = sscanf(data, "%u", &v_uint);
if (result == 1) {
*(uint16_t *) specs->v = (uint16_t) v_uint;
} else {
Expand All @@ -119,7 +126,7 @@ int parse(char *s, int len, struct parse_param *specs, int *err_index)
}
break;
case parse_u32:
result = sscanf(data, "%d", &v_uint);
result = sscanf(data, "%u", &v_uint);
if (result == 1) {
*(uint32_t *) specs->v = v_uint;
} else {
Expand Down
9 changes: 8 additions & 1 deletion daemons/common/parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ struct parse_param {
void *v;
};

int parse(char *s, int len, struct parse_param *specs, int *err_index);
/** Parse a string of parameters into specified types.
* @param s a null terminated string to be parsed
* @param len the length of buffer containing the string to be parsed. This is not strlen(s)!.
* @param specs a pointer to an array of parsing specificaions
* @param the parameter index at which a parsing error occured
* @return 0 on success
*/
int parse(const char *s, int len, struct parse_param *specs, int *err_index);

#endif /* PARSE_H_ */
2 changes: 1 addition & 1 deletion daemons/mrpd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if(APPLE)
add_executable (mrpd ${MRPD_SRC} "mrpd.c")
elseif(UNIX)
add_executable (mrpd ${MRPD_SRC} "mrpd.c")
target_link_libraries(pthread)
target_link_libraries(mrpd pthread)
elseif(WIN32)
if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
link_directories($ENV{WPCAP_DIR}/Lib/x64)
Expand Down
16 changes: 8 additions & 8 deletions daemons/mrpd/msrp.c
Original file line number Diff line number Diff line change
Expand Up @@ -3282,7 +3282,7 @@ int msrp_dumptable(struct sockaddr_in *client)

}

static int msrp_cmd_parse_stream_id(char *buf, int buflen,
static int msrp_cmd_parse_stream_id(const char *buf, int buflen,
uint8_t *stream_id,
int *err_index )
{
Expand All @@ -3299,7 +3299,7 @@ static int msrp_cmd_parse_stream_id(char *buf, int buflen,

/* S+? - (re)JOIN a stream */
/* S++ - NEW a stream */
static int msrp_cmd_parse_join_or_new_stream(char *buf, int buflen,
static int msrp_cmd_parse_join_or_new_stream(const char *buf, int buflen,
struct msrpdu_talker_fail
*talker_ad, int *err_index)
{
Expand All @@ -3322,7 +3322,7 @@ static int msrp_cmd_parse_join_or_new_stream(char *buf, int buflen,
return parse(buf + 4, buflen - 4, specs, err_index);
}

static int msrp_cmd_parse_join_or_new_stream_failure(char *buf, int buflen,
static int msrp_cmd_parse_join_or_new_stream_failure(const char *buf, int buflen,
struct msrpdu_talker_fail
*talker_ad, int *err_index)
{
Expand Down Expand Up @@ -3379,7 +3379,7 @@ static int msrp_cmd_join_or_new_stream(struct msrpdu_talker_fail *talker_ad,
}

/* S-- - LV a stream */
static int msrp_cmd_parse_leave_stream(char *buf, int buflen,
static int msrp_cmd_parse_leave_stream(const char *buf, int buflen,
struct msrpdu_talker_fail *talker_ad,
int *err_index)
{
Expand Down Expand Up @@ -3409,7 +3409,7 @@ 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,
static int msrp_cmd_parse_report_listener_status(const char *buf, int buflen,
struct msrpdu_talker_fail
*talker_ad,
uint32_t * substate,
Expand Down Expand Up @@ -3445,7 +3445,7 @@ 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
static int msrp_cmd_parse_withdraw_listener_status(const char *buf, int buflen, struct msrpdu_talker_fail
*talker_ad, int *err_index)
{
struct parse_param specs[] = {
Expand Down Expand Up @@ -3483,7 +3483,7 @@ static int msrp_cmd_withdraw_listener_status(struct msrpdu_talker_fail

/* S+D Report a domain status */
/* S-D Withdraw a domain status */
static int msrp_cmd_parse_domain_status(char *buf, int buflen,
static int msrp_cmd_parse_domain_status(const char *buf, int buflen,
struct msrpdu_domain *domain,
int *err_index)
{
Expand Down Expand Up @@ -3522,7 +3522,7 @@ static int msrp_cmd_report_domain_status(struct msrpdu_domain *domain,
return 0;
}

int msrp_recv_cmd(char *buf, int buflen, struct sockaddr_in *client)
int msrp_recv_cmd(const char *buf, int buflen, struct sockaddr_in *client)
{
int rc;
char respbuf[64];
Expand Down
2 changes: 1 addition & 1 deletion daemons/mrpd/msrp.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ struct msrp_database {
int msrp_init(int msrp_enable, int max_interesting_stream_ids, int enable_pruning);
void msrp_reset(void);
int msrp_event(int event, struct msrp_attribute *rattrib);
int msrp_recv_cmd(char *buf, int buflen, struct sockaddr_in *client);
int msrp_recv_cmd(const char *buf, int buflen, struct sockaddr_in *client);
int msrp_send_notifications(struct msrp_attribute *attrib, int notify);
int msrp_reclaim(void);
void msrp_bye(struct sockaddr_in *client);
Expand Down
6 changes: 3 additions & 3 deletions daemons/mrpd/tests/simple/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ if(APPLE)
target_link_libraries(mrpd_simple_test CppUTest CppUTestExt)
elseif(UNIX)
include_directories( include ${CPPUTEST_DIR}/include/Platforms/Gcc )
link_directories(${CPPUTEST_DIR}/src/CppUTest ${CPPUTEST_DIR}/src/CppUTestExt )
link_directories(mrpd_simple_test ${CPPUTEST_DIR}/src/CppUTest ${CPPUTEST_DIR}/src/CppUTestExt )
add_executable (mrpd_simple_test ${MRPD_SRC} ${CPPUTEST_SRC} mrp_doubles.c)
target_link_libraries(mrpd_simple_test CppUTest CppUTestExt)
elseif(WIN32)
if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
link_directories($ENV{WPCAP_DIR}/Lib/x64 ${CPPUTEST_DIR}/src/CppUTest ${CPPUTEST_DIR}/src/CppUTestExt)
link_directories(mrpd_simple_test $ENV{WPCAP_DIR}/Lib/x64 ${CPPUTEST_DIR}/src/CppUTest ${CPPUTEST_DIR}/src/CppUTestExt)
elseif( CMAKE_SIZEOF_VOID_P EQUAL 4 )
link_directories($ENV{WPCAP_DIR}/Lib ${CPPUTEST_DIR}/src/CppUTest ${CPPUTEST_DIR}/src/CppUTestExt)
link_directories(mrpd_simple_test $ENV{WPCAP_DIR}/Lib ${CPPUTEST_DIR}/src/CppUTest ${CPPUTEST_DIR}/src/CppUTestExt)
endif()

add_definitions(-D_CRT_SECURE_NO_WARNINGS)
Expand Down
Loading

0 comments on commit 81a3a7a

Please sign in to comment.