#include #include #include extern int AT_ROUTING; struct gateway_list_head *glh;/*to be exported*/ struct gateway_list_head *rlh;/*to be exported, route list head*/ uint32_t at_state; uint32_t at_mycid; asmlinkage int sys_add_routable_node(uint32_t gw, int action) { struct gateway_list_node gln; gln.gw = gw; /*copy the gateway node*/ if(AT_ROUTING == 0)/*No alpha-t routing*/ { return -EUNATCH;/*protocol driver not attached*/ } else { switch(action) { case 0: /*delete gateway node*/ remove_from_list(&glh, &gln); break; case 1: /*add gateway node*/ add_to_list(&glh, &gln); break; case 2: /*change state*/ if(gw > 4) return -EINVAL; else at_state = gw; break; case 3: /*delete reachable node, note rlh below*/ remove_from_list(&rlh, &gln); break; case 4: /*add reachable node, note rlh below*/ add_to_list(&rlh, &gln); break; case 5: /*return current state, no error check TODO*/ return at_state; /*AT STATE BEING RETURNED*/ break; case 6:/*set your cid*/ at_mycid = gw; break; case 7:/*get back your cid*/ return at_mycid; break; default: return -EINVAL; } return 0; /*success*/ } } /* int populate_proc_routable(char *page, char **start, off_t offset, int count, int *eof, void *data) { struct printable_buffer pbf; pbf.offset = 0; pbf.buff = page; *eof = 1; return apply_function_to_list(&rlh, fill_proc_buffer,&pbf); } */ int populate_proc_routable(char *page, char **start, off_t offset, int count, int *eof, void *data) { struct printable_buffer pbf; pbf.offset = 0; pbf.buff = page; pbf.buff[0] = '\0'; *eof = 1; apply_function_to_list(&rlh, fill_gateway_buffer, &pbf); return strlen(pbf.buff); } int populate_proc_gateways(char *page, char **start, off_t offset, int count, int *eof, void *data) { struct printable_buffer pbf; pbf.offset = 0; pbf.buff = page; pbf.buff[0] = '\0'; *eof = 1; apply_function_to_list(&glh, fill_gateway_buffer, &pbf); return strlen(pbf.buff); } int populate_proc_state(char *page, char **start, off_t offset, int count, int *eof, void *data) { *eof = 1; sprintf(page, "%d\n", at_state); return strlen(page); } int populate_proc_cid(char *page, char **start, off_t offset, int count, int *eof, void *data) { *eof = 1; sprintf(page, "%d.%d.%d.%d\n", NIPQUAD(at_mycid)); return strlen(page); }