projects
/
openvswitch
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e3eaf2b
)
dhcp: New function dhcp_option_equals().
author
Ben Pfaff
<blp@nicira.com>
Wed, 30 Jul 2008 22:45:38 +0000
(15:45 -0700)
committer
Ben Pfaff
<blp@nicira.com>
Wed, 30 Jul 2008 22:46:38 +0000
(15:46 -0700)
include/dhcp.h
patch
|
blob
|
history
lib/dhcp.c
patch
|
blob
|
history
diff --git
a/include/dhcp.h
b/include/dhcp.h
index 2d00f0261a017d3262dcf2d220360c04878cc3fd..f44c4c65244020e87dda83a66c4588383f1c193f 100644
(file)
--- a/
include/dhcp.h
+++ b/
include/dhcp.h
@@
-218,6
+218,11
@@
struct dhcp_option {
void *data; /* Data. */
};
void *data; /* Data. */
};
+const char *dhcp_option_to_string(const struct dhcp_option *, int code,
+ struct ds *);
+bool dhcp_option_equals(const struct dhcp_option *,
+ const struct dhcp_option *);
+
/* Abstracted DHCP protocol message, to make them easier to manipulate than
* through raw protocol buffers. */
struct dhcp_msg {
/* Abstracted DHCP protocol message, to make them easier to manipulate than
* through raw protocol buffers. */
struct dhcp_msg {
@@
-266,8
+271,6
@@
bool dhcp_msg_get_uint8(const struct dhcp_msg *, int code,
size_t offset, uint8_t *);
bool dhcp_msg_get_uint16(const struct dhcp_msg *, int code,
size_t offset, uint16_t *);
size_t offset, uint8_t *);
bool dhcp_msg_get_uint16(const struct dhcp_msg *, int code,
size_t offset, uint16_t *);
-const char *dhcp_option_to_string(const struct dhcp_option *, int code,
- struct ds *);
const char *dhcp_msg_to_string(const struct dhcp_msg *, bool multiline,
struct ds *);
int dhcp_parse(struct dhcp_msg *, const struct buffer *);
const char *dhcp_msg_to_string(const struct dhcp_msg *, bool multiline,
struct ds *);
int dhcp_parse(struct dhcp_msg *, const struct buffer *);
diff --git
a/lib/dhcp.c
b/lib/dhcp.c
index 5021d5e0b8903714c0663b8427893935485985ce..3c0ed82a6573ac5a8ba0c55adc53117cbb12c533 100644
(file)
--- a/
lib/dhcp.c
+++ b/
lib/dhcp.c
@@
-488,6
+488,15
@@
dhcp_option_to_string(const struct dhcp_option *opt, int code, struct ds *ds)
return ds_cstr(ds);
}
return ds_cstr(ds);
}
+/* Returns true if 'a' and 'b' have the same content, false otherwise. */
+bool
+dhcp_option_equals(const struct dhcp_option *a, const struct dhcp_option *b)
+{
+ return ((a->data != NULL) == (b->data != NULL)
+ && a->n == b->n
+ && !memcmp(a->data, b->data, a->n));
+}
+
/* Replaces 'ds' by a string representation of 'msg'. If 'multiline' is
* false, 'ds' receives a single-line representation of 'msg', otherwise a
* multiline representation. */
/* Replaces 'ds' by a string representation of 'msg'. If 'multiline' is
* false, 'ds' receives a single-line representation of 'msg', otherwise a
* multiline representation. */