diff options
Diffstat (limited to 'misc.c')
-rw-r--r-- | misc.c | 26 |
1 files changed, 25 insertions, 1 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: misc.c,v 1.92 2013/10/14 23:28:23 djm Exp $ */ | 1 | /* $OpenBSD: misc.c,v 1.93 2014/04/20 02:30:25 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2000 Markus Friedl. All rights reserved. | 3 | * Copyright (c) 2000 Markus Friedl. All rights reserved. |
4 | * Copyright (c) 2005,2006 Damien Miller. All rights reserved. | 4 | * Copyright (c) 2005,2006 Damien Miller. All rights reserved. |
@@ -788,6 +788,20 @@ get_u32(const void *vp) | |||
788 | return (v); | 788 | return (v); |
789 | } | 789 | } |
790 | 790 | ||
791 | u_int32_t | ||
792 | get_u32_le(const void *vp) | ||
793 | { | ||
794 | const u_char *p = (const u_char *)vp; | ||
795 | u_int32_t v; | ||
796 | |||
797 | v = (u_int32_t)p[0]; | ||
798 | v |= (u_int32_t)p[1] << 8; | ||
799 | v |= (u_int32_t)p[2] << 16; | ||
800 | v |= (u_int32_t)p[3] << 24; | ||
801 | |||
802 | return (v); | ||
803 | } | ||
804 | |||
791 | u_int16_t | 805 | u_int16_t |
792 | get_u16(const void *vp) | 806 | get_u16(const void *vp) |
793 | { | 807 | { |
@@ -826,6 +840,16 @@ put_u32(void *vp, u_int32_t v) | |||
826 | p[3] = (u_char)v & 0xff; | 840 | p[3] = (u_char)v & 0xff; |
827 | } | 841 | } |
828 | 842 | ||
843 | void | ||
844 | put_u32_le(void *vp, u_int32_t v) | ||
845 | { | ||
846 | u_char *p = (u_char *)vp; | ||
847 | |||
848 | p[0] = (u_char)v & 0xff; | ||
849 | p[1] = (u_char)(v >> 8) & 0xff; | ||
850 | p[2] = (u_char)(v >> 16) & 0xff; | ||
851 | p[3] = (u_char)(v >> 24) & 0xff; | ||
852 | } | ||
829 | 853 | ||
830 | void | 854 | void |
831 | put_u16(void *vp, u_int16_t v) | 855 | put_u16(void *vp, u_int16_t v) |