Skip to content

Commit f582007

Browse files
authored
Improve READMEs, other minor improvements (#25)
* readme prep, reorganize docker a bit. add missing dep * add contribute
1 parent a4293d1 commit f582007

File tree

13 files changed

+308
-8
lines changed

13 files changed

+308
-8
lines changed

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tests/external

.gitignore

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
.idea/
1+
.idea*
22
cmake-build-*/
3-
cmd/.idea/
3+
.DS_Store*
4+
docs/html-documentation-generated*
5+
tests/external

3rd/EndianPortable/EndianPortable.h

+210
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
/*
2+
* librdkafka - Apache Kafka C library
3+
*
4+
* Copyright (c) 2012-2015 Magnus Edenhill
5+
* All rights reserved.
6+
*
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions are met:
9+
*
10+
* 1. Redistributions of source code must retain the above copyright notice,
11+
* this list of conditions and the following disclaimer.
12+
* 2. Redistributions in binary form must reproduce the above copyright notice,
13+
* this list of conditions and the following disclaimer in the documentation
14+
* and/or other materials provided with the distribution.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26+
* POSSIBILITY OF SUCH DAMAGE.
27+
*/
28+
#ifndef _ENDIANPORTABLE_H_
29+
#define _ENDIANPORTABLE_H_
30+
31+
/**
32+
* Provides portable endian-swapping macros/functions.
33+
*
34+
* be64toh()
35+
* htobe64()
36+
* be32toh()
37+
* htobe32()
38+
* be16toh()
39+
* htobe16()
40+
* le64toh()
41+
*/
42+
43+
#ifdef __FreeBSD__
44+
#include <sys/endian.h>
45+
#elif defined __GLIBC__
46+
#include <endian.h>
47+
#ifndef be64toh
48+
/* Support older glibc (<2.9) which lack be64toh */
49+
#include <byteswap.h>
50+
#if __BYTE_ORDER == __BIG_ENDIAN
51+
#define be16toh(x) (x)
52+
#define be32toh(x) (x)
53+
#define be64toh(x) (x)
54+
#define le64toh(x) __bswap_64 (x)
55+
#define le32toh(x) __bswap_32 (x)
56+
#else
57+
#define be16toh(x) __bswap_16 (x)
58+
#define be32toh(x) __bswap_32 (x)
59+
#define be64toh(x) __bswap_64 (x)
60+
#define le64toh(x) (x)
61+
#define le32toh(x) (x)
62+
#endif
63+
#endif
64+
65+
#elif defined __CYGWIN__
66+
#include <endian.h>
67+
#elif defined(WIN32) || defined(WINx64)
68+
#include <winsock2.h>
69+
#if(BYTE_ORDER == LITTLE_ENDIAN)
70+
#define htobe16(x) htons(x)
71+
#define htole16(x) (x)
72+
#define be16toh(x) ntohs(x)
73+
#define le16toh(x) (x)
74+
75+
#define htobe32(x) htonl(x)
76+
#define htole32(x) (x)
77+
#define be32toh(x) ntohl(x)
78+
#define le32toh(x) (x)
79+
80+
#define htobe64(x) htonll(x)
81+
#define htole64(x) (x)
82+
#define be64toh(x) ntohll(x)
83+
#define le64toh(x) (x)
84+
#else
85+
#define htobe16(x) (x)
86+
#define htole16(x) __builtin_bswap16(x)
87+
#define be16toh(x) (x)
88+
#define le16toh(x) __builtin_bswap16(x)
89+
90+
#define htobe32(x) (x)
91+
#define htole32(x) __builtin_bswap32(x)
92+
#define be32toh(x) (x)
93+
#define le32toh(x) __builtin_bswap32(x)
94+
95+
#define htobe64(x) (x)
96+
#define htole64(x) __builtin_bswap64(x)
97+
#define be64toh(x) (x)
98+
#define le64toh(x) __builtin_bswap64(x)
99+
#endif
100+
#elif defined __BSD__
101+
#include <sys/endian.h>
102+
#elif defined sun
103+
#include <sys/byteorder.h>
104+
#include <sys/isa_defs.h>
105+
#define __LITTLE_ENDIAN 1234
106+
#define __BIG_ENDIAN 4321
107+
#ifdef _BIG_ENDIAN
108+
#define __BYTE_ORDER __BIG_ENDIAN
109+
#define be64toh(x) (x)
110+
#define be32toh(x) (x)
111+
#define be16toh(x) (x)
112+
#define le16toh(x) ((uint16_t)BSWAP_16(x))
113+
#define le32toh(x) BSWAP_32(x)
114+
#define le64toh(x) BSWAP_64(x)
115+
# else
116+
#define __BYTE_ORDER __LITTLE_ENDIAN
117+
#define be64toh(x) BSWAP_64(x)
118+
#define be32toh(x) ntohl(x)
119+
#define be16toh(x) ntohs(x)
120+
#define le16toh(x) (x)
121+
#define le32toh(x) (x)
122+
#define le64toh(x) (x)
123+
#define htole16(x) (x)
124+
#define htole64(x) (x)
125+
#endif /* sun */
126+
127+
#elif defined __APPLE__
128+
#include <machine/endian.h>
129+
#include <libkern/OSByteOrder.h>
130+
#if __DARWIN_BYTE_ORDER == __DARWIN_BIG_ENDIAN
131+
#define be64toh(x) (x)
132+
#define be32toh(x) (x)
133+
#define be16toh(x) (x)
134+
#define le16toh(x) OSSwapInt16(x)
135+
#define le32toh(x) OSSwapInt32(x)
136+
#define le64toh(x) OSSwapInt64(x)
137+
#else
138+
#define be64toh(x) OSSwapInt64(x)
139+
#define be32toh(x) OSSwapInt32(x)
140+
#define be16toh(x) OSSwapInt16(x)
141+
#define le16toh(x) (x)
142+
#define le32toh(x) (x)
143+
#define le64toh(x) (x)
144+
#endif
145+
146+
#elif defined(_MSC_VER)
147+
#include <intrin.h>
148+
149+
#define be64toh(x) _byteswap_uint64(x)
150+
#define be32toh(x) _byteswap_ulong(x)
151+
#define be16toh(x) _byteswap_ushort(x)
152+
#define le16toh(x) (x)
153+
#define le32toh(x) (x)
154+
#define le64toh(x) (x)
155+
156+
#elif defined _AIX /* AIX is always big endian */
157+
#define be64toh(x) (x)
158+
#define be32toh(x) (x)
159+
#define be16toh(x) (x)
160+
#define le32toh(x) \
161+
((((x) & 0xff) << 24) | \
162+
(((x) & 0xff00) << 8) | \
163+
(((x) & 0xff0000) >> 8) | \
164+
(((x) & 0xff000000) >> 24))
165+
#define le64toh(x) \
166+
((((x) & 0x00000000000000ffL) << 56) | \
167+
(((x) & 0x000000000000ff00L) << 40) | \
168+
(((x) & 0x0000000000ff0000L) << 24) | \
169+
(((x) & 0x00000000ff000000L) << 8) | \
170+
(((x) & 0x000000ff00000000L) >> 8) | \
171+
(((x) & 0x0000ff0000000000L) >> 24) | \
172+
(((x) & 0x00ff000000000000L) >> 40) | \
173+
(((x) & 0xff00000000000000L) >> 56))
174+
#else
175+
#include <endian.h>
176+
#endif
177+
178+
179+
180+
/*
181+
* On Solaris, be64toh is a function, not a macro, so there's no need to error
182+
* if it's not defined.
183+
*/
184+
#if !defined(__sun) && !defined(be64toh)
185+
#error Missing definition for be64toh
186+
#endif
187+
188+
#ifndef be32toh
189+
#define be32toh(x) ntohl(x)
190+
#endif
191+
192+
#ifndef be16toh
193+
#define be16toh(x) ntohs(x)
194+
#endif
195+
196+
#ifndef htobe64
197+
#define htobe64(x) be64toh(x)
198+
#endif
199+
#ifndef htobe32
200+
#define htobe32(x) be32toh(x)
201+
#endif
202+
#ifndef htobe16
203+
#define htobe16(x) be16toh(x)
204+
#endif
205+
206+
#ifndef htole32
207+
#define htole32(x) le32toh(x)
208+
#endif
209+
210+
#endif /* _ENDIANPORTABLE_H_ */

3rd/README.md

Whitespace-only changes.

CONTRIBUTING.md

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
## How to Contribute
2+
At NS1, it makes us very happy to get pull requests, and we appreciate the time
3+
and effort it takes to put one together. Below are a few guidelines that can
4+
help get your pull request approved and merged quickly and easily.
5+
6+
It's important to note that the guidelines are recommendations, not
7+
requirements. You may submit a pull request that does not adhere to the
8+
guidelines, but ideation and development may take longer or be more involved.
9+
10+
* Avoid getting nitpicked for basic formatting. Match the style of any given
11+
file as best you can - tabs or spaces as appropriate, curly bracket
12+
placement, indentation style, line length, etc. If there are any linters
13+
mentioned in docs or Makefile, please run them.
14+
15+
* Avoid changes that have any possibility of breaking existing uses. Some of
16+
these codebases have many of users, doing creative things with them. Breaking
17+
changes can cause significant challenges for other users. It's important to
18+
note that some projects are dependencies of other projects, and changes may
19+
require cross-code base coordination. It can be challenging to identify if a
20+
small change will have large ramifications, so we mainly ask that you keep
21+
this in mind when writing or modifying code. Do your best to preserve
22+
interfaces, and understand that NS1 may need to reject pull requests if they
23+
would jeopardize platform stability or place an undue burden on other users.
24+
25+
* If there are unit and/or integration tests, keeping the test suites passing
26+
is a must before we can merge. And nice tests around the changes will
27+
definitely help get a patch merged quickly.
28+
29+
* Ensure that any documentation that is part of the project is updated as part
30+
of the pull request. This helps to expedite the merge process.
31+
32+
* Be considerate when introducing new dependencies to a project. If a new
33+
dependency is necessary, try to choose a well-known project, and to pin the
34+
version as specifically as possible.
35+
36+
## Opening an issue
37+
38+
Below are a few guidelines for opening an issue on one of NS1's open-source
39+
repositories. Adhering to these guidelines to the best of your ability will
40+
help ensure that requests are resolved quickly and efficiently.
41+
42+
* **Be specific about the problem.** When describing your issue, it's helpful
43+
to include as many details as you can about the expected behavior versus
44+
what happened or is happening instead.
45+
* **Be specific about your objective.** Help us understand exactly what you are
46+
trying to accomplish so that our developers have a clear understanding about
47+
the particular problem you are trying to solve. In other words, help us
48+
avoid the "[XY Problem](http://xyproblem.info)".
49+
* **Indicate which products, software versions, and programming languages you
50+
are using.** In your request, indicate which NS1 product(s) you're using and,
51+
if relevant, which versions you are running. Also include any third-party
52+
software and versions that are relevant to the issue. If not obvious, include
53+
which programming language(s) you are using.
54+
* **If possible, provide a reproducible example of the problem.** This allows
55+
us to better examine the issue and test solutions.
56+
* **If possible, include stack/error traces.** Note: ensure there is no
57+
sensitive included in your stack/error traces.
58+
59+
## Closing an issue
60+
61+
* If an issue is closed by a commit, reference the relevant PR or commit when
62+
closing.
63+
* If an issue is closed by NS1 for any reason, you should expect us to include
64+
a reason for it.
65+
* If the fix does not work or is incomplete, you are welcome to re-open or
66+
recreate the issue. When doing so, it's important to be clear about why the
67+
previous fix was inadequate, to clarify the previous problem statement,
68+
and/or to modify the scope of the request. Please keep in mind that project
69+
status consideration or conflicting priorities may require us to close or
70+
defer work on the new or reopened issue. If that happens, feel free to reach
71+
out of [email protected] for more information.
72+
73+
## Tags on issues
74+
75+
In some projects we (NS1) may apply basic tags on some issues, for
76+
organizational purposes. Note: we do not use tags to indicate timelines or
77+
priorities.
78+
79+
Here are definitions for the most common tags we use:
80+
81+
* **BUG** - This tag confirms that the issue is a bug we intend to fix. The
82+
issue will remain open until it is resolved.
83+
* **ENHANCEMENT** - This tag indicates that we have categorized the issue as a
84+
feature request. Depending on priorities and timelines, we may close issues
85+
with this tag and track them in our internal backlog instead.

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,12 @@ cmake ..
157157
make
158158
```
159159

160-
Building the docker image:
160+
Building the docker image (from the root project directory):
161161
```
162162
org="myorg"
163163
image="mypktvisor"
164164
tag="latest"
165-
docker build -t ${org}/${image}:${tag} -f Dockerfile .
165+
docker build -t ${org}/${image}:${tag} -f docker/Dockerfile .
166166
```
167167

168168
Contributions

cmd/README.md

Whitespace-only changes.

Dockerfile renamed to docker/Dockerfile

+4-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ RUN \
3030
go get github.com/pkg/errors && \
3131
go get github.com/jroimartin/gocui && \
3232
go get github.com/docopt/docopt-go && \
33-
go build /src/cmd/pktvisor/pktvisor.go
33+
cd /src/cmd/pktvisor && \
34+
go build
3435

3536
FROM debian:buster-slim AS runtime
3637

@@ -42,8 +43,8 @@ RUN \
4243
rm -rf /var/lib/apt
4344

4445
COPY --from=build /tmp/build/pktvisord /usr/local/sbin/pktvisord
45-
COPY --from=build /tmp/build/pktvisor /usr/local/bin/pktvisor
46-
COPY entry.sh /usr/local/bin/
46+
COPY --from=build /src/cmd/pktvisor/pktvisor /usr/local/bin/pktvisor
47+
COPY docker/entry.sh /usr/local/bin/
4748

4849
ENTRYPOINT [ "entry.sh" ]
4950

File renamed without changes.

reporting/README.md

Whitespace-only changes.

src/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://github.com/ns1/pktvisor/projects/1#card-51299219

tests/README.md

Whitespace-only changes.

tests/external.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/bin/bash -x
22

33
# if a file called external/run.sh exists, run it.
44
FILE=external/run.sh

0 commit comments

Comments
 (0)