fix for fragment keys
This commit is contained in:
parent
d2ed8e8361
commit
9e8e50ed4a
3
arp.c
3
arp.c
@ -40,7 +40,8 @@ void arp_process_packet(struct ether_t *ether, struct arp_packet_t *packet) {
|
||||
arp_packet.tha[4] = packet->sha[4];
|
||||
arp_packet.tha[5] = packet->sha[5];
|
||||
arp_packet.tpa = packet->spa;
|
||||
struct ether_packet_t *ether_packet = (struct ether_packet_t *)dbmalloc(sizeof(struct arp_packet_t) + sizeof(struct ether_packet_t), "arp_process_packet 1");
|
||||
struct ether_packet_t *ether_packet =
|
||||
(struct ether_packet_t *)dbmalloc(sizeof(struct arp_packet_t) + sizeof(struct ether_packet_t), "arp_process_packet 1");
|
||||
|
||||
ether_packet->destmac[0] = packet->sha[0];
|
||||
ether_packet->destmac[1] = packet->sha[1];
|
||||
|
3
ether.h
3
ether.h
@ -5,8 +5,7 @@
|
||||
|
||||
#define htons(A) ((((uint16_t)(A)&0xff00) >> 8) | (((uint16_t)(A)&0x00ff) << 8))
|
||||
#define htonl(A) \
|
||||
((((uint32_t)(A)&0xff000000) >> 24) | (((uint32_t)(A)&0x00ff0000) >> 8) | (((uint32_t)(A)&0x0000ff00) << 8) | \
|
||||
(((uint32_t)(A)&0x000000ff) << 24))
|
||||
((((uint32_t)(A)&0xff000000) >> 24) | (((uint32_t)(A)&0x00ff0000) >> 8) | (((uint32_t)(A)&0x0000ff00) << 8) | (((uint32_t)(A)&0x000000ff) << 24))
|
||||
|
||||
#define ETH_MIN_PACKET_SIZE 60
|
||||
|
||||
|
11
gui.c
11
gui.c
@ -28,8 +28,8 @@ struct gui_colour_scheme_t sys_color;
|
||||
outportw(0x8A00, 0x08AE0);
|
||||
#define BochsConsolePrintChar(c) outportb(0xe9, c)
|
||||
|
||||
void render(uint8_t *dest, uint8_t *src, uint32_t src_width, uint32_t src_height, int dest_x, int dest_y, uint32_t dest_width,
|
||||
uint32_t dest_height, uint32_t src_depth);
|
||||
void render(uint8_t *dest, uint8_t *src, uint32_t src_width, uint32_t src_height, int dest_x, int dest_y, uint32_t dest_width, uint32_t dest_height,
|
||||
uint32_t src_depth);
|
||||
void gui_pagemap();
|
||||
|
||||
struct ModeInfoBlock {
|
||||
@ -359,8 +359,7 @@ int gui_change_window_caption(int serialno, char *cap) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int gui_add_window(uint8_t *contents, char *name, int x, int y, int w, int h, uint8_t *icon, uint32_t flags,
|
||||
void (*keyboard_d)(uint8_t c, uint8_t state)) {
|
||||
int gui_add_window(uint8_t *contents, char *name, int x, int y, int w, int h, uint8_t *icon, uint32_t flags, void (*keyboard_d)(uint8_t c, uint8_t state)) {
|
||||
struct window_t *new_window;
|
||||
|
||||
new_window = (struct window_t *)dbmalloc(sizeof(struct window_t), "gui: add window (malloc 1)");
|
||||
@ -879,8 +878,8 @@ static uint32_t blendPreMulAlpha(uint32_t p1, uint32_t p2) {
|
||||
return ((rb & RBMASK) | (ag & AGMASK));
|
||||
}
|
||||
|
||||
void render(uint8_t *dest, uint8_t *src, uint32_t src_width, uint32_t src_height, int dest_x, int dest_y, uint32_t dest_width,
|
||||
uint32_t dest_height, uint32_t src_depth) {
|
||||
void render(uint8_t *dest, uint8_t *src, uint32_t src_width, uint32_t src_height, int dest_x, int dest_y, uint32_t dest_width, uint32_t dest_height,
|
||||
uint32_t src_depth) {
|
||||
int i;
|
||||
int pitch = dest_width * depth;
|
||||
int src_off_x = 0;
|
||||
|
@ -35,7 +35,7 @@ map_t hashmap_new() {
|
||||
|
||||
m->data = (hashmap_element *)dbmalloc(sizeof(hashmap_element) * INITIAL_SIZE, "hashmap new 2");
|
||||
memset(m->data, 0, sizeof(hashmap_element) * INITIAL_SIZE);
|
||||
// m->data = (hashmap_element *)calloc(INITIAL_SIZE, sizeof(hashmap_element));
|
||||
// m->data = (hashmap_element *)calloc(INITIAL_SIZE, sizeof(hashmap_element));
|
||||
if (!m->data)
|
||||
goto err;
|
||||
|
||||
@ -197,7 +197,7 @@ int hashmap_rehash(map_t in) {
|
||||
hashmap_map *m = (hashmap_map *)in;
|
||||
hashmap_element *temp = (hashmap_element *)dbmalloc((2 * m->table_size) * sizeof(hashmap_element), "hashmap rehash");
|
||||
memset(temp, 0, (2 * m->table_size) * sizeof(hashmap_element));
|
||||
//hashmap_element *temp = (hashmap_element *)calloc(2 * m->table_size, sizeof(hashmap_element));
|
||||
// hashmap_element *temp = (hashmap_element *)calloc(2 * m->table_size, sizeof(hashmap_element));
|
||||
if (!temp)
|
||||
return MAP_OMEM;
|
||||
|
||||
|
@ -127,7 +127,6 @@ void init_isrs() {
|
||||
|
||||
extern uint32_t read_cr2();
|
||||
|
||||
|
||||
void print_regs(struct regs *r) {
|
||||
kprintf("EIP: %p CS: %x\n", r->eip, r->cs);
|
||||
kprintf("EAX: %p, EBX: %p, ECX: %p, EDX: %p\n", r->eax, r->ebx, r->ecx, r->edx);
|
||||
@ -140,7 +139,6 @@ void print_regs(struct regs *r) {
|
||||
kprintf("KSTACK: 0x%p USTACK: 0x%p TASK: %s\n", current_task->kstack, current_task->ustack, current_task->name);
|
||||
}
|
||||
|
||||
|
||||
// int i;
|
||||
|
||||
/*
|
||||
@ -391,7 +389,6 @@ void init_irqs(void) {
|
||||
|
||||
int irq_handler(struct regs *r) {
|
||||
|
||||
|
||||
if (current_task != NULL) {
|
||||
current_task->eflags = r->eflags;
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
#ifndef __INTTYPES_H
|
||||
#define __INTTYPES_H
|
||||
|
||||
|
||||
extern void __assert_fail(const char *__assertion, const char *__file, unsigned int __line);
|
||||
#define assert(expr) ((expr ? (void)(0) : __assert_fail(#expr, __FILE__, __LINE__)))
|
||||
|
||||
|
21
ipv4.c
21
ipv4.c
@ -45,9 +45,9 @@ struct ipv4_header_t {
|
||||
struct ipv4_frag_t {
|
||||
char key[6];
|
||||
struct ipv4_header_t *first_packet;
|
||||
struct ipv4_header_t *last_packet;
|
||||
struct ipv4_header_t **middle_packets;
|
||||
int middle_packet_count;
|
||||
struct ipv4_header_t *last_packet;
|
||||
uint32_t time_created;
|
||||
};
|
||||
|
||||
@ -84,7 +84,7 @@ void ipv4_fragment_trim() {
|
||||
if (frag->last_packet != NULL) {
|
||||
dbfree(frag->last_packet, "ipv4_fragment_trim 2");
|
||||
}
|
||||
for (size_t j = 0; j < frag->middle_packet_count; j++ ) {
|
||||
for (size_t j = 0; j < frag->middle_packet_count; j++) {
|
||||
dbfree(frag->middle_packets[j], "ipv4_fragment_trim 3");
|
||||
}
|
||||
if (frag->middle_packet_count > 0) {
|
||||
@ -206,14 +206,15 @@ void ipv4_reassemble_packet(struct ether_t *ether, struct ipv4_header_t *iph) {
|
||||
struct ipv4_frag_t *frag;
|
||||
int error;
|
||||
int i;
|
||||
shortkey[5] = '\0';
|
||||
ptr = &shortkey[5];
|
||||
ptr = shortkey;
|
||||
|
||||
while (key > 0) {
|
||||
ptr--;
|
||||
while (key > 0 && ptr) {
|
||||
*ptr = (key % 10) + '0';
|
||||
ptr++;
|
||||
*ptr = '\0';
|
||||
key = key / 10;
|
||||
}
|
||||
|
||||
error = hashmap_get(ipv4_frag_map, shortkey, (void **)&frag);
|
||||
if (error == MAP_OK) {
|
||||
if (!(htons(iph->ipoffset) & 0x8000)) {
|
||||
@ -237,7 +238,8 @@ void ipv4_reassemble_packet(struct ether_t *ether, struct ipv4_header_t *iph) {
|
||||
if (frag->middle_packet_count == 0) {
|
||||
frag->middle_packets = (struct ipv4_header_t **)dbmalloc(sizeof(struct ipv4_header_t *), "ipv4 reassemble packet 3");
|
||||
} else {
|
||||
frag->middle_packets = (struct ipv4_header_t **)dbrealloc(frag->middle_packets, sizeof(struct ipv4_header_t *) * (frag->middle_packet_count + 1), "ipv4 reassemble packet 4");
|
||||
frag->middle_packets = (struct ipv4_header_t **)dbrealloc(frag->middle_packets, sizeof(struct ipv4_header_t *) * (frag->middle_packet_count + 1),
|
||||
"ipv4 reassemble packet 4");
|
||||
}
|
||||
frag->middle_packets[frag->middle_packet_count] = (struct ipv4_header_t *)dbmalloc(htons(iph->len), "ipv4 reassemble packet 5");
|
||||
memcpy(frag->middle_packets[frag->middle_packet_count], iph, htons(iph->len));
|
||||
@ -265,7 +267,8 @@ void ipv4_reassemble_packet(struct ether_t *ether, struct ipv4_header_t *iph) {
|
||||
if (frag->middle_packet_count == 0) {
|
||||
frag->middle_packets = (struct ipv4_header_t **)dbmalloc(sizeof(struct ipv4_header_t *), "ipv4 reassemble packet 9");
|
||||
} else {
|
||||
frag->middle_packets = (struct ipv4_header_t **)dbrealloc(frag->middle_packets, sizeof(struct ipv4_header_t *) * (frag->middle_packet_count + 1), "ipv4 reassemble packet 10");
|
||||
frag->middle_packets = (struct ipv4_header_t **)dbrealloc(frag->middle_packets, sizeof(struct ipv4_header_t *) * (frag->middle_packet_count + 1),
|
||||
"ipv4 reassemble packet 10");
|
||||
}
|
||||
frag->middle_packets[frag->middle_packet_count] = (struct ipv4_header_t *)dbmalloc(htons(iph->len), "ipv4 reassemble packet 11");
|
||||
memcpy(frag->middle_packets[frag->middle_packet_count], iph, htons(iph->len));
|
||||
@ -359,7 +362,9 @@ void ipv4_reassemble_packet(struct ether_t *ether, struct ipv4_header_t *iph) {
|
||||
for (i = 0; i < frag->middle_packet_count; i++) {
|
||||
dbfree(frag->middle_packets[i], "ipv4 reassemble packet 17");
|
||||
}
|
||||
if (frag->middle_packet_count > 0) {
|
||||
dbfree(frag->middle_packets, "ipv4 reassemble packet 18");
|
||||
}
|
||||
dbfree(frag, "ipv4 reassemble packet 19");
|
||||
}
|
||||
|
||||
|
2
malloc.c
2
malloc.c
@ -1446,7 +1446,7 @@ DLMALLOC_EXPORT int mspace_mallopt(int, int);
|
||||
if (!(x)) \
|
||||
ABORT
|
||||
#else /* ABORT_ON_ASSERT_FAILURE */
|
||||
//QUINN.. assert is in inttypes
|
||||
// QUINN.. assert is in inttypes
|
||||
#endif /* ABORT_ON_ASSERT_FAILURE */
|
||||
#else /* DEBUG */
|
||||
#ifndef assert
|
||||
|
23
memory.c
23
memory.c
@ -64,8 +64,8 @@ static __inline__ uint32_t round_up_to_page(uint32_t addr) {
|
||||
extern uint8_t *endkernel;
|
||||
|
||||
void init_mem(multiboot_info_t *mbd) {
|
||||
//int available = 0;
|
||||
//int total = 0;
|
||||
// int available = 0;
|
||||
// int total = 0;
|
||||
uint32_t mem_end;
|
||||
int i;
|
||||
|
||||
@ -80,9 +80,9 @@ void init_mem(multiboot_info_t *mbd) {
|
||||
pages_above_kernel = mmap->len / PAGE_SIZE;
|
||||
end_free_mem = (uint8_t *)((uint32_t)mmap->addr + (uint32_t)mmap->len);
|
||||
}
|
||||
//available += mmap->len;
|
||||
// available += mmap->len;
|
||||
}
|
||||
//total += mmap->len;
|
||||
// total += mmap->len;
|
||||
|
||||
mmap = (multiboot_memory_map_t *)((uint32_t)mmap + mmap->size + sizeof(uint32_t));
|
||||
}
|
||||
@ -170,7 +170,7 @@ int mem_cpy_pages(struct task_t *old_task, struct task_t *new_task) {
|
||||
new_task->user_pages_cnt = old_task->user_pages_cnt;
|
||||
|
||||
for (i = 0; i < old_task->user_pages_cnt; i++) {
|
||||
//virt = i * 0x1000 + 0x40000000;
|
||||
// virt = i * 0x1000 + 0x40000000;
|
||||
new_task->user_pages[i] = (uint32_t)mem_alloc_pid(new_task->pid);
|
||||
new_task->user_pages_virt[i] = old_task->user_pages_virt[i];
|
||||
mem_map_page(new_task->user_pages[i], (uint32_t)fake_tab, 7);
|
||||
@ -197,7 +197,7 @@ int mem_cpy_pages(struct task_t *old_task, struct task_t *new_task) {
|
||||
}
|
||||
|
||||
// copy environment
|
||||
//virt = 0xf0000000;
|
||||
// virt = 0xf0000000;
|
||||
for (i = 0; i < 64; i++) {
|
||||
virt = 0xf0000000 + (i * 0x1000);
|
||||
new_task->user_env_pages[i] = (uint32_t)mem_alloc_pid(new_task->pid);
|
||||
@ -554,7 +554,8 @@ char *mem_alloc_user_page(uint32_t virt) {
|
||||
current_task->user_pages_virt = (uint32_t *)dbmalloc(current_task->user_pages_cnt * sizeof(uint32_t), "mem alloc user page 2");
|
||||
} else {
|
||||
current_task->user_pages = (uint32_t *)dbrealloc(current_task->user_pages, current_task->user_pages_cnt * sizeof(uint32_t), "mem alloc user page 3");
|
||||
current_task->user_pages_virt = (uint32_t *)dbrealloc(current_task->user_pages_virt, current_task->user_pages_cnt * sizeof(uint32_t), "mem alloc user page 4");
|
||||
current_task->user_pages_virt =
|
||||
(uint32_t *)dbrealloc(current_task->user_pages_virt, current_task->user_pages_cnt * sizeof(uint32_t), "mem alloc user page 4");
|
||||
}
|
||||
|
||||
current_task->user_pages[current_task->user_pages_cnt - 1] = (uint32_t)mem_alloc();
|
||||
@ -682,7 +683,7 @@ struct db_tail {
|
||||
|
||||
void *dbmalloc(int size, const char *caller) {
|
||||
for (int i = 1; i < 20; i++) {
|
||||
db_malloc_caller[i-1] = db_malloc_caller[i];
|
||||
db_malloc_caller[i - 1] = db_malloc_caller[i];
|
||||
}
|
||||
db_malloc_caller[19] = caller;
|
||||
|
||||
@ -703,7 +704,7 @@ void *dbrealloc(void *ptr, int size, const char *caller) {
|
||||
}
|
||||
|
||||
for (int i = 1; i < 20; i++) {
|
||||
db_malloc_caller[i-1] = db_malloc_caller[i];
|
||||
db_malloc_caller[i - 1] = db_malloc_caller[i];
|
||||
}
|
||||
db_malloc_caller[19] = caller;
|
||||
|
||||
@ -744,13 +745,13 @@ void dbfree(void *ptr, const char *caller) {
|
||||
}
|
||||
|
||||
for (int i = 1; i < 20; i++) {
|
||||
db_malloc_caller[i-1] = db_malloc_caller[i];
|
||||
db_malloc_caller[i - 1] = db_malloc_caller[i];
|
||||
}
|
||||
db_malloc_caller[19] = caller;
|
||||
|
||||
struct db_header *data = (struct db_header *)((char *)ptr - sizeof(struct db_header));
|
||||
|
||||
if(data->magic != 0xdeadbeef || data->tail->magic != 0xcafefeed) {
|
||||
if (data->magic != 0xdeadbeef || data->tail->magic != 0xcafefeed) {
|
||||
kprintf("BAD MAGIC ! %p %p\n", data->magic, ptr);
|
||||
kprintf("CALLED BY %s\n", caller);
|
||||
abort();
|
||||
|
11
minix.c
11
minix.c
@ -218,8 +218,8 @@ int minix_add_directory_entry(struct vfs_device_t *device, struct minix_inode *d
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct minix_inode *minix_new_node(struct vfs_device_t *device, struct minix_inode *dirp, uint32_t dir_ino, char *name, uint16_t mode,
|
||||
uint32_t z0, uint32_t *new_ino) {
|
||||
static struct minix_inode *minix_new_node(struct vfs_device_t *device, struct minix_inode *dirp, uint32_t dir_ino, char *name, uint16_t mode, uint32_t z0,
|
||||
uint32_t *new_ino) {
|
||||
struct minix_inode *new_inode;
|
||||
uint32_t ino;
|
||||
|
||||
@ -892,7 +892,6 @@ struct minix_inode *minix_get_inode(struct vfs_device_t *device, int ino) {
|
||||
int inodes_per_block = mdata->sb.s_blocksize / sizeof(struct minix_inode);
|
||||
uint32_t block;
|
||||
|
||||
|
||||
char *buffer = (char *)dbmalloc(mdata->sb.s_blocksize, "minix get inode 1");
|
||||
|
||||
if (!buffer) {
|
||||
@ -1404,8 +1403,7 @@ int minix_read_data(struct vfs_device_t *device, struct minix_file_info *info, c
|
||||
}
|
||||
} else if ((device->device & 0xff00) == 0x100) {
|
||||
for (j = block_start; j < block_start + blockcount; j++) {
|
||||
hd_read_block((device->device & 0xff), minix_read_map(device, inode, (uint64_t)(j * mdata->sb.s_blocksize)), tempbuffer,
|
||||
mdata->sb.s_blocksize);
|
||||
hd_read_block((device->device & 0xff), minix_read_map(device, inode, (uint64_t)(j * mdata->sb.s_blocksize)), tempbuffer, mdata->sb.s_blocksize);
|
||||
if (j == block_start) {
|
||||
if (count + block_offset > mdata->sb.s_blocksize) {
|
||||
memcpy(buffer, &tempbuffer[block_offset], mdata->sb.s_blocksize - block_offset);
|
||||
@ -1436,8 +1434,7 @@ int minix_read_data(struct vfs_device_t *device, struct minix_file_info *info, c
|
||||
return 0;
|
||||
}
|
||||
|
||||
int minix_get_dents(struct vfs_device_t *device, struct minix_file_info *info, char *buffer, int len, uint64_t offset,
|
||||
uint64_t *newoffset) {
|
||||
int minix_get_dents(struct vfs_device_t *device, struct minix_file_info *info, char *buffer, int len, uint64_t offset, uint64_t *newoffset) {
|
||||
struct minix_inode *inode = minix_get_inode(device, info->inode);
|
||||
char *buffer2;
|
||||
int dirlen = minix_read_entire_file(device, inode, &buffer2);
|
||||
|
3
minix.h
3
minix.h
@ -55,8 +55,7 @@ struct minix_data {
|
||||
#define NO_BLOCK 0
|
||||
|
||||
extern struct minix_inode *minix_get_inode(struct vfs_device_t *device, int ino);
|
||||
extern int minix_get_dents(struct vfs_device_t *device, struct minix_file_info *info, char *buffer, int len, uint64_t offset,
|
||||
uint64_t *newoffset);
|
||||
extern int minix_get_dents(struct vfs_device_t *device, struct minix_file_info *info, char *buffer, int len, uint64_t offset, uint64_t *newoffset);
|
||||
extern struct minix_file_info *minix_check_if_exists(struct vfs_device_t *device, const char *path, int type);
|
||||
extern int minix_create_file(struct vfs_device_t *device, char *path);
|
||||
extern void minix_trunc_file(struct vfs_device_t *device, struct minix_file_info *finfo);
|
||||
|
8
pata.c
8
pata.c
@ -29,7 +29,7 @@ void init_pata() {
|
||||
if (devcount == 1) {
|
||||
ide_devices = (struct ide_dev **)dbmalloc(sizeof(struct ide_dev *), "init pata 1");
|
||||
} else {
|
||||
ide_devices = (struct ide_dev **)dbrealloc(ide_devices, sizeof(struct ide_dev *) * devcount , "init pata 4");
|
||||
ide_devices = (struct ide_dev **)dbrealloc(ide_devices, sizeof(struct ide_dev *) * devcount, "init pata 4");
|
||||
}
|
||||
|
||||
ide_device = (struct ide_dev *)dbmalloc(sizeof(struct ide_dev), "init pata 3");
|
||||
@ -267,8 +267,7 @@ void ide_wait_irq() {
|
||||
}
|
||||
|
||||
void ide_irq_isr(struct regs *r) { ide_irq_invoked = 1; }
|
||||
uint8_t ide_ata_dma_access(struct ide_dev *device, uint8_t direction, uint8_t drive, uint32_t lba, uint8_t numsects,
|
||||
uint16_t selector, uint32_t edi) {
|
||||
uint8_t ide_ata_dma_access(struct ide_dev *device, uint8_t direction, uint8_t drive, uint32_t lba, uint8_t numsects, uint16_t selector, uint32_t edi) {
|
||||
uint32_t channel = device->ide_devices[drive].channel; // Read the Channel.
|
||||
uint32_t slavebit = device->ide_devices[drive].drive; // Read the Drive [Master/Slave]
|
||||
|
||||
@ -404,8 +403,7 @@ uint8_t ide_ata_dma_access(struct ide_dev *device, uint8_t direction, uint8_t dr
|
||||
ide_write(device, channel, ATA_REG_CONTROL, device->channels[channel].nIEN = (ide_irq_invoked = 0x0) + 0x2);
|
||||
return 0;
|
||||
}
|
||||
uint8_t ide_ata_access(struct ide_dev *device, uint8_t direction, uint8_t drive, uint32_t lba, uint8_t numsects,
|
||||
uint16_t selector, uint32_t edi) {
|
||||
uint8_t ide_ata_access(struct ide_dev *device, uint8_t direction, uint8_t drive, uint32_t lba, uint8_t numsects, uint16_t selector, uint32_t edi) {
|
||||
uint8_t lba_mode /* 0: CHS, 1:LBA28, 2: LBA48 */, dma /* 0: No DMA, 1: DMA */, cmd;
|
||||
uint8_t lba_io[6];
|
||||
uint32_t channel = device->ide_devices[drive].channel; // Read the Channel.
|
||||
|
Loading…
x
Reference in New Issue
Block a user