readerwriter.h revision 1.2
1/* 2 * Copyright (c) 2005-2008 Nominet UK (www.nic.uk) 3 * All rights reserved. 4 * Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted 5 * their moral rights under the UK Copyright Design and Patents Act 1988 to 6 * be recorded as the authors of this copyright work. 7 * 8 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 9 * use this file except in compliance with the License. 10 * 11 * You may obtain a copy of the License at 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, software 15 * distributed under the License is distributed on an "AS IS" BASIS, 16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 * 18 * See the License for the specific language governing permissions and 19 * limitations under the License. 20 */ 21 22#ifndef __OPS_READERWRITER_H__ 23#define __OPS_READERWRITER_H__ 24 25#include "create.h" 26 27#include "memory.h" 28 29/* if this is defined, we'll use mmap in preference to file __ops */ 30#define USE_MMAP_FOR_FILES 1 31 32void __ops_reader_set_fd(__ops_parse_info_t *, int); 33void __ops_reader_set_mmap(__ops_parse_info_t *, int); 34void 35__ops_reader_set_memory(__ops_parse_info_t *, const void *, size_t); 36 37/* Do a sum mod 65536 of all bytes read (as needed for secret keys) */ 38void __ops_reader_push_sum16(__ops_parse_info_t *); 39unsigned short __ops_reader_pop_sum16(__ops_parse_info_t *); 40 41void 42__ops_reader_push_se_ip_data(__ops_parse_info_t *, __ops_crypt_t *, __ops_region_t *); 43void __ops_reader_pop_se_ip_data(__ops_parse_info_t *); 44 45/* */ 46bool 47__ops_write_mdc(const unsigned char *, __ops_create_info_t *); 48bool 49__ops_write_se_ip_pktset(const unsigned char *, 50 const unsigned int, 51 __ops_crypt_t *, 52 __ops_create_info_t *); 53void __ops_writer_push_encrypt_crypt(__ops_create_info_t *, __ops_crypt_t *); 54void __ops_writer_push_encrypt_se_ip(__ops_create_info_t *, const __ops_keydata_t *); 55/* Secret Key checksum */ 56 57void __ops_push_skey_checksum_writer(__ops_create_info_t *, __ops_secret_key_t *); 58bool __ops_pop_skey_checksum_writer(__ops_create_info_t *); 59 60 61/* memory writing */ 62void __ops_setup_memory_write(__ops_create_info_t **, __ops_memory_t **, size_t); 63void __ops_teardown_memory_write(__ops_create_info_t *, __ops_memory_t *); 64 65/* memory reading */ 66void 67__ops_setup_memory_read(__ops_parse_info_t **, __ops_memory_t *, 68 void *, 69 __ops_parse_cb_return_t callback(const __ops_packet_t *, __ops_parse_cb_info_t *), bool); 70void __ops_teardown_memory_read(__ops_parse_info_t *, __ops_memory_t *); 71 72/* file writing */ 73int __ops_setup_file_write(__ops_create_info_t **, const char *, bool); 74void __ops_teardown_file_write(__ops_create_info_t *, int); 75 76/* file appending */ 77int __ops_setup_file_append(__ops_create_info_t **, const char *); 78void __ops_teardown_file_append(__ops_create_info_t *, int); 79 80/* file reading */ 81int __ops_setup_file_read(__ops_parse_info_t **, const char *, void *, 82 __ops_parse_cb_return_t callback(const __ops_packet_t *, __ops_parse_cb_info_t *), bool); 83void __ops_teardown_file_read(__ops_parse_info_t *, int); 84 85bool __ops_reader_set_accumulate(__ops_parse_info_t *, bool); 86 87/* useful callbacks */ 88__ops_parse_cb_return_t 89literal_data_cb(const __ops_packet_t *, __ops_parse_cb_info_t *); 90__ops_parse_cb_return_t 91pk_session_key_cb(const __ops_packet_t *, __ops_parse_cb_info_t *); 92__ops_parse_cb_return_t 93get_secret_key_cb(const __ops_packet_t *, __ops_parse_cb_info_t *); 94 95/* from reader_fd.c */ 96void __ops_reader_set_fd(__ops_parse_info_t *, int); 97 98#endif /* OPS_READERWRITER_H__ */ 99