PERFORCE change 177694 for review
Gabor Pali
pgj at FreeBSD.org
Tue May 4 06:03:17 UTC 2010
http://p4web.freebsd.org/@@177694?ac=10
Change 177694 by pgj at csupor on 2010/05/04 06:03:09
Fix -O2 compilation problem (temporarily).
Affected files ...
.. //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat_internal.h#64 edit
.. //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat_stat.c#27 edit
.. //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat_util.c#73 edit
Differences ...
==== //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat_internal.h#64 (text+ko) ====
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2009 Gabor Pali
+ * Copyright (c) 2009, 2010 Gabor Pali
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -319,6 +319,12 @@
struct bpf_type *bpti_next;
};
+/* Timestamp type. */
+struct timestamp_type {
+ u_int32_t ts_sec;
+ u_int32_t ts_usec;
+};
+
/* General statistics type. */
struct stat_type {
enum stat stt_type;
@@ -360,7 +366,8 @@
#ifdef SCTP
struct sctp_stat {
- struct sctpstat s;
+ struct timestamp_type discontinuitytime;
+ struct sctpstat *s;
};
#endif
@@ -433,12 +440,6 @@
};
#endif
-/* Timestamp type. */
-struct timestamp_type {
- u_int32_t ts_sec;
- u_int32_t ts_usec;
-};
-
struct val2str {
int val;
const char *str;
==== //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat_stat.c#27 (text+ko) ====
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2009 Gabor Pali
+ * Copyright (c) 2009, 2010 Gabor Pali
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -204,6 +204,24 @@
break;
#endif /* !IPSEC */
+ /*
+ * XXX : Try to avoid breaking strict aliasing rules, but it might not be
+ * the best solution.
+ */
+
+#ifdef SCTP
+ case stat_SCTP:
+ sttp->stt_data = malloc(sizeof(struct sctp_stat));
+ if (sttp->stt_data == NULL) {
+ sttp->stt_error = NETSTAT_ERROR_NOMEMORY;
+ free(buffer);
+ return(-1);
+ }
+ ((struct sctp_stat *)sttp->stt_data)->discontinuitytime.ts_sec = ((struct sctpstat *)buffer)->sctps_discontinuitytime.tv_sec;
+ ((struct sctp_stat *)sttp->stt_data)->discontinuitytime.ts_usec = ((struct sctpstat *)buffer)->sctps_discontinuitytime.tv_usec;
+ ((struct sctp_stat *)sttp->stt_data)->s = (struct sctpstat *)buffer;
+ break;
+#endif /* !SCTP */
default:
sttp->stt_data = buffer;
}
==== //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat_util.c#73 (text+ko) ====
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2009 Gabor Pali
+ * Copyright (c) 2009, 2010 Gabor Pali
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -1298,7 +1298,8 @@
void
netstat_stat_free(struct stat_type *sttp)
{
- if (sttp->stt_type == stat_IPcomp)
+ if (sttp->stt_type == stat_IPcomp ||
+ sttp->stt_type == stat_SCTP)
free(((struct ipcomp_stat *)sttp->stt_data)->s);
free(sttp->stt_data);
free(sttp);
@@ -1655,16 +1656,12 @@
#ifdef SCTP
#define SCTP_ACC(field) \
- STATS_ACC(u_int32_t,sctp,field)
+ STATS_ACCP(u_int32_t,sctp,field)
const struct timestamp_type *
netstat_sctps_get_discontinuitytime(const struct sctp_stat *ssp)
{
-// return ((const struct timestamp_type *)&ssp->s.sctps_discontinuitytime);
- const struct timestamp_type * result;
- struct sctpstat ss = ssp->s;
- result = (const struct timestamp_type *)&ss.sctps_discontinuitytime;
- return result;
+ return &ssp->discontinuitytime;
}
STATS_GET(sctp,SCTP);
More information about the p4-projects
mailing list